Repository navigation
feat(managed): bind Portable PDB sequence points to selected methods - #2435
vincent-peng wants to merge 9 commits into
Conversation
Adds optional pdb_path / pdb_embedded selectors to inspect_managed_members on both CLI and MCP. The PE debug directory is parsed for CodeView RSDS identity and embedded MPDB entries (raw Deflate); the Portable PDB #Pdb stream, Document and MethodDebugInformation tables are decoded with ECMA-335 compressed-integer semantics, and sequence points are bound to build-local MethodDef tokens. Identity mismatches, malformed rows and unreadable declarations degrade to debug_map evidence rather than discarding member output; the PDB projection is charged to its own decode budget and issues are bounded. No source content is fetched and no target code is executed. Refs morluto#2351 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Technical Review & Findings1. Incomplete Deflate Output Length Guard (
|
|
Thanks for the detailed review — verified each finding against the code and the 1. Deflate output length guard — already handled in the pushed diff. The check sits directly below the quoted call in const result = inflateRawSync(bytes.subarray(offset + 8, offset + size), {
maxOutputLength: uncompressedSize + 1,
});
if (result.length !== uncompressedSize) {
pushIssue(issues, `Embedded Portable PDB inflated to ${result.length} bytes, expected ${uncompressedSize}`, offset + 4);
return null;
}
2. Non-first // skip all document records and update the current document accordingly:
int deltaOffset;
while ((deltaOffset = _reader.ReadCompressedInteger()) == 0)
document = ReadDocumentHandle();
offset = AddOffsets(_current.Offset, deltaOffset);Our 3. Signed compressed integer decode — the current decode is the ECMA-335 II.23.2 semantics, verified bit-for-bit against bool signExtend = (value & 0x1) != 0;
value >>= 1;
if (signExtend) {
case 1: value |= unchecked((int)0xffffffc0); break; // ~0x3f
case 2: value |= unchecked((int)0xffffe000); break; // ~0x1fff
default: value |= unchecked((int)0xf0000000); break; // ~0x0fffffff
}Bit 0 is the sign and bits 1..(6|13|28) carry the two's-complement payload, sign-extended by encoded width — exactly Net: no code changes from this review — finding 1 was already implemented, and findings 2–3 describe the correct ECMA-335 behavior as verified against the reference implementation. |
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai review |
|
Address greptile review on PR morluto#2435: - Match PDBs by CodeView GUID + debug-entry TimeDateStamp, not RSDS Age; portable records keep Age=1 while the entry stamp completes the 20-byte PDB ID, so real compiler pairs no longer report mismatched. - A degraded debug-directory declaration (unreadable entries, truncated RSDS, enumeration issues) now marks identity unverifiable instead of undeclared or absent. - Map decode or admission failures after identity resolution keep the source digest, PDB facts, and declared identity instead of a bare stub. - Hidden sequence points validate IL-offset range and ordering; only source-line constraints stay non-hidden. - Document columns decode independently so a bad GUID or blob index cannot suppress readable sibling fields. - The fixture's signed compressed encoder keeps the selected width so two- and four-byte negative deltas encode correctly. - Debug-directory issue accounting counts drops from every reporter and forwards the omitted total instead of a summary issue the map sink could discard; non-RSDS CodeView records are now visible issues. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Thanks @greptile-apps[bot] — all seven findings verified against the PE-COFF and Portable PDB specs plus the SRM reference implementation. All were valid (with two clarifications noted below) and are addressed in FixesP1 — Portable PDBs looked mismatched ✅ Confirmed and fixed. Per PE-COFF §"Debug Directory", portable CodeView records keep P2 — Unreadable declarations looked absent ✅ P2 — Failed maps lost identity ✅ The decode + projection-admission section now returns a P2 — Invalid hidden offsets passed ✅ The IL-offset range and ordering checks now run before the hidden early-return, and P2 — Bad document fields hid readable data ✅ Each Document column decodes independently (same isolation pattern as the name column): an out-of-range language GUID now nulls only P2 — Fixture signed-compressed width ✅ Confirmed: P2 — Dropped directory issues undercounted ✅ Every directory parse failure now flows through a counted reporter, and Regression coverageNew/extended tests: producer-shaped Age=1 identity match, truncated RSDS → Validation: 29 unit + 46 focused boundary/MCP/CLI + 183 |
Address greptile round-2 review on PR morluto#2435: - Bound the CodeView RSDS path at its producer (64 KiB cap plus a coverage issue) so a declared_path that exceeded the projection budget cannot ride the malformed-map fallback into oversized output. - Bound the #Pdb version string (1 KiB) for the same reason; real roots carry "PDB v1.0". - Replace issues-based identityUnknown with a dedicated degraded flag: only structural directory failures and unreadable or unusable CodeView/embedded-PDB entries hide PDB presence; unrelated entry failures stay in coverage and embedded selection still reports absent. Regression tests cover unrelated-entry absence, oversized-path truncation, and the unchanged truncated-RSDS unverifiable case. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Thanks @greptile-apps[bot] — both round-2 findings verified and addressed in P2 (security) — Failed maps keep oversized paths ✅ Fixed at the producing boundary. P2 — Missing PDBs look unreadable ✅ Valid — the first-round Regression tests: unrelated-type entry failure → Validation: 31 unit + 48 focused boundary/MCP/CLI tests pass; |
A crafted document-name blob can list millions of empty parts at one encoded byte each while each retains an array slot and string, so charge a per-part projection before allocating. Name parts are stored strings rather than text files, so the decoder now keeps a leading U+FEFF like the metadata heap readers do. The initial document record in a sequence-points blob was decoded without the row bound applied to mid-blob records, letting nil or out-of-range rows report decoded null-document points. Validate it against the Document table immediately. #Pdb row counts are unvalidated claims about the assembly, so bound Document and StandAloneSig validity checks at the 24-bit token row space instead of trusting declared counts; rows above 0xffffff can no longer forge a token for another table. The fixture adds small heap columns before the name blob so oversized names still fit two-byte indexes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The describe block merged from main (morluto#2704) runs 162 lines, over the 150-line lint bound, so the operand-width matrix moves into its own describe. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Verified and addressed all four findings in P1 — Empty path parts exhaust memory ( P2 — BOM stripping in document names: Confirmed. P2 — Invalid initial document row accepted: Confirmed, including the no-points escape path — mid-blob document records were range-checked but the initial record was not, so a nil or out-of-range row produced P2 — Row counts above the 24-bit token range: Confirmed — Regression coverage added: 600 K empty name parts → Also pushed Validation: 35 Portable PDB unit tests, 52 tests across the focused provider/MCP/CLI lanes, 183 |
Keep the Portable PDB selection alongside the new userStrings member inspection option, report #US literals next to the bound debug_map, and carry the upstream operand-width describe split name. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
TL;DR: The new I tested head 807c35a as pushed, on the PR's own byte-built fixtures. I wrote one throwaway test that saves those fixtures as files, then ran the real CLI on them. Base is bbf0638 (#3044). Results
The matching pair uses age 1 with a different stamp. That is the shape of a real compiler pair, and it is the case the P1 fix was about. It reads as matched. Hidden points show start and end line 16,707,566 (0xFEEFEE) next to With no selector, I also joined head with main b7dcf78 (#3825) as text, outside git. It gives 4 conflict regions in 3 files: Not run
Thanks, Vincent Peng, for the feature and for the fast, careful answers to every review round. Test setup
CommandsEach build and run sat under 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@vincent-peng thanks for the PR — this branch has merge conflicts with |
Summary
Fixes #2351.
inspect_managed_membersgains optionalpdb_path/pdb_embeddedselectors on both CLI (--pdb,--pdb-embedded) and MCP. When a Portable PDB is selected, the result carries adebug_mapthat verifies the PDB against the assembly's own declarations and reports documents, checksums and sequence points keyed to build-local MethodDef tokens and IL offsets.Problem and expected behavior
Managed member inspection reported IL extents but no source-level sequence points. The issue asks to bind Portable PDB sequence points to the selected managed methods so callers can map IL offsets to source lines without guessing which PDB belongs to the build.
Change and scope
src/dotnet/ManagedDebugDirectory.tsparses PE debug-directory entries: CodeViewRSDS(GUID, age, declared path) andMPDBembedded Portable PDB payloads (raw RFC 1951 Deflate, bounded inflation). Directory enumeration is capped at 4096 entries.src/dotnet/PortablePdbLayout.tsparses the Portable PDB metadata root (BSJB), stream headers, the#Pdbstream (20-byte content ID, entry-point token, referenced type-system rows) and debug-table layouts using the existing ECMA-335 coded-index sizing.src/dotnet/PortablePdbDebugMap.tsdecodes Document rows (names, path parts, checksum algorithms/bytes, language GUIDs — unknown GUIDs retained), MethodDebugInformation rows, and sequence-point blobs including hidden points, document switches and signed line/column deltas per ECMA-335 II.23.2. MDI rows are bound to MethodDef tokens; rows not covered by MDI are counted inmethods_without_debug_information.#Pdbcontent GUID/stamp and reported asmatched/mismatched/undeclared/unverifiablewithout blocking the evidence.ManagedStaticProvider(mutually exclusive,pdb_pathmust be absolute, read through the existing bounded/cancellable snapshot path).debug_maptomalformedwithout discarding member evidence; retained issues are bounded with an omitted count.docs/specs/managed/portable-pdb-sequence-points/.Contract and boundary impact
src/dotnet/readers own the format facts;ManagedStaticProviderowns the external file read; CLI/MCP expose the selectors unchanged elsewhere.debug_map, defaultsnull); selector exclusivity enforced in the provider so both adapters agree.debug_mapreports sourcepath,byte_lengthandsha256; identity mismatch remains visible rather than blocking evidence.docs/public/product-catalog.json), package, or installation impact: none; the catalog is CI-generated from the edited contracts.Expected effects:
Evidence and regression coverage
src/dotnet/PortablePdbDebugMap.test.ts(22),tests/boundary/providers/managed/managedPortablePdb.test.ts(6), plus MCP and CLI parity cases. Fixtures are byte-built synthesizers (PortablePdb.fixture.ts,ManagedPe.fixture.tsdebug-directory support), not binaries.debug_mapisnulland prior output is unchanged; with a selector, matching/mismatched/undeclared/malformed states are asserted end-to-end.rea inspect-managed-members <pe> --pdb <pdb> --jsonreportsnormalized_result.debug_mapwithsource,pdbprovenance,identity,documents,methods[].sequence_pointsandcoverage.inflateRawSyncmatches theDeflateStreamwire format.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/dotnet/PortablePdbDebugMap.test.ts tests/boundary/providers/managed/managedPortablePdb.test.ts tests/boundary/mcp/managedMcp.test.ts tests/acceptance/managedCliOutput.test.ts— 39 tests passed.npm run test:local -- src/dotnet/ManagedMemberInspector.test.ts src/dotnet/ManagedArtifactInspector.test.ts src/dotnet/ManagedArtifactFailures.test.ts(plus the othersrc/dotnet/suites) — 183 tests passed.npm run check:fast— typecheck + lint pass.npm run docs:check— pass.npm run verify:test-discovery— 1000 test files discovered.Compatibility, safety, and release
debug_mapis a nullable additive field.Before merge
type(scope): outcome.