Difference between revisions of "Gdb"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 3: Line 3:
 
= Notable functions =
 
= Notable functions =
 
  info functions
 
  info functions
 +
 +
= Example =
 +
 +
== How to debug vlc ==
 +
Here I try to find out where vlc exits because I am root:
 +
gdb /usr/bin/vlc
 +
(gdb) info functions
 +
All defined functions:
 +
 +
Non-debugging symbols:
 +
[...]
 +
0x0000000000400f40  geteuid
 +
[...]
 +
(gdb) break geteuid
 +
Breakpoint 1 at 0x400f40
 +
(gdb) run
 +
Starting program: /usr/bin/vlc
 +
 +
Breakpoint 1, 0x00007ffff71cfc70 in geteuid () from /lib64/libc.so.6
 +
ok, let's trace the program one command at a time:
 +
(gdb) stepi
 +
0x00007ffff71cfc75 in geteuid () from /lib64/libc.so.6
 +
(gdb) stepi
 +
0x00007ffff71cfc77 in geteuid () from /lib64/libc.so.6
 +
(gdb)
 +
0x0000000000401103 in ?? ()
 +
(gdb)
 +
0x0000000000401105 in ?? ()
 +
(gdb)
 +
0x000000000040170f in ?? ()
 +
[...]
 +
(gdb) break *0x40170e
 +
Breakpoint 3 at 0x40170e
 +
(gdb) continue
 +
  
 
= See also =
 
= See also =
 
* [[objdump]] -- disassemble a program
 
* [[objdump]] -- disassemble a program
 
* [[strace]] -- show syscalls from a running process
 
* [[strace]] -- show syscalls from a running process

Revision as of 15:07, 26 November 2011

gdb allows you to debug Linux programs.

Notable functions

info functions

Example

How to debug vlc

Here I try to find out where vlc exits because I am root:

gdb /usr/bin/vlc
(gdb) info functions
All defined functions:

Non-debugging symbols:
[...]
0x0000000000400f40  geteuid
[...]
(gdb) break geteuid
Breakpoint 1 at 0x400f40
(gdb) run
Starting program: /usr/bin/vlc 

Breakpoint 1, 0x00007ffff71cfc70 in geteuid () from /lib64/libc.so.6

ok, let's trace the program one command at a time:

(gdb) stepi
0x00007ffff71cfc75 in geteuid () from /lib64/libc.so.6
(gdb) stepi
0x00007ffff71cfc77 in geteuid () from /lib64/libc.so.6
(gdb) 
0x0000000000401103 in ?? ()
(gdb) 
0x0000000000401105 in ?? ()
(gdb) 
0x000000000040170f in ?? ()
[...]
(gdb) break *0x40170e
Breakpoint 3 at 0x40170e
(gdb) continue


See also

  • objdump -- disassemble a program
  • strace -- show syscalls from a running process