Skip to content

Commit 8e7d22b

Browse files
authored
Merge pull request #2 from ntherning/alternate-mono_pmip-symbol-lookup
Alternate method of finding the mono_pmip symbol which also works on 64-bit processes
2 parents 30b57f7 + 5d03406 commit 8e7d22b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

PmipRunner.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
using Microsoft.VisualStudio.Debugger;
33
using Microsoft.VisualStudio.Debugger.CallStack;
44
using Microsoft.VisualStudio.Debugger.Evaluation;
5+
using Microsoft.VisualStudio.Debugger.Native;
56

67
namespace PmipMyCallStack
78
{
89
class PmipRunner
910
{
1011
private static readonly DkmLanguage CppLanguage = DkmLanguage.Create("C++", new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp));
11-
private static readonly string[] Modules = { "mono", "monosgen-2.0" };
1212

1313
private readonly DkmStackContext _stackContext;
1414
private readonly DkmStackWalkFrame _frame;
@@ -59,14 +59,12 @@ private bool TryGetPmipFunction(out PmipFunctionDataItem pmipFunction)
5959
if (pmipFunction != null)
6060
return true;
6161

62-
foreach (var module in Modules)
62+
foreach (var module in this._frame.RuntimeInstance.GetModuleInstances())
6363
{
64-
var definition = $"{{,,{module}}}mono_pmip";
65-
66-
PmipFunctionDataItem item = null;
67-
if (!EvaluateExpression(definition, r => item = new PmipFunctionDataItem {PmipFunction = definition}))
64+
var address = (module as DkmNativeModuleInstance)?.FindExportName("mono_pmip", IgnoreDataExports: true);
65+
if (address == null)
6866
continue;
69-
67+
var item = new PmipFunctionDataItem { PmipFunction = "0x" + address.CPUInstructionPart.InstructionPointer.ToString("X") };
7068
pmipFunction = item;
7169
_stackContext.SetDataItem(DkmDataCreationDisposition.CreateAlways, item);
7270
return true;
@@ -116,4 +114,4 @@ private bool EvaluateExpression(string expression, Action<DkmSuccessEvaluationRe
116114
return success;
117115
}
118116
}
119-
}
117+
}

0 commit comments

Comments
 (0)