pwndbg registers, variables, and stack
The context pane is useful for orientation, but explicit commands make observations easier to repeat and record.
Registers and variables
Section titled “Registers and variables”regs # pwndbg register viewinfo registers # GDB register viewp $raxp/x $ripp/d $rdip variable # if symbols are availablep/x variableinfo localsinfo args| Command | What it does |
|---|---|
regs |
pwndbg’s compact register display for the current stop. |
info registers |
GDB’s full register listing. |
p EXPR |
Evaluates and prints an expression. |
p/x EXPR / p/d EXPR |
Prints an expression in hexadecimal or decimal. |
info locals |
Lists named locals in the selected frame, if symbols allow it. |
info args |
Lists named parameters in the selected frame. |
GDB’s p evaluates an expression. A stripped binary may not have source-level variable names; then inspect the register or memory location that carries the value. On Linux x86-64, the first integer or pointer arguments are commonly in RDI, RSI, RDX, RCX, R8, and R9.
To inspect memory as a typed value, use a cast:
p *(int *)$rdip *(char **)($rbp-0x20)x/s $rdix/32bx $rdip *(int *)$rdi reads four bytes at the address in RDI as an integer. p *(char **)($rbp-0x20) treats the address at RBP-0x20 as a pointer value. x/s reads bytes as a NUL-terminated string; x/32bx reads a raw 32-byte range. These commands inspect different interpretations of the same memory; use the type and length that fit the question.
Only dereference addresses that are mapped and readable. A bad pointer can itself trigger a debugger error or target fault.
Stack views
Section titled “Stack views”stack # pwndbg stack summarytelescope $rsp 24 # follow likely pointers from RSPx/24gx $rsp # raw eight-byte wordsx/96bx $rsp # raw bytesx/8gx $rbp-0x20 # nearby frame area, if RBP is a frame pointer| Command | What it does |
|---|---|
stack |
pwndbg’s compact view of stack words around the current stack pointer. |
telescope ADDRESS COUNT |
Displays words and follows values that look like pointers. |
x/24gx $rsp |
GDB’s raw view of 24 eight-byte values starting at RSP. |
x/96bx $rsp |
GDB’s raw view of 96 individual bytes starting at RSP. |
x/8gx $rbp-0x20 |
Reads eight eight-byte values starting near the current frame pointer. |
telescope follows values that look like pointers and labels likely code or data references. Use x when you need the exact raw bytes. Stack layout varies with the function, compiler, ABI, and optimization. The frame pointer is not guaranteed to be present.
Call stack and frame navigation
Section titled “Call stack and frame navigation”bt # backtracebt full # include available local variablesframe 1 # select caller frame 1info frameupdown| Command | What it does |
|---|---|
bt |
Lists active call frames from the current function outward. |
bt full |
Adds available local-variable values to the backtrace. |
frame N |
Selects frame N for local and argument inspection. |
info frame |
Shows the selected frame’s saved state and stack details. |
up / down |
Selects the caller frame or the callee frame. |
Frame selection changes which source-level locals GDB can show; it does not rewind the process. Return to the top frame with frame 0 before interpreting current registers.
Refresh after stepping
Section titled “Refresh after stepping”After ni, si, continue, or a breakpoint hit, inspect the state again. The stack changes when instructions push, pop, or reserve space. pwndbg’s automatic context is a view of the latest stop, but a prior terminal dump remains old output.
niregstelescope $rsp 16nearpcHere ni executes one instruction, regs shows the updated registers, telescope $rsp 16 rereads 16 stack entries, and nearpc shows instructions around the new RIP. Together these commands refresh the context after stepping.