An application crashed, and there was a core file generated.
1. Collect all the associated libraries, and run “gdb”.
(gdb) file testApp
(gdb) set solib-search-path .
(gdb) core testApp. core
it will show something like:
Program terminated with signal 11, Segmentation fault.
#0 0x781306a6 in xx_thread () from libcapture-soc-xx.so
#0 0x781306a6 in xxx_thread () from libcapture-soc-xxx.so
#1 0x01025a8c in timer_settime () from libc.so.3
So you want to know what the instruction is at 0x781306a6.. go to..
2. check the disassembly code
(gdb) disassemble hw_capture_thread
it will show you the assembly code and where the crash occurs.
(gdb) info registers
so it is clear that an invalid address is being accessed: register r3 is 0.
3. Which piece of C code?
you need have a library with symbols (-g), and run “pahole libcapture-soc-xx.so”, or run “pahole xx.o”, it will show all the structures in that library/file.
the crashing point shows that the code was trying to access a member of a structure at offset 52, so you look for the structures which has a member at 52..
Note: why does the backtrace show “imer_settime()” calls “xx_thread()”?
the reason is, it is some function in C library which calls/schedules xx_thread. However, since there are no debug symbols in libC, gdb can’t locate the exact function, and can only return a static/global function which is closer.
1. “info” is a very useful command.
- info threads
- info shared libraries
- info registers
2. to check the states of other threads, ” thread apply all bt”.
3. Pohole (Poke-a-Hole) was developed to find the size of the data structures, and the holes caused due to aligning the data elements to the word-size of the CPU by the compiler. see https://lwn.net/Articles/335942/