Debug Tools

- 1 min

GDB

Ref: Linux Tools Quick Tutorial, GDB Debug Using Args, How to Debug Using GDB

Start GDB

  1. When compiling, add ‘-g’ option: g++ -g hello.cpp -o hello

  2. gdb hello

Arguments

  1. (gdb) set args [arguments]

    eg: (gdb) set args -v test.v

Commands

  1. run ( r ): run the program

  2. continue ( c ): continue the debug

  3. next ( n ): execute next line

  4. step: step into a function

  5. break [n] ( b [n] ): set breakpoint in line n

  6. break [function] ( b [function] ): set breakpoint in the entrance of the function

  7. break [file]:[n] ( b [file]:[n] ): set breakpoint in line n of the specified file

  8. info breakpoints: list information of all breakpoints

  9. disable [n]: disable break point n

  10. list ( l ): show the source code

  11. print [expression] ( p [expression] ): print the value of the expression

PDB

Ref: pdb - The Python Debugger

Start PDB

python -m pdb demo.py

Commands

  1. next ( n ): execute next line

  2. print ( p ): print the variable values

  3. list ( l ): show the source code

  4. step ( s ): step into a function

  5. continue ( c ): continue the debug

  6. break [n] ( b [n] ): set breakpoint in line n

Kaixin Yang

Kaixin Yang

做你该做的事情,并接受它的事与愿违

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora