Debug your first AGL application
Debug is based on gdb and you need to use
xds-gdb as a wrapper on gdb to cross-debug your application.
This tool allows you to debug an application built with an xds-server without the need to install gdb or any cross tool.
Two debugging models are supported:
XDS remote debugging requiring an XDS server and allowing cross debug your application.
By default XDS remote debug is used and you need to define
variable to use native gdb debug mode instead.
xds-gdb configuration is defined by variables (see listed below).
These variables may be set using :
- environment variables (inherited),
- or a config file set with
XDS_CONFIGenvironment variable, for example:
- or by setting variables within a gdb ini file (see details below),
- or a “user” config file located in following directory (first found is taken):
Config file defining
XDS_xxx configuration variables. Variables of this file
will overwrite inherited environment variables. Variables definition may be
prefixed or not by “export” keyword.
Here is an example of configuration file
# for example: # MY_PROJECT_DIR=/home/seb/xds-workspace/helloworld-native-application cat > $MY_PROJECT_DIR/xds-gen3.conf << EOF export XDS_SERVER_URL=http://docker:8000 export XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject export XDS_SDK_ID=poky-agl_aarch64_4.0.1 EOF
Set logging level (supported levels: panic, fatal, error, warn, info, debug)
Set logging file, default
Use native gdb mode instead of remote XDS server mode.
XDS_PROJECT_ID (mandatory with XDS server mode)
Project ID you want to build
Relative path into project
XDS_SDK_ID (mandatory with XDS server mode)
Cross Sdk ID to use to build project
XDS_SERVER_URL (mandatory with XDS server mode)
Remote XDS server url
Configuration variables set within gdb init command file
XDS_xxx variables may also be defined within gdb init command file
(see –command or -x option of genuine Gdb).
You must respect the following syntax: commented line including
Example of gdb init file where we define project and sdk ID:
# :XDS-ENV: XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject # :XDS-ENV: XDS_SDK_ID=poky-agl_aarch64_4.0.1
Using xds-gdb from command line
XDS remote debugging mode
First the project you want to debug must be declared on an xds-server and this project may also has been built using this xds-server (see xds-server for more details).
So to debug it you need to know the xds-server url (eg. http://docker:8000),
you also need the project and sdk unique id. You can find these IDs in project
page of XDS dashboard or you can get them from command line using the
This option lists all existing projects ID:
XDS_SERVER_URL=http://docker:8000 xds-gdb --list
Now to refer your project, just set
You are now ready to use
xds-gdb to for example cross debug your project.
Here is an example to build and debug a project based on CMakefile and
# Go into your project directory (for example helloworld-native-application) cd ~/xds-workspace git clone https://github.com/iotbzh/helloworld-native-application.git cd helloworld-service # Declare your project on xds-server # <for now, you can only do this step using xds HTML dashboard (see xds-server doc)> # Define XDS config cat <<EOF >./xds-config.env XDS_SERVER_URL=http://docker:8000 XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject XDS_SDK_ID=poky-agl_aarch64_4.0.1 EOF # Tell to xds-exec and xds-gdb which is your config file export XDS_CONFIG=../xds-gen3.conf # Create a new build directory mkdir build && cd build # Start remote cross build xds-exec -- cmake -DRSYNC_TARGET=root@myTarget .. xds-exec -- make xds-exec -- make remote-target-populate # Start debugging xds-gdb -x target/gdb-on-root@myTarget.ini
Note: : helloworld-native-application project is an AGL project based on app-templates (included as a git submodule). This CMake templating, used to develop application with the AGL Application Framework, will automatically generate makefile rules (eg.
remote-target-populate) or scripts (eg.
For more info about app-template, please refer to this documentation.
To enable native debugging mode, you need to define
Using xds-gdb within an IDE
Netbeans 8.x :
- Open menu Tools -> Options
Open C/C++ tab, in Build Tools sub-tab, click on Add button:
Then, you should set Make Command and Debugger Command to point to xds tools:
Finally click on OK button.
Edit project properties (using menu File -> Project Properties) to update Debug settings:
Be sure that “Gen3 board” configuration is selected
- Select Run category, and set:
- Run Command:
firstname.lastname@example.org(script name may depend of RSYNC_TARGET variable you set in pre-build command)
- Run Directory:
- Run Command:
- Select Debug category, and set:
- Debug command:
- Working Directory: empty field
- Gdb Init File:
email@example.com(script name may depend of RSYNC_TARGET variable you set in pre-build command)
- Debug command:
- Click on Apply and then OK button to save settings
You can now start debugging your application with menu Debug -> Debug Project (or CTRL+F5 shortcut)