-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[cDAC] Implement DacDbi GetNativeCodeInfo / GetNativeCodeInfoForAddr #128338
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
base: main
Are you sure you want to change the base?
Changes from all commits
352ebcc
794e87e
1a185ec
51fe617
109f48f
efc62f0
7f0ded6
a948fbc
5d7dd6f
dfaa609
575085a
e7644f1
2b2c1a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Contract EnC | ||
|
|
||
| This contract reports Edit and Continue (EnC) function version numbers for jitted | ||
| managed methods. EnC function versions are 1-based monotonically increasing counters | ||
| that the runtime assigns to each `EnC`-emitted instance of a method body. | ||
|
|
||
| ## APIs of contract | ||
|
|
||
| ``` csharp | ||
| // Returns the latest EnC version number associated with the method identified by | ||
| // (module, methodDef). If no EnC-jitted instance exists for that method, returns | ||
| // the default EnC function version (1). | ||
| TargetNUInt GetLatestEnCVersion(TargetPointer module, uint methodDef); | ||
|
|
||
| // Returns the EnC version number for the specific jitted instance of the method | ||
| // identified by (module, methodDef) whose hot region starts at the given native | ||
| // code address. If no matching jitted instance exists (for example, the method | ||
| // was never EnC-edited), returns the default EnC function version (1). | ||
| TargetNUInt GetEnCVersion(TargetPointer module, uint methodDef, TargetCodePointer nativeCodeAddress); | ||
| ``` | ||
|
|
||
| ## Version 1 | ||
|
|
||
| Data descriptors used: | ||
| | Data Descriptor Name | Field | Type | Purpose | | ||
| | --- | --- | --- | --- | | ||
| | `Module` | `EnCDataList` | nuint | Head of the singly linked list of `EnCData` entries for jitted EnC-versioned methods in this module | | ||
| | `EnCData` | `AddrOfCode` | nuint | Native code start (TADDR) for the jitted instance | | ||
| | `EnCData` | `Token` | uint32 | `mdMethodDef` token of the method | | ||
| | `EnCData` | `EnCVersion` | nuint | EnC function version number for this jitted instance | | ||
| | `EnCData` | `Next` | nuint | Next entry in the module's `EnCData` list, or null | | ||
|
|
||
| Global variables used: | ||
| | Global Name | Type | Purpose | | ||
| | --- | --- | --- | | ||
| | `CorDBDefaultEnCFunctionVersion` | nuint | Default EnC function version reported for methods that have never been EnC-edited (matches `CorDB_DEFAULT_ENC_FUNCTION_VERSION` in `src/coreclr/inc/cordbpriv.h`) | | ||
|
|
||
| Contracts used: none | ||
|
|
||
| ``` csharp | ||
| // Returns the address of the first EnCData entry on module's EnCDataList whose Token | ||
| // matches methodDef and (when addrOrZero is non-null) whose AddrOfCode matches | ||
| // addrOrZero. Returns TargetPointer.Null if no entry matches. | ||
| TargetPointer FindEnCDataEntry(TargetPointer module, uint methodDef, | ||
| TargetPointer addrOrZero) | ||
| { | ||
| TargetPointer cur = _target.ReadPointer(module + /* Module::EnCDataList offset */); | ||
| while (cur != TargetPointer.Null) | ||
| { | ||
| uint token = _target.Read<uint>(cur + /* EnCData::Token offset */); | ||
| TargetPointer addrOfCode = _target.ReadPointer(cur + /* EnCData::AddrOfCode offset */); | ||
| if (token == methodDef && | ||
| (addrOrZero == TargetPointer.Null || addrOfCode == addrOrZero)) | ||
| { | ||
| return cur; | ||
| } | ||
| cur = _target.ReadPointer(cur + /* EnCData::Next offset */); | ||
| } | ||
| return TargetPointer.Null; | ||
| } | ||
| ``` | ||
|
|
||
| ``` csharp | ||
| TargetNUInt GetLatestEnCVersion(TargetPointer module, uint methodDef) | ||
| { | ||
| TargetPointer entry = FindEnCDataEntry(module, methodDef, TargetPointer.Null); | ||
| if (entry == TargetPointer.Null) | ||
| return new TargetNUInt(/* CorDBDefaultEnCFunctionVersion global */); | ||
|
|
||
| return _target.ReadNUInt(entry + /* EnCData::EnCVersion offset */); | ||
| } | ||
| ``` | ||
|
|
||
| ``` csharp | ||
| TargetNUInt GetEnCVersion(TargetPointer module, uint methodDef, | ||
| TargetCodePointer nativeCodeAddress) | ||
| { | ||
| if (nativeCodeAddress.Value == 0) | ||
| return new TargetNUInt(/* CorDBDefaultEnCFunctionVersion global */); | ||
|
|
||
| TargetPointer entry = FindEnCDataEntry(module, methodDef, | ||
| new TargetPointer(nativeCodeAddress.Value)); | ||
| if (entry == TargetPointer.Null) | ||
| return new TargetNUInt(/* CorDBDefaultEnCFunctionVersion global */); | ||
|
|
||
| return _target.ReadNUInt(entry + /* EnCData::EnCVersion offset */); | ||
| } | ||
| ``` | ||
|
|
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -1226,6 +1226,17 @@ void DebuggerJitInfo::Init(TADDR newAddress) | |||
| this->m_sizeOfCode = this->m_codeRegionInfo.getSizeOfTotalCode(); | ||||
|
|
||||
| this->m_encVersion = this->m_methodInfo->GetCurrentEnCVersion(); | ||||
| #ifdef FEATURE_METADATA_UPDATER | ||||
| if (this->m_encVersion != CorDB_DEFAULT_ENC_FUNCTION_VERSION) | ||||
| { | ||||
| Module* pModule = this->m_pLoaderModule; | ||||
| EnCData* pEnCData = (EnCData*)(void*)pModule->GetLoaderAllocator()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(EnCData))); | ||||
| pEnCData->addrOfCode = (TADDR)this->m_addrOfCode; | ||||
| pEnCData->token = this->m_methodInfo->m_token; | ||||
| pEnCData->encVersion = this->m_encVersion; | ||||
| pModule->AddEncData(pEnCData); | ||||
|
rcj1 marked this conversation as resolved.
Comment on lines
1228
to
+1237
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. Only possibly relevant in runtime/src/coreclr/debug/di/divalue.cpp Line 2748 in 3206a8e
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
| } | ||||
| #endif // FEATURE_METADATA_UPDATER | ||||
|
|
||||
| this->InitFuncletAddress(); | ||||
|
|
||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.