From ebb30e0c3731ee4acc86de63c4b32a6be9e4de4f Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Mon, 11 Dec 2017 20:13:35 +0200 Subject: Revert "Collect crash dumps also for vectored exceptions" This reverts commit b75e3c12318267be1589cee5e13a9fc89b0097b1. --- src/main.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index dbf41afb..7f1f199e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,12 +123,6 @@ bool bootstrap() static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs) { - if ((exceptionPtrs->ExceptionRecord->ExceptionCode < 0x80000000) // non-critical - || (exceptionPtrs->ExceptionRecord->ExceptionCode == 0xe06d7363)) { // cpp exception - // don't report non-critical exceptions - return EXCEPTION_CONTINUE_SEARCH; - } - const std::wstring& dumpPath = OrganizerCore::crashDumpsPath(); int dumpRes = CreateMiniDump(exceptionPtrs, OrganizerCore::getGlobalCrashDumpsType(), dumpPath.c_str()); @@ -532,7 +526,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, int main(int argc, char *argv[]) { - AddVectoredExceptionHandler(0, MyUnhandledExceptionFilter); + SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); MOApplication application(argc, argv); QStringList arguments = application.arguments(); -- cgit v1.3.1 From 2c69f9c407ec803c3c99713fe591717ebcee191b Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Mon, 11 Dec 2017 20:23:42 +0200 Subject: call previous unhandled exception filter --- src/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 7f1f199e..eed4dfd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,20 +120,22 @@ bool bootstrap() return true; } +LPTOP_LEVEL_EXCEPTION_FILTER prevUnhandledExceptionFilter = nullptr; static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs) { const std::wstring& dumpPath = OrganizerCore::crashDumpsPath(); int dumpRes = CreateMiniDump(exceptionPtrs, OrganizerCore::getGlobalCrashDumpsType(), dumpPath.c_str()); - if (!dumpRes) { + if (!dumpRes) qCritical("ModOrganizer has crashed, crash dump created."); - return EXCEPTION_EXECUTE_HANDLER; - } - else { + else qCritical("ModOrganizer has crashed, CreateMiniDump failed (%d, error %lu).", dumpRes, GetLastError()); + + if (prevUnhandledExceptionFilter) + return prevUnhandledExceptionFilter(exceptionPtrs); + else return EXCEPTION_CONTINUE_SEARCH; - } } static bool HaveWriteAccess(const std::wstring &path) @@ -526,7 +528,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, int main(int argc, char *argv[]) { - SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); + prevUnhandledExceptionFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); MOApplication application(argc, argv); QStringList arguments = application.arguments(); -- cgit v1.3.1 From 240900de39aaf1562332ed88708b4b128703ad0e Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Tue, 12 Dec 2017 23:22:04 +0200 Subject: Move crash dumps to instance-dependant data folder --- src/main.cpp | 5 +++-- src/organizercore.cpp | 9 ++++----- src/settings.cpp | 12 ++++++++++++ src/settings.h | 2 ++ src/settingsdialog.ui | 9 +++++---- src/shared/appconfig.inc | 1 + 6 files changed, 27 insertions(+), 11 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index eed4dfd3..b4faf570 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -528,8 +528,6 @@ int runApplication(MOApplication &application, SingleInstance &instance, int main(int argc, char *argv[]) { - prevUnhandledExceptionFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); - MOApplication application(argc, argv); QStringList arguments = application.arguments(); @@ -586,6 +584,9 @@ int main(int argc, char *argv[]) } application.setProperty("dataPath", dataPath); + // initialize dump collection only after "dataPath" since the crashes are stored under it + prevUnhandledExceptionFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); + LogBuffer::init(100, QtDebugMsg, qApp->property("dataPath").toString() + "/logs/mo_interface.log"); QString splash = dataPath + "/splash.png"; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index bc0578b3..deb0b718 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -670,11 +670,10 @@ void OrganizerCore::setGlobalCrashDumpsType(int crashDumpsType) { //static std::wstring OrganizerCore::crashDumpsPath() { - wchar_t appDataLocal[MAX_PATH]{ 0 }; - ::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataLocal); - std::wstring dumpPath{ appDataLocal }; - dumpPath += L"\\modorganizer\\crashDumps"; - return dumpPath; + return ( + qApp->property("dataPath").toString() + "/" + + QString::fromStdWString(AppConfig::dumpsDir()) + ).toStdWString(); } void OrganizerCore::setCurrentProfile(const QString &profileName) diff --git a/src/settings.cpp b/src/settings.cpp index 05a62591..b2fc8939 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -24,6 +24,7 @@ along with Mod Organizer. If not, see . #include "settingsdialog.h" #include "versioninfo.h" #include "appconfig.h" +#include "organizercore.h" #include #include #include @@ -48,6 +49,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include // for Qt::UserRole, etc #include // for qDebug, qWarning @@ -755,10 +757,20 @@ Settings::DiagnosticsTab::DiagnosticsTab(Settings *m_parent, SettingsDialog &m_d , m_logLevelBox(m_dialog.findChild("logLevelBox")) , m_dumpsTypeBox(m_dialog.findChild("dumpsTypeBox")) , m_dumpsMaxEdit(m_dialog.findChild("dumpsMaxEdit")) + , m_diagnosticsExplainedLabel(m_dialog.findChild("diagnosticsExplainedLabel")) { m_logLevelBox->setCurrentIndex(m_parent->logLevel()); m_dumpsTypeBox->setCurrentIndex(m_parent->crashDumpsType()); m_dumpsMaxEdit->setValue(m_parent->crashDumpsMax()); + QString logsPath = qApp->property("dataPath").toString() + + "/" + QString::fromStdWString(AppConfig::logPath()); + m_diagnosticsExplainedLabel->setText( + m_diagnosticsExplainedLabel->text() + .replace("LOGS_FULL_PATH", logsPath) + .replace("LOGS_DIR", QString::fromStdWString(AppConfig::logPath())) + .replace("DUMPS_FULL_PATH", QString::fromStdWString(OrganizerCore::crashDumpsPath())) + .replace("DUMPS_DIR", QString::fromStdWString(AppConfig::dumpsDir())) + ); } void Settings::DiagnosticsTab::update() diff --git a/src/settings.h b/src/settings.h index 9ee29ba3..ae38223f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,6 +41,7 @@ class QLineEdit; class QSpinBox; class QListWidget; class QWidget; +class QLabel; struct ServerInfo; @@ -414,6 +415,7 @@ private: QComboBox *m_logLevelBox; QComboBox *m_dumpsTypeBox; QSpinBox *m_dumpsMaxEdit; + QLabel *m_diagnosticsExplainedLabel; }; /** Display/store the configuration in the 'nexus' tab of the settings dialogue */ diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 6d462cfa..7a902748 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -483,12 +483,13 @@ If you use pre-releases, never contact me directly by e-mail or via private mess - + - Dumps are stored in <a href="%LOCALAPPDATA%\modorganizer\crashDumps">%LOCALAPPDATA%\modorganizer\crashDumps</a>. - Sending such dumps to the developers can help solve crashes caused by MO. - It is recommended to compress the dumps before sending, especially on the larger settings. + Logs and crash dumps are stored under your current instance in the <a href="LOGS_FULL_PATH">LOGS_DIR</a> + and <a href="DUMPS_FULL_PATH">DUMPS_DIR</a> folders. + Sending logs and/or crash dumps to the developers can help investigate issues. + It is recommended to compress large log and dmp files before sending. diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc index e98757d3..e572a32b 100644 --- a/src/shared/appconfig.inc +++ b/src/shared/appconfig.inc @@ -8,6 +8,7 @@ APPPARAM(std::wstring, stylesheetsPath, L"stylesheets") APPPARAM(std::wstring, cachePath, L"webcache") APPPARAM(std::wstring, tutorialsPath, L"tutorials") APPPARAM(std::wstring, logPath, L"logs") +APPPARAM(std::wstring, dumpsDir, L"crashDumps") APPPARAM(std::wstring, profileTweakIni, L"profile_tweaks.ini") APPPARAM(std::wstring, logFileName, L"ModOrganizer.log") APPPARAM(std::wstring, iniFileName, L"ModOrganizer.ini") -- cgit v1.3.1