22using Microsoft . VisualStudio . Debugger ;
33using Microsoft . VisualStudio . Debugger . CallStack ;
44using Microsoft . VisualStudio . Debugger . Evaluation ;
5+ using Microsoft . VisualStudio . Debugger . Native ;
56
67namespace 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