Add WasmFileKeyGenerator for split Wasm symbol files#5853
Conversation
There was a problem hiding this comment.
Pull request overview
Adds WebAssembly module support to Microsoft.SymbolStore key generation by introducing a WasmFileKeyGenerator that extracts a build_id custom section and distinguishes stripped vs split-debug Wasm files via .debug_* custom sections, enabling symbol-server indexing using wasm-buildid and wasm-buildid-sym prefixes.
Changes:
- Added
WasmFileKeyGeneratorto parse Wasm headers/sections, extractbuild_id, and detect DWARF debug sections. - Updated
FileKeyGeneratorauto-detection chain to include Wasm support. - Added unit tests covering Wasm modules, symbol files, and missing build IDs.
Reviewed changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/tests/Microsoft.SymbolStore.UnitTests/KeyGeneratorTests.cs | Adds unit tests for Wasm key generation (module vs symbol file vs missing build_id). |
| src/Microsoft.SymbolStore/KeyGenerators/WasmFileKeyGenerator.cs | Introduces the Wasm key generator and parsing logic for build_id and .debug_* sections. |
| src/Microsoft.SymbolStore/KeyGenerators/FileKeyGenerator.cs | Adds Wasm detection to the generic file key generator chain. |
Comments suppressed due to low confidence (1)
src/Microsoft.SymbolStore/KeyGenerators/WasmFileKeyGenerator.cs:184
nameStartis assigned but never used here as well; with TreatWarningsAsErrors enabled this breaks the build. Remove the unused local variable.
if (sectionId == CustomSectionId)
{
long nameStart = stream.Position;
string name = ReadWasmString(stream);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@dotnet-policy-service agree company="Microsoft" |
|
Could someone review this? Who are the right reviewers? |
|
|
||
| if (sectionId == CustomSectionId) | ||
| { | ||
| string name = ReadWasmString(stream); |
There was a problem hiding this comment.
This read could read past secondEnd, along with my comment below on clamping the number of bytes ReadWasmString reads, maybe we should pass sectionEnd to ReadWasmString and also ensure we don't read past the end of the section?
| { | ||
| return; | ||
| } | ||
| _parsed = true; |
There was a problem hiding this comment.
This should probably go at the end of the try block in case we hit an exception.
|
@thaystg - could you take a look at this? @paolosevMSFT - is there any existing standard you aware of around this? So far the only convention we have documented is for unsplit wasm files. If we are creating new conventions I think the place we should start is updating the spec and get some understanding of what tools/scenarios we expect will initially consume this. |
|
The primary scenario is serving split Wasm DWARF symbols from Microsoft symbol servers for Chromium DevTools, via the DWARF-C/C++ DevTools Extension. The build_id custom section is already produced by the emscripten toolchain (-gseparate-dwarf -Wl,--build-id) and reported via CDP's Debugger.scriptParsed (https://chromedevtools.github.io/devtools-protocol/1-3/Debugger/) event. However, there's currently no symbol server support for indexing split Wasm symbols by build ID, which is exactly what this PR enables. This is the server-side piece needed to close the loop: toolchain produces build_id => symbol server indexes by build_id => debugger fetches symbols using build_id. I'm happy to update SSQP_Key_Conventions.md to document this. Would you prefer that as a prerequisite or in parallel? |
Adds support for indexing WebAssembly modules on symbol servers by introducing a
WasmFileKeyGeneratorthat parses Wasm binaries and extracts the build_id custom section.This enables uploading and retrieving both halves of split-debug Wasm files. (It follows the same convention as ELF (elf-buildid vs elf-buildid-sym):
Changes:
WasmFileKeyGeneratorclass that validates the Wasm header, scans custom sections for build_id, and detects symbol files via .debug_* sectionsFileKeyGeneratorto includeWasmFileKeyGeneratorin the auto-detection chain