3

I compiled a C++ program and want to debug it with gdb now. Version of gcc is gcc (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5, of gdb it's GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1, so this doesn't seem to be a problem in my case.

Starting gdb like $ gdb --args ./my_program /path/to/a/file works, but it yields the following message:

Reading symbols from ./my_program...(no debugging symbols found)...done.

I can still run the program using run, but anything that requires debug symbols will fail, like setting breakpoints on lines, or using i line or i locals.

So as suggested in this answer, I ran $ objdump --debugging ./my_program, and the output fills a few thousand lines, so I'm fairly certain that debugging symbols are indeed available.

There's also this question but it seems to be more related to shared libraries. Running info sharedlibrary in gdb shows that those don't have debugging info in my case, but I don't think I need to be concerned about that.

(gdb) info sharedlibrary
From                To                  Syms Read   Shared Object Library
0x00007ffff7ddab00  0x00007ffff7df5660  Yes         /lib64/ld-linux-x86-64.so.2
0x00007ffff74f1250  0x00007ffff74f1dc3  Yes (*)     /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
0x00007ffff72e0a80  0x00007ffff72eb5e0  Yes (*)     /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0
0x00007ffff70a5810  0x00007ffff70b6a43  Yes (*)     /usr/lib/x86_64-linux-gnu/libexif.so.12
[...]
(*): Shared library is missing debugging information.

As suggested in the comments, I also checked for stripping:

$ file ./my_program
./shore_evaluate: ELF 64-bit LSB  executable, x86-64, version 1 (GNU/Linux), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.24,
BuildID[sha1]=aa85fb21d388828eced5bd0be4202a50bbba1b90, not stripped

What can I do to make GDB find the debugging symbols?

iFreilicht
  • 13,271
  • 9
  • 43
  • 74
  • 3
    how do you compile your binary ? Check the man page for gcc normally you need to compile with `-g` or `-ggdb` generating executable with debug symbols – deimus Jul 14 '17 at 11:57
  • I'm using cmake. `-g` is in my `CMAKE_CXX_FLAGS`, and as far as I know the output of `objdump` proves that. – iFreilicht Jul 14 '17 at 12:01
  • 1
    try replaceing `-g` with `-ggdb` and be sure that you don't have any stripping e.g. `-s` or `-S` – deimus Jul 14 '17 at 12:11
  • Done, didn't change anything. I also tried `file ./my_program` which shows that no stripping is occuring after compilation. – iFreilicht Jul 14 '17 at 12:26
  • @deimus It seems that I was in the wrong, the problem was actually cmake. I have added `-gddb` and cleared the cache, re-ran cmake and then re-compiled everything using make, and now the debugging symbols are all there: `Reading symbols from ./my_program...done.` Thank you so much for your help! – iFreilicht Jul 14 '17 at 14:27

0 Answers0