Opening core dump with gdb

What is the most essential thing you would want to do with a core file.
I guess it is the backtrace.
Today I had some time to practice with gdb under Linux.

So first step is launching gdb, loading symbols and core file.

>gdb
>file "executable"

Reading symbols from /opt/test/executable...(no debugging symbols found)...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".

>core-file "core.23555"

warning: core file may not match specified executable file.
Core was generated by `/opt/test/executable'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /opt/ect/lib/libACE.so.5.4.6...done.
Loaded symbols for /opt/ect/lib/libACE.so.5.4.6
Reading symbols from /opt/ect/lib/libAxisEngine.so...done.
Loaded symbols for /opt/ect/lib/libAxisEngine.so
Reading symbols from /opt/ect/lib/libxerces-c.so.22...done.
Loaded symbols for /opt/ect/lib/libxerces-c.so.22
Reading symbols from /opt/ect/lib/libHTTPChannel.so...done.
Loaded symbols for /opt/ect/lib/libHTTPChannel.so
Reading symbols from /opt/ect/lib/libHTTPTransport.so...done.
Loaded symbols for /opt/ect/lib/libHTTPTransport.so
...
#0  0x00888b7d in fflush () from /lib/tls/libc.so.6

Now the dump and the executable are both loaded and it is possible to investigate what causes the application to crash.

> bt

#0  0x00888b7d in fflush () from /lib/tls/libc.so.6
#1  0x001ceb9a in std::__basic_file<char>::close () from /usr/lib/libstdc++.so.5
#2  0x00184719 in std::basic_filebuf<char, std::char_traits<char> >::close ()
         from /usr/lib/libstdc++.so.5
#3  0x0805ced5 in TestClass::ExecuteSomething()
#4  0x080534ff in AnotherClass::DoSomething()
#5  0x08053399 in ThirdClass::SomeMethod()
#6  0x00e80822 in ACE_Thread_Adapter::invoke_i (this=0x0) at some_file.cpp:139
#7  0x00e80789 in ACE_Thread_Adapter::invoke (this=0x9c39530) at some_file.cpp:3
#8  0x00e1c25f in ace_thread_adapter (args=0xb7315e98) at some_other_file.cpp:11
#9  0x00749dd8 in start_thread () from /lib/tls/libpthread.so.0
#10 0x00905d1a in clone () from /lib/tls/libc.so.6

From this typical output it can be realized which place in the code caused the problem.
Now it is good to recompile the application with some additional tracing included in the places where program crashes.

Leave a Reply