GDB

GDB, the GNU project debugger is supported in linux-0.7.3 and later releases.

GDB in linux-0.7.3 supports remote debugging via Ethernet and serial port. No native GDB is implemented in the release.

The gdb runs on host system (RHEL4/Ubuntu10.04) after gdbserver has been started on target board, e.g. EVMC6472, DSK6455.

The executable gdb (c6x-uclinux-gdb) is located in the directory ~/my-linux-c6x/c6x-4.5/bin/, and gdbserver is in ~/my-linux-c6x/c6x-4.5/c6x-uclinux/libc/usr/bin/. Since gdbserver need to be run on target board, you can make a directory in NFS file system, e.g. min-root-c6x/gdb, and then copy the executable gdbserver as well as your application that need to be debugged to the directory.

The documentation of “Debugging with GDB” is located in ~/my-linux-c6x/c6x-4.5/share/doc/c6x-c6x-uclinux/pdf/

Debugging via Ethernet
a. On target board, launch the gdbserver:

# ./gdbserver localhost:3456 ./sample 1 3 5 4

Above will start gdbserver with port number 3456 for debugging application “sample” with arguments (1, 3, 5, 4).

You should be able to see the following response from terminal: Process ./sample created; pid = 92 Listening on port 3456

b. On host, issue the following command to debug application remotely.

$ c6x-uclinux-gdb sample (gdb) target remote 158.218.109.220:3456 warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. 158.218.109.220 is the target board IP address.

To remove above warning, you need to set sysroot path properly so that gdb can find the shared library, for instance,

set sysroot /opt/gcc-full-root-c6x

To debug shared library, the compiler option –g must be used when generating the shared objects.

Once the gdb/gdbserver connection is established, gbdserver will respond the followings:

Remote debugging from host 158.218.109.31 getting fdpic loadmap exec getting fdpic loadmap interp

Refer to GDB user manual http://www.gnu.org/software/gdb/documentation/ to get familiar with GDB commands.

Debugging via serial port
On target board, launch gdbserver with the following commands: # ./gdbserver /dev/ttySI0 ./sample 1 Process ./sample created; pid = 107 Remote debugging using /dev/ttySI0

On the host, start gdb: $ ./c6x-uclinux-gdb -b 115200 ./sample GNU gdb (Sourcery G++ Lite 4.5-97) 7.2.50.20100908-cvs Copyright (C) 2010 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later  This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=c6x-uclinux". For bug reporting instructions, please see: ...  Reading symbols from /home/a0132884/sample/sample...done. (gdb) set remoteflow off (gdb) target remote /dev/ttyS0 Remote debugging using /dev/ttyS0

Example GDB session
Below is an example GDB session via Ethernet, in which demonstrates some basic debugging command usage.

$ c6x-uclinux-gdb sample GNU gdb (Sourcery G++ Lite 4.5-97) 7.2.50.20100908-cvs Copyright (C) 2010 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later  This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=c6x-uclinux". For bug reporting instructions, please see: ...  Reading symbols from /sim/scratch_a0132884/sample/sample...done. (gdb) set sysroot /opt/gcc-full-root-c6x/

(gdb) target remote 158.218.109.233:3456 Remote debugging using 158.218.109.233:3456

(gdb) break 73 Breakpoint 1 at 0xef46eb24: file sample.c, line 73. (gdb) c  Continuing. Breakpoint 1, main (argc=5, argv=0xef49fe34) at sample.c:73 73             a = (int *)malloc((argc - 1) * sizeof(int));

(gdb) b shell_sort Breakpoint 2 at 0xef5ef74c: file sort.c, line 4.

(gdb) i shared From       To          Syms Read   Shared Object Library 0xef5ef520 0xef5efa00  Yes         /opt/gcc-full-root-c6x/lib/libcsort.so.1 0xef60e900 0xef66b6c0  Yes (*)     /opt/gcc-full-root-c6x/lib/libc.so.0 0xef561260 0xef568b60  Yes (*)     /opt/gcc-full-root-c6x/lib/ld-uClibc.so.0 (*): Shared library is missing debugging information.

(gdb) c  Continuing. Breakpoint 2, shell_sort (a=0xef671760, size=5) at sort.c:4 4              int h = 1; (gdb) b sort.c:14 Breakpoint 3 at 0xef5ef7ec: file sort.c, line 14. (gdb) c  Continuing. Breakpoint 3, shell_sort (a=0xef671760, size=5) at sort.c:14 14                             for (j = i; j >= h && a[j - h] > v; j -= h)

(gdb) print h  $2 = 4 (gdb) print a[0] $3 = 1  (gdb) print j   $5 = -280566016

(gdb) b sort.c:16 Breakpoint 4 at 0xef5ef8c4: file sort.c, line 16. (gdb) c  Continuing. Breakpoint 4, shell_sort (a=0xef671760, size=5) at sort.c:16 16                             if (i != j)   (gdb) print j   $6 = 0 (gdb) c  Continuing.

Program exited normally. (gdb)

Graphic GDB debuggers
Two graphic GDB debuggers have been tested: DDD(Data Display Debugger) and CCSv5.

CCSv5 needs extra steps to set up debug configuration. For details on GDB debugging configuration in CCSv5, refer to http://processors.wiki.ti.com/index.php/Linux_Debug_in_CCSv5, note steps listed in the “Linux Debug in CCSv5” wiki page is targeted to ARM device rather than DSP, and the CCSv5 is not updated to latest version C5.0.1.00036.

For details on DDD usage, refer to http://www.gnu.org/software/ddd/

Below are the screen shots of DDD and CCSv5.

a. DDD



b. CCSv5





Reference
1. GDB user manual: http://www.gnu.org/software/gdb/documentation/

2. Linux debugging in CCSv5: http://processors.wiki.ti.com/index.php/Linux_Debug_in_CCSv5

3. DDD: http://www.gnu.org/software/ddd/