문제

I am using backtrace() and backtrace_symbols() to output backtrace on SIGSEGV and other signals in format like this:

0: [0xb750818]
1: /opt/server/libQtScript.so.4(+0x6f42a) [0xb782c42a]
2: /opt/server/libQtScript.so.4(+0x7bffc) [0xb7838ffc]
3: /opt/server/libQtScript.so.4(+0x86946) [0xb7843946]
4: /opt/server/libQtScript.so.4(+0x7c4bc) [0xb78394bc]
5: /opt/server/libQtScript.so.4(+0x86946) [0xb7843946]
6: /opt/server/libQtScript.so.4(+0x9603e) [0xb785303e]
7: /opt/server/libQtScript.so.4(_ZN12QScriptValue4callERKS_RK5QListIS_E+0x2e7) [0xb7891647]

In this particular case, frame #7 is fine for me, though frame 1-6 gives me some kind "+x" addresses.

How to get exact line in disassemble for "+0x6f42a" and other addresses in GDB? And what frame #0, without described module, means?

도움이 되었습니까?

해결책

How to get exact line in disassemble for "+0x6f42a" and other addresses in GDB?

gdb /opt/server/libQtScript.so.4
(gdb) x/10i 0x6f42a

Usually you'll want instructions that executed before 0x6f42a, so you'll do this:

(gdb) x/20i 0x6f42a-30

Ignore the first few instructions: you could be starting disassembly from a middle of one. Usually the disassembly will re-synchronize after a few instructions, and will start showing correct instruction stream after that.

And what frame #0, without described module, means?

Your library has been stripped of symbols, so the only symbols you see (e.g. _ZN12QScriptValue4callERKS_RK5QListIS_E) are the externally-visible (aka exported) ones.

There are libQtScript.so.4.5.2.debug symbol file in QT_SOURCE/lib folder. So maybe I should copy .debug file near executable to get backtrace with full symbols?

GDB should load symbols from libQtScript.so.4.5.2.debug automatically if you set debug-file-directory to $QT_SOURCE/lib.

Update:

I ment getting backtrace with symbols without attaching GDB

I don't believe there is any support in backtace_symbols() for loading separate debuginfo files.

다른 팁

If you have libQTScript compiled with debug-symbols you will get a better backtrace with function names and parameter values. I don't know exactly how to extract the same information without debug symbols (although it should be possible if you have the correct map-file or symbol-table file of libQTScript).

But the easy way is to install libqt with debug symbols and run the backtrace again. If both the stripped and debug libs are installed and gdb chooses the stripped one, try to point gdb to the debug libs with LD_LIBRARY_PATH=path/to/debug/libs. (see this answer for another method to set the path How do I prepend a directory the library path when loading a core file in gdb on Linux)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top