Don't try to recreate breakpad server if it's still running

This commit is contained in:
baldurk
2018-08-13 18:27:26 +01:00
parent 9b7581011e
commit 2bc81b8617
3 changed files with 67 additions and 55 deletions
-2
View File
@@ -181,8 +181,6 @@ RenderDoc &RenderDoc::Inst()
void RenderDoc::RecreateCrashHandler()
{
UnloadCrashHandler();
#if ENABLED(RDOC_CRASH_HANDLER)
m_ExHandler = new CrashHandler(m_ExHandler);
#endif
-3
View File
@@ -52,9 +52,6 @@ bool is_exr_file(FILE *f);
struct ICrashHandler
{
virtual ~ICrashHandler() {}
virtual void WriteMinidump() = 0;
virtual void WriteMinidump(void *data) = 0;
virtual void RegisterMemoryRegion(void *mem, size_t size) = 0;
virtual void UnregisterMemoryRegion(void *mem) = 0;
};
+67 -50
View File
@@ -42,7 +42,15 @@ public:
google_breakpad::AppMemoryList mem;
if(existing)
{
mem = ((CrashHandler *)existing)->m_ExHandler->QueryRegisteredAppMemory();
}
else
{
CreateCrashHandlingServer();
}
_CrtSetReportMode(_CRT_ASSERT, 0);
SAFE_DELETE(existing);
@@ -58,51 +66,6 @@ public:
MINIDUMP_TYPE dumpType = MINIDUMP_TYPE(MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory);
{
PROCESS_INFORMATION pi;
STARTUPINFOW si;
RDCEraseEl(pi);
RDCEraseEl(si);
HANDLE waitEvent = CreateEventA(NULL, TRUE, FALSE, "RENDERDOC_CRASHHANDLE");
wchar_t radpath[MAX_PATH] = {0};
GetModuleFileNameW(GetModuleHandleA("renderdoc.dll"), radpath, MAX_PATH - 1);
wchar_t *slash = wcsrchr(radpath, L'\\');
if(slash)
{
*slash = 0;
}
else
{
slash = wcsrchr(radpath, L'/');
if(slash)
*slash = 0;
else
{
radpath[0] = L'.';
radpath[1] = 0;
}
}
wstring cmdline = L"\"";
cmdline += radpath;
cmdline += L"/renderdoccmd.exe\" crashhandle";
wchar_t *paramsAlloc = new wchar_t[512];
wcscpy_s(paramsAlloc, 511, cmdline.c_str());
CreateProcessW(NULL, paramsAlloc, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
WaitForSingleObject(waitEvent, 2000);
CloseHandle(waitEvent);
}
static google_breakpad::CustomInfoEntry breakpadCustomInfo[] = {
google_breakpad::CustomInfoEntry(L"version", L""),
google_breakpad::CustomInfoEntry(L"logpath", L""),
@@ -121,24 +84,78 @@ public:
google_breakpad::CustomClientInfo custom = {&breakpadCustomInfo[0],
ARRAY_COUNT(breakpadCustomInfo)};
_CrtSetReportMode(_CRT_ASSERT, 0);
m_ExHandler = new google_breakpad::ExceptionHandler(
dumpFolder.c_str(), NULL, NULL, NULL, google_breakpad::ExceptionHandler::HANDLER_ALL,
dumpType, L"\\\\.\\pipe\\RenderDocBreakpadServer", &custom);
if(!m_ExHandler->IsOutOfProcess())
{
RDCWARN("Couldn't find existing breakpad server");
SAFE_DELETE(m_ExHandler);
CreateCrashHandlingServer();
m_ExHandler = new google_breakpad::ExceptionHandler(
dumpFolder.c_str(), NULL, NULL, NULL, google_breakpad::ExceptionHandler::HANDLER_ALL,
dumpType, L"\\\\.\\pipe\\RenderDocBreakpadServer", &custom);
}
m_ExHandler->set_handle_debug_exceptions(true);
for(size_t i = 0; i < mem.size(); i++)
m_ExHandler->RegisterAppMemory((void *)mem[i].ptr, mem[i].length);
}
virtual ~CrashHandler() { SAFE_DELETE(m_ExHandler); }
void WriteMinidump() { m_ExHandler->WriteMinidump(); }
void WriteMinidump(void *data)
void CreateCrashHandlingServer()
{
m_ExHandler->WriteMinidumpForException((EXCEPTION_POINTERS *)data);
RDCLOG("Creating crash-handling server");
PROCESS_INFORMATION pi;
STARTUPINFOW si;
RDCEraseEl(pi);
RDCEraseEl(si);
HANDLE waitEvent = CreateEventA(NULL, TRUE, FALSE, "RENDERDOC_CRASHHANDLE");
wchar_t radpath[MAX_PATH] = {0};
GetModuleFileNameW(GetModuleHandleA("renderdoc.dll"), radpath, MAX_PATH - 1);
wchar_t *slash = wcsrchr(radpath, L'\\');
if(slash)
{
*slash = 0;
}
else
{
slash = wcsrchr(radpath, L'/');
if(slash)
*slash = 0;
else
{
radpath[0] = L'.';
radpath[1] = 0;
}
}
wstring cmdline = L"\"";
cmdline += radpath;
cmdline += L"/renderdoccmd.exe\" crashhandle";
wchar_t *paramsAlloc = new wchar_t[512];
wcscpy_s(paramsAlloc, 511, cmdline.c_str());
CreateProcessW(NULL, paramsAlloc, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
WaitForSingleObject(waitEvent, 2000);
CloseHandle(waitEvent);
}
virtual ~CrashHandler() { SAFE_DELETE(m_ExHandler); }
void RegisterMemoryRegion(void *mem, size_t size) { m_ExHandler->RegisterAppMemory(mem, size); }
void UnregisterMemoryRegion(void *mem) { m_ExHandler->UnregisterAppMemory(mem); }
private: