1 / 19

LESSON 20

LESSON 20. Overview of Previous Lesson(s). Over View. Debugger A program that controls the execution of program code in such a way that we can step through the source code one line at a time, or run to a particular point in the program.

felice
Download Presentation

LESSON 20

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LESSON 20

  2. Overview of Previous Lesson(s)

  3. Over View • Debugger • A program that controls the execution of program code in such a way that we can step through the source code one line at a time, or run to a particular point in the program. • A breakpoint is a point in our program where the debugger automatically suspends execution when in debugging mode. • A trace-point is a special kind of breakpoint that has a custom action associated with it.

  4. Over View.. Following are the ways of starting application in debug mode.

  5. Over View... • Local tab • The Locals tab shows the values of the variables local to the current function. • Auto Tab • Shows the automatic variables in use in the current statement and its immediate predecessor. • Threads Tab • Allows to inspect and control threads in advanced applications

  6. Over View... • Modules Tab • Lists details of the code modules currently executing. • Watch1 Tab • Variables can be added to the Watch1 tab that we want to watch.

  7. Over View… #include <cassert> void assert(int expression); #define NDEBUG // Switch off assertions in the code #include < cassert > // Declares assert()

  8. TODAY’S LESSON

  9. Contents • Customized Debugging Code • Debugging a program • The Call Stack • Step Over to the Error

  10. Customized Debugging Code • Customized debugging code is aimed at highlighting bugs wherever possible and providing tracking output to help you pin down where the bugs are. • Line by line debugging is monotonous & longish. • Only required in testing a phase.

  11. Customized Debugging Code.. • This overhead is not needed in the final version. • So this code only operates in the debug version of a program, not in the release version. • The output produced by debug code provide clues as to what is causing a problem.

  12. Adding Code • Using preprocessor directives, a programmer can add any code to the program. • Preprocessor symbol, DEBUG, is always defined automatically in Visual C++ in the debug version of a program, but is not defined in the release version. • Debugging code is enclosed between a preprocessor #ifdef / #endif pair of directives.

  13. Adding Code.. #ifdef _DEBUG // Code for debugging purposes... #endif // _DEBUG • The code between the #ifdefand the #endifis compiled only if the symbol DEBUG is defined.

  14. Adding Code... • The debug code can do anything that is helpful in the debugging process. • Simply outputting a message. • To trace the sequence of execution to providing additional calculations to verify and validate data, or calling functions providing debug output.

  15. Adding Code... • Many blocks of debug code can be written in the source program. • Can use customized preprocessor symbols to provide more selectivity as to what debug code is included. • Ex .. some of debug code may produce voluminous output and only want to generate when it was really necessary. • To provide granularity in debug output, so we can pick & choose which output is produced on each run.

  16. Adding Code... The following directives will ensure that these symbols are defined only if DEBUG is defined: #ifdef _DEBUG #define MYDEBUG #define VOLUMEDEBUG #endif Lets try it …

  17. The Call Stack • The call stack stores information about functions that have been called and are still executing because they have not returned yet. • Call stack window shows the sequence of function calls outstanding at the current point in the program.

  18. The Call Stack.. • The sequence of function calls outstanding runs from the most recent call at the top.

  19. Thank You

More Related