130 likes | 260 Vues
This project focuses on using GDB (GNU Debugger) for debugging C programs in operating systems. Learn essential GDB commands such as stepping through lines (s), stepping over lines (n), printing pointers (p.ptr), backtraces (bt), setting breakpoints (b), and continuing execution (c). Prerequisites include compiling with gcc using the right parameters (-ggdb) and verifying installations of gcc, gdb, and your text editor. Follow the GDB online manual for further details and ensure a smooth debugging experience through practical examples.
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