Skip to content

Commit 7fafe7e

Browse files
author
Michael DeRoy
committed
Use the pretty PMIP instead when available. When unavailable callback to normal pmip. remove quotes from output
1 parent 8e7d22b commit 7fafe7e

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

PmipRunner.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public DkmStackWalkFrame PmipStackFrame()
3636
var eval = EvaluateExpression(call, r =>
3737
{
3838
isNull = r.Address.InstructionAddress.CPUInstructionPart.InstructionPointer == 0;
39-
result = r.Value;
39+
result = r.Value?.Split('"')[1];
4040
});
4141

4242
if (!eval || isNull)
@@ -53,24 +53,37 @@ public DkmStackWalkFrame PmipStackFrame()
5353
_frame.Annotations);
5454
}
5555

56+
private DkmNativeInstructionAddress FindInstructionAddress(string functionName)
57+
{
58+
foreach (var module in this._frame.RuntimeInstance.GetModuleInstances())
59+
{
60+
var address = (module as DkmNativeModuleInstance)?.FindExportName(functionName,
61+
IgnoreDataExports: true);
62+
if(address != null)
63+
return address;
64+
}
65+
return null;
66+
}
67+
5668
private bool TryGetPmipFunction(out PmipFunctionDataItem pmipFunction)
5769
{
5870
pmipFunction = _stackContext.GetDataItem<PmipFunctionDataItem>();
5971
if (pmipFunction != null)
6072
return true;
6173

62-
foreach (var module in this._frame.RuntimeInstance.GetModuleInstances())
63-
{
64-
var address = (module as DkmNativeModuleInstance)?.FindExportName("mono_pmip", IgnoreDataExports: true);
65-
if (address == null)
66-
continue;
67-
var item = new PmipFunctionDataItem { PmipFunction = "0x" + address.CPUInstructionPart.InstructionPointer.ToString("X") };
68-
pmipFunction = item;
69-
_stackContext.SetDataItem(DkmDataCreationDisposition.CreateAlways, item);
70-
return true;
71-
}
74+
var pmipOrig = FindInstructionAddress("mono_pmip");
75+
var pmipPretty = FindInstructionAddress("mono_pmip_pretty");
76+
77+
var pmipFnToUse = pmipPretty ?? pmipOrig;
78+
79+
if (pmipFnToUse == null)
80+
return false;
81+
82+
var item = new PmipFunctionDataItem { PmipFunction = "0x" + pmipFnToUse.CPUInstructionPart.InstructionPointer.ToString("X") };
83+
pmipFunction = item;
84+
_stackContext.SetDataItem(DkmDataCreationDisposition.CreateAlways, item);
7285

73-
return false;
86+
return true;
7487
}
7588

7689
private static DkmLanguageExpression CppExpression(string expression)

0 commit comments

Comments
 (0)