From 7f0fe603be200c09c74cf9cc295a972f3c3dbdfd Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 21 Jun 2016 14:49:44 +0200 Subject: Change minidump filename format to include version and date The new format is VERSION_DATE_UUID.dmp. Included the diff for the Breakpad modification. Test-Information: Tested by adding crashing code and verified the filename of the created minidump file on Windows 8 with VS 2013. Change-Id: I963e7913fadf4787742439da590e12e121ef3435 diff --git a/3rdParty/Breakpad/01_breakpad_filename_prefix.diff b/3rdParty/Breakpad/01_breakpad_filename_prefix.diff new file mode 100644 index 0000000..b63180d --- /dev/null +++ b/3rdParty/Breakpad/01_breakpad_filename_prefix.diff @@ -0,0 +1,66 @@ +diff --git a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc +index 6e5b724..272ca5f 100644 +--- a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc ++++ b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc +@@ -124,6 +124,7 @@ void ExceptionHandler::Initialize(const wstring& dump_path, + callback_ = callback; + callback_context_ = callback_context; + dump_path_c_ = NULL; ++ dump_filename_prefix_c_ = NULL; + next_minidump_id_c_ = NULL; + next_minidump_path_c_ = NULL; + dbghelp_module_ = NULL; +@@ -217,6 +218,7 @@ void ExceptionHandler::Initialize(const wstring& dump_path, + + // set_dump_path calls UpdateNextID. This sets up all of the path and id + // strings, and their equivalent c_str pointers. ++ set_dump_filename_prefix(wstring()); + set_dump_path(dump_path); + } + +@@ -914,8 +916,8 @@ void ExceptionHandler::UpdateNextID() { + next_minidump_id_c_ = next_minidump_id_.c_str(); + + wchar_t minidump_path[MAX_PATH]; +- swprintf(minidump_path, MAX_PATH, L"%s\\%s.dmp", +- dump_path_c_, next_minidump_id_c_); ++ swprintf(minidump_path, MAX_PATH, L"%s\\%s%s.dmp", ++ dump_path_c_, dump_filename_prefix_c_, next_minidump_id_c_); + + // remove when VC++7.1 is no longer supported + minidump_path[MAX_PATH - 1] = L'\0'; +diff --git a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h +index 09f5177..6f59348 100644 +--- a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h ++++ b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h +@@ -188,6 +188,12 @@ class ExceptionHandler { + UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. + } + ++ void set_dump_filename_prefix(const wstring& dump_prefix) { ++ dump_filename_prefix_ = dump_prefix; ++ dump_filename_prefix_c_ = dump_filename_prefix_.c_str(); ++ UpdateNextID(); ++ } ++ + // Requests that a previously reported crash be uploaded. + bool RequestUpload(DWORD crash_id); + +@@ -313,6 +319,9 @@ class ExceptionHandler { + // argument to the constructor, or set_dump_path. + wstring dump_path_; + ++ // The filename prefix used for the minidump files. ++ wstring dump_filename_prefix_; ++ + // The basename of the next minidump to be written, without the extension. + wstring next_minidump_id_; + +@@ -327,6 +336,7 @@ class ExceptionHandler { + // should be equivalent to the lifetimes of the associated wstring, provided + // that the wstrings are not altered. + const wchar_t* dump_path_c_; ++ const wchar_t* dump_filename_prefix_c_; + const wchar_t* next_minidump_id_c_; + const wchar_t* next_minidump_path_c_; + diff --git a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc index 6e5b724..272ca5f 100644 --- a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc +++ b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.cc @@ -124,6 +124,7 @@ void ExceptionHandler::Initialize(const wstring& dump_path, callback_ = callback; callback_context_ = callback_context; dump_path_c_ = NULL; + dump_filename_prefix_c_ = NULL; next_minidump_id_c_ = NULL; next_minidump_path_c_ = NULL; dbghelp_module_ = NULL; @@ -217,6 +218,7 @@ void ExceptionHandler::Initialize(const wstring& dump_path, // set_dump_path calls UpdateNextID. This sets up all of the path and id // strings, and their equivalent c_str pointers. + set_dump_filename_prefix(wstring()); set_dump_path(dump_path); } @@ -914,8 +916,8 @@ void ExceptionHandler::UpdateNextID() { next_minidump_id_c_ = next_minidump_id_.c_str(); wchar_t minidump_path[MAX_PATH]; - swprintf(minidump_path, MAX_PATH, L"%s\\%s.dmp", - dump_path_c_, next_minidump_id_c_); + swprintf(minidump_path, MAX_PATH, L"%s\\%s%s.dmp", + dump_path_c_, dump_filename_prefix_c_, next_minidump_id_c_); // remove when VC++7.1 is no longer supported minidump_path[MAX_PATH - 1] = L'\0'; diff --git a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h index 09f5177..6f59348 100644 --- a/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h +++ b/3rdParty/Breakpad/src/client/windows/handler/exception_handler.h @@ -188,6 +188,12 @@ class ExceptionHandler { UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. } + void set_dump_filename_prefix(const wstring& dump_prefix) { + dump_filename_prefix_ = dump_prefix; + dump_filename_prefix_c_ = dump_filename_prefix_.c_str(); + UpdateNextID(); + } + // Requests that a previously reported crash be uploaded. bool RequestUpload(DWORD crash_id); @@ -313,6 +319,9 @@ class ExceptionHandler { // argument to the constructor, or set_dump_path. wstring dump_path_; + // The filename prefix used for the minidump files. + wstring dump_filename_prefix_; + // The basename of the next minidump to be written, without the extension. wstring next_minidump_id_; @@ -327,6 +336,7 @@ class ExceptionHandler { // should be equivalent to the lifetimes of the associated wstring, provided // that the wstrings are not altered. const wchar_t* dump_path_c_; + const wchar_t* dump_filename_prefix_c_; const wchar_t* next_minidump_id_c_; const wchar_t* next_minidump_path_c_; diff --git a/SwifTools/CrashReporter.cpp b/SwifTools/CrashReporter.cpp index 15b5cd0..bf637c8 100644 --- a/SwifTools/CrashReporter.cpp +++ b/SwifTools/CrashReporter.cpp @@ -5,10 +5,11 @@ */ #include -#include #include #include +#include + #if defined(HAVE_BREAKPAD) #pragma GCC diagnostic ignored "-Wold-style-cast" @@ -38,7 +39,7 @@ struct CrashReporter::Private { std::shared_ptr handler; }; -CrashReporter::CrashReporter(const boost::filesystem::path& path) { +CrashReporter::CrashReporter(const boost::filesystem::path& path, const std::string& dumpPrefix) { // Create the path that will contain the crash dumps if (!boost::filesystem::exists(path)) { try { @@ -61,6 +62,7 @@ CrashReporter::CrashReporter(const boost::filesystem::path& path) { handleDump, (void*) 0, google_breakpad::ExceptionHandler::HANDLER_ALL)); + p->handler->set_dump_filename_prefix(std::wstring(dumpPrefix.begin(), dumpPrefix.end())); // Turning it off for Mac, because it doesn't really help us //#elif defined(SWIFTEN_PLATFORM_MACOSX) // p->handler = std::make_shared(pathToString(path), (google_breakpad::ExceptionHandler::FilterCallback) 0, handleDump, (void*) 0, true, (const char*) 0); @@ -73,7 +75,7 @@ CrashReporter::CrashReporter(const boost::filesystem::path& path) { // Dummy implementation namespace Swift { - CrashReporter::CrashReporter(const boost::filesystem::path&) {} + CrashReporter::CrashReporter(const boost::filesystem::path&, const std::string&) {} } #endif diff --git a/SwifTools/CrashReporter.h b/SwifTools/CrashReporter.h index c80b1a2..1efa801 100644 --- a/SwifTools/CrashReporter.h +++ b/SwifTools/CrashReporter.h @@ -14,7 +14,7 @@ namespace Swift { class CrashReporter { public: - CrashReporter(const boost::filesystem::path& path); + CrashReporter(const boost::filesystem::path& path, const std::string& dumpPrefix); private: struct Private; diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp index dde1487..11f51f6 100644 --- a/Swift/QtUI/main.cpp +++ b/Swift/QtUI/main.cpp @@ -4,10 +4,13 @@ * See the COPYING file for more information. */ -#include - +#include #include +#include +#include +#include +#include #include #include #include @@ -35,7 +38,15 @@ int main(int argc, char* argv[]) { Swift::PlatformApplicationPathProvider applicationPathProvider(SWIFT_APPLICATION_NAME); - Swift::CrashReporter crashReporter(applicationPathProvider.getDataDir() / "crashes"); + // Set crash report prefix to include date and version. + std::stringstream prefix; + auto outputFacet = std::unique_ptr(new boost::gregorian::date_facet()); + outputFacet->format("%Y-%m-%d"); + prefix.imbue(std::locale(std::locale::classic(), outputFacet.get())); + + prefix << buildVersion << "_" << boost::gregorian::date(boost::gregorian::day_clock::local_day()) << "_"; + + Swift::CrashReporter crashReporter(applicationPathProvider.getDataDir() / "crashes", prefix.str()); #if QT_VERSION < 0x050000 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); -- cgit v0.10.2-6-g49f6