Debugging shared libraries with gdbserver

I am using gdbserver for the target and CodeSourcery IDE. My equipment is gumstix with omap3530.

I can execute the code in my main application, but if I try to enter a function in a shared library, I get the memory address and the debugger exits.

This is my library that is compiled and copied to the / lib folder on the target system (it has debugging symbols). I tried using the .gbdinit file to install solib-absolute-prefix / lib

Here are the warnings from the gdb track:

903,056 13-gdb-set sysroot-on-target /lib 903,065 13^done 903,065 (gdb) 903,065 14-target-select remote 192.168.1.101:2345 903,114 =thread-group-started,id="i1",pid="42000" 903,114 =thread-created,id="1",group-id="i1" 903,115 15-list-thread-groups --available 903,120 16-list-thread-groups 903,128 &"warning: Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code." 903,128 &"\n" 

That leads to

 903,395 &"Error while mapping shared library sections:\n" 903,397 &"/lib/libCoreLib.so: Invalid argument.\n" 903,399 =library-loaded,id="/lib/libCoreLib.so",target-name="/lib/libCoreLib.so",hostname="/lib/libCoreLib.so",low-address="0x0",high-address="0x0",symbols-loaded="0",thread-group="i1" 
+4
source share
4 answers

You can debug the library installed on your host if the debugging machine is also a development machine. In this case, you use set sysroot instead of set sysroot-on-target. For instance:

 set sysroot /home/username/.../rootfs/ 

where /home/username/.../rootfs/ contains a copy of the target file system

I think you should also specify / instead of /lib

+4
source

A similar problem occurred during debugging. Debugging hung. The configuration is as follows

Host : Ubuntu 12.04LTS

IDE : Eclipse Kepler

Target : Beaglebone Black / ARM A8

OS : Angstrom

Decision

Update libraries and enable

Select properties for a project in Eclipse

  • C / C ++ General> Paths and Symbols> (enable TAB) GNU C> Add> System Files> / "> usr Change / usr / lib / gcc / i686-linux-gnu / 4/6 / enable to / usr / arm-linux-gnueabi / include

  • C / C ++ General> Paths and Symbols> (enable TAB) GNU C ++> Add>
    File Systems> / "> usr / usr / arm-linux-gnueabi / include / C ++ / 4.6.3 / arm-linux-gnueabi

  • C / C ++ General> Paths and Symbols> (TAB Library Paths)> Add> System Files> / "> usr / usr / arm-linux-gnueabi / lib

0
source

Good afternoon,

If the "debug-file-directory" parameter in GDB is set incorrectly, then the error messages reported contain: warning: it is not possible to find a dynamic function of the breakpoint.

The target root file system is located on my host machine under / opt / hand-linux-gnueabihf-root file system

The following two commands helped me achieve remote debugging through gdbserver using GDB (v7.11.1):

 set debug-file-directory /opt/arm-linux-gnueabihf-rootfs/usr/lib/debug set sysroot /opt/arm-linux-gnueabihf-rootfs 

I noticed that if "sysroot" has a trailing slash in the path, then GDB will not be able to use it. After connecting to the remote target, you will see this (incorrect output):

 Reading /lib/ld-linux-armhf.so.3 from remote target... 

or

 Reading symbols from /opt/arm-linux-gnueabihf-rootfs/lib/ld-linux- armhf.so.3...(no debugging symbols found)...done 

instead of the correct output:

 Reading symbols from /opt/arm-linux-gnueabihf-rootfs/lib/ld-linux- armhf.so.3... Reading symbols from /opt/arm-linux-gnueabihf-rootfs/usr/lib/debug/ lib/arm-linux-gnueabihf/ld-2.23.so...done. 

Regards, Frikkie Thirion

0
source

Target with Debug Symbols

This is the easiest way to work, and it is especially useful when developing one specific shared library.

First, copy the test executable and shared library to the target with debugging information:

Then on target:

 gdbserver --multi :1234 ./executable_name 

Leading:

 arm-linux-gnueabihf-gdb -q -nh \ -ex "target extended-remote target-hostname-or-ip:1234" \ -ex "file ./executable_name" \ -ex 'tb main' \ -ex 'c' \ -ex 'set solib-search-path .' 

sharedlibrary libmylib.so also works.

The problem was that gdbserver stopped at the dynamic loader before main , and dynamic libraries were not loading at that moment, and therefore GDB did not know where the characters would still be displayed.

GDB has some mechanisms for automatically loading shared library characters, and if I compile for the host and run gdbserver locally, starting in main not required. But on target ARM is the most reliable thing.

Target gdbserver 7.12-6, host arm-linux-gnueabihf-gdb 7.6.1 from Linaro.

Target libraries without debugging symbols

It is common to deploy target libraries before deploying to embedded objects, since debugging information makes them larger.

For example, Buildroot does this by default, but you can disable it with BR2_STRIP_none=y .

You can define this scenario by doing:

 info shared 

Which shows something like:

 From To Syms Read Shared Object Library 0x00007ffff7df7f90 0x00007ffff7dfcdd7 Yes (*) target:/lib/ld64-uClibc.so.0 0x00007ffff7b3a9b0 0x00007ffff7bbe05d Yes (*) target:/lib/libc.so.0 (*): Shared library is missing debugging information. 

so there are asterisks ( * ) for both libraries that say that there is no debugging information.

If so, you need to tell GDB to use shared libraries on the host before removing them.

Buildroot, for example, makes this easy for us, because it maintains a staging directory that contains shared libraries until they are deleted and in the same relative paths as in the target:

 set sysroot buildroot/output/staging/ 

When this option is set, gdb immediately looks for libraries in the host instead of the target and finds /lib/libc.so.0 in the buildroot/output/staging/ + /lib/libc.so.0 :

 Reading symbols from buildroot/output/staging/lib/ld64-uClibc.so.0...done. Reading symbols from buildroot/output/staging/lib/libc.so.0...done. 

TODO: I don’t think you can install more than one sysroot , so all of your shared libraries should be placed in their correct relative paths, like in the target image.

If you check the bad default sysroot, you will see:

 show sysroot 

gives:

 target: 

which means that gdb by default searches for shared libraries on the target root / .

0
source

Source: https://habr.com/ru/post/1387661/


All Articles