- Forward


Debugging
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Getting to Debugging
Back SMYC Forward
  • Testing:
    • The output of a failed test is a symptom and one of the trigger conditions that gives rise to the symptom
  • Debugging:
    • Using the trigger condition to identify and correct the fault
The Debugging Process
Back SMYC Forward
  1. Stabilize - Understand the symptom and the trigger condition identified by the test so that the failure can be reproduced.
  2. Localize - Locate the fault.
    • Examine the sections of code that are likely to be influenced by the trigger condition.
    • Form a hypothesis about the fault.
    • Instrument the relevant sections of code.
    • Execute the code using the instrumentation.
    • Prove or disprove the hypothesis. If proven, go to step 3; otherwise go to step 2.
  3. Correct - Fix the fault.
  4. Verify - Test the fix and run regression tests.
  5. Globalize - Look for and fix similar defects in other parts of the system. Refactor if necessary.
Nerd Humor
Back SMYC Forward
/imgs
(Courtesy of xkcd)
Instrumentation Techniques
Back SMYC Forward
  • Using Debug Code:
    • Add temporary output statements that can be used to monitor state information
    • Add temporary input statements that can be used to pause the execution
  • Using a Debugger:
    • Use watches to monitor state information
    • Set breakpoints to pause the execution
    • Execute statements "one at a time" (e.g., step into, step over)
There's Always More to Learn
Back -