From beec92b3ce834508fc128267c9cfc92032288db9 Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Wed, 2 Dec 2026 08:53:07 +0000 Subject: [PATCH] Step debugger guide: add case-of-the-unexpected-61 exercise, Rust/Python debugger note, re-verify 8 known bugs (Dec 2) --- docs/step-debugger-guide.md | 56 ++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/step-debugger-guide.md b/docs/step-debugger-guide.md index 38d95fa..99556c2 100644 --- a/docs/step-debugger-guide.md +++ b/docs/step-debugger-guide.md @@ -298,6 +298,39 @@ DONE sum=9 [Inferior 1 (process 696825) exited normally] ``` +## Your turn — the case of the unexpected 61 + +You have done every move in this guide now. Here is one to solve +yourself, with no new buttons to learn. + +Run the console program with no breakpoints and look at the last +lines: + +``` +TOTAL total=61 sum=9 +``` + +`compute(10, 20)` — ten plus twenty — should be 30. Where did 61 +come from? Don't guess; make the debugger tell you: + +1. Set a breakpoint at `console.cpp:28` (the `compute(10, 20)` call) + and press **Continue** (`F5`). +2. When it stops, press **Step Into** (`F11`). You are inside + `compute()` at line 13: `s` = 30, as expected. +3. Press **Step Over** (`F10`) once to reach line 14, then **Step + Into** again. Now you are inside `helper()` with `v` = 30. +4. Press **Step Over**: line 8 runs, `r` = 61. There it is. +5. **Step Out** twice and you are back in `main()` at line 29 with + `total` = 61. + +`compute()` doesn't just add — it passes the sum through `helper()`, +which doubles it and adds one: 30 × 2 + 1 = 61. The program is +correct as written; your assumption was the bug. If 30 is what you +actually wanted, the fix is one line — `return s;` in `compute()` — +but the debugger's job was to show you what the code *does*, not +what you assumed it does. That is the whole skill: stop arguing with +the program in your head and watch it run. + ## 13. Stop and Restart * **Stop** interrupts a running target (breaks into the debugger wherever @@ -381,6 +414,26 @@ case. Build a tiny project and debug it end to end: 7. **Stop** interrupts it; **Restart** kills it and re-runs to `main()` again (§13). +## Debugging in the Rust and Python designers + +This guide covers the C designer — that is the one with a working +debugger today. The other two are at different stages: + +* **Rust:** the debugger (`crates/lightgui-debug`, GDB/MI) is still in + progress. The Debug menu entries exist but report that on the status + bar instead of pretending to work. When it lands, the workflow will + be the same as here — same GDB underneath. +* **Python:** there is a working pdb-based step debugger in its own + window, with the same shape as this one: breakpoints (staged before + start, live after), Run / Continue / Step Over / Step Into / Step + Out, Stop, Restart, Settings (stop on entry, break on main), Locals, + Watches, call stack, a Hits column, and an output console. Two + differences to know: there is **no logpoint UI** (pdb has no + `dprintf` equivalent), and a breakpoint on a `def` line fires at + definition time — pdb stops when the `def` statement executes, not + when the function is later called — so use "Break on main" or a + breakpoint on the first line inside the function to stop on entry. + ## Toolbar reference | Button | Key | What it does | @@ -493,7 +546,8 @@ project, `make CXXFLAGS="-g -O0 -Wall -std=c++17"` — the generated ## Known bugs found while writing this guide Found during the screenshot sessions; reported here, not fixed (this -guide is documentation only): +guide is documentation only). Checked Dec 2, 2026: no debugger fixes +have landed since Nov 29, so all eight are still there. 1. Breakpoint pane too narrow by default (see above). 2. Breakpoint list selection doesn't stick — **Edit…** / **Remove**