summaryrefslogtreecommitdiffstats
path: root/docs/part-1/debug-cmd-line.md
blob: f279c7b2a086427e46d549e2e2513546c1c39a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Using the XDS Command Line

You can debug your AGL application using the XDS command line
in XDS remote mode or in native mode.

## XDS Remote Mode

XDS remote debugging is the default mode for using XDS to debug your
application.


Follow this procedure to use XDS remotely to debug your application:

1. Declare to the `xds-server` the project you want to debug.
   The project can also have been built using XDS.
   See the "[Create your first AGL application](../../../#create-your-first-agl-application)"
   section for more details.

2. Be sure you have the XDS agent and XDS server chain in place.
   You can find more information on this chain in the
   "[Overview](../../../#xds-overview)" section.

3. Determine the unique project and sdk ID values.
   Two methods exist for you to locate these ID values:

   - Use the "Project" page of XDS dashboard.

   - Use the `xds-gdb --list` command from the XDS command line.
     This command returns the list of all existing project and SDK
     IDs:

     ```bash
     xds-gdb --list
     ```

4. Define the `XDS_PROJECT_ID` and `XDS_SDK_ID` variables.
   Defining these variables refers the project to the
   `xds-server`.
   Once you refer the project, you are ready to use `xds-gdb`
   (e.g. cross debug your project).

5. Build and debug the project.

**Example**

Following is an example that builds and debugs a project
based on a CMakefile and the
[cmake-apps-module](https://git.automotivelinux.org/src/cmake-apps-module/):

```bash
# Go into your project directory (e.g. helloworld-native-application)
cd ~/xds-workspace
# Clone the project files into your local directory.
git clone https://github.com/iotbzh/helloworld-native-application.git
# Go to the local project's directory.
cd helloworld-service

# Declare your project on xds-server
# For now, you can only do this step using the XDS Dashboard.
# See the "Build Using the XDS Dashboard" topic in the "Create Your
# First Application" section.

# Define XDS configuration variables by creating a "xds-config.env" file.
cat <<EOF >./xds-config.env
#optional if not default value: XDS_AGENT_URL=http://localhost:8800
XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject
XDS_SDK_ID=poky-agl_aarch64_4.0.1
EOF

# Tell the xds-cli and xds-gdb what configuration file to use.
export XDS_CONFIG=../xds-gen3.conf

# Create a new build directory.
mkdir build && cd build

# Start remote cross build
xds-cli exec -- cmake -DRSYNC_TARGET=root@myTarget ..
xds-cli exec -- make
xds-cli exec -- make remote-target-populate

# Start debugging
xds-gdb -x target/gdb-on-root@myTarget.ini
```

<!-- section-note -->
**NOTE:**

The [helloworld-native-application](https://github.com/iotbzh/helloworld-native-application)
project is an AGL project based on the
[cmake-apps-module](https://git.automotivelinux.org/src/cmake-apps-module/).
For information on installing this module, see the
"[Installing the CMAKE Templates](../../cmakeafbtemplates/dev_guide/installing-cmake.html))"
section.

The CMake templates, used to develop applications with the AGL Application
Framework, automatically generates Makefile rules
(e.g. `remote-target-populate`) or scripts (e.g. `build/target/*`).

For more info about the CMake templates, see the
"[Using the Cmake Applications Module](../../../#using-the-cmake-applications-module).
<!-- end-section-note -->

## Native debugging

Native debugging using GDB directly.

To enable native debugging mode, set the `XDS_NATIVE_GDB` variable.

For information on debugging with GDB, see the
"[Debugging with GDB](https://www.sourceware.org/gdb/onlinedocs/gdb.html#index-_002d_002dcommand)"
section.