Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crash uploading option for breakpad crashes #403

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Main/include/GameConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ DefineEnum(GameConfigKeys,
GameplaySettingsDialogLastTab,
TransferScoresOnChartUpdate,

ShowCrashUploadPrompt,

// Gameplay options
GaugeType,
MirrorChart,
Expand Down
60 changes: 59 additions & 1 deletion Main/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,62 @@ void Application::m_InitDiscord()
Discord_Initialize(DISCORD_APPLICATION_ID, &dhe, 1, nullptr);
}

#ifdef _WIN32
#ifdef CRASHDUMP
bool g_HandleCrash(
const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS*,
MDRawAssertionInfo*,
bool succeeded)
{
if (!g_gameConfig.GetBool(GameConfigKeys::ShowCrashUploadPrompt))
return false;
if (!succeeded)
return false;
bool res = g_gameWindow->ShowYesNoMessage("Report USC Crash?", "USC has crashed. Would you like to upload the crash dump?");

if (!res) {
g_application->Shutdown();
return true;
}
std::wstring asciiPath(dump_path);
std::wstring asciiId(minidump_id);
String path = String(asciiPath.begin(), asciiPath.end()) + "\\"
+ String(asciiId.begin(), asciiId.end()) + ".dmp";

cpr::Response resp = cpr::Post(
cpr::Url{ "http://uscdmp.stackchk.fail/symbolify" },
//cpr::Url{ "http://192.168.65.128:1338/" },
cpr::Multipart{
#ifdef GIT_COMMIT
{"commit", GIT_COMMIT},
#endif
{"ingame", "true"},
{"file", cpr::File{ path }}
});

if (resp.status_code < 400)
{
for (char c : resp.text)
{
if (!((c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')))
{
g_application->Shutdown();
return true;
}
}
Path::OpenInBrowser("http://uscdmp.stackchk.fail/"+resp.text);
}
g_application->Shutdown();
return true;
}
#endif
#endif

bool Application::m_Init()
{
ProfilerScope $("Application Setup");
Expand Down Expand Up @@ -649,7 +705,7 @@ bool Application::m_Init()
auto handler = new google_breakpad::ExceptionHandler(
L".\\crash_dumps",
NULL,
NULL,
g_HandleCrash,
NULL,
google_breakpad::ExceptionHandler::HANDLER_ALL,
MiniDumpNormal,
Expand Down Expand Up @@ -882,6 +938,8 @@ bool Application::m_Init()

return true;
}


void Application::m_MainLoop()
{
Timer appTimer;
Expand Down
2 changes: 2 additions & 0 deletions Main/src/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void GameConfig::InitDefaults()
Set(GameConfigKeys::AutoResetSettings, false);
Set(GameConfigKeys::AutoResetToSpeed, 400.0f);
Set(GameConfigKeys::SlamThicknessMultiplier, 1.0f);

Set(GameConfigKeys::ShowCrashUploadPrompt, true);

Set(GameConfigKeys::SettingsTreesOpen, 1);

Expand Down
1 change: 1 addition & 0 deletions Main/src/SettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ class SettingsScreen_Impl : public SettingsScreen
ToggleSetting(GameConfigKeys::MuteUnfocused, "Mute the game when unfocused");
ToggleSetting(GameConfigKeys::CheckForUpdates, "Check for updates on startup");
ToggleSetting(GameConfigKeys::OnlyRelease, "Only check for new release versions");
ToggleSetting(GameConfigKeys::ShowCrashUploadPrompt, "Ask to upload crash dumps on crash");

EnumSetting<Logger::Enum_Severity>(GameConfigKeys::LogLevel, "Logging level");

Expand Down
2 changes: 2 additions & 0 deletions Shared/include/Shared/Path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Path
static bool CopyDir(String srcFolder, String dstFolder);
// Go to specified path using the system default file browser
static bool ShowInFileBrowser(const String& path);
// Go to specified url using the system default web browser
static void OpenInBrowser(const String& url);
// Open external program with specified parameters (used to open charts in editor)
static bool Run(const String& programPath, const String& parameters);

Expand Down
6 changes: 5 additions & 1 deletion Shared/src/Unix/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ Vector<String> Path::GetSubDirs(const String& path)
closedir(dir);
return ret;
}
void Path::OpenInBrowser(const String& path)
{
Log("Path::OpenInBrowser function not implemented yet", Logger::Severity::Error);
}
bool Path::ShowInFileBrowser(const String& path)
{
Log("Path::ShowInFileBrowser function not implemented yet", Logger::Severity::Error);
Expand All @@ -190,4 +194,4 @@ bool Path::Run(const String& programPath, const String& parameters)
{
Log("Path::Run function not implemented yet", Logger::Severity::Error);
return false;
}
}
6 changes: 6 additions & 0 deletions Shared/src/Windows/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ Vector<String> Path::GetSubDirs(const String& path)
return res;
}

void Path::OpenInBrowser(const String& path)
{
WString wpath = Utility::ConvertToWString(path);
ShellExecuteW(NULL, L"open", *wpath, NULL, NULL, SW_SHOWNORMAL);
}

bool Path::ShowInFileBrowser(const String& path)
{
WString wpath = Utility::ConvertToWString(path);
Expand Down