Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cdac] Implement !PrintException #99302

Open
22 of 25 tasks
Tracked by #99298
lambdageek opened this issue Mar 5, 2024 · 2 comments
Open
22 of 25 tasks
Tracked by #99298

[cdac] Implement !PrintException #99302

lambdageek opened this issue Mar 5, 2024 · 2 comments
Assignees
Labels
area-Diagnostics-coreclr enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@lambdageek
Copy link
Member

lambdageek commented Mar 5, 2024

Part of #99298

This will require bringing up a basic data stream reader and registering enough data types and instances in the runtime so that we can get at the exception.

.NET 10

  • Module name fallback if debugger and GetPEFileName() can't get the name

Additionally see sos_printexception_walkthrough.md#exception-informaiton for a walkthrough of the relationship of these interfaces to what SOS is doing

For CLRMA, we will need a few additional methods:
https://github.com/dotnet/diagnostics/blob/main/documentation/clrma.md#dac-interfaces-used-by-clrma

.NET 9

We maintain a branch feature/9.0-cdac-backports that has selected data descriptor and contract changes necessary for the cdacreader to interrogate a net9.0 runtime. The backports to this branch include:

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 5, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Mar 5, 2024
@ghost
Copy link

ghost commented Mar 5, 2024

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: lambdageek
Assignees: -
Labels:

area-Diagnostics-coreclr, untriaged, needs-area-label

Milestone: -

@lambdageek lambdageek added this to the 9.0.0 milestone Mar 5, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Mar 5, 2024
@lambdageek lambdageek removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 5, 2024
@tommcdon tommcdon added the enhancement Product code improvement that does NOT require public API changes/additions label Mar 11, 2024
@lambdageek
Copy link
Member Author

lambdageek commented Jun 28, 2024

DAC interfaces used by CLRMA https://github.com/mikem8361/diagnostics/blob/clrma/documentation/clrma.md#dac-interfaces-used-by-clrma

Managed stack walking:

  • IXCLRDataProcess::GetTaskByOSThreadID()
  • IXCLRDataTask::CreateStackWalk()
  • IXCLRDataStackWalk::Request(DACSTACKPRIV_REQUEST_FRAME_DATA, ...)
  • IXCLRDataStackWalk::GetContext()
  • IXCLRDataStackWalk::Next()

The stack walker is only used in the fallback case for hang dumps. Crash dumps are the most important

davidwrighton added a commit that referenced this issue Jul 17, 2024
Add new details to the RuntimeTypeSystem and Loader contracts as needed to load metadata and examine and identify all of the kinds of type that the CoreCLR type system can represent

Add a type name generator based on a line by line copy from the CoreCLR codebase

Add an Ecma335 metadata parser which is pure safe managed code, and is capable of loading metadata that is not structured as a single array. This implementation is heavily based on the dnmd implementation. It is intended that this implementation is short-lived, and really ought to be replaced by dnmd or System.Reflection.Metadata when those apis become suitable for use in this scenario.

Provide implementations and documentation for all of the new contracts except for the RW metadata one. (Its rarely needed, so we can add it later)

Enhance the target infrastructure to better handle various forms of arrays, and contracts which do math based on target pointer sizes.

Contributes to #99302
@tommcdon tommcdon modified the milestones: 9.0.0, 10.0.0 Jul 23, 2024
davidwrighton added a commit that referenced this issue Aug 13, 2024
Add a number of new `MethodDesc` contract definitions

| Contract algorithm on RuntimeTypeSystem |
| --- |
| `IsGenericMethodDefinition`|
|`GetGenericMethodInstantiation`|
|`GetMethodToken`|
|`IsArrayMethod`|
|`IsDynamicMethod`|
|`IsStoredSigMethodDesc`|
|`IsNoMetadataMethod`|
|`IsILStub`|

Update cDAC compat asserts in cDAC to always be enabled by using a tls variable in `mscordaccore`

Implement `GetMethodDescName` on `ISOSDacInterface` in the `cdacreader`

Stub out an implementation of `GetPath` in the `Loader` contract used in a fallback after a fallback. This will need further work, but is included to make sure the code path isn't lost.

Fix the `EcmaMetadataReader` to be able to find blobs in the metadata

Add ability to read target data from a buffer held on the cdac side using the `Target` class. This was needed to handle signature containing a `CorElementType.Internal`.

And finally actually implement the name generation algorithm via a line for line port from the CoreCLR codebase.

Contributes to #99302
lambdageek added a commit to lambdageek/runtime that referenced this issue Oct 17, 2024
The CodeVersions contract implements the IL and native code versioning
as described in [code-versioning.md](docs/design/features/code-versioning.md)

Contributes to dotnet#108553
Contributes to dotnet#99302

* rename contract NativeCodePointers => CodeVersions

*  FindActiveILCodeVersion

* implement GetModuleLookupMapElement

* FindActiveILCodeVersion/FindActiveNativeCodeVersion

* il code version lookup table

* remove AppDomain.CodeVersionManager from cdac

* CodeVersionManager is basically a static class in the C++ side

* NativeCodeVersionContract.GetSpecificNativeCodeVersion

* checkpoint: start adding NativeCodeVersion operations

* WIP: native code version
lambdageek added a commit that referenced this issue Oct 18, 2024
* [cdac] Add a CodeVersions contract

The CodeVersions contract implements the IL and native code versioning
as described in [code-versioning.md](docs/design/features/code-versioning.md)

Contributes to #108553
Contributes to #99302

* rename contract NativeCodePointers => CodeVersions

*  FindActiveILCodeVersion

* implement GetModuleLookupMapElement

* FindActiveILCodeVersion/FindActiveNativeCodeVersion

* il code version lookup table

* remove AppDomain.CodeVersionManager from cdac

* CodeVersionManager is basically a static class in the C++ side

* NativeCodeVersionContract.GetSpecificNativeCodeVersion

* checkpoint: start adding NativeCodeVersion operations

* WIP: native code version

* tighter cdac_data friends

* remove unused DataType values

they'll come in from a future PR

* move ecma metadata helpers to their own class

* WIP: CodeVersionsTests

* WIP: TestGetNativeCodeVersionOneVersionVersionable

* implement GetNativeCode for a NativeCodeVersionNode handle

* checkpoint: TestGetNativeCodeVersionOneVersionVersionable passes

* Add TestGetActiveNativeCodeVersionDefaultCase

* don't add ILCodeVersioningState::Next field yet

* describe Loader::GetModuleLookupMapElement contract

* remove unused member

* update contract markdown

* simplify flags handling a bit

* add TODOs for RuntimeTypeSystem additions
lambdageek added a commit that referenced this issue Oct 24, 2024
Adds a `PrecodeStubs` contract for working with precode.
Adds a `CDacMetadata` contract for exposing useful platform-specific properties

Contributes to #99302 
Contributes to #108553 

* [cdac] PrecodeStubs contract
* move PrecodeStubs to a separate contract
* remove instance field initialization from PrecodeMachineDescriptor
* PrecodeMachineDescriptor::Init() will initialize g_PrecodeMachineDescriptor
* fix thumb flag logic
* add FixupPrecodeData
* checkpoint: StubPrecodeData, StubCodePageSize
* checkpoint: PrecodeMachineDescriptor and KnownPrecodeType
* WIP: start adding PrecodeStubs test infrastructure
* checkpoint: stub precode test passing
* set the "thumb" bit
* cleanup thumb bit
* add a CDacMetadata struct
* permute PrecodeMachineDescriptor fields for better packability
* reader for CDacMetadata contract
* WIP: code pointer flags
* checkpoint tests with CDacMetadata
* rename CDacMetadata -> PlatformMetadata
* add a define for Loongarch64 stub precode shift
* conditionally define fields for precode absent precode types
* clarify how stub and pinvoke precodes work

---------

Co-authored-by: Elinor Fung <[email protected]>
lambdageek added a commit that referenced this issue Nov 1, 2024
This is enough for `!PrintException` without R2R methods on the stack

There's also a `ReJIT` contract here which just checks whether rejit is enabled.

Most of the complexity is in validating MethodDescs

Contributes to #99302
Contributes to #108553

---

* ReJIT contract

* document the ExecutionManager methods

* cache EECodeInfo based on given code pointer, not start of the method

   The EECodeInfo includes the relative offset (given ip - start of method) so it's not ok to share for different code pointers into the same method

* add legacy DAC comparison for GetMethodDescData

* add documentation to managed contract impl

* add TODOs for RuntimeTypeSystem additions

* update contract markdown

* get collectible flag for module from Assembly instead of LoaderAllocator

* Use CodePointerFlags in RuntimeTypeSystem

* implement MethodDesc GetLoaderModule

   via the loader module attached to a chunk

* implement MethodTable GetLoaderModule

* add MethodTable.AuxiliaryData field to test typeinfo

* implement vtable indirections

* fixup: GetVtableIndirections

   - add MethodTable size to data descriptor

* rename some vestigial CDacMetadata references

* WIP: MethodDesc tests

* checkpoint GetMethodToken test passes

* move MethodValidation to a separate class

   also move method flags out of the RuntimeTypeSystem_1 contract

   for the cases where the method validation needs to call back to type validation, go via the contract

* move COR_PRF_MONITOR into ReJIT_1

   it's an implementation detail

* Update src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs

   Co-authored-by: Aaron Robinson <[email protected]>

* assert the expected slot number

* Exercise a few more easy properties of MethodDesc

* remove TypeHandleFromAddress from contract

   we just use GetTypeHandle now

* clean up MethodClassification -> size lookups

* document RuntimeTypeSystem contract additions

* update the CodeVersions contract to match implementation

* remove some TODO comments

* add sizes for method desc subclasses

   the "additional pointers" logic in RuntimeTypeSystem_1 depends on the sizes

---------

Co-authored-by: Elinor Fung <[email protected]>
Co-authored-by: Aaron Robinson <[email protected]>
@lambdageek lambdageek assigned steveisok and unassigned lambdageek Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Diagnostics-coreclr enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

4 participants