Skip to content

pwndbg registers, variables, and stack

The context pane is useful for orientation, but explicit commands make observations easier to repeat and record.

regs # pwndbg register view
info registers # GDB register view
p $rax
p/x $rip
p/d $rdi
p variable # if symbols are available
p/x variable
info locals
info 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 *)$rdi
p *(char **)($rbp-0x20)
x/s $rdi
x/32bx $rdi

p *(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 # pwndbg stack summary
telescope $rsp 24 # follow likely pointers from RSP
x/24gx $rsp # raw eight-byte words
x/96bx $rsp # raw bytes
x/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.

bt # backtrace
bt full # include available local variables
frame 1 # select caller frame 1
info frame
up
down
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.

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.

ni
regs
telescope $rsp 16
nearpc

Here 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.