0

Compile options of shared library:

g++ -DNO_STORAGE -Wall -DDEBUG_BUILD  -O0 -ggdb3 -DLOG_OUTPUT -fPIC

Compile options of executable:

g++ -Wall -O0 -std=c++11 -ggdb3 -c -Iinc -IDRAMSim2 -LDRAMSim2 -ldramsim

link options:

g++ -LDRAMSim2/ -ldramsim  -ggdb3

As you can see, I use -ggdb3 everywhere. But still when I try single stepping in a function of the shared library, I get:

Single stepping until exit from function _ZN7DRAMSim14addressMappingEmRjS0_S0_S0_S0_@plt, which has no line number information.

I have set LD_PRELOAD and LD_LIBRARY_PATH, neither works.

info shared gives the path of shared libraries which have been linked, /media/psf/Home/box/champsim/ChamSim-CS422A/DRAMSim2/libdramsim.so is exactly what I build with -ggdb3.

(gdb) info shared
From                To                  Syms Read   Shared Object Library
0x00007ffff7fd0100  0x00007ffff7ff2674  Yes         /lib64/ld-linux-x86-64.so.2
0x00007ffff7f825c0  0x00007ffff7faf504  Yes         /media/psf/Home/box/champsim/ChamSim-CS422A/DRAMSim2/libdramsim.so
0x00007ffff7ddd160  0x00007ffff7ec5452  Yes (*)     /usr/lib/x86_64-linux-gnu/libstdc++.so.6
0x00007ffff7d275e0  0x00007ffff7d38045  Yes (*)     /lib/x86_64-linux-gnu/libgcc_s.so.1
0x00007ffff7b54630  0x00007ffff7cc918d  Yes         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff79f03c0  0x00007ffff7a96f18  Yes         /lib/x86_64-linux-gnu/libm.so.6

Also, file command shows the shared library has debug information.

$ file /media/psf/Home/box/champsim/ChamSim-CS422A/DRAMSim2/libdramsim.so
/media/psf/Home/box/champsim/ChamSim-CS422A/DRAMSim2/libdramsim.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=243a1ab772b321d27e5cb1906108cb26e99895b5, with debug_info, not stripped

platform(ubuntu 20.04):

$ uname -a
Linux ubuntu 5.4.0-97-generic #110-Ubuntu SMP Thu Jan 13 18:22:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

gdb version:

$ gdb -v
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2

g++ version:

$ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Tokubara
  • 392
  • 3
  • 13
  • How do you know whether the executable loaded the shared library you compiled? Have you run `ldd`? – Louis Go Mar 25 '22 at 08:03
  • @LouisGo Yes, I have run `ldd`. It gives the path to the shared library that I want to debug, – Tokubara Mar 25 '22 at 08:09
  • The commands you show are incomplete, and due to the ordering of objects/source file and libraries when linking is significant you might not link with the library you believe. Also, using linker flags when compiling to object files is not needed. – Some programmer dude Mar 25 '22 at 08:10
  • Then have you checked the shared library containing the line number you want by `objdump` or `readelf`? – Louis Go Mar 25 '22 at 08:17
  • @Someprogrammerdude I use `info shared` and `ldd` check, the path is exactly what I build. – Tokubara Mar 25 '22 at 08:35
  • 3
    I'm guessing you set a breakpoint to this function (some more info on the gdb commands+output would have been helpful). Apparently it stopped in the `plt` (see [here](https://stackoverflow.com/a/5469334/1983398)) function, once you `continue` from there, it should stop at the real function, and stepping should also work there. – ssbssa Mar 25 '22 at 09:39

0 Answers0