WCU / Cybersecurity
~/CSC 471/Class 03/KP 18
Class 03 · KP 18 / 21

Dumping Raw Stack Memory

(gdb) x/16xg $rsp     # 16 giant (8-byte) words in hex from top
(gdb) x/8xg  $rbp     # inspect around the frame base
(gdb) p/x $rsp        # print RSP value
(gdb) p/x $rbp        # print RBP value
(gdb) break *add_squares+4   # break just after the prologue
  • x/16xg $rsp — examine 16 giant words in hex.
  • Set a breakpoint at the prologue, single-step push rbp and mov rbp, rsp, and watch RSP/RBP move.
  • Compare x/16xg $rsp before and after a call to see the return address appear.