Courses / Computer Science I
Introduction to Computers

Machine-Level Debugging Logic

Computer Science I 223 words Free to read

Finding the Fault

A running program is state: register values, memory contents, and the program counter. A bug is where that state diverges from correct execution.

Debugging makes state observable using a debugger with three primary tools:

ToolAction
BreakpointPause execution at an instruction
InspectView actual registers and memory
Single-stepExecute one instruction at a time

The strategy is a binary search in time: verify state at an early point, verify it is wrong later, and narrow the gap to find the first incorrect instruction.

Pitfall: Debugging by guessing. Never change code on intuition; inspect actual values at breakpoints. Reason strictly from evidence.

Debugging as bisection over TIME, not over an array

Bug Families & Evidence

Machine-level bugs cluster into five recognizable families that speed up the debugging hunt:

Bug FamilyDescription
Off-by-oneError in loop bound calculations
Integer overflowValue wraps around unexpectedly
Wrong addressReading or writing incorrect memory
UninitializedUsing leftover state in cells/registers
Signed/unsignedMisinterpreting number representations

The overriding principle is to reason from evidence, not assumption. Observe what the state actually is at each step, letting the discrepancy point directly to the fault.

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

12practice questions
2interactive scenes

Introduction to Computers