GDB seems to have been clearly made with source-level debugging in mind, the kind where the source code of the program is available. Sometimes this is not the case, or you just don’t want to bother looking for the source code. Here I’ll put a bunch of useful commands.
layout asm
: enable TUI mode and show assembly instructionslayout regs
: enable TUI mode and show CPU registersset disassembly-flavor intel
: use Intel-like disassembly, which is more familiar to those writing or debugging assembly code on WindowsCtrl+P
,Ctrl+N
: serve as alternatives to “up” and “down” when the active TUI window is not the command windowCtrl+X, O
: switch the active TUI windowCtrl+X, (A or Shift+A or Ctrl+A)
: toggle TUI modex/5i $pc
: check out 5 instructions, starting at the program counterni
(nexti
) andsi
(stepi
): next/step, but on an instruction levelb *0x<addr>
: breakpoint on a specific addressinfo registers
: look at CPU registersinfo frame
: look at current stack frame, potentially useful for finding function arguments and local varsx/8g $sp
: look at (64-bit words) in the stack