Bug 386959 - crashreporter gets wrong restart arguments for xulrunner apps, r=bsmedberg
authorwr@rosenauer.org
Tue, 24 Jul 2007 18:06:12 -0700
changeset 3921 0fe94f077aaf4758f069da5466d32890f2bca660
parent 3920 914dbc7adef28e88b6ac0458151bf775e7596628
child 3922 120a21e26640fec9c322d98f6dad9ac6c4db4eba
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)
reviewersbsmedberg
bugs386959
milestone1.9a7pre
Bug 386959 - crashreporter gets wrong restart arguments for xulrunner apps, r=bsmedberg
toolkit/crashreporter/client/crashreporter.cpp
toolkit/crashreporter/nsExceptionHandler.cpp
--- a/toolkit/crashreporter/client/crashreporter.cpp
+++ b/toolkit/crashreporter/client/crashreporter.cpp
@@ -429,16 +429,31 @@ int main(int argc, char** argv)
     if (!MoveCrashData(pendingDir, gDumpFile, gExtraFile)) {
       return 0;
     }
 
     string sendURL = queryParameters["ServerURL"];
     // we don't need to actually send this
     queryParameters.erase("ServerURL");
 
+    // re-set XUL_APP_FILE for xulrunner wrapped apps
+    const char *appfile = getenv("MOZ_CRASHREPORTER_RESTART_XUL_APP_FILE");
+    if (appfile && *appfile) {
+      const char prefix[] = "XUL_APP_FILE=";
+      char *env = (char*) malloc(strlen(appfile)+strlen(prefix));
+      if (!env) {
+        UIError("Out of memory");
+        return 0;
+      }
+      strcpy(env, prefix);
+      strcat(env, appfile);
+      putenv(env);
+      free(env);
+    }
+
     vector<string> restartArgs;
 
     ostringstream paramName;
     int i = 0;
     paramName << "MOZ_CRASHREPORTER_RESTART_ARG_" << i++;
     const char *param = getenv(paramName.str().c_str());
     while (param && *param) {
       restartArgs.push_back(param);
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -465,11 +465,20 @@ SetRestartArgs(int argc, char **argv)
   // PR_SetEnv() wants the string to be available for the lifetime
   // of the app, so dup it here
   env = ToNewCString(envVar);
   if (!env)
     return NS_ERROR_OUT_OF_MEMORY;
 
   PR_SetEnv(env);
 
+  // make sure we save the info in XUL_APP_FILE for the reporter
+  const char *appfile = PR_GetEnv("XUL_APP_FILE");
+  if (appfile && *appfile) {
+    envVar = "MOZ_CRASHREPORTER_RESTART_XUL_APP_FILE=";
+    envVar += appfile;
+    env = ToNewCString(envVar);
+    PR_SetEnv(env);
+  }
+
   return NS_OK;
 }
 } // namespace CrashReporter