Q&A

  1. While you’re in a gdb session, how do you set the arguments that will be passed to the program when it’s run?

    A: set args [arguments] for setting arguments, show args for showing arguments.

  2. How do you create a breakpoint? A: break <position>

  3. How do you execute the next line of C code in the program after stopping at a breakpoint? A: next

  4. If the next line of code is a function call, you’ll execute the whole function call at once if you use your answer to #3. (If not, consider a different command for #3!) How do you tell GDB that you want to debug the code inside the function (i.e. step into the function) instead? A: step

  5. How do you continue the program after stopping at a breakpoint? A: continue

  6. How can you print the value of a variable (or even an expression like 1+2) in gdb? A: print <var>

  7. How do you configure gdb so it displays the value of a variable after every step? A: watch <var>. List all watchpoints: info break. Delete a watchpoint: delete 1

  8. How do you show a list of all variables and their values in the current function? A: info locals

  9. How do you quit out of gdb? A: quit

  10. How to show disassemble instructions at position? A: disass <position>

  11. How to set disassembly flavor? A: set disassembly-flavor intel|att

  12. How to show register infos? A: info registers