|
Debugging Shared Libraries
Search Paths
As gdb-cris has support for shared library debugging
enabled, you need to specify where it should get them from. If
you don't, gdb is likely to pick up the libraries that are
installed on your host, which may cause all sorts of problems.
When it comes to debugging, shared libraries are really no
different in the regard that you want debug information in
them if you want to be able to do anything useful with them.
If you want to know what shared libraries gdb has loaded,
use the 'sharedlibrary' command.
glibc
The following sets suitable paths for a glibc-based system
(other settings may function equally well):
set solib-absolute-prefix /dev/null/
set solib-search-path /usr/local/cris/cris-axis-linux-gnu/lib/
The reason solib-search-path
is made to point at the libraries installed with the compiler
is that those come with debug information, whereas the libraries in the
target directory are stripped.
uclibc
If you want to be able to debug uclibc, or any shared
library which doesn't contain debug information by default,
you need to rebuild it with debug information. In uclibc,
that is controlled by the DODEBUG variable in the .config
file.
Note: you do not need to rebuild uclibc with
debug information just to be able to debug an application
that uses it. However, anything involving the library
itself, such as backtracing from a SIGSEGV in printf, will
not work. If that is ok, then
set solib-absolute-prefix /dev/null/
set solib-search-path <AXIS_TOP_DIR>/target/cris-axis-linux-gnuuclibc/lib
should be enough.
If you do rebuild uclibc with debug information, you want
gdb to find that information and pick it up. In order for that
to happen, you need to provide links in the uclibc directory
similar to those in the target directory. For example, in the
target/cris-axis-linux-gnuuclibc/lib directory there is a
link:
libc.so.0 -> libuClibc-<version>.so
The name "libc.so.0" is what the application
opens, and what gdb will look for. Therefore you need to
provide an identical link in (for example) libs/uClibc/libc
and then place that directory first in the shared library
path:
set solib-absolute-prefix /dev/null/
set solib-search-path <AXIS_TOP_DIR>/libs/uClibc/libc:<AXIS_TOP_DIR>/target/cris-axis-linux-gnuuclibc/lib
If you do this, gdb will pick up debug information for
libc.so.0 (as pointed out by your link) but not for any other
library (the ones picked up from the target directory).
Other libraries
If your application uses additional libraries, just append
the search paths to those libraries, separated by ':'.
Source Code
If you want gdb to be able to display the source code for a
function in shared library which you don't by default have the
source code to, you need to make the source code available to
gdb by using the directory command (which adds a path to the
search path for source code). Say you want to display
the source code to printf. Simply trying to list printf will
tell you that gdb doesn't know of any printf.c:
(gdb) list printf
23 printf.c: No such file or directory.
in printf.c
Grab a glibc tarball that matches the compiler you have
installed, then add the search path to the file printf.c:
(gdb) directory <path to glibc>/stdio-common/
Now gdb should find it. Try again:
(gdb) list printf
23
24 /* Write formatted output to stdout from the format string FORMAT. */
25 /* VARARGS1 */
26 int
27 printf (const char *format, ...)
28 {
29 va_list arg;
30 int done;
31
32 va_start (arg, format);
|