mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #8214 from janisozaur/more-backtrace-info
Add compressed sv6 to backtrace.io uploads
This commit is contained in:
commit
eeaca6112e
|
@ -1341,6 +1341,18 @@ static int32_t cc_abort(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t cc_dereference(
|
||||||
|
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc)
|
||||||
|
{
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wnull-dereference"
|
||||||
|
// Dereference a nullptr to induce a crash to be caught by crash handler, on supported platforms
|
||||||
|
uint8_t* myptr = nullptr;
|
||||||
|
*myptr = 42;
|
||||||
|
return 0;
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t cc_terminate(
|
static int32_t cc_terminate(
|
||||||
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc)
|
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc)
|
||||||
{
|
{
|
||||||
|
@ -1413,6 +1425,7 @@ static constexpr const console_command console_command_table[] = {
|
||||||
{ "clear", cc_clear, "Clears the console.", "clear" },
|
{ "clear", cc_clear, "Clears the console.", "clear" },
|
||||||
{ "close", cc_close, "Closes the console.", "close" },
|
{ "close", cc_close, "Closes the console.", "close" },
|
||||||
{ "date", cc_for_date, "Sets the date to a given date.", "Format <year>[ <month>[ <day>]]." },
|
{ "date", cc_for_date, "Sets the date to a given date.", "Format <year>[ <month>[ <day>]]." },
|
||||||
|
{ "dereference", cc_dereference, "Dereferences a nullptr, for testing purposes only", "dereference" },
|
||||||
{ "echo", cc_echo, "Echoes the text to the console.", "echo <text>" },
|
{ "echo", cc_echo, "Echoes the text to the console.", "echo <text>" },
|
||||||
{ "exit", cc_close, "Closes the console.", "exit" },
|
{ "exit", cc_close, "Closes the console.", "exit" },
|
||||||
{ "get", cc_get, "Gets the value of the specified variable.", "get <variable>" },
|
{ "get", cc_get, "Gets the value of the specified variable.", "get <variable>" },
|
||||||
|
|
|
@ -48,12 +48,15 @@ const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE);
|
||||||
// so just hope the file name with '.gz' suffix is enough.
|
// so just hope the file name with '.gz' suffix is enough.
|
||||||
// For docs on uplading to backtrace.io check
|
// For docs on uplading to backtrace.io check
|
||||||
// https://documentation.backtrace.io/product_integration_minidump_breakpad/
|
// https://documentation.backtrace.io/product_integration_minidump_breakpad/
|
||||||
static bool UploadMinidump(const wchar_t* dumpPath, int& error, std::wstring& response)
|
static bool UploadMinidump(const std::map<std::wstring, std::wstring>& files, int& error, std::wstring& response)
|
||||||
{
|
{
|
||||||
|
for (auto file : files)
|
||||||
|
{
|
||||||
|
wprintf(L"files[%s] = %s\n", file.first.c_str(), file.second.c_str());
|
||||||
|
}
|
||||||
std::wstring url(L"https://openrct2.sp.backtrace.io:6098/"
|
std::wstring url(L"https://openrct2.sp.backtrace.io:6098/"
|
||||||
L"post?format=minidump&token=f9c5e640d498f15dbe902eab3e822e472af9270d5b0cbdc269cee65a926bf306");
|
L"post?format=minidump&token=f9c5e640d498f15dbe902eab3e822e472af9270d5b0cbdc269cee65a926bf306");
|
||||||
std::map<std::wstring, std::wstring> parameters;
|
std::map<std::wstring, std::wstring> parameters;
|
||||||
std::map<std::wstring, std::wstring> files;
|
|
||||||
parameters[L"product_name"] = L"openrct2";
|
parameters[L"product_name"] = L"openrct2";
|
||||||
// In case of releases this can be empty
|
// In case of releases this can be empty
|
||||||
if (wcslen(_wszCommitSha1Short) > 0)
|
if (wcslen(_wszCommitSha1Short) > 0)
|
||||||
|
@ -64,7 +67,6 @@ static bool UploadMinidump(const wchar_t* dumpPath, int& error, std::wstring& re
|
||||||
{
|
{
|
||||||
parameters[L"commit"] = String::ToUtf16(gVersionInfoFull);
|
parameters[L"commit"] = String::ToUtf16(gVersionInfoFull);
|
||||||
}
|
}
|
||||||
files[L"upload_file_minidump"] = dumpPath;
|
|
||||||
int timeout = 10000;
|
int timeout = 10000;
|
||||||
bool success = google_breakpad::HTTPUpload::SendRequest(url, parameters, files, &timeout, &response, &error);
|
bool success = google_breakpad::HTTPUpload::SendRequest(url, parameters, files, &timeout, &response, &error);
|
||||||
wprintf(L"Success = %d, error = %d, response = %s\n", success, error, response.c_str());
|
wprintf(L"Success = %d, error = %d, response = %s\n", success, error, response.c_str());
|
||||||
|
@ -88,12 +90,15 @@ static bool OnCrash(
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::wstring, std::wstring> uploadFiles;
|
||||||
|
|
||||||
// Get filenames
|
// Get filenames
|
||||||
wchar_t dumpFilePath[MAX_PATH];
|
wchar_t dumpFilePath[MAX_PATH];
|
||||||
wchar_t saveFilePath[MAX_PATH];
|
wchar_t saveFilePath[MAX_PATH];
|
||||||
|
wchar_t saveFilePathGZIP[MAX_PATH];
|
||||||
swprintf_s(dumpFilePath, sizeof(dumpFilePath), L"%s\\%s.dmp", dumpPath, miniDumpId);
|
swprintf_s(dumpFilePath, sizeof(dumpFilePath), L"%s\\%s.dmp", dumpPath, miniDumpId);
|
||||||
swprintf_s(saveFilePath, sizeof(saveFilePath), L"%s\\%s.sv6", dumpPath, miniDumpId);
|
swprintf_s(saveFilePath, sizeof(saveFilePath), L"%s\\%s.sv6", dumpPath, miniDumpId);
|
||||||
const wchar_t* minidumpToUpload = dumpFilePath;
|
swprintf_s(saveFilePathGZIP, sizeof(saveFilePathGZIP), L"%s\\%s.sv6.gz", dumpPath, miniDumpId);
|
||||||
|
|
||||||
wchar_t dumpFilePathNew[MAX_PATH];
|
wchar_t dumpFilePathNew[MAX_PATH];
|
||||||
swprintf_s(
|
swprintf_s(
|
||||||
|
@ -103,28 +108,32 @@ static bool OnCrash(
|
||||||
wchar_t dumpFilePathGZIP[MAX_PATH];
|
wchar_t dumpFilePathGZIP[MAX_PATH];
|
||||||
swprintf_s(dumpFilePathGZIP, sizeof(dumpFilePathGZIP), L"%s.gz", dumpFilePathNew);
|
swprintf_s(dumpFilePathGZIP, sizeof(dumpFilePathGZIP), L"%s.gz", dumpFilePathNew);
|
||||||
|
|
||||||
FILE* input = _wfopen(dumpFilePath, L"rb");
|
// Compress the dump
|
||||||
FILE* dest = _wfopen(dumpFilePathGZIP, L"wb");
|
|
||||||
|
|
||||||
if (util_gzip_compress(input, dest))
|
|
||||||
{
|
{
|
||||||
// TODO: enable upload of gzip-compressed dumps once supported on
|
FILE* input = _wfopen(dumpFilePath, L"rb");
|
||||||
// backtrace.io (uncomment the line below). For now leave compression
|
FILE* dest = _wfopen(dumpFilePathGZIP, L"wb");
|
||||||
// on, as GitHub will accept .gz files, even though it does not
|
|
||||||
// advertise it officially.
|
|
||||||
|
|
||||||
/*
|
if (util_gzip_compress(input, dest))
|
||||||
minidumpToUpload = dumpFilePathGZIP;
|
{
|
||||||
*/
|
// TODO: enable upload of gzip-compressed dumps once supported on
|
||||||
|
// backtrace.io (uncomment the line below). For now leave compression
|
||||||
|
// on, as GitHub will accept .gz files, even though it does not
|
||||||
|
// advertise it officially.
|
||||||
|
|
||||||
|
/*
|
||||||
|
uploadFiles[L"upload_file_minidump"] = dumpFilePathGZIP;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
fclose(input);
|
||||||
|
fclose(dest);
|
||||||
}
|
}
|
||||||
fclose(input);
|
|
||||||
fclose(dest);
|
|
||||||
|
|
||||||
// Try to rename the files
|
// Try to rename the files
|
||||||
if (_wrename(dumpFilePath, dumpFilePathNew) == 0)
|
if (_wrename(dumpFilePath, dumpFilePathNew) == 0)
|
||||||
{
|
{
|
||||||
std::wcscpy(dumpFilePath, dumpFilePathNew);
|
std::wcscpy(dumpFilePath, dumpFilePathNew);
|
||||||
}
|
}
|
||||||
|
uploadFiles[L"upload_file_minidump"] = dumpFilePath;
|
||||||
|
|
||||||
// Compress to gzip-compatible stream
|
// Compress to gzip-compatible stream
|
||||||
|
|
||||||
|
@ -149,11 +158,29 @@ static bool OnCrash(
|
||||||
}
|
}
|
||||||
free(saveFilePathUTF8);
|
free(saveFilePathUTF8);
|
||||||
|
|
||||||
|
// Compress the save
|
||||||
|
if (savedGameDumped)
|
||||||
|
{
|
||||||
|
FILE* input = _wfopen(saveFilePath, L"rb");
|
||||||
|
FILE* dest = _wfopen(saveFilePathGZIP, L"wb");
|
||||||
|
|
||||||
|
if (util_gzip_compress(input, dest))
|
||||||
|
{
|
||||||
|
uploadFiles[L"attachment_park.sv6.gz"] = saveFilePathGZIP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uploadFiles[L"attachment_park.sv6"] = saveFilePath;
|
||||||
|
}
|
||||||
|
fclose(input);
|
||||||
|
fclose(dest);
|
||||||
|
}
|
||||||
|
|
||||||
if (gOpenRCT2SilentBreakpad)
|
if (gOpenRCT2SilentBreakpad)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
std::wstring response;
|
std::wstring response;
|
||||||
UploadMinidump(minidumpToUpload, error, response);
|
UploadMinidump(uploadFiles, error, response);
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +198,7 @@ static bool OnCrash(
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
std::wstring response;
|
std::wstring response;
|
||||||
bool ok = UploadMinidump(minidumpToUpload, error, response);
|
bool ok = UploadMinidump(uploadFiles, error, response);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
const wchar_t* MessageFormat2 = L"There was a problem while uploading the dump. Please upload it manually to "
|
const wchar_t* MessageFormat2 = L"There was a problem while uploading the dump. Please upload it manually to "
|
||||||
|
|
Loading…
Reference in New Issue