Debug Tools
- 1 minGDB
Ref: Linux Tools Quick Tutorial, GDB Debug Using Args, How to Debug Using GDB
Start GDB
-
When compiling, add ‘-g’ option: g++ -g hello.cpp -o hello
-
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
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