From 9146e4b8b8a83d12d02ca9ba6c25cf2a122d15ca Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 20 Feb 2022 22:34:00 +0100 Subject: [PATCH] First vversion of uploader. Only do so when user selected "always" send, as of now there is no way to ask the user for consent in case they selected "ask before sending". --- .../linux_crash_logger/linux_crash_logger.cpp | 105 +++++++++--------- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewerlinux.cpp | 26 +++-- indra/newview/viewer_manifest.py | 1 + 4 files changed, 70 insertions(+), 64 deletions(-) diff --git a/indra/linux_crash_logger/linux_crash_logger.cpp b/indra/linux_crash_logger/linux_crash_logger.cpp index 02744f1378..307acc955e 100644 --- a/indra/linux_crash_logger/linux_crash_logger.cpp +++ b/indra/linux_crash_logger/linux_crash_logger.cpp @@ -24,67 +24,66 @@ * $/LicenseInfo$ */ +#include +#include #include +/* Called via + execl( gCrashLogger.c_str(), gCrashLogger.c_str(), descriptor.path(), gVersion.c_str(), gBugsplatDB.c_str(), nullptr ); +*/ int main(int argc, char **argv) { - curl_global_init(CURL_GLOBAL_ALL); + std::cerr << "linux crash logger called: "; + for( int i = 1; i < argc; ++i ) + std::cerr << argv[i] << " "; - auto curl = curl_easy_init(); - if( curl) - { - auto form = curl_mime_init(curl); - - auto field = curl_mime_addpart(form); - curl_mime_name(field, "upload_file_minidump"); - curl_mime_filedata(field, "minidump.dmp"); + std::cerr << std::endl; - field = curl_mime_addpart(form); - curl_mime_name(field, "product"); - curl_mime_data(field, "Firestorm-Releasex64", CURL_ZERO_TERMINATED); - - field = curl_mime_addpart(form); - curl_mime_name(field, "version"); - curl_mime_data(field, "6.4.21.64531", CURL_ZERO_TERMINATED); - - curl_easy_setopt(curl, CURLOPT_URL, "https://fs_test.bugsplat.com/post/bp/crash/crashpad.php"); - curl_easy_setopt(curl, CURLOPT_MIMEPOST, form); - - auto res = curl_easy_perform(curl); - - if(res != CURLE_OK) - fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); - - curl_easy_cleanup(curl); - - curl_mime_free(form); - } - /* - - LL_INFOS() << "Starting crash reporter." << LL_ENDL; - - LLCrashLoggerLinux app; - app.parseCommandOptions(argc, argv); - - LLSD options = LLApp::instance()->getOptionData( - LLApp::PRIORITY_COMMAND_LINE); - //LLApp::PRIORITY_RUNTIME_OVERRIDE); - - - if (!(options.has("pid") && options.has("dumpdir"))) + if( argc < 4 ) { - LL_WARNS() << "Insufficient parameters to crash report." << LL_ENDL; + std::cerr << argv[0] << "Not enough arguments" << std::endl; + return 1; } - if (! app.init()) - { - LL_WARNS() << "Unable to initialize application." << LL_ENDL; - return 1; - } + std::string dmpFile{ argv[1] }; + std::string version{ argv[2] }; + std::string strDb{ argv[3] }; - app.frame(); - app.cleanup(); - LL_INFOS() << "Crash reporter finished normally." << LL_ENDL; - */ - return 0; + + std::string url{ "https://" }; + url += strDb; + url += ".bugsplat.com/post/bp/crash/crashpad.php"; + + curl_global_init(CURL_GLOBAL_ALL); + + auto curl = curl_easy_init(); + if( curl) + { + auto form = curl_mime_init(curl); + + auto field = curl_mime_addpart(form); + curl_mime_name(field, "upload_file_minidump"); + curl_mime_filedata(field, dmpFile.c_str() ); + + field = curl_mime_addpart(form); + curl_mime_name(field, "product"); + curl_mime_data(field, "Firestorm-Releasex64", CURL_ZERO_TERMINATED); + + field = curl_mime_addpart(form); + curl_mime_name(field, "version"); + curl_mime_data(field, version.c_str(), CURL_ZERO_TERMINATED); + + curl_easy_setopt(curl, CURLOPT_URL, url.c_str() ); + curl_easy_setopt(curl, CURLOPT_MIMEPOST, form); + + auto res = curl_easy_perform(curl); + + if(res != CURLE_OK) + std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl; + + curl_easy_cleanup(curl); + + curl_mime_free(form); + } + return 0; } diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index cc635e0522..1c850adf50 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2573,6 +2573,7 @@ if (NOT ENABLE_MEDIA_PLUGINS) #media_plugin_gstreamer010 media_plugin_libvlc llcommon + linux-crash-logger ) else (NOT ENABLE_MEDIA_PLUGINS) set(COPY_INPUT_DEPENDENCIES @@ -2582,6 +2583,7 @@ else (NOT ENABLE_MEDIA_PLUGINS) media_plugin_cef #media_plugin_gstreamer010 llcommon + linux-crash-logger ) endif (NOT ENABLE_MEDIA_PLUGINS) diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index a43338b84b..8a802183d5 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -49,6 +49,7 @@ #include "breakpad/client/linux/handler/exception_handler.h" #include "breakpad/common/linux/http_upload.h" #include "lldir.h" +#include "../llcrashlogger/llcrashlogger.h" #endif #include "fsversionvalues.h" @@ -140,20 +141,21 @@ LLAppViewerLinux::~LLAppViewerLinux() } #if LL_SEND_CRASH_REPORTS +std::string gCrashLogger; +std::string gVersion; +std::string gBugsplatDB; + static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) { - printf("Dump path: %s\n", descriptor.path() ); + if( fork() == 0 ) + execl( gCrashLogger.c_str(), gCrashLogger.c_str(), descriptor.path(), gVersion.c_str(), gBugsplatDB.c_str(), nullptr ); return succeeded; } -#endif -#if LL_SEND_CRASH_REPORTS void setupBreadpad() { std::string build_data_fname(gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "build_data.json")); - - std::string strVersion; - std::string strDB; + gCrashLogger = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "linux-crash-logger.bin"); llifstream inf(build_data_fname.c_str()); if(!inf.is_open()) @@ -178,12 +180,13 @@ void setupBreadpad() << "'" << LL_ENDL; return; } - strVersion = STRINGIZE( + gVersion = STRINGIZE( LL_VIEWER_VERSION_MAJOR << '.' << LL_VIEWER_VERSION_MINOR << '.' << LL_VIEWER_VERSION_PATCH << '.' << LL_VIEWER_VERSION_BUILD); - strDB = BugSplat_DB.asString(); - + gBugsplatDB = BugSplat_DB.asString(); + LL_INFOS("BUGSPLAT") << "Initializing with crash logger: " << gCrashLogger << " database: " << gBugsplatDB << " version: " << gVersion << LL_ENDL; + google_breakpad::MinidumpDescriptor *descriptor = new google_breakpad::MinidumpDescriptor( gDirUtilp->getExpandedFilename(LL_PATH_DUMP, "")); google_breakpad::ExceptionHandler *eh = new google_breakpad::ExceptionHandler(*descriptor, NULL, dumpCallback, NULL, @@ -203,8 +206,9 @@ bool LLAppViewerLinux::init() #if LL_SEND_CRASH_REPORTS S32 nCrashSubmitBehavior = gCrashSettings.getS32("CrashSubmitBehavior"); - // Don't ever send? bail out! - if (success && nCrashSubmitBehavior != 2 /*CRASH_BEHAVIOR_NEVER_SEND*/) + + // For the first version we just consider always send and create a nice dialog for CRASH_BEHAVIOR_ASK later. + if (success && nCrashSubmitBehavior == CRASH_BEHAVIOR_ALWAYS_SEND) setupBreadpad(); #endif diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index ab255c2346..e124cb18d5 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -1837,6 +1837,7 @@ class LinuxManifest(ViewerManifest): self.path("install.sh") with self.prefix(dst="bin"): + self.path( os.path.join(os.pardir,'build_data.json'), "build_data.json" ) self.path("firestorm-bin","do-not-directly-run-firestorm-bin") self.path("../linux_crash_logger/linux-crash-logger","linux-crash-logger.bin") self.path2basename("../llplugin/slplugin", "SLPlugin")