Debug Tools
- 1 minGDB
Ref: Linux Tools Quick Tutorial, GDB Debug Using Args, How to Debug Using GDB
Start GDB
-
Enable the debug mode by adding the ‘-g’ configuration when compiling: g++ -g hello.cpp -o hello
-
Start the debug mode using the ‘gdb’ command: gdb hello
Arguments
-
(gdb) set args [arguments]
eg: (gdb) set args -v test.v
Commands
-
run ( r ): run the program
-
continue ( c ): continue the debug
-
next ( n ): execute next line
-
step: step into a function
-
break [n] ( b [n] ): set breakpoint in line n
-
break [function] ( b [function] ): set breakpoint in the entrance of the function
-
break [file]:[n] ( b [file]:[n] ): set breakpoint in line n of the specified file
-
info breakpoints: list information of all breakpoints
-
disable [n]: disable break point n
-
list ( l ): show the source code
-
print [expression] ( p [expression] ): print the value of the expression
PDB
Start PDB
- Enable the debug mode by adding the ‘-m pdb’ configuration: python -m pdb demo.py
Commands
-
next ( n ): execute next line
-
print ( p ): print the variable values
-
list ( l ): show the source code
-
step ( s ): step into a function
-
continue ( c ): continue the debug
-
break [n] ( b [n] ): set breakpoint in line n