GDB works over a serial connection, so you can debug a program on a target when a networking link isn't available on that device
or when you're debugging networking.
Note:
Debugging support is limited for serial connections, because you can start an application process with GDB attached but
you can't attach GDB to a running process.
You must
configure the target for serial communication before
performing the IDE steps to select the target and launch the application with GDB attached.
To debug a program over a serial link:
-
In the Launch Target dropdown, click New Launch Target to open the launch target wizard
selector.
-
Select QNX Serial Port Connection in the list of target types, then click
Next to open the New QNX Serial Port Connection dialog.
-
Fill in the serial port connection settings.
You can provide any name for your new connection; this name will show up in the Launch Target dropdown.
The Serial port field must name the host port used to talk over the physical link to the
target. The Baud rate setting must match the value reported for the serial port on the
target; this value is listed when you run stty on that target port when configuring serial
communication. For the remaining fields, you can adjust their values but the default values shown are the more
commonly used settings.
-
Click Finish to create the target connection.
An entry for the new target connection is added to and selected in the Launch Target dropdown.
The IDE tries to connect to the target; if it succeeds, the dropdown entry shows a
purple circle symbolizing a physical connector but with no red box
(
).
If it fails, you'll see a red box with an X in the lower left corner of the icon
(
).
-
In the Launch Configuration dropdown, select the project defining the application that you want to debug.
In this release, you don't need to create a special launch configuration for serial debugging—you can use the
default configuration for any project that supports debugging because this configuration works whether you're
debugging over a TCP/IP or a serial link. Also, the Serial Port and Baud Rate properties no longer appear in the
launch configuration (because they're set in the target connection).
-
Click the Debug button ().
The IDE switches to the Debug perspective, which displays the source code being traced and other essential debugging
information. If necessary, the IDE builds the application binary (with debugging information) and uploads it to the target.
Then, it starts running the binary and GDB, which it attaches to the binary. If configured to do so in the
Debug settings, the debugger stops on
startup (by default, in the first line of main()).
For information on the debugging controls, see Debug perspective controls.
When a debugging session ends, the support agent used in serial connections,
pdebug, always exits.
You must then either restart it manually or use the target's reset command
(if
pdebug is launched during startup). The following script shows how to quickly restart
pdebug to keep it running:
while true
do
pidin | grep -q pdebug
if [ $? -ne 0 ]
then
echo Start pdebug
pdebug /dev/ser1,115200
fi
sleep 1
done