-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[cDAC] Support x86 stackwalking #116072
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] Support x86 stackwalking #116072
Conversation
Tagging subscribers to this area: @tommcdon |
We recently switched x86 to use funclets which is a major R2R breaking change. I feel that there's no point in supporting anything older, both cDAC and x86/funclets are on the same shipping schedule. |
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/InfoHdr.cs
Outdated
Show resolved
Hide resolved
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/InfoHdr.cs
Outdated
Show resolved
Hide resolved
...ostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/GCInfoDecoding/GCInfo.cs
Outdated
Show resolved
Hide resolved
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
...soft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
#if DEBUG | ||
if (_legacyImpl is not null) | ||
{ | ||
DacpUsefulGlobalsData dataLocal; | ||
int hrLocal = _legacyImpl.GetUsefulGlobals(&dataLocal); | ||
Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}"); | ||
if (hr == HResults.S_OK) | ||
// Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented out assert intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This was something I discovered while running the SOS tests on x86.
SOS can call GetUsefulGlobals
API before global pointer data is initialized. When built with MSVC, the DAC global table is statically constructed and is available leading to a successful call. When building on clang, the table is constructed in EEStartup
and probably wouldn't be available when SOS calls. Since it would be very difficult (and unnecessary) to match this behavior exactly, for now, I loosened the cDAC assertion around GetUsefulGlobals
.
If the cDAC and the DAC have different HResults, but the same data (usually all 0s), that seems acceptable.
I noted it in the PR description but will add a comment explaining why the assertion is loosened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment
return _runtimeFunctions.GetRuntimeFunctionAddress(r2rInfo.RuntimeFunctions, index); | ||
private uint AdjustRuntimeFunctionIndexForHotCold(Data.ReadyToRunInfo r2rInfo, uint index) | ||
{ | ||
bool featureEHFunclets = Target.ReadGlobal<byte>(Constants.Globals.FeatureEHFunclets) != 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I do not think we need to bother maintaining FeatureEHFunclets checks. It should be fine to assume funclets for cdac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@@ -85,6 +99,7 @@ Global variables used: | |||
| `HashMapSlotsPerBucket` | uint32 | Number of slots in each bucket of a `HashMap` | | |||
| `HashMapValueMask` | uint64 | Bitmask used when storing values in a `HashMap` | | |||
| `FeatureEHFunclets` | uint8 | 1 if EH funclets are enabled, 0 otherwise | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete this constant too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple other uses of the FeatureEHFunclets
flag, I was going to open a different PR to totally remove the datadescriptor if that is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#116743 created, to avoid merge conflicts it will fail to build until this PR is merged
/azp run runtime-diagnostics |
This comment was marked as duplicate.
This comment was marked as duplicate.
Azure Pipelines successfully started running 1 pipeline(s). |
/ba-g Failures unrelated to changes. dotnet/dnceng#5904 |
Sync changes made for dotnet/runtime#116072 over to diagnostics repo
Changes
IExecutionManager
RealCodeHeader::GCInfo
ReadyToRunJitManager
asGetGCInfo
,GetUnwindInfo
, andGetMethodInfo
had very similar implementations.GetMethodDesc
andGetStartAddress
Extension IsFunclet
IExecutionManager.StartAddress(cbh) != IExecutionManager.GetFuncletStartAddress(cbh)
IStackWalk
IPlatformAgnosticContext.GetContextForPlatform
support x86src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/x86/
gc_unwind_x86.inl
GCInfo
usesInfoHdr
to decode the header. This involves reading an initial header from a lookup table then modifying with a series of instructions.GCArgTable
to decode the argument/stack depth table.GCTransition
used as part of the GCArgTable decoding.CallPattern
to decode common call pattern encodings in the GCArgTable. Uses look up table similar to InfoHdr.Issues
SOS can call
GetUsefulGlobals
API before global pointer data is initialized.EEStartup
and probably wouldn't be available when SOS calls.GetUsefulGlobals
has been loosened. If the cDAC and the DAC have different HResults, but the same data (usually all 0s), that is acceptable.GCInfo Version
ILStubTypeFEATURE_INSTANTIATINGSTUB_AS_IL
. Currently this PR only needs values before they have different numbering.runtime/src/coreclr/vm/method.hpp
Lines 2708 to 2734 in 6ab0311
For now, we are encoding the enum as a contract constant like other enums defined inmethod.hpp
. Currently we are only using static values, so the runtime did not need to be changed. If we need values later, we can modify the runtime enum to remove the ifdef or add an else block to fill the same number of enum slots.JitHalt Debug
ifdef
is really for the target runtime as well. This is not true for the cDAC. Is this check acceptable in release builds? Alternatively, I can add a datadescriptor to check if the target runtime is built in Debug or Release and match the DAC behavior exactly.runtime/src/coreclr/vm/gc_unwind_x86.inl
Lines 2773 to 2780 in 3aa0c97
_DEBUG
check for consistency.[cDAC] Implement sign extension for ClrDataAddresses #116222
X86 GCDecoder RevPInvoke nits #116264
IExecutionManager.GetGCInfo
needs the function entry unwind info, not the unwind info directly correlating to the offset.Handle parsing ArgTab correctly when GCInfo header does not have an argTabOffset.