Skip to content

fix: make DWARF line lookup and cross-CU indexing precise#173

Merged
swananan merged 3 commits into
mainfrom
fix/dwarf-line-end-sequence
May 11, 2026
Merged

fix: make DWARF line lookup and cross-CU indexing precise#173
swananan merged 3 commits into
mainfrom
fix/dwarf-line-end-sequence

Conversation

@swananan
Copy link
Copy Markdown
Owner

This PR fixes a set of DWARF lightweight-index and source-line lookup regressions around duplicate line rows, line-sequence boundaries, and cross-CU origin/specification references.

swananan added 3 commits May 11, 2026 20:31
Store every DWARF line row for a PC instead of replacing earlier rows in
the address-to-line map. Optimized binaries can legitimately emit multiple
rows for one instruction, such as inline or header locations sharing a PC,
and source-line queries need to score all of those candidates.

Keep generic nearest-line and prologue lookup behavior compatible with the
old representative row semantics, while teaching source-line queries to
prefer the requested file and line when exact-PC duplicates exist.

Add a dwarf_index_regressions e2e case that finds a real same-PC line-row
fixture in complex_types_program and verifies both address lookup and
best-effort source-line query preserve the requested line.
DWARF line rows cover half-open address ranges. Preserve duplicate rows while
recording the next row address so nearest-previous source lookups do not cross
end_sequence boundaries or gaps.

When choosing source-line probe addresses, only treat an address as a statement
row if the matching row belongs to the requested file and line. This avoids
selecting unrelated same-PC inline/header rows.

Add unit and e2e coverage for same-PC statement filtering, zero-length rows, and
sequence gaps. Also update an existing e2e assertion to satisfy inline format
linting.
Follow origin/specification refs that point outside the current CU when
building the lightweight index, using absolute .debug_info offsets for caches
and recursion guards.

Add unit and object-backed e2e coverage for cross-CU origin/spec names, and
tighten source-line hint path matching so duplicate-PC rows cannot reintroduce
unrelated same-basename files.
@swananan swananan merged commit 778c816 into main May 11, 2026
10 checks passed
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