Commit ab3cbf5
[cDAC] Add interpreter support for stack walking and diagnostics (#126520)
## Summary
Adds interpreter support to the cDAC (contract-based Data Access
Component), enabling diagnostic tools to correctly walk stacks
containing interpreter frames, resolve interpreter precodes, retrieve
method information for interpreted methods, and surface interpreter code
via the legacy SOS DAC interface.
## Changes
### Native Data Descriptors
- Added interpreter type descriptors to `datadescriptor.inc`:
`InterpreterRealCodeHeader`, `InterpreterPrecodeData`,
`InterpByteCodeStart`, `InterpMethod`, `InterpMethodContextFrame`,
`InterpreterFrame`
- Added `InterpreterFrame` to `frames.h` explicit frame list for cDAC
visibility
### Execution Manager — Interpreter JIT Manager
- New `ExecutionManagerCore.InterpreterJitManager` handles code address
lookups for interpreter code heaps
- `GetCodeBlockHandle` now searches interpreter code heaps when JIT
heaps don't contain the address
- `GetMethodDesc` resolves `MethodDesc` from interpreter code headers
### Precode Resolution
(`GetInterpreterCodeFromInterpreterPrecodeIfPresent`)
- New API on `IPrecodeStubs` matching the native DAC pattern: each call
site resolves interpreter precodes before passing addresses to
`ExecutionManager`
- Passthrough semantics: returns the original address if not an
interpreter precode
- NOTHROW contract via `VirtualReadException` catch
- Applied at 4 call sites: `GetMethodDescData`,
`CopyNativeCodeVersionToReJitData`, `GetTieredVersions`,
`GetILAddressMap`
### Stack Walking
- `FrameIterator` handles `InterpreterFrame` — extracts `MethodDesc` and
native code pointer from `InterpMethodContextFrame`
- `StackWalk_1` resolves interpreter frames during enumeration and uses
`InterpreterVirtualUnwind` instead of OS unwind when the current IP is
interpreter code
- Per-arch `BaseFrameHandler` / `AMD64FrameHandler` /
`ARM64FrameHandler` set the first-arg register to the `InterpreterFrame`
when crossing an active `InlinedCallFrame`, matching the native runtime
- Cross-platform interpreter context mirroring (`AMD64Context` /
`ARM64Context` / `ARMContext`) tracks the latest interpreter frame
pointer
- Adds `ARM/ARMUnwinder.cs` and `ARM64/ARM64Unwinder.cs` so the cDAC
stack walker doesn't crash when an interpreter IP has no native unwind
info — outer failures `return false` (matching the native
`OOPStackUnwinder*` convention) without clobbering `Pc`
### Legacy SOS DAC Interface (`SOSDacImpl`)
- `GetCodeHeaderData` now returns `CodeHeaderData` for interpreter
methods, populating `MethodDescPtr` and routing the GC-info decode by
code kind
- `GetILOffsetsByAddress` succeeds for interpreter IPs by resolving
through the interpreter code header
### RuntimeTypeSystem
- `MethodValidation` updated to handle interpreter method descriptors
(`IsInterpreterStub` flag, chunk validation)
### Documentation
- Updated `ExecutionManager.md`, `PrecodeStubs.md`, `StackWalk.md` with
interpreter support details
### CI
- New interpreter SOS leg in `eng/pipelines/runtime-diagnostics.yml`
exercises the new contracts under the diagnostics SOS test suite
### Tests
- **Unit tests**: `ExecutionManagerTests` (interpreter JIT manager),
`FrameIteratorTests` (interpreter frame handling), `PrecodeStubsTests`
(interpreter precode resolution), `MethodDescTests` (interpreter method
validation), `SOSDacInterface5Tests` (interpreter precode resolution via
legacy interface)
- **Dump tests**: `InterpreterStackDumpTests` integration tests use a
mixed JIT/interpreter stack debuggee (`InterpreterStack` + `Trampoline`)
to validate interleaved frame layout, precode resolution, and thread
enumeration; `ISOSDacInterfaceTests` validates `GetCodeHeaderData` for
interpreter methods over a real dump
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Max Charlamb <maxcharlamb@github.com>
Co-authored-by: Max Charlamb <maxcharlamb@microsoft.com>1 parent d7a10f4 commit ab3cbf5
64 files changed
Lines changed: 2206 additions & 389 deletions
File tree
- docs/design/datacontracts
- eng/pipelines
- diagnostics
- src
- coreclr/vm
- datadescriptor
- installer/pkg/sfx/Microsoft.NETCore.App
- native/managed/cdac
- Microsoft.Diagnostics.DataContractReader.Abstractions
- Contracts
- Microsoft.Diagnostics.DataContractReader.Contracts
- Contracts
- ExecutionManager
- StackWalk
- Context
- ARM64
- ARM
- FrameHandling
- GC
- Data
- RuntimeTypeSystemHelpers
- Microsoft.Diagnostics.DataContractReader.Legacy
- tests
- DumpTests
- Debuggees
- InterpreterStack
- Trampoline
- ExecutionManager
- MockDescriptors
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
187 | 192 | | |
188 | 193 | | |
189 | 194 | | |
| |||
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
285 | | - | |
| 290 | + | |
286 | 291 | | |
287 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
288 | 295 | | |
289 | 296 | | |
290 | 297 | | |
| |||
303 | 310 | | |
304 | 311 | | |
305 | 312 | | |
306 | | - | |
307 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
308 | 317 | | |
309 | 318 | | |
310 | 319 | | |
| |||
480 | 489 | | |
481 | 490 | | |
482 | 491 | | |
| 492 | + | |
| 493 | + | |
483 | 494 | | |
484 | 495 | | |
485 | 496 | | |
| |||
490 | 501 | | |
491 | 502 | | |
492 | 503 | | |
| 504 | + | |
| 505 | + | |
493 | 506 | | |
494 | 507 | | |
495 | 508 | | |
| |||
498 | 511 | | |
499 | 512 | | |
500 | 513 | | |
| 514 | + | |
| 515 | + | |
501 | 516 | | |
502 | 517 | | |
503 | 518 | | |
| |||
511 | 526 | | |
512 | 527 | | |
513 | 528 | | |
514 | | - | |
| 529 | + | |
515 | 530 | | |
516 | 531 | | |
517 | 532 | | |
518 | | - | |
| 533 | + | |
519 | 534 | | |
520 | 535 | | |
521 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
47 | 56 | | |
48 | 57 | | |
49 | 58 | | |
| |||
263 | 272 | | |
264 | 273 | | |
265 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
266 | 291 | | |
267 | 292 | | |
268 | 293 | | |
| |||
286 | 311 | | |
287 | 312 | | |
288 | 313 | | |
| 314 | + | |
| 315 | + | |
289 | 316 | | |
290 | 317 | | |
291 | 318 | | |
| |||
299 | 326 | | |
300 | 327 | | |
301 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
302 | 356 | | |
303 | 357 | | |
304 | 358 | | |
| |||
0 commit comments