gdb - itzjac/cpplearning GitHub Wiki
Best way to learn gdb is going through the assembly and disassembly instructions, the same techniques are applied to higher level languages. The following tutorial is a detailed gdb explanation on how to debug x86 binaries on a Linux machine that has a x64 OS.
- x86 Assembly on a 64 bit Linux - Part 1/3
- x86 Assembly on a 64 bit Linux - Part 2/3
- x86 Assembly on a 64 bit Linux - Part 3/3
Other useful tutorials
Comprehensive tutorial about gdb - GNU debugger
Give me 5min and I will change your view of GDB
Little programming Guides | C, C++, Linux, gdb by Faye Williams
Use a file to specify the information you want to print on every step
display/10i $eip
display/x $eax
display/x $ebx
display/x $ecx
display/x $edx
display/x $edi
display/x $esi
display/x $ebp
display/16xw $esp
break main
Will display 10 assembly instructions from the eip, eax, ebx ... ebp resgisters, and 16 instructions from esp.
If this file is called commands.txt, to invoke from command line
$gdb myProgram -x commands.txt
If you want to explore memory instead of displaying
$x/x $eax
To only print the eax content
$print/x $eax
When using breakpoint on function, like main on our command list, gdb skips all the function setup call (push ebp, mov ebp, esp, etc..). So how can we visualize the entire function call sequence?
$x/10i main
Which will print 10 assembly instructions starting from main.
Stepping in code and assembly instructions respectively. Step over with next
$step
$stepi
Step over and step out
$nexti
$finish
List current break points
$break 10
$break main
$info breakpoints
$layout regs
$layout asm