Check out my first novel, midnight's simulacra!

Gdb: Difference between revisions

From dankwiki
(Created page with '==Display== <tt>display</tt> will evaluate and print an expression after each command run. * Use <tt>display/i $pc</tt> to get the current instruction address and decode')
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
<tt>display</tt> will evaluate and print an expression after each command run.
<tt>display</tt> will evaluate and print an expression after each command run.
* Use <tt>display/i $pc</tt> to get the current instruction address and decode
* Use <tt>display/i $pc</tt> to get the current instruction address and decode
** <tt>2i</tt> will give you the current and next instruction
==Control flow==
* Use <tt>finish</tt> to move to the end of a stack frame
* Use <tt>step</tt> and <tt>stepi</tt> to move forward, descending into new stack frames
* Use <tt>next</tt> and <tt>nexti</tt> to move forward, skipping over new stack frames
* Export <tt>LD_BIND_NOW=1</tt> to force early symbol binding. This eliminates annoying dl code when resolving the [[ELF|.plt section]]
* Use <tt>set follow-fork-mode child</tt> to follow the child of <tt>fork</tt>/<tt>vfork</tt>
==Stacktraces==
* Stacktrace of all threads -- <tt>thread apply all bt</tt>

Latest revision as of 20:45, 7 October 2019

Display

display will evaluate and print an expression after each command run.

  • Use display/i $pc to get the current instruction address and decode
    • 2i will give you the current and next instruction

Control flow

  • Use finish to move to the end of a stack frame
  • Use step and stepi to move forward, descending into new stack frames
  • Use next and nexti to move forward, skipping over new stack frames
  • Export LD_BIND_NOW=1 to force early symbol binding. This eliminates annoying dl code when resolving the .plt section
  • Use set follow-fork-mode child to follow the child of fork/vfork

Stacktraces

  • Stacktrace of all threads -- thread apply all bt