-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[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
Changes from 17 commits
b5140fe
89e9505
02f14ef
99a7f56
6829dda
f71b823
3fe4a8a
6b58012
fba0091
7f6b388
2917ef9
34a7169
1b19fb2
3092546
3b02419
05e5909
5e813b6
1505bbb
e648dda
2335f6d
7f06960
570659d
7e75287
d7a99f0
d6ecb88
e1feb95
aeb8dc4
61fbed5
af6a9b1
82eb5aa
ebf14c3
350b993
233615e
dce3e02
dff89fd
2170a9f
9710bde
43eed4f
7909b7d
408c566
55e26f9
675673b
0bcaaf0
26d4b7d
581ea4a
7e4d18f
905b3dc
116f178
38c5048
4b2df0f
c8bba50
9160287
0a5b3d5
ef1281e
423ff27
fe4ead1
4c96d48
cf8dd64
49d1631
7b18c84
8b7f03f
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,12 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Diagnostics.DataContractReader.Contracts.Extensions; | ||
|
|
||
| public static class IExecutionManagerExtensions | ||
| { | ||
| public static bool IsFunclet(this IExecutionManager eman, CodeBlockHandle codeBlockHandle) | ||
| { | ||
| return eman.GetStartAddress(codeBlockHandle) != eman.GetFuncletStartAddress(codeBlockHandle); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ internal partial class ExecutionManagerCore<T> : IExecutionManager | |
| { | ||
| private sealed class ReadyToRunJitManager : JitManager | ||
| { | ||
| private const uint GCINFO_VERSION = 4; | ||
|
|
||
| private readonly uint _runtimeFunctionSize; | ||
| private readonly PtrHashMapLookup _hashMap; | ||
| private readonly HotColdLookup _hotCold; | ||
|
|
@@ -122,6 +124,42 @@ public override TargetPointer GetUnwindInfo(RangeSection rangeSection, TargetCod | |
| return _runtimeFunctions.GetRuntimeFunctionAddress(r2rInfo.RuntimeFunctions, index); | ||
| } | ||
|
|
||
| public override void GetGCInfo(RangeSection rangeSection, TargetCodePointer jittedCodeAddress, out TargetPointer gcInfo, out uint gcVersion) | ||
| { | ||
| gcInfo = TargetPointer.Null; | ||
| gcVersion = 0; | ||
|
|
||
| // ReadyToRunJitManager::GetGCInfoToken | ||
| if (rangeSection.Data == null) | ||
| throw new ArgumentException(nameof(rangeSection)); | ||
|
|
||
| Debug.Assert(rangeSection.Data.R2RModule != TargetPointer.Null); | ||
|
|
||
| Data.Module r2rModule = Target.ProcessedData.GetOrAdd<Data.Module>(rangeSection.Data.R2RModule); | ||
| Debug.Assert(r2rModule.ReadyToRunInfo != TargetPointer.Null); | ||
| Data.ReadyToRunInfo r2rInfo = Target.ProcessedData.GetOrAdd<Data.ReadyToRunInfo>(r2rModule.ReadyToRunInfo); | ||
|
|
||
| // Check if address is in a thunk | ||
| if (IsStubCodeBlockThunk(rangeSection.Data, r2rInfo, jittedCodeAddress)) | ||
| return; | ||
|
|
||
| // Find the relative address that we are looking for | ||
| TargetPointer addr = CodePointerUtils.AddressFromCodePointer(jittedCodeAddress, Target); | ||
| TargetPointer imageBase = rangeSection.Data.RangeBegin; | ||
| TargetPointer relativeAddr = addr - imageBase; | ||
|
|
||
| uint index; | ||
| if (!_runtimeFunctions.TryGetRuntimeFunctionIndexForAddress(r2rInfo.RuntimeFunctions, r2rInfo.NumRuntimeFunctions, relativeAddr, out index)) | ||
| return; | ||
|
|
||
| Data.RuntimeFunction runtimeFunction = _runtimeFunctions.GetRuntimeFunction(r2rInfo.RuntimeFunctions, index); | ||
|
|
||
| TargetPointer unwindInfo = runtimeFunction.UnwindData + imageBase; | ||
| uint unwindDataSize = sizeof(uint); // TODO(cdac): This is platform specific and maybe needs its own contract. Current value is for x86 | ||
| gcInfo = unwindInfo + unwindDataSize; | ||
| gcVersion = GCINFO_VERSION; // TODO(cdac): This depends on the major version of the runtime. | ||
|
||
| } | ||
|
|
||
| private bool IsStubCodeBlockThunk(Data.RangeSection rangeSection, Data.ReadyToRunInfo r2rInfo, TargetCodePointer jittedCodeAddress) | ||
| { | ||
| if (r2rInfo.DelayLoadMethodCallThunks == TargetPointer.Null) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.