Skip to content

Avoid changing global SOS symbol options - #6242

Merged
hoyosjs merged 1 commit into
mainfrom
dev/max-charlamb/scoped-public-symbol-lookup
Nov 14, 2026
Merged

hoyosjs merged 1 commit into
mainfrom
dev/max-charlamb/scoped-public-symbol-lookup

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

Remove the session-wide SYMOPT.PUBLICS_ONLY setting introduced in #5991. Loading SOS should not change how the debugger or other extensions resolve symbols.

For managed SOS symbol lookups under DbgEng, request the public symbol name with IDebugAdvanced2.GetSymbolInformation(GET_SYMBOL_NAME_BY_OFFSET_AND_TAG_WIDE, SymTagPublicSymbol), then resolve that module-qualified name with GetOffsetByNameWide. Calculate displacement from the selected public symbol's address rather than reusing a private symbol's displacement. LLDB retains its existing lookup path.

The implementation also handles two behaviors observed with real DbgEng calls:

  • The UTF-16 name can include an extra null terminator.
  • Export-only lookups can return an empty name at interior addresses; retry the public-name query at the ordinary symbol's base.

Ambiguous or failed address resolution does not return a partial symbol result.

Validation

  • Built SOS.Extensions for net462 and net8.0.
  • Passed seven focused regression cases covering Unicode/null termination, displacement, export-base retries, ambiguity/failure, and unsigned-underflow prevention.
  • Exercised the actual managed helper against a native PDB fixture with distinct private display/public alias names, ordinary function/data symbols, and nonzero displacement: eight cases passed.
  • Removed the fixture's PDB and verified two export-only cases.
  • Verified debugger symbol options remained unchanged during those real lookups.

Resolve public names per query and calculate displacement from the selected symbol address without changing debugger options.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 56b7f1ec-323f-44e6-bee9-b2af0e9fc062
@max-charlamb
max-charlamb marked this pull request as ready for review November 14, 2026 16:24
@max-charlamb
max-charlamb requested a review from a team as a code owner November 14, 2026 16:24
@max-charlamb
max-charlamb requested review from tommcdon and removed request for a team November 14, 2026 16:24

@tommcdon tommcdon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hoyosjs hoyosjs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main concern is the impact of this for something like FindPointersIn - this is 5-8 COM calls per frame.

  • Also - if this is too slow we could cache the module name per module index and clear that on module change.
  • The interface casts can be done one in the constructor just like DebugClient to avoid this getting done per frame.
  • I don't think we use this for special names, but for things that are ambiguous like overrides, GetOffsetByName returns S_FALSE (I don't think what we care about has those?). The main risk here is if there's code folding.
  • Should we fall back to GetNameByOffset when no public symbol is found?

@hoyosjs
hoyosjs merged commit cac379d into main Nov 14, 2026
25 checks passed
hoyosjs pushed a commit that referenced this pull request Nov 17, 2026
## Summary

A faster replacement for the public-name reverse lookup introduced in
#6242:

- Select the public name with
`IDebugAdvanced2.GetSymbolInformation(GET_SYMBOL_NAME_BY_OFFSET_AND_TAG_WIDE,
address, SymTagPublicSymbol)`.
- Obtain displacement with an ordinary, unfiltered
`IDebugSymbols3.GetNameByOffsetWide` call instead of reverse-resolving
the public name with `GetOffsetByNameWide`.
- Keep this policy in a module-owned `DbgEngModuleSymbols` helper,
leaving `DebuggerServices` as the low-level wrapper.
- Preserve export-only name retry and failure propagation, without
changing global symbol options or enumerating/caching module symbols.

## Performance

Measured on Windows x64 using a synthetic workload with 100,000
generated methods and 215,422 public PDB symbols:

| Approach | Warm time/query | Startup through first lookup | Retained
managed-memory delta |
|---|---:|---:|---:|
| Original `GetNameByOffset` with global `PUBLICS_ONLY` | 17.47 us |
36.99 ms | 1,600 bytes |
| Scoped public-name + reverse-lookup algorithm (prior measurement) |
1.392 s | 1,529 ms | 4,224 bytes |
| This PR: public name + ordinary displacement | 24.49 us | 75.75 ms |
3,120 bytes |

The proposed lookup avoids the expensive reverse-name lookup. Compared
with the original global-public-only behavior, warm lookup time is
approximately 40.2% higher (+7.02 us/query). There is no module-wide
symbol cache.


## Known correctness limitations

Ordinary lookup can select a private symbol with a different starting
address from the selected public symbol. Pairing its displacement with
the public name can therefore report an incorrect public-symbol start.

Against an original-public-only reference:

- All 300,563 generated-method queries matched both name and
displacement.
- Of 343,166 normal reference queries, 343,144 matched and 22 had
different displacements. These are native code/data cases; this
prototype does not fix them.
- An additional 474 cross-section `<PERF>` formatting differences and
one before-first-public boundary difference were recorded separately.

---------

Co-authored-by: Max Charlamb <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 56b7f1ec-323f-44e6-bee9-b2af0e9fc062
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.

3 participants