From 875f7deebb6e0b2236b3ff672c4e48100c63c19c Mon Sep 17 00:00:00 2001 From: "ted.mielczarek%gmail.com" Date: Wed, 25 Jul 2007 01:06:43 +0000 Subject: [PATCH] bug 380421 - get crash reporter params from nsXULAppInfo. r=bsmedberg --- .../crashreporter/client/crashreporter.cpp | 39 ++++++++++++------- toolkit/crashreporter/client/crashreporter.h | 4 ++ .../crashreporter/client/crashreporter.ini | 3 -- .../client/crashreporter_win.cpp | 5 ++- toolkit/crashreporter/nsExceptionHandler.cpp | 18 ++++----- toolkit/crashreporter/nsExceptionHandler.h | 3 +- .../test/TestCrashReporterAPI.cpp | 2 +- 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/toolkit/crashreporter/client/crashreporter.cpp b/toolkit/crashreporter/client/crashreporter.cpp index 3d09b0e8a20..b30157e9e92 100644 --- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -39,6 +39,8 @@ #include "crashreporter.h" +// Disable exception handler warnings. +#pragma warning( disable : 4530 ) #include #include @@ -53,12 +55,9 @@ StringTable gStrings; int gArgc; const char** gArgv; -static string gSendURL; static string gDumpFile; static string gExtraFile; static string gSettingsPath; -static bool gDeleteDump = true; - static string kExtraDataExtension = ".extra"; @@ -98,11 +97,6 @@ static bool ReadConfig() if (!ReadStringsFromFile(iniPath, gStrings)) return false; - gSendURL = gStrings["URL"]; - - string deleteSetting = gStrings["Delete"]; - gDeleteDump = deleteSetting.empty() || atoi(deleteSetting.c_str()) != 0; - return true; } @@ -196,12 +190,10 @@ bool CrashReporterSendCompleted(bool success, const string& serverResponse) { if (success) { - if (gDeleteDump) { - if (!gDumpFile.empty()) - UIDeleteFile(gDumpFile); - if (!gExtraFile.empty()) - UIDeleteFile(gExtraFile); - } + if (!gDumpFile.empty()) + UIDeleteFile(gDumpFile); + if (!gExtraFile.empty()) + UIDeleteFile(gExtraFile); return AddSubmittedReport(serverResponse); } @@ -246,6 +238,11 @@ int main(int argc, const char** argv) return 0; } + if (queryParameters.find("ServerURL") == queryParameters.end()) { + UIError("No server URL specified"); + return 0; + } + string product = queryParameters["ProductName"]; string vendor = queryParameters["Vendor"]; if (!UIGetSettingsPath(vendor, product, gSettingsPath)) { @@ -259,7 +256,19 @@ int main(int argc, const char** argv) return 0; } - UIShowCrashUI(gDumpFile, queryParameters, gSendURL); + string sendURL = queryParameters["ServerURL"]; + // we don't need to actually send this + queryParameters.erase("ServerURL"); + + // allow override of the server url via environment variable + //XXX: remove this in the far future when our robot + // masters force everyone to use XULRunner + char* urlEnv = getenv("MOZ_CRASHREPORTER_URL"); + if (urlEnv && *urlEnv) { + sendURL = urlEnv; + } + + UIShowCrashUI(gDumpFile, queryParameters, sendURL); } UIShutdown(); diff --git a/toolkit/crashreporter/client/crashreporter.h b/toolkit/crashreporter/client/crashreporter.h index 8b97b4524c5..92725dc1cb1 100644 --- a/toolkit/crashreporter/client/crashreporter.h +++ b/toolkit/crashreporter/client/crashreporter.h @@ -1,6 +1,9 @@ #ifndef CRASHREPORTER_H__ #define CRASHREPORTER_H__ +#pragma warning( push ) +// Disable exception handler warnings. +#pragma warning( disable : 4530 ) #include #include #include @@ -71,4 +74,5 @@ bool UIEnsurePathExists(const std::string& path); bool UIMoveFile(const std::string& oldfile, const std::string& newfile); bool UIDeleteFile(const std::string& oldfile); +#pragma warning( pop ) #endif diff --git a/toolkit/crashreporter/client/crashreporter.ini b/toolkit/crashreporter/client/crashreporter.ini index 3e1b4af5162..59800133d22 100644 --- a/toolkit/crashreporter/client/crashreporter.ini +++ b/toolkit/crashreporter/client/crashreporter.ini @@ -14,6 +14,3 @@ SubmitSuccess=Crash report submitted successfully SubmitFailed=Failed to submit crash report CrashID=Crash ID: %s CrashDetailsURL=You can view details of this crash at %s - -[Settings] -URL=https://crash-reports.mozilla.com/submit diff --git a/toolkit/crashreporter/client/crashreporter_win.cpp b/toolkit/crashreporter/client/crashreporter_win.cpp index d135c6c9f28..4dd5fd04560 100644 --- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -430,10 +430,11 @@ bool UIEnsurePathExists(const string& path) bool UIMoveFile(const string& oldfile, const string& newfile) { - return MoveFile(UTF8ToWide(oldfile).c_str(), UTF8ToWide(newfile).c_str()); + return MoveFile(UTF8ToWide(oldfile).c_str(), UTF8ToWide(newfile).c_str()) + == TRUE; } bool UIDeleteFile(const string& oldfile) { - return DeleteFile(UTF8ToWide(oldfile).c_str()); + return DeleteFile(UTF8ToWide(oldfile).c_str()) == TRUE; } diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 4d338559e78..b2cbf0145ac 100755 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -288,21 +288,14 @@ static nsresult GetExecutablePath(nsString& exePath) #endif } -nsresult SetExceptionHandler(nsILocalFile* aXREDirectory) +nsresult SetExceptionHandler(nsILocalFile* aXREDirectory, + const char* aServerURL) { nsresult rv; if (gExceptionHandler) return NS_ERROR_ALREADY_INITIALIZED; - // check environment var to see if we're enabled. - // we're off by default until we sort out the - // rest of the infrastructure, - // so it must exist and be set to a non-empty value. - const char* airbagEnv = PR_GetEnv("MOZ_AIRBAG"); - if (airbagEnv == NULL || *airbagEnv == '\0') - return NS_ERROR_NOT_AVAILABLE; - // this environment variable prevents us from launching // the crash reporter client const char* noReportEnv = PR_GetEnv("MOZ_CRASHREPORTER_NO_REPORT"); @@ -363,7 +356,7 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory) return NS_ERROR_NOT_IMPLEMENTED; #endif - // finally, set the exception handler + // now set the exception handler gExceptionHandler = new google_breakpad:: ExceptionHandler(CONVERT_UTF16_TO_XP_CHAR(tempPath).get(), nsnull, @@ -374,6 +367,11 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory) if (!gExceptionHandler) return NS_ERROR_OUT_OF_MEMORY; + // store server URL with the API data + if (aServerURL) + AnnotateCrashReport(NS_LITERAL_CSTRING("ServerURL"), + nsDependentCString(aServerURL)); + return NS_OK; } diff --git a/toolkit/crashreporter/nsExceptionHandler.h b/toolkit/crashreporter/nsExceptionHandler.h index d3abf506a8c..96db6b73b91 100644 --- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -43,7 +43,8 @@ #include "nsStringGlue.h" namespace CrashReporter { -nsresult SetExceptionHandler(nsILocalFile* aXREDirectory); +nsresult SetExceptionHandler(nsILocalFile* aXREDirectory, + const char* aServerURL); nsresult SetMinidumpPath(const nsAString& aPath); nsresult UnsetExceptionHandler(); nsresult AnnotateCrashReport(const nsACString &key, const nsACString &data); diff --git a/toolkit/crashreporter/test/TestCrashReporterAPI.cpp b/toolkit/crashreporter/test/TestCrashReporterAPI.cpp index 987c30e4dc0..dc4e1ea5916 100644 --- a/toolkit/crashreporter/test/TestCrashReporterAPI.cpp +++ b/toolkit/crashreporter/test/TestCrashReporterAPI.cpp @@ -63,7 +63,7 @@ char * test_init_exception_handler() { mu_assert("CrashReporter::SetExceptionHandler", - CrashReporter::SetExceptionHandler(nsnull)); + CrashReporter::SetExceptionHandler(nsnull, nsnull)); return 0; }