Bug 994707 - Provide the crash events path as an environment variable for the crashreporter. r=ted

--HG--
extra : rebase_source : 96388b73c887a71fae9039a071e4733c9302eb61
This commit is contained in:
Steven MacLeod 2014-07-03 17:51:08 -04:00
parent e489aa6107
commit 7e85a0256a

View File

@ -163,6 +163,7 @@ static XP_CHAR* crashReporterPath;
// Where crash events should go.
static XP_CHAR* eventsDirectory;
static char* eventsEnv = nullptr;
// If this is false, we don't launch the crash reporter
static bool doReport = true;
@ -2107,10 +2108,29 @@ SetCrashEventsDir(nsIFile* aDir)
nsString path;
eventsDir->GetPath(path);
eventsDirectory = reinterpret_cast<wchar_t*>(ToNewUnicode(path));
// Save the path in the environment for the crash reporter application.
nsAutoString eventsDirEnv(NS_LITERAL_STRING("MOZ_CRASHREPORTER_EVENTS_DIRECTORY="));
eventsDirEnv.Append(path);
_wputenv(eventsDirEnv.get());
#else
nsCString path;
eventsDir->GetNativePath(path);
eventsDirectory = ToNewCString(path);
// Save the path in the environment for the crash reporter application.
nsAutoCString eventsDirEnv("MOZ_CRASHREPORTER_EVENTS_DIRECTORY=");
eventsDirEnv.Append(path);
// PR_SetEnv() wants the string to be available for the lifetime
// of the app, so dup it here.
char* oldEventsEnv = eventsEnv;
eventsEnv = ToNewCString(eventsDirEnv);
PR_SetEnv(eventsEnv);
if (oldEventsEnv) {
NS_Free(oldEventsEnv);
}
#endif
}