Use any version of Zig >=0.11.0 (latest test just now was done with 0.12.0-dev.2059+42389cb9c)
In VS Code, ensure CodeLLDB is installed along with Ziglang tools.
zig build
Set a breakpoint on line 8 of src/main.zig.
In debugger view on the left (run button with a bug in bottom left corner), run Zibug.
Step through, observe debugger briefly reports that it is about to execute the last statement inside the while loop, which is strictly impossible for at least two reasons:
a) The predicate guarding each block must have evaluated to false, because (0 > 1) == false.
b) The last statement of each control flow block is immediately preceded by a print statement. If we were actually about to execute the last statement of the while/if loop, we would stdout, but we actually see nothing.
The repo was created using zig init with only one change -- explicitly demanding Debug optimizations.
Expected Behavior
Evaluating the predicate of a control-flow block (like a while or if) to false should never show that the instruction pointer briefly dips inside of the code block. First time it happened took me more than a few seconds to wrap my head around it.
OS:
macOS Monterey 12.6.3
VSCode version:
1.85.1
CodeLLDB version:
1.10.0
Compiler:
zig
Debuggee:
zig
Verbose log
Zig Version
0.12.0-dev.2059+42389cb9c
Steps to Reproduce and Observed Behavior
Visit this repo: https://github.com/iiian/zig-debug-symbs
The repo was created using
zig init
with only one change -- explicitly demanding Debug optimizations.Expected Behavior
Evaluating the predicate of a control-flow block (like a while or if) to false should never show that the instruction pointer briefly dips inside of the code block. First time it happened took me more than a few seconds to wrap my head around it.