e1ee121cae
A gdbinit file passed via '-x' will be read _after_ parsing any object/core file passed on the command-line. In cross-compilation context, this is particularly a problem when loading a core file, because without the 'sysroot' specified in the gdbinit file, it will give a lot of warnings, like: warning: .dynamic section for "/lib/libstdc++.so.6" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/librt.so.1" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libm.so.6" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libgcc_s.so.1" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/ld-linux.so.2" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libanl.so.1" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libdl.so.2" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libpthread.so.0" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/usr/lib/libz.so.1" is not at the expected address (wrong library or version mismatch?) warning: .dynamic section for "/lib/libnss_files.so.2" is not at the expected address (wrong library or version mismatch?) warning: Could not load shared library symbols for 17 libraries, e.g. [...] Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? In contrast, the '-ix' option will load the specified gdbinit file _before_ parsing object/core files. This will remove said warnings. See also: https://sourceware.org/bugzilla/show_bug.cgi?id=28330 Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
54 lines
1.9 KiB
Plaintext
54 lines
1.9 KiB
Plaintext
// -*- mode:doc; -*-
|
|
// vim: set syntax=asciidoc:
|
|
|
|
==== Using +gdb+ in Buildroot
|
|
|
|
Buildroot allows to do cross-debugging, where the debugger runs on the
|
|
build machine and communicates with +gdbserver+ on the target to
|
|
control the execution of the program.
|
|
|
|
To achieve this:
|
|
|
|
* If you are using an _internal toolchain_ (built by Buildroot), you
|
|
must enable +BR2_PACKAGE_HOST_GDB+, +BR2_PACKAGE_GDB+ and
|
|
+BR2_PACKAGE_GDB_SERVER+. This ensures that both the cross gdb and
|
|
gdbserver get built, and that gdbserver gets installed to your target.
|
|
|
|
* If you are using an _external toolchain_, you should enable
|
|
+BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY+, which will copy the
|
|
gdbserver included with the external toolchain to the target. If your
|
|
external toolchain does not have a cross gdb or gdbserver, it is also
|
|
possible to let Buildroot build them, by enabling the same options as
|
|
for the _internal toolchain backend_.
|
|
|
|
Now, to start debugging a program called +foo+, you should run on the
|
|
target:
|
|
|
|
----------------------------
|
|
gdbserver :2345 foo
|
|
----------------------------
|
|
|
|
This will cause +gdbserver+ to listen on TCP port 2345 for a connection
|
|
from the cross gdb.
|
|
|
|
Then, on the host, you should start the cross gdb using the following
|
|
command line:
|
|
|
|
----------------------------
|
|
<buildroot>/output/host/bin/<tuple>-gdb -ix <buildroot>/output/staging/usr/share/buildroot/gdbinit foo
|
|
----------------------------
|
|
|
|
Of course, +foo+ must be available in the current directory, built
|
|
with debugging symbols. Typically you start this command from the
|
|
directory where +foo+ is built (and not from +output/target/+ as the
|
|
binaries in that directory are stripped).
|
|
|
|
The +<buildroot>/output/staging/usr/share/buildroot/gdbinit+ file will tell the
|
|
cross gdb where to find the libraries of the target.
|
|
|
|
Finally, to connect to the target from the cross gdb:
|
|
|
|
----------------------------
|
|
(gdb) target remote <target ip address>:2345
|
|
----------------------------
|