How to debug shared libraries compiled with debugging information

I am compiling a program with debugging symbols that reference a shared library (liballegro), also compiled with debugging symbols. When I try to enter the function of this shared library, I do not see any code.

file myBin 
mybin: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d4133ef127e81ffb007c4c17e10f4ddaefac6a0f, with debug_info, not stripped

file lib/liballegro-debug.so
liballegro-debug.so.5.2.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=dd75ca87e0ed86832ed02a1c40548a055ad4f551, with debug_info, not stripped

GDB shows how this library loads with debugging information:

(gdb) info shared
From                To                  Syms Read   Shared Object Library
0x00007ffff7dd9b40  0x00007ffff7df5110  Yes (*)     /lib64/ld-linux-x86-64.so.2
0x00007ffff7a5a0d0  0x00007ffff7b84591  Yes         correct/path/to/liballegro-debug.so
0x00007ffff76ffd60  0x00007ffff7778eef  Yes (*)     /usr/lib/libm.so.6
0x00007ffff74e1640  0x00007ffff74eefb1  Yes (*)     /usr/lib/libpthread.so.0
[...]

So, I set a breakpoint in a function call that lives in a shared library (al_load_bitmap):

90      level->tileset.parent = al_load_bitmap(filename);

The source code al_load_bitmap is located in the path to the file / in / src / bitmap_io.c , which is indicated in the output of gdb information sources

And go into it:

(gdb) si
0x0000555555555f00 in al_load_bitmap@plt ()

At this moment, I cannot figure out how to see the source code of this function, since the list command does not show anything.

, ?

PD: lldb , - .

.

+4
1

al_load_bitmap@plt - PLT- ( , ), . , , , , . , ( LD_BIND_NOW=1).

s (step) ( ).

, file , - GDB (, ). , , / debuginfo, ELF ( , file ).

+5

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


All Articles