GNU Debugger (GDB)
From mylearnings
Jump to navigationJump to search
Basic Commands
- Find start address and end address of a function
info line <Function Name>
- To view the instruction at a specific address.
x/i <Address>
- Print string pointed by a register.
x/s $rdi
- Disassemble a specific range of address.
disass <start address> <end address>
- Display the local variables
info locals
- Run GDB until the end of current function
finish
- Break out of a loop
until
- Get line number from address
info symbol <address>
Watchpoints and Breakpoints
- Stop when foo is modified
gdb> watch foo
- Watch location
gdb> watch -l foo
- Stop when foo is read
gdb> rwatch foo
- Stop when thread 3 modifies foo
gdb> watch foo thread 3
- Stop when foo is > 10
gdb> watch foo if foo > 10
- Enable a break point.
gdb> enable <comma separated break point numbers..>
- Disable break points.
gdb> disable <comma separated break point numbers..>
- List all break points.
gdb> info b
Debugging a multithreaded program
- List all the threads.
gdb> info threads