Software Testing · Software Engineering

Debugging

Definition

Debugging is the process of locating the root cause of a defect (identified during testing) and fixing it — distinct from testing, which only identifies that a failure occurred.

Testing vs. Debugging (Key Distinction)

Testing Debugging
Finds/identifies that something is wrong Finds why/where it's wrong and fixes it
Can be automated Largely a manual, analytical process
Performed throughout SDLC Happens after a failure is detected
Goal: detect failures Goal: locate fault, remove it

Debugging Process (General Steps)

  1. Reproduce the failure — get a reliable way to trigger the bug
  2. Isolate the fault — narrow down which part of the code causes it (using breakpoints, logging, print statements)
  3. Identify the root cause — understand why the fault produces the observed failure
  4. Fix the fault — correct the code
  5. Re-test — verify the fix resolves the issue and doesn't introduce new bugs (regression testing)

Common Debugging Approaches

1. Brute Force Method

  • Add print statements/logs everywhere and examine output — simple but inefficient for complex bugs

2. Backtracking

  • Start from the point of failure and trace backward through the code to find where things went wrong — works well for small programs

3. Cause Elimination

  • Form hypotheses about possible causes, then design tests/data to eliminate each hypothesis systematically until the actual cause is isolated

4. Program Slicing

  • Extract only the code statements relevant to a specific variable's value at a point of failure, narrowing the search space

Tools Used for Debugging

  • Debuggers (breakpoints, step-through execution, variable inspection) — e.g., GDB, Chrome DevTools, IDE debuggers
  • Logging frameworks
  • Static analysis tools

Debugging Strategies vs. Effort

Debugging is often reported as consuming a significant fraction of total development time, especially for complex, hard-to-reproduce bugs (e.g., race conditions, memory leaks).


Exam tip: Be clear on the Testing vs. Debugging distinction (Testing finds, Debugging fixes), and list at least 2-3 debugging approaches (Brute Force, Backtracking, Cause Elimination) with a one-line description.

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Software Engineering modules