1. Make sure your debuginfo files are part of LD_LIBRARY_PATH.

To do this, either
a) add the path where you stored the .debug files to your LD_LIBRARY_PATH environment variable, e.g.:

$ export LD_LIBRARY_PATH=/opt/STM/STLinux-2.3/devkit/sh4_uclibc/target/usr/lib/debug:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin/../lib:/opt/STM/STMCR1.5.0/lib:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin/../../../host/stmc/lib

Then restart gdb.

b) start gdb and set the LD_LIBRARY_PATH from within gdb:

(gdb) set env LD_LIBRARY_PATH /opt/STM/STLinux-2.3/devkit/sh4_uclibc/target/usr/lib/debug:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin/../lib:/opt/STM/STMCR1.5.0/lib:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin/../../../host/stmc/lib

In my case the debug info symbol files for my uClibc lib are in /opt/STM/STLinux-2.3/devkit/sh4_uclibc/target/usr/lib/debug, so, as you can see I’ve added that dir to the beginning of my LD_LIBRARY_PATH var.

2. Use the directory command in gdb to examine and set the path to your sorce files:

(gdb) directory
Reinitialize source path to empty? (y or n) n
Source directories searched: /opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin//.././stdcmd:$cdir:$cwd

(gdb) directory data/downloads/st/libc/uClibc-0.9.30-svn/libc/:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin//.././stdcmd:$cdir:$cwd
Source directories searched: /data/downloads/st/libc/uClibc-0.9.30-svn/libc:/opt/STM/STLinux-2.3/devkit/sh4_uclibc/bin//.././stdcmd:$cdir:$cwd

My uClibc sources are kept in directory /data/downloads/st/libc/uClibc-0.9.30-svn, more particularly in the libc folder, so that is what I’ve prepended to the gdb “directory”. It may be enough to add just the top directory (e.g. /data/downloads/st/libc/uClibc-0.9.30-svn) or youmay need to be more specific, adding the libc sub-directory like I did, or you may even need to add the specific sub0system directory, (e.g. /data/downloads/st/libc/uClibc-0.9.30-svn/libc/stdio if you want to debug stdio). You’ll need to experiment with that and see what works in your case.

3. Tell gdb to step into .so’s:

(gdb) set step-mode on


The above should do it. Now if you set a breakpoint in a libc function, e.g. fopen gdb should tell you where it put he breakpoint iun the source files, so instead of seeing something like:

(gdb) b fopen
Breakpoint 3 at 0x400a50

, you should now see the file name and line number of the uClibc source file reported by gdb:

(gdb) b fopen
Breakpoint 3, *__GI_fopen (filename=0x7bd57e6f "stats.txt", mode=0x403d84 "w") at libc/stdio/fopen.c:20
Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

Set your Twitter account name in your settings to use the TwitterBar Section.