Skip to content

Debug information: line tables - #24

Draft
vchuravy wants to merge 1 commit into
vc/jc-22-llvmcall-ccfrom
vc/jc-23-debuginfo
Draft

vchuravy wants to merge 1 commit into
vc/jc-22-llvmcall-ccfrom
vc/jc-23-debuginfo

Conversation

@vchuravy

Copy link
Copy Markdown
Contributor

Stacked on #23. This is the plan's debug-info item. GPUCompiler needs it because its error messages build backtraces from !dbg locations.

CodegenConfig(; debug_info) selects the debug information, as the debug_info_kind of Julia's CodegenParams does: :none (the default), or line tables in a compile unit of emission kind :line_tables, :directives (what GPUCompiler uses for PTX) or :full.

  • Compile unit: DW_LANG_Julia, producer julia, file julia in ., all as native code's. The module gets the Debug Info Version and Dwarf Version flags if it lacks them.
  • Subprograms: every function has one, named after its method, with the LLVM name as its linkage name. That includes entries, stubs and C-callable wrappers; their instructions, including calls to the functions they inline, get the function's line. This keeps LLVM's verifier satisfied when bodies are inlined into their entries.
  • Statement locations: every statement gets its line, with the functions inlined at it as inlined frames (inlinedAt chains, from Base.IRShow.buildLineInfoNode). Inlined methods get their own subprograms.
  • Not included: no information about variables or types.

codegen_output finalizes the DIBuilder.

Tests (test/debuginfo.jl)

  • FileCheck of the compile unit, the file, subprograms and call locations;
  • inlined frames;
  • entries having subprograms;
  • no !dbg without debug info;
  • differential runs with debug info;
  • the three emission kinds, and invalid values.

I also ran the whole suite once with debug info enabled in the test configuration (not kept): it passes apart from the one test that expects no debug info. LLVM's verifier and Julia's pipeline accept every module.

Tested locally with julia +1.12, +1.13 and +nightly: 5960, 5966 and 5965 tests pass.

🤖 Generated with Claude Code

`CodegenConfig(; debug_info)` selects the debug information, as the
`debug_info_kind` of Julia's `CodegenParams`: `:none` (the default), or
line tables in a compile unit of the emission kind `:line_tables`,
`:directives` (GPUCompiler's for PTX) or `:full`.

- The compile unit is of the file `julia` in `.`, as native code's, and the
  module gets the "Debug Info Version" and "Dwarf Version" flags if it lacks
  them.
- Every function has a subprogram named after its method, with the LLVM
  name as its linkage name. That includes entries, stubs and C-callable
  wrappers, whose instructions (calls of the functions they inline included)
  get the function's line.
- Every statement gets the location of its line, with the lines of the
  functions inlined at it as inlined frames (`inlinedAt`), from the IR's
  line information.
- There is no information about variables or types.

`codegen_output` finalizes the debug information. The whole suite passes
with debug information on in the test configuration (checked once, not
kept).

Assisted-by: Claude Code (Opus 5.5)
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