Stepping Through Calls in a Debugger

A debugger can continue over a call as one step, enter it to inspect parameters, or run until its current frame returns.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose the frame of interest
  2. Use a conditional stopping point
  3. Use a call boundary to narrow the search
  4. Inspect values in the frame that owns them

Choose the frame of interest

While checking total = add_tax(amount), step over a known-good call to see the assigned total. Step into it when the input or its calculation is suspect. Nested call traces describe which bindings belong to each call.

Use a conditional stopping point

For an unexpected third order, a breakpoint can stop only when the order identifier matches. Inspect the line before the problematic calculation. Record input and actual output afterward so a small reproduction survives the debugger session.[1]

Use a call boundary to narrow the search

A function builds a label by formatting a parsed number. At the call to the parser, stepping over shows the returned number without pausing inside that helper. If the number is already wrong, repeat and step into the parser to inspect the conversion path. See tracing nested calls.

Caller receives raw "008"
Step over parse → observe parsed value
If wrong, step into parse before repeating the conversion
Step out returns to label assembly

Inspect values in the frame that owns them

A local input can have the same name in several frames. Check active frame and line before interpreting the value. A conditional breakpoint can reach the failing case without stepping through many valid inputs.

References

  1. Python Software Foundation, pdb: The Python Debugger ↩