#include "standardpch.h"
#include "methodcallsummarizer.h"
+#include "logging.h"
MethodCallSummarizer::MethodCallSummarizer(WCHAR* logPath)
{
HANDLE hFile = CreateFileW(dataFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ LogError("Couldn't open file '%ws': error %d", dataFileName, ::GetLastError());
+ return;
+ }
+
DWORD len = (DWORD)sprintf_s(buff, 512, "FunctionName,Count\n");
WriteFile(hFile, buff, len, &bytesWritten, NULL);
#include "spmiutil.h"
#include "jithost.h"
-HMODULE g_hRealJit = 0; // We leak this currently (could do the proper shutdown in process_detach)
-WCHAR* g_realJitPath = nullptr; // We leak this (could do the proper shutdown in process_detach)
-WCHAR* g_logPath = nullptr; // Again, we leak this one too...
-char* g_logFilePath = nullptr; // We *don't* leak this, hooray!
-WCHAR* g_HomeDirectory = nullptr;
-WCHAR* g_DefaultRealJitPath = nullptr;
+HMODULE g_hRealJit = 0; // We leak this currently (could do the proper shutdown in process_detach)
+WCHAR* g_realJitPath = nullptr; // We leak this (could do the proper shutdown in process_detach)
+WCHAR* g_logPath = nullptr; // Again, we leak this one too...
+char* g_logFilePath = nullptr; // We *don't* leak this, hooray!
+WCHAR* g_HomeDirectory = nullptr;
+WCHAR* g_DefaultRealJitPath = nullptr;
+MethodCallSummarizer* g_globalContext = nullptr;
void SetDefaultPaths()
{
delete[] g_logFilePath;
g_logFilePath = nullptr;
+ if (g_globalContext != nullptr)
+ {
+ g_globalContext->SaveTextFile();
+ }
+
break;
case DLL_THREAD_ATTACH:
}
g_ourJitHost = new JitHost(host);
+
+ if (g_globalContext == nullptr)
+ {
+ SetLogPath();
+ g_globalContext = new MethodCallSummarizer(g_logPath);
+ }
+
+ g_ourJitHost->setMethodCallSummarizer(g_globalContext);
+
pnjitStartup(g_ourJitHost);
}
SetDefaultPaths();
SetLibName();
- SetLogPath();
// Load Library
if (g_hRealJit == 0)
pJitInstance = new interceptor_ICJC();
pJitInstance->original_ICorJitCompiler = tICJI;
- pJitInstance->mcs = new MethodCallSummarizer(g_logPath);
- if (g_ourJitHost != nullptr)
+
+ if (g_globalContext == nullptr)
{
- g_ourJitHost->setMethodCallSummarizer(pJitInstance->mcs);
+ SetLogPath();
+ g_globalContext = new MethodCallSummarizer(g_logPath);
}
+ pJitInstance->mcs = g_globalContext;
return pJitInstance;
}