diff options
Diffstat (limited to 'src/coreclr/ToolBox')
-rw-r--r-- | src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp | 10 | ||||
-rw-r--r-- | src/coreclr/ToolBox/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp | 38 |
2 files changed, 37 insertions, 11 deletions
diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 9f5f1e912a4..85cca8a129d 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1710,6 +1710,13 @@ void interceptor_ICJI::getCallInfo( param.flags = flags; param.pResult = pResult; +#ifdef HOST_UNIX + // We don't seem to be able to capture the exception code in PAL exceptions when thrown + // from crossgen2. So assume there will be some error, then set it to zero (no error) + // if the `getCallInfo` call doesn't throw. + param.exceptionCode = 1; +#endif // HOST_UNIX + PAL_TRY(Param*, pOuterParam, ¶m) { PAL_TRY(Param*, pParam, pOuterParam) @@ -1717,6 +1724,9 @@ void interceptor_ICJI::getCallInfo( pParam->pThis->mc->cr->AddCall("getCallInfo"); pParam->pThis->original_ICorJitInfo->getCallInfo(pParam->pResolvedToken, pParam->pConstrainedResolvedToken, pParam->callerHandle, pParam->flags, pParam->pResult); +#ifdef HOST_UNIX + pParam->exceptionCode = 0; +#endif // HOST_UNIX } PAL_EXCEPT_FILTER(FilterSuperPMIExceptions_CaptureExceptionAndContinue) { diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp index 1b0363ec859..1731ecf3d4d 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp @@ -27,6 +27,7 @@ WCHAR* g_DefaultRealJitPath = nullptr; MethodContext* g_globalContext = nullptr; WCHAR* g_debugRecStr = nullptr; WCHAR* g_debugRepStr = nullptr; +bool g_initialized = false; void SetDefaultPaths() { @@ -102,6 +103,28 @@ void SetDebugVariables() } } +void InitializeShim() +{ + if (g_initialized) + { + return; + } + +#ifdef HOST_UNIX + if (0 != PAL_InitializeDLL()) + { + fprintf(stderr, "Error: Fail to PAL_InitializeDLL\n"); + exit(1); + } +#endif // HOST_UNIX + + Logger::Initialize(); + SetLogFilePath(); + Logger::OpenLogFile(g_logFilePath); + + g_initialized = true; +} + extern "C" #ifdef HOST_UNIX DLLEXPORT // For Win32 PAL LoadLibrary emulation @@ -112,17 +135,7 @@ extern "C" switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: -#ifdef HOST_UNIX - if (0 != PAL_InitializeDLL()) - { - fprintf(stderr, "Error: Fail to PAL_InitializeDLL\n"); - exit(1); - } -#endif // HOST_UNIX - - Logger::Initialize(); - SetLogFilePath(); - Logger::OpenLogFile(g_logFilePath); + InitializeShim(); break; case DLL_PROCESS_DETACH: @@ -142,6 +155,9 @@ extern "C" extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host) { + // crossgen2 doesn't invoke DllMain on Linux/Mac (under PAL), so optionally do initialization work here. + InitializeShim(); + SetDefaultPaths(); SetLibName(); SetDebugVariables(); |