Debugging disassembled libraries with gdb

on Linux and Mac OS X I can use stepi and nexti to debug an application without debugging information.

Mac OS X gdb displays the functions that are called inside the library, although sometimes there are several assembler instructions in each stepi instruction.

On Linux, when I enter the dynamic library, gdb is lost. For example, with puts () there are three assembler commands inside puts (), when gdb reaches the jump at 0x080482bf, it fails with the message "No function contains program counter for the selected frame".

0x080482ba in puts@plt () (gdb) disassemble Dump of assembler code for function puts@plt: 0x080482b4 <puts@plt+0>: jmp *0x8049580 0x080482ba <puts@plt+6>: push $0x10 0x080482bf <puts@plt+11>: jmp 0x8048284 <_init+48> End of assembler dump. (gdb) stepi 0x080482bf in puts@plt () (gdb) stepi 0x08048284 in ?? () (gdb) disassemble No function contains program counter for selected frame. 

You know how to debug these library calls with gdb.

+10
assembly x86 disassembly gdb
Oct 18 '09 at 16:24
source share
1 answer

If GDB does not have debugging symbols for the function you are trying to debug, GDB will not be able to determine the range of memory addresses for dismounting. To get around this, you can pass the range to the disassemble command. For example:

 (gdb) p $pc $4 = (void (*)()) 0x70c72d <_IO_puts+29> (gdb) disassemble 0x70c72d 0x70c740 Dump of assembler code from 0x70c72d to 0x70c740: 0x0070c72d <_IO_puts+29>: mov %eax,(%esp) 0x0070c730 <_IO_puts+32>: call 0x721f10 <strlen> 0x0070c735 <_IO_puts+37>: mov 0x84c(%ebx),%edx 0x0070c73b <_IO_puts+43>: cmpw $0x0,(%edx) 0x0070c73f <_IO_puts+47>: mov %edx,-0x10(%ebp) End of assembler dump. 

There may be a way to set debugging symbols. On my Ubuntu system, I installed the libc6-dbg package, which allows me to enter functions in the standard library.

+12
Oct 24 '09 at 8:51
source share



All Articles