70 likes | 219 Views
Debugging. Xin Tong. GDB. GDB GNU Project debugger Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing statement) Four main kinds of things: Start your program, specifying anything that might affect its behavior.
E N D
Debugging Xin Tong
GDB • GDB • GNU Project debugger • Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing statement) • Four main kinds of things: • Start your program, specifying anything that might affect its behavior. • Make your program stop on specified conditions. • Examine what has happened, when your program has stopped. • Change things in your program • Ada, C, C++, Objective-C, Pascal (and many other languages). Reference: http://beej.us/guide/bggdb/ http://www.gnu.org/software/gdb/
Visual Studio as Example • An integrated development environment (IDE) from Microsoft. • Supports different programming languages, such as C, C++, VB.NET, C#, and F#.
Breakpoints • Debugging with Breakpoints • Step Over • Step Into • Step Out • Continue • Set Next Statement • Show Next Statement • Run to cursor • Labeling in Break Point • Conditional Breakpoint • Breakpoint Hit Count • Breakpoint When Hit Reference: http://www.codeproject.com/Articles/79508/Mastering-Debugging-in-Visual-Studio-A-Beginn
Data Tip • Pin Inspect Value During Debugging • Drag-Drop Pin Data Tip • Adding Comments • Import Export Data Tips • Change Value Using Data Tips • Inspect containers • Clear Data Tips
Debug Windows • Watch Windows • Locals • Autos • return value from last statement • File base address • Watch • Memory Window • Immediate Window • Call Stack
Example Bugs • Array index out of bounds • Uninitialized variable Reference: http://www.klocwork.com/blog/nasty-bugs/top-5-cc-quality-bugs/