fix: make DWARF line lookup and cross-CU indexing precise#173
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.