Thursday, April 22, 2010

Rebuild backtrace of GDB

Sometimes the GDB had a corrupt backtrace, which has to be rebuilt. Here is an example:


find out the stack base pointer
(gdb) info reg ebp
ebp            0xbf9ef358        0xbf9ef358

examine 2048 bytes in hex format for the memory around that address
(gdb) x/2048h 0xbf9ef358
0xbf9ef358: 0xbf9ef388  0x00d94cf7  0x0a85e988  0x00000024
0xbf9ef368: 0xbf9ef388  0x00d94d8a  0x00000000  0x05000000
0xbf9ef378: 0x00000000  0x0a85e994  0x00000000  0x0a86dacc
0xbf9ef388: 0xbf9ef418  0x00c331ab  0x0a85e994  0x00000015
0xbf9ef398: 0x00000000  0xb7800000  0x0992f188  0xbf9ef40c
So you have stack:
StackFrame | Instruction
Pointer    | Pointer
------------------------
0xbf9ef388 | 0x00d94cf7
0xbf9ef418 | 0x00c331ab
dump the symobl information
objdump -Dt /usr/sbin/squid > squid.dis

Then look for 
0x00c331ab
inside squid.dis
 

No comments: