Skip to content

Add managed SOS command infrastructure and port threadstate, dumpassembly, and dumpdomain - #6295

Open
max-charlamb wants to merge 4 commits into
mainfrom
dev/max-charlamb/managed-sos-infra
Open

max-charlamb wants to merge 4 commits into
mainfrom
dev/max-charlamb/managed-sos-infra

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

Adds the shared infrastructure for implementing SOS commands in managed code and ports the first three commands (threadstate, dumpassembly, dumpdomain) end-to-end as the initial PR of the managed SOS command migration.

Infrastructure

  • Reuses mirrored cDAC COM declarations (ISOSDacInterface, IXCLRData, ICLRData, IMetaDataImport, and marshalling helpers) in SOS.Hosting.
  • Adds runtime-scoped DAC proxy ownership (RuntimeWrapper.GetSosDac) with explicit ComObject final release (ComWrapper.FinalReleaseUniqueProxy).
  • Adds SosDacCommandBase (DAC acquisition, pointer-size-aware AsDacAddress/AsTargetAddress, and expression-aware address parsing) and DacCommandHelpers (DML links, assembly/module/domain formatting).
  • Adds optional IDebuggerExpressionService / INativeDebuggerExpressionService in DbgEng (DbgEngServices), LLDB (LLDBServices), and SOS.Extensions (DebuggerComService<T>), and disables response-file expansion in CommandService for DbgEng/LLDB so expressions like @$t0 pass through.
  • Queries SupportsDml dynamically in ConsoleServiceFromDebuggerServices.

Ported commands

Each command includes managed implementation, AnalysisModule registration, native DbgEng forwarding stub (managedcommands.cpp), LLDB managed-command routing (lldbplugin/soscommand.cpp), removal of the native Strike implementation, and test coverage:

  • threadstate (ThreadState alias): non-DAC command that decodes thread-state bitmasks, honoring the debugger expression evaluator and handling 0 / invalid input.
  • dumpassembly (DumpAssembly alias, --dml / /d): DAC-backed assembly inspection with parent domain, name, and module listing; preserves MINIDUMP_NOT_SUPPORTED().
  • dumpdomain (DumpDomain alias, --dml / /d): DAC-backed AppDomain enumeration and single-domain inspection with system/shared domains, heap addresses, stage, assemblies, and modules; preserves MINIDUMP_NOT_SUPPORTED().

Validation

  • Targeted build of src/SOS/SOS.Extensions/SOS.Extensions.csproj (including SOS.Hosting, Microsoft.Diagnostics.ExtensionCommands, and Microsoft.Diagnostics.DebugServices) succeeded with 0 warnings and 0 errors.
  • Includes unit/integration test updates in DumpDomainTests.cs and MemoryAndDecodeTests.cs for full CI validation across Windows/Linux/macOS and DbgEng/LLDB/dotnet-dump hosts.

Max Charlamb and others added 4 commits December 3, 2026 15:11
Reuse the mirrored cDAC COM declarations in SOS.Hosting on .NET 8. Add runtime-scoped DAC proxy ownership, shared address and output helpers, and optional debugger COM services for expressions, dump metadata, and minidump safe mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 20509674-cc28-401c-a1fa-0f8dbe23d5f0
Preserve assembly output and accept debugger expressions for the assembly address.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 20509674-cc28-401c-a1fa-0f8dbe23d5f0
Preserve domain enumeration and rendering, and validate explicit zero and debugger expressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 20509674-cc28-401c-a1fa-0f8dbe23d5f0
Decode thread-state flags in managed code and cover debugger expressions and zero.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 20509674-cc28-401c-a1fa-0f8dbe23d5f0
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