Bug 1286802 - Part 1: Enable heap regions in the minidump with opt-in pref or on dev edition. r?ted
MozReview-Commit-ID: LYF90q3ycos
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -481,16 +481,20 @@ bool SimpleNoCLibDtoA(double aValue, cha
}
aBuffer[i] = '\0';
}
return ok;
}
namespace CrashReporter {
+#if defined(XP_LINUX) || defined(XP_WIN32)
+static bool sIncludeHeapRegions = false;
+#endif
+
#ifdef XP_LINUX
inline void
my_inttostring(intmax_t t, char* buffer, size_t buffer_length)
{
my_memset(buffer, 0, buffer_length);
my_uitos(buffer, t, my_uint_len(t));
}
#endif
@@ -2354,16 +2358,21 @@ nsresult UnregisterAppMemory(void* ptr)
#if defined(XP_LINUX) || defined(XP_WIN32)
gExceptionHandler->UnregisterAppMemory(ptr);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
+void SetIncludeHeapRegions(bool aEnabled)
+{
+ sIncludeHeapRegions = aEnabled;
+}
+
bool GetServerURL(nsACString& aServerURL)
{
if (!gExceptionHandler)
return false;
return GetAnnotation(NS_LITERAL_CSTRING("ServerURL"), aServerURL);
}
--- a/toolkit/crashreporter/nsExceptionHandler.h
+++ b/toolkit/crashreporter/nsExceptionHandler.h
@@ -89,16 +89,19 @@ nsresult SetRestartArgs(int argc, char**
nsresult SetupExtraData(nsIFile* aAppDataDirectory,
const nsACString& aBuildID);
bool GetLastRunCrashID(nsAString& id);
// Registers an additional memory region to be included in the minidump
nsresult RegisterAppMemory(void* ptr, size_t length);
nsresult UnregisterAppMemory(void* ptr);
+// Enable or disable inclusion of heap regions in the minidump.
+void SetIncludeHeapRegions(bool aEnabled);
+
// Functions for working with minidumps and .extras
typedef nsDataHashtable<nsCStringHashKey, nsCString> AnnotationTable;
void DeleteMinidumpFilesForID(const nsAString& id);
bool GetMinidumpForID(const nsAString& id, nsIFile** minidump);
bool GetIDFromMinidump(nsIFile* minidump, nsAString& id);
bool GetExtraFileForID(const nsAString& id, nsIFile** extraFile);
bool GetExtraFileForMinidump(nsIFile* minidump, nsIFile** extraFile);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4252,16 +4252,26 @@ XREMain::XRE_mainRun()
nsCString userAgentLocale;
// Try a localized string first. This pref is always a localized string in
// Fennec, and might be elsewhere, too.
if (NS_SUCCEEDED(Preferences::GetLocalizedCString("general.useragent.locale", &userAgentLocale))) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale);
} else if (NS_SUCCEEDED(Preferences::GetCString("general.useragent.locale", &userAgentLocale))) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale);
}
+
+#if defined(XP_WIN) || defined(XP_LINUX)
+ bool includeHeapRegions =
+#ifndef RELEASE_BUILD
+ true || // Include heap regions on nightly and aurora by default.
+#endif
+ Preferences::GetBool("toolkit.crashreporter.includeHeapRegions", false);
+ CrashReporter::SetIncludeHeapRegions(includeHeapRegions);
+#endif
+
#endif
appStartup->GetShuttingDown(&mShuttingDown);
nsCOMPtr<nsICommandLineRunner> cmdLine;
nsCOMPtr<nsIFile> workingDir;
rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));