gdb: how to get a complete backtrace when segfaults?


I'm experiencing segmentation faults in the fglrx dri library when running my own Qt based OpenGL application. The backtrace I get from gdb (with dbg symbols installed for Qt and my own application):

Thread 1 (Thread 0xb7fd9720 (LWP 1809)):
#0  0x06276705 in ?? () from /usr/lib/fglrx/dri/
#1  0x000020dc in ?? ()
#2  0x000020d9 in ?? ()
#3  0x00000000 in ?? ()

I can not see where from my code I call the fglrx function which causes the segmentation fault. How could I extend this backtrace to see it completely from the main() function down to the fglrx dri library?

edit: To confirm my own application is built with debug symbols:

Reading symbols from /home/user/fglrx crash/crashtest-build-desktop-Qt_4_8_1__Qt-4_8_1__Debug/crashtest...done.
(gdb) br main
Breakpoint 1 at 0x804996d: file ../program/main.cpp, line 21.
(gdb) run
Starting program: /home/user/fglrx crash/crashtest-build-desktop-Qt_4_8_1__Qt-4_8_1__Debug/crashtest  [Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=1, argv=0xbffff2a4) at ../program/main.cpp:21
21      QApplication a(argc, argv);
(gdb) bt
#0  main (argc=1, argv=0xbffff2a4) at ../program/main.cpp:21
(gdb) n
[New Thread 0xb7d2bb70 (LWP 2475)]
[New Thread 0xb752ab70 (LWP 2476)]
22      QMainWindow w;
(gdb) bt
#0  main (argc=1, argv=0xbffff2a4) at ../program/main.cpp:22
(gdb) s
QFlags<Qt::WindowType>::QFlags (this=0xbffff164) at /usr/local/Trolltech/Qt-4.8.1/include/QtCore/qglobal.h:2284
2284        Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
(gdb) bt
#0  QFlags<Qt::WindowType>::QFlags (this=0xbffff164) at /usr/local/Trolltech/Qt-4.8.1/include/QtCore/qglobal.h:2284
#1  0x080499a4 in main (argc=1, argv=0xbffff2a4) at ../program/main.cpp:22
asked on Stack Overflow Jun 23, 2012 by Christophe • edited Jun 23, 2012 by Christophe

2 Answers


You have to generate debug symbols for your own binary as well. Compile your application with GCC's -g option. It's also advisable to turn off optimization for the time of debugging; use GCC's -O0 flag for this purpose.

answered on Stack Overflow Jun 23, 2012 by (unknown user)

The simple and awful answer is you can't. According to Graham Sellers of AMD, the driver is compiled with the -fomit-frame-pointer flag, which confuses gdb if it's deeper down the stack.

answered on Stack Overflow Dec 10, 2013 by IneQuation • edited Dec 11, 2013 by IneQuation

User contributions licensed under CC BY-SA 3.0