Updated: April 19, 2023

Debugger (GNU)


gdb_variant [options] [executable] [ core_file | pid ]

gdb_variant [options] set args executable [ inferior-arguments ...]

where gdb_variant depends on the target platform, as follows:

Target platform gdb_variant
ARMv7 ntoarmv7-gdb
AArch64 ntoaarch64-gdb
x86 64-bit ntox86_64-gdb

Runs on:

Linux, Mac, Microsoft Windows


Invoke the GNU Debugger by running gdb. Once started, gdb reads commands from the terminal until you tell it to exit.

  • GDB parses the ~/.gdbinit file if it exists. An existing configuration for the development host may cause conflicts.
  • QEMU doesn't emulate the DBGAUTHSTATUS register on ARMLE-v7 virtual machines, so when gdb tries to access it, an exception occurs, and the kernel crashes.
  • GDB only supports up to 100 environment variables. If additional arguments are provided, they are dropped.

For more information about GDB, see

QNX Neutrino extensions

The QNX Neutrino implementation of GDB includes some extensions:

target qnx com_port_specifier | host:port
Specify the target to use.
Note: The devc-pty manager must be running on the machine that's running pdebug or qconn, and a ptyp/ttyp pair must be available.
set nto-executable path_on_target
Point GDB at an existing remote executable. You can do this instead of uploading a copy to the target. For example, to debug echo on the target you can start gdb on the host, and then point it to the target executable:
# ntoaarch64-gdb $QNX_TARGET/aarch64le/bin/echo
(gdb) set nto-executable /bin/echo
(gdb) run hello
Note: The upload command implicitly sets the nto-executable value. This behavior can be controlled with the option upload-sets-exec.
set nto-inherit-env value
Set where the remote process inherits its environment from, based on the value argument:
  • 0 — the process inherits its environment from GDB.
  • 1 (the default) — the process inherits its environment from pdebug. In this case, you can't set LD_LIBRARY_PATH through gdb. The env command works but it doesn't have an effect.
Note: The QNX Neutrino implementation of GDB only supports up to 100 environment variables and any additional environment variables are dropped without warning. This is important to note because running pdebug in debug mode uses over 100 environment variables and generates a terminal message that says, incorrectly, that the target has run out of memory. The real issue is that the limit on the number of environment variables was exceeded.
set nto-cwd path
Specify the remote process's working directory. You should do this before starting your program.
set nto-debug
Provides debug-specific information when given a positive non-zero value. Different information is displayed for various positive non-zero values.
set nto-stop-on-thread-events stop
Stop on thread events. When stop is 1, gdb stops on thread created and thread destroyed events. The default is 0 (disabled).
set nto-timeout time
If your communication line is slow, you might need to set the timeout for remote reads; time is the timeout, in seconds. The default is 10 seconds.
upload local_path remote_path
Send a file to a remote target system.
A flag that controls if nto-executable is set by using upload.
download remote_path local_path
Retrieve a file from a remote target system.
info pidlist
List processes on the target. You can use an optional argument to filter out process names that do not contain an argument string (case insensitive). For example, running it in the GDB console with pdebug as its argument generates the following output:
    (gdb) info pidlist pdebug
usr/bin/pdebug - 872540/1
Running it in the GDB console with slog as its argument generates the following output:
    (gdb) info pidlist slog
proc/boot/slogger2 - 12296/1
You can also use pidin or ps on the target system to get this information.
info meminfo
Display a list of memory-region mappings (shared objects) for the current process being debugged. Here is sample output from running it on the GDB console:
    (gdb) info meminfo
        text=00053000 bytes @ 0x01000000
        data=00002000 bytes @ 0x010af000
        text=00010000 bytes @ 0x0109b000
        data=00009000 bytes @ 0x100db000
        text=00001000 bytes @ 0x100c8000
        data=00001000 bytes @ 0x100da000
info tidinfo
Displays the threads for the current process. For example, when run against a process with a pid of 884827 it outputs:
(gdb) info tidinfo
Threads for pid 884827 (/bins/sleep)
Tid:    State:  Flags:
 *1      3       131

A quick overview of starting the debugger

To debug an application, do the following:

  1. Start GDB, optionally the application as an argument:


    gdb_variant local_path/my_application
  2. If you didn't specify the application when you started GDB, load the symbol information for the application:
    file my_application
  3. Set the target:
    target qnx com_port_specifier | host:port
  4. Send the application to the target:
    upload my_application /tmp/my_application
  5. Set any breakpoints. For example, to set a breakpoint in main():
    set break main
  6. Start the application:

To remote start and debug a binary with GDB, do the following:

  1. Start GDB using env-i and setting the target:
          env -i \
               QNX_TARGET=${QNX_TARGET} \
                 ntoaarch64-gdb \
                 target qnx target_ip:port \
  2. To search for symbols, manually set solib-search-path:
          set solib-search-path /host/symbol/search/path:/path2/
  3. At this point, if you choose to not inherit the enviroment from pdebug or qconn, the environment variables to apply on the target need to be set manually. For example:
          set nto-inherit-env 0
          unset environment QNX_TARGET
          set environment PATH=/proc/boot:/bin:/usr/bin:/sbin:/usr/sbin
          set environment LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib
          set environment
          set environment GRAPHICS_ROOT=/usr/lib/graphics/...
          file /host/path/to/executable/symbol/file
  4. Lastly, set the nto-executable:
    set nto-executable /target/path/to/execuable
  5. Start the application:
    run arg1 arg2

Contributing author: