130 likes | 253 Views
CO004 Projects on Operating Systems. Debug 2 gdb and insight. GDB commands. Use gdb directly (commands only) s 2 (step in 2 lines) n (step over 1 lines) p ptr (print the value of ptr) bt (back trace) b (break point) c (continue to run). GDB. Demo: bugs .c Prerequisite
E N D
CO004 Projects on Operating Systems Debug 2 gdb and insight
GDB commands • Use gdb directly (commands only) • s 2 (step in 2 lines) • n (step over 1 lines) • p ptr (print the value of ptr) • bt (back trace) • b (break point) • c (continue to run)
GDB • Demo: • bugs.c • Prerequisite • Compile using proper parameter • gcc -ggdb -o bugs bugs.c • Reference • GDB Online Manual http://www.gnu.org/software/gdb/documentation/
Insight+gdb • Things to Install • gcc • vim (or other text editor) • gdb • insight (or other debugger like “ddd”)
Before Installation • Check which one has been installed • gcc –-version • gdb -–version • vim --version • insight --version
You should see the source code Remember to use “gcc -ggdb xxxxxxx”, otherwise you cannot see any source code
Breakpoint Program will stop before executing this statement!
Breakpoint Program will stop before executing this statement!
• Run : run/start the program • Step: Execute the current line of code, jump into the function if possible • Next: Similar to “Step”, but don’t jump into the function • Finish: Jump out of the current function • Continue: Execute until hitting another breakpoint