Draft: Versioned Debug Info Metadata for Daml
Author: Walnut
Status: Early draft / not a funding request
Scope: Future technical proposal
Motivation
Daml and Canton already expose useful transaction and package data, and LF already carries source span information. That is enough for many forms of inspection and visualization, but richer source-aware tooling needs a stable way to describe how compiled Daml code relates back to source code.
Other mature ecosystems rely on explicit debug metadata formats: DWARF for many native toolchains, PDB/CodeView on Windows, and ETHDebug in the EVM ecosystem. A versioned Daml debug metadata format would give debugger, profiler, coverage, trace, and explorer tools a common target instead of each tool inventing its own mapping.
Proposed Direction
Define a versioned debug metadata schema for Daml packages.
The first version should build on existing LF span information and focus on metadata that can be emitted by the compiler or as a sidecar artifact:
- package id and package name/version
- source file paths and hashes
- module, template, choice, and expression spans
- mapping between source spans and LF-level entities
- stable identifiers suitable for tools to reference steps, spans, and values
- variable/value tracking for source-level bindings where this makes sense for Daml
The format could be embedded in DARs or emitted as a separate artifact. The exact packaging should be decided with Daml/Canton maintainers.
What Walnut Would Work On
Walnut could help drive the end-to-end workstream:
- draft the schema
- prototype compiler emission
- build a small reader/validator library
- integrate the metadata with
dpm trace
- document examples and compatibility rules
- iterate with Daml/Canton maintainers toward an accepted format
This matches Walnut's existing work on compiler debug information, source mapping, and blockchain debugging tooling.
Open Questions
- Should the metadata live inside DARs, as a sidecar artifact, or both?
- Which parts should be generated by
damlc versus derived by tools?
- What stability guarantees are needed across SDK versions?
- How should multi-package projects be represented?
- What should "variable tracking" mean for Daml: choice arguments, contract fields, let-bindings, return values, or a smaller subset?
- What extra runtime/interpreter hooks would be needed for true breakpoint-style debugging?