# Build the application with debug symbols

Source: [https://docs.qualcomm.com/doc/80-41102-1/topic/Build-the-application-with-debug-symbols.html](https://docs.qualcomm.com/doc/80-41102-1/topic/Build-the-application-with-debug-symbols.html)

When building an app, build as normal, but add `-d <debug-path>` to the mkapp command-line to generate debug symbols in `<debug-path>`. The same directory can be used for all apps — each program or library will use a unique name.

When building the TelAF image from source, debug symbols for the TelAF framework are always generated and placed in build/&lt;target&gt;/debug. It is recommended to set the app debug path as the same build/&lt;target&gt;/debug path.

## Deploy gdbserver with devMode application

Build the devMode tool with the devMode.adef application definition file under legato/legato-af/apps/tools and load it onto the target.

## Start gdb on an app on the target

On the dev machine, set up port forwarding from the local host to the target. This bypasses the firewall on the target and allows the gdb server to connect.

    $ ssh -L 2000:localhost:2000 root@192.168.2.2Copy to clipboard

Warning: Do not end the session to the target or the port forwarding will end and GDB will not be able to connect to the target.

On the target, start `gdbserver` by starting the app with the arguments specified after `--` (two dashes):

    # app runProc <app name> --exe=<gdbserver bin dir>/gdbserver -- localhost:2000 <app bin dir>/<app bin>Copy to clipboard

        For example:

    # app runProc helloWorld --exe=/legato/systems/current/appsWriteable/devMode/bin/gdbserver -- localhost:2000 /legato/systems/current/appsWriteable/helloWorld/bin/helloWorld Copy to clipboard

        If started successfully, the following will be returned:

    Process /legato/systems/current/appsWriteable/helloWorld/bin/helloWorld created; pid = 9783
    Listening on port 2000Copy to clipboard

## Launch gdb on the dev host

Commands must be run from the directory where the helloWorld app was made. The \_build\_helloWorld/sa515m/app/helloWorld/staging/read-only/bin/helloWorld path is relative to the app directory; this build directory is generated when an app is made and the gdb commands must be run here.

The following example shows running the gdb tool (`arm-oe-linux-gnueabi-gdb`) located in the target's toolchain path (/opt/qct/sa515m/sysroots/x86\_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/ for sa515m).

Launch gdb from the toolchain using the following command:

    $ ~/TelAFApps/helloWorld$ /opt/qct/sa515m/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gdbCopy to clipboard

## Connect remotely

After gdb is launched, tell gdb to fetch the libraries to debug across the network, but use local debug symbols:

    $ (gdb) set debug-file-directory <debug-path>
    $ (gdb) set sysroot target:/Copy to clipboard

Note: By default the &lt;debug-path&gt; would be `$TELAF_ROOT/build/<target>/debug/`. It is recommended to archive that directory along with releases so as to be able to process core dumps.

Use the `target remote` command to connect to the target:

    $ (gdb) target remote localhost:2000Copy to clipboard

Note: If you receive an error about connecting, ensure there is a ssh -L (port forwarding) session open between the dev machine and the target.

The target will display:

    Remote debugging using localhost:2000Copy to clipboard

        You should see gdb reading symbols for TelAF components.

You can now run any of the standard gdb debugging commands on `helloWorld`.

## Remove gdb from the target

Once finished with debugging, remove `gdbserver` by removing the devMode application.

Refer to one of the many available open source resources if needing help using gdb.

**Parent Topic:** [Debug with GDB](https://docs.qualcomm.com/doc/80-41102-1/topic/Debug-with-GDB.html)

Last Published: May 12, 2026

[Previous Topic
Install gdb and gdbserver to toolchain](https://docs.qualcomm.com/bundle/publicresource/80-41102-1/topics/Install-gdb-and-gdbserver-to-toolchain.md) [Next Topic
Use TelAF simulation](https://docs.qualcomm.com/bundle/publicresource/80-41102-1/topics/use-telaf-simulation.md)