Lack of line numbers from debugging symbols for the library as a whole program, but not separately

I see a strange problem when trying to use gdb to debug a test program for a package created using libtool. If I run libtool --mode=execute gdb .libs/libfoo.so and ask him to list the source of some list Bar::Baz function, I get the source code as expected. If I run libtool --mode=execute gdb binary , I can break into Bar::Baz() and see its arguments in the stack trace, but I don't get any source files or lines, for example:

 #7 0x018348e5 in Bar::Baz(Qux*, Quux*) () from /path/to/libfoo.so ^^^^^^^^^^^ <--- debug symbols are present! 

Similarly, if I try to list Bar::Baz while debugging the executable, I get

 No line number known for 'Bar::Baz'. 

I have confirmed that the binary is associated with -g , and I can list its main function, so I know that there is some kind of debugging information.

When I say info sources , I get a complete list of the files the library is built from, with the correct absolute paths. When I say info shared , I get the correct path specified in the object file, with Yes in the Syms column.

Any other ideas what could go wrong and how to fix it?


Edit 1: by chance, I ran objdump -g into the intruder library and received the following output:

 /path/to/foo.so.0.0.0: file format elf32-i386 objdump: /path/to/foo.so.0.0.0: no recognized debugging information 

This is surprising since objdump -h (what I was trying to run) contains a list of .debug_* sections. The objdump manual also suggests readelf -w , and this seems to print a huge amount of information. I need to take a look at what it actually provides.


Edit 2: So readelf -w produced some enlightenment. For some reason, the shared object file does not seem to contain debug information from the vast majority of any of the objects associated with it. Based on Make files, it is possible that a command that actually collects objects into a shared library is not passed -g , and therefore the information is not properly distributed. The funny thing is that it works (it has full debugging information) for all our other configurations, including the same x86_64 compiler version (compared to the real x86).


Edit 3: Actually, a complete redistribution went through with a modified Makefile with -g added to LDFLAGS, and that didn't make any difference. Now I am well and really puzzled.

+4
source share
3 answers

This is the answer to the old question, but your problem matched mine, but none of the solutions worked. Here is what worked for me.

Change CFLAGS -g to "-g -gstabs".

objdump did not recognize dwarf style debugging information. -gstabs changes this format to one that works with objdump -g and objdump -S and my debugger.

Hope this helps.

NOTE. For me, I created the linux kernel. This change has been made to the linux kernel makefile.

+5
source

Your first confusion: Bar::Baz(Qux*, Quux*) does not mean that there are debugging symbols (and actually implies that they are not).

The debugger simply enters the name of the function. If there were actually debugging symbols, you would see Bar::Baz(Qux* qux = 0x12..., Quux* quux = 0x234...)

Regarding the real issue, I suspect the symbol is defined in some other library, which

  • appears on the link for the binary before libfoo.so , and
  • was created without debugging symbols

(The runtime loader will bind the link to Bar::Baz() to the first definition that it sees.)

If you are typing ip in frame # 7, then make info symbol <value-just-printed> , I suspect you will have “Aha!”. moment.

EDIT: Your update made your question inconsistent. AFAICT,

  • gdb can see debugging symbols when executing libtool --mode=execute gdb .libs/libfoo.so
  • but not when executing libtool --mode=execute gdb binary
  • You have confirmed that the symbol definition comes from exactly the same .libs/libfoo.o
  • and readelf -w do not display debug symbols in .libs/libfoo.o

At least one of the statements above is most likely incorrect.

If all of them are truly correct, you probably have a strange gdb and readelf error (there may be an error in one case, a simultaneous error in both cases is unlikely).

Also note that adding -g to LDFLAGS is usually incorrect. Do you want to add it instead of CXXFLAGS ?

+2
source

Something made me wonder what the show language result is when you are having problems. If it's not c++ , maybe set language c++ necessary?

0
source

All Articles