Skip to content

--di: a debugger stops once at each statement, leaves at the closing brace, steps over compiler glue - #1126

Merged
ASDAlexander77 merged 5 commits into
mainfrom
debug-step-statements
Dec 4, 2026
Merged

ASDAlexander77 merged 5 commits into
mainfrom
debug-step-statements

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Stepping through a --di build stopped at nearly every operation. Every op kept the place of the expression it was made for, so the line table had a row for each expression and, under CodeView, a column for each (len() with one return had 12 rows). It also went back and forth over multi-line statements, went back to a variable's declaration to release it at the end of a scope, returned through the function's first line, and stepped into compiler glue shown at the user's lines.

What changes

  • MLIRGen records the statements it generates, plus field initializers and function bodies, in ts.debug_statements. Only nodes of the file being generated are recorded: other files' trees are generated under its name too.
  • New DebugStepLocationsPass runs under --di, ahead of DIScopeForLLVMFuncOpPass:
    • an op's place becomes the start of its innermost statement, giving one row per statement;
    • under CodeView there are no columns, as clang does;
    • a function with no statement of the program (thunks, .new, .instanceOf, rc/own routines) gets line 0 throughout, so it has no source and debuggers step over it;
    • code going back in a block to a line already stopped at gets line 0;
    • without --opt, callsite(a at b) on calls becomes b, which removes fake inline frames.
  • The function exit and its return block sit on the closing brace.

Rows before → after (CodeView PDB, real.ts with the default library)

  • Point.len: 12 rows, 3 3 4 4 4 4 4 4 4 4 4 3, each with a column → 3 4 5
  • a default-library generic instantiated in the program: 92 column rows → 25 statement rows
  • WinDbg p through main: 17 … 26, then }; sum: 9 10 11 10 11 … 13 }

Tests

  • New test-compile-debug-info-steps checks each function's rows under gc/rc/none/own. It covers multi-line statements, loops, field initializers before and after a constructor, a callback, an empty callee, and rc release routines.
  • jit-native.cmake: cdb's frame check takes any line of greeting. Under --opt only the return is left, now at } (line 3).
  • Full release ctest: 10429/10429. The default library (lib.ts, lib.win32.ts) compiles with --di --opt_level=0 under all four models. A --di compile of the test corpus shows only failures that the Dec 2 compiler shows too.

Not run: Visual Studio or VS Code's cppvsdbg (only WinDbg here), GDB, LLDB. A prebuilt default library keeps its columns until it is rebuilt.

🤖 Generated with Claude Code

ASDAlexander77 and others added 5 commits December 4, 2026 01:06
…brace, and steps over compiler glue

Every op had the place of the expression it was made for, so the line table had a row for each
expression and, under CodeView, a column for each (the Visual Studio debugger and cppvsdbg step
through those), went back and forth over a statement on several lines, back to a variable's
declaration to release it at the end of its scope, returned through the function's first line,
and stepped into the compiler's glue shown at the user's lines.

- MLIRGen records the statements it generates (ts.debug_statements, only nodes of the file being
  generated: other files' trees are generated under its name too).
- DebugStepLocationsPass, ahead of DIScopeForLLVMFuncOpPass: an op's place becomes the start of the
  innermost statement it is in; no columns under CodeView (as clang); a function with no statement
  (a thunk marked LocalToUnit, `.new`, `.instanceOf`, the rc/own routines) gets line 0 throughout,
  so it has no source; calls into such glue and code that goes back to an earlier statement in the
  same block get line 0; without --opt `callsite(a at b)` becomes `b` (a fake inline frame).
- A function's way out is its closing brace: the exit and its return block (made with the entry).
- debug-info-steps.cmake checks the rows of each function under all four models; jit-native's cdb
  check takes any line of `greeting` (line 3 now under --opt, the only code left is the return).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ly lines already stopped at

- A field's initializer is a step of its own (recorded where the field is typed): `class B { v = make() }`
  had its constructor hidden, and initializers before or after an explicit constructor lost their row
  or folded the constructor's statements away.
- A function's body is a barrier in the statement table: a callback written in a call keeps its own
  closing brace instead of the call's line.
- Code going back in a block, or a call into glue, folds only onto a line already stopped at (the
  function's own line counts): `noop();` of an empty function keeps its row, and a constructor steps
  through initializers written after it, then its statements. Inlined ops (--opt) are left alone.
- 00debug_steps.ts covers these shapes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s too; the compiler's own TypeScript is at no line of the program's; functions stepped over have no first line

A lexical block took the compile unit's file, so the rows of a default library's generic made in the
program (Array.sort's mergeSort) were shown at lines of the program past its end. Code parsed from the
compiler's own TypeScript (helper sources, Math.max, inspect) took the program's file and line map; its
nodes are now located in a pseudo-file `<tslang>` that DebugStepLocationsPass gives line 0. A hidden
function's subprogram (or the one made for a lowering routine) is at line 0, so CodeView gives it no row
at its first line for a step into it to stop at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nippet leaves no address for another

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… T elements

`Array(3)` called the default library's static class Array, so `a[0] = 1` failed with
"can't resolve property '.index' of class 'Array'". A program's own Array function is
still called. `const c: string[] = new Array(2)` made s32[] (the length's type) and
failed to cast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 9ba1a17 into main Dec 4, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the debug-step-statements branch December 4, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant