Skip to content

Commit

Permalink
Moved crash dumps to the user data directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Apr 1, 2016
1 parent 0dc18b6 commit 29f1c15
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 62 deletions.
86 changes: 44 additions & 42 deletions Infrastructure/breakpad.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@

#include "infrastructure/breakpad.h"
#include "breakpad\exception_handler.h"
#include "infrastructure/format.h"

// Delegate back to breakpad
static bool HandleCrashCallbackDelegate(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded) {
auto breakpad = (Breakpad*)context;

auto msg = fmt::format(L"Sorry! TemplePlus seems to have crashed. A crash report was written to {}\\{}.dmp.\n\n"
L"If you want to report this issue, please make sure to attach this file.",
dump_path,
minidump_id);

// Now starts the tedious work of reporting on this crash, heh.
MessageBox(NULL, msg.c_str(), L"TemplePlus Crashed - Oops!", MB_OK);

return false;
}

Breakpad::Breakpad()
{
using google_breakpad::ExceptionHandler;

mHandler.reset(new ExceptionHandler(
L".",
nullptr,
HandleCrashCallbackDelegate,
this,
ExceptionHandler::HANDLER_ALL
));

}

Breakpad::~Breakpad()
{
}

#include "infrastructure/breakpad.h"
#include "breakpad\exception_handler.h"
#include "infrastructure/format.h"

// Delegate back to breakpad
static bool HandleCrashCallbackDelegate(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded) {
auto breakpad = (Breakpad*)context;

auto msg = fmt::format(L"Sorry! TemplePlus seems to have crashed. A crash report was written to {}\\{}.dmp.\n\n"
L"If you want to report this issue, please make sure to attach this file.",
dump_path,
minidump_id);

// Now starts the tedious work of reporting on this crash, heh.
MessageBox(NULL, msg.c_str(), L"TemplePlus Crashed - Oops!", MB_OK);

return false;
}

Breakpad::Breakpad(const std::wstring &crashDumpFolder)
{
using google_breakpad::ExceptionHandler;

CreateDirectory(crashDumpFolder.c_str(), nullptr);

mHandler.reset(new ExceptionHandler(
crashDumpFolder.c_str(),
nullptr,
HandleCrashCallbackDelegate,
this,
ExceptionHandler::HANDLER_ALL
));

}

Breakpad::~Breakpad()
{
}
37 changes: 19 additions & 18 deletions Infrastructure/include/infrastructure/breakpad.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#pragma once

namespace google_breakpad {
class ExceptionHandler;
}

#include <memory>

/*
Abstracts the interface to Google breakpad
*/
class Breakpad {
public:
Breakpad();
~Breakpad();
private:
std::unique_ptr<google_breakpad::ExceptionHandler> mHandler;
};
#pragma once

namespace google_breakpad {
class ExceptionHandler;
}

#include <memory>
#include <string>

/*
Abstracts the interface to Google breakpad
*/
class Breakpad {
public:
Breakpad(const std::wstring &crashDumpFolder);
~Breakpad();
private:
std::unique_ptr<google_breakpad::ExceptionHandler> mHandler;
};
5 changes: 3 additions & 2 deletions TemplePlus/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
auto& dll = temple::Dll::GetInstance();
dll.ReserveMemoryRange();

Breakpad breakpad;

// Cannot get known folders without initializing COM sadly
ComInitializer comInitializer;

Breakpad breakpad(GetUserDataFolder());

SetIniPath();

config.Load();
Expand Down

0 comments on commit 29f1c15

Please sign in to comment.