Bug 383603 - Disable the crash-reporter hook entirely if MOZ_CRASHREPORTER_DISABLE is set, r=luser
authorbenjamin@smedbergs.us
Tue, 24 Jul 2007 18:06:10 -0700
changeset 3912 ba50b24295f4fe03a5c147a40057116f6760ae97
parent 3911 b058297fabf57e39708571b1aa0ff0c0cbe6286d
child 3913 2f184da3fba63d8aa7799c35da4190cf7b688ba5
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluser
bugs383603
milestone1.9a7pre
Bug 383603 - Disable the crash-reporter hook entirely if MOZ_CRASHREPORTER_DISABLE is set, r=luser
toolkit/crashreporter/nsExceptionHandler.cpp
toolkit/crashreporter/test/TestCrashReporterAPI.cpp
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -228,20 +228,24 @@ bool MinidumpCallback(const XP_CHAR* dum
 nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
                              const char* aServerURL)
 {
   nsresult rv;
 
   if (gExceptionHandler)
     return NS_ERROR_ALREADY_INITIALIZED;
 
+  const char *envvar = PR_GetEnv("MOZ_CRASHREPORTER_DISABLE");
+  if (envvar && *envvar)
+    return NS_OK;
+
   // this environment variable prevents us from launching
   // the crash reporter client
-  const char* noReportEnv = PR_GetEnv("MOZ_CRASHREPORTER_NO_REPORT");
-  if (noReportEnv && *noReportEnv)
+  envvar = PR_GetEnv("MOZ_CRASHREPORTER_NO_REPORT");
+  if (envvar && *envvar)
     doReport = false;
 
   // allocate our strings
   crashReporterAPIData = new nsCString();
   NS_ENSURE_TRUE(crashReporterAPIData, NS_ERROR_OUT_OF_MEMORY);
 
   crashReporterAPIData_Hash =
     new nsDataHashtable<nsCStringHashKey,nsCString>();
@@ -423,16 +427,19 @@ nsresult AnnotateCrashReport(const nsACS
                                            crashReporterAPIData);
 
   return NS_OK;
 }
 
 nsresult
 SetRestartArgs(int argc, char **argv)
 {
+  if (!gExceptionHandler)
+    return NS_OK;
+
   int i;
   nsCAutoString envVar;
   char *env;
   for (i = 0; i < argc; i++) {
     envVar = "MOZ_CRASHREPORTER_RESTART_ARG_";
     envVar.AppendInt(i);
     envVar += "=";
     envVar += argv[i];
--- a/toolkit/crashreporter/test/TestCrashReporterAPI.cpp
+++ b/toolkit/crashreporter/test/TestCrashReporterAPI.cpp
@@ -147,17 +147,17 @@ static char* all_tests()
 }
 
 int
 main (int argc, char **argv)
 {
   NS_InitXPCOM2(nsnull, nsnull, nsnull);
 
   char* env = new char[13];
-  strcpy(env, "MOZ_AIRBAG=1");
+  strcpy(env, "MOZ_CRASHREPORTER=1");
   PR_SetEnv(env);
 
   char* result = all_tests();
   if (result != 0) {
     printf("FAIL: %s\n", result);
   }
   else {
     printf("ALL TESTS PASSED\n");