tailieunhanh - Lecture Practical C++ programming - Chapter 17: Debugging and optimization

Everyone has their own way of debugging. Some people are good at sitting down and analyzing their programs while others need to use the interactive debugger. In this chapter we present the students with a variety of techniques. Let them decide which ones are useful. | Chapter - 17 Debugging and Optimization Practical C Programming Copyright 2003 O Reilly and Associates Page 1 Debugging Techniques Divide and conquer Debug only code Debug Command Line Switch Note Use I O redirection and the editor to browse large volumes of debug output. Interactive Debuggers Practical C Programming Copyright 2003 O Reilly and Associates Page 2 Gnu Debugger gdb commands run Start execution of a program. break line-number Insert a breakpoint at the given line number. break function-name Insert a breakpoint at the first line of the named function. cont Continue execution after a breakpoint. print expression Display the value of an expression. step Execute a single line in the program. next Execute a single line in the program skip over function calls. list List the source program. where Print the list of currently active functions. status Print out a list of breakpoints delete Remove a break point. Practical C Programming Copyright 2003 O Reilly and Associates Page