Development Debugging CS 2204 Class meeting 10 Notes
Development: Debugging CS 2204 Class meeting 10 *Notes by Doug Bowman and other members of the (C) Doug. Tech. Bowman, Virginia Tech, CS faculty at Virginia Copyright 2001 -2003. 2001
Overview of software development process n Creation of source files (. c, . h, . cpp) n n Compilation (e. g. *. c n n RCS, last lecture *. o) and linking g++ and make, a previous lecture Running and testing programs n gdb debugger, this lecture (C) Doug Bowman, Virginia Tech, 2001 2
Why use a debugger? n n No one writes perfect code first time, every time Desk checking code can be tedious and error-prone Putting print statements in the code requires re-compilation and a guess as to the source of the problem Debuggers are powerful and flexible (C) Doug Bowman, Virginia Tech, 2001 3
Common debugger functions n n n Run program Stop program at breakpoints Execute one line at a time Display values of variables Show sequence of function calls Catch signals (C) Doug Bowman, Virginia Tech, 2001 4
The GNU debugger (gdb) n n n Free, like all GNU software Command line debugger Most common ways to invoke: n n n gdb executable core gdb executable process_id (C) Doug Bowman, Virginia Tech, 2001 5
Execution commands n list or l (list code) n n run or r (run program from beginning) n n list main list 56 run file. txt file 2. txt next or n (execute next line, stepping over function calls) step or s (execute next line, stepping into function calls) (C) Doug Bowman, Virginia Tech, 2001 6
Breakpoint commands n break or b (set a breakpoint) n n n delete or d (delete a breakpoint) n n n break main break 10 delete 2 continue or c (continue execution when stopped) (C) Doug Bowman, Virginia Tech, 2001 7
Program information commands n print or p (print value) n n n print x*y print function(x) display (continuously display value) undisplay (remove displayed value) where (show current function stack) (C) Doug Bowman, Virginia Tech, 2001 8
Miscellaneous commands n set (change a value) n n help or h (display help text) n n set n=3 help step help breakpoints quit or q (quit gdb) (C) Doug Bowman, Virginia Tech, 2001 9
- Slides: 9