--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -228,21 +228,16 @@ static nsString* lastRunCrashID = nullpt
#if defined(MOZ_WIDGET_ANDROID)
// on Android 4.2 and above there is a user serial number associated
// with the current process that gets lost when we fork so we need to
// explicitly pass it to am
static char* androidUserSerial = nullptr;
#endif
-// these are just here for readability
-static const char kTimeSinceLastCrashParameter[] = "SecondsSinceLastCrash=";
-static const int kTimeSinceLastCrashParameterLen =
- sizeof(kTimeSinceLastCrashParameter)-1;
-
// this holds additional data sent via the API
static Mutex* crashReporterAPILock;
static Mutex* notesFieldLock;
static AnnotationTable* crashReporterAPIData_Hash;
static nsCString* crashReporterAPIData = nullptr;
static nsCString* crashEventAPIData = nullptr;
static nsCString* notesField = nullptr;
static bool isGarbageCollecting;
@@ -475,17 +470,17 @@ bool SimpleNoCLibDtoA(double aValue, cha
aBuffer[i] = '\0';
}
return ok;
}
namespace CrashReporter {
#ifdef XP_LINUX
-inline void
+static 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
#ifdef XP_WIN
@@ -555,35 +550,20 @@ void AnnotateOOMAllocationSize(size_t si
static size_t gTexturesSize = 0;
void AnnotateTexturesSize(size_t size)
{
gTexturesSize = size;
}
-static size_t gNumOfPendingIPC = 0;
-static uint32_t gTopPendingIPCCount = 0;
-static const char* gTopPendingIPCName = nullptr;
-static uint32_t gTopPendingIPCType = 0;
-
-void AnnotatePendingIPC(size_t aNumOfPendingIPC,
- uint32_t aTopPendingIPCCount,
- const char* aTopPendingIPCName,
- uint32_t aTopPendingIPCType)
-{
- gNumOfPendingIPC = aNumOfPendingIPC;
- gTopPendingIPCCount = aTopPendingIPCCount;
- gTopPendingIPCName = aTopPendingIPCName;
- gTopPendingIPCType = aTopPendingIPCType;
-}
-
#ifndef XP_WIN
// Like Windows CopyFile for *nix
-bool copy_file(const char* from, const char* to)
+static bool
+copy_file(const char* from, const char* to)
{
const int kBufSize = 4096;
int fdfrom = sys_open(from, O_RDONLY, 0);
if (fdfrom < 0) {
return false;
}
bool ok = false;
@@ -714,17 +694,17 @@ private:
int mFD;
};
#else
#error "Need implementation of PlatformWrite for this platform"
#endif
template<int N>
-void
+static void
WriteLiteral(PlatformWriter& pw, const char (&str)[N])
{
pw.WriteBuffer(str, N - 1);
}
static void
WriteString(PlatformWriter& pw, const char* str) {
#ifdef XP_LINUX
@@ -770,17 +750,17 @@ OpenAPIData(PlatformWriter& aWriter,
size += 4;
}
}
Concat(p, extraFileExtension, &size);
aWriter.Open(extraDataPath);
}
#ifdef XP_WIN
-void
+static void
WriteGlobalMemoryStatus(PlatformWriter* apiData, PlatformWriter* eventFile)
{
char buffer[128];
// Try to get some information about memory.
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
if (GlobalMemoryStatusEx(&statex)) {
@@ -931,17 +911,18 @@ LaunchCrashReporterActivity(XP_CHAR* aPr
Unused << HANDLE_EINTR(sys_waitpid(pid, &status, __WALL));
}
return true;
}
#endif
-bool MinidumpCallback(
+static bool
+MinidumpCallback(
#ifdef XP_LINUX
const MinidumpDescriptor& descriptor,
#else
const XP_CHAR* dump_path,
const XP_CHAR* minidump_id,
#endif
void* context,
#ifdef XP_WIN32
@@ -1001,29 +982,16 @@ bool MinidumpCallback(
XP_STOA(gOOMAllocationSize, oomAllocationSizeBuffer, 10);
}
char texturesSizeBuffer[32] = "";
if (gTexturesSize) {
XP_STOA(gTexturesSize, texturesSizeBuffer, 10);
}
- char numOfPendingIPCBuffer[32] = "";
- char topPendingIPCCountBuffer[32] = "";
- char topPendingIPCTypeBuffer[11] = "0x";
- if (gNumOfPendingIPC) {
- XP_STOA(gNumOfPendingIPC, numOfPendingIPCBuffer, 10);
- if (gTopPendingIPCCount) {
- XP_STOA(gTopPendingIPCCount, topPendingIPCCountBuffer, 10);
- }
- if (gTopPendingIPCType) {
- XP_STOA(gTopPendingIPCType, &topPendingIPCTypeBuffer[2], 16);
- }
- }
-
// calculate time since last crash (if possible), and store
// the time of this crash.
time_t crashTime;
#ifdef XP_LINUX
struct kernel_timeval tv;
sys_gettimeofday(&tv, nullptr);
crashTime = tv.tv_sec;
#else
@@ -1172,33 +1140,16 @@ bool MinidumpCallback(
WriteAnnotation(eventFile, "OOMAllocationSize", oomAllocationSizeBuffer);
}
if (texturesSizeBuffer[0]) {
WriteAnnotation(apiData, "TextureUsage", texturesSizeBuffer);
WriteAnnotation(eventFile, "TextureUsage", texturesSizeBuffer);
}
- if (numOfPendingIPCBuffer[0]) {
- WriteAnnotation(apiData, "NumberOfPendingIPC", numOfPendingIPCBuffer);
- WriteAnnotation(eventFile, "NumberOfPendingIPC", numOfPendingIPCBuffer);
- if (topPendingIPCCountBuffer[0]) {
- WriteAnnotation(apiData, "TopPendingIPCCount", topPendingIPCCountBuffer);
- WriteAnnotation(eventFile, "TopPendingIPCCount", topPendingIPCCountBuffer);
- }
- if (gTopPendingIPCName) {
- WriteAnnotation(apiData, "TopPendingIPCName", gTopPendingIPCName);
- WriteAnnotation(eventFile, "TopPendingIPCName", gTopPendingIPCName);
- }
- if (topPendingIPCTypeBuffer[2]) {
- WriteAnnotation(apiData, "TopPendingIPCType", topPendingIPCTypeBuffer);
- WriteAnnotation(eventFile, "TopPendingIPCType", topPendingIPCTypeBuffer);
- }
- }
-
if (memoryReportPath) {
WriteLiteral(apiData, "ContainsMemoryReport=1\n");
WriteLiteral(eventFile, "ContainsMemoryReport=1\n");
}
std::function<void(const char*)> getThreadAnnotationCB =
[&] (const char * aAnnotation) -> void {
if (aAnnotation) {
@@ -1410,42 +1361,16 @@ PrepareChildExceptionTimeAnnotations()
// rust_panic_reason is not null-terminated.
WriteLiteral(apiData, "MozCrashReason=");
apiData.WriteBuffer(rust_panic_reason, rust_panic_len);
WriteLiteral(apiData, "\n");
} else if (gMozCrashReason) {
WriteAnnotation(apiData, "MozCrashReason", gMozCrashReason);
}
- char numOfPendingIPCBuffer[32] = "";
- char topPendingIPCCountBuffer[32] = "";
- char topPendingIPCTypeBuffer[11] = "0x";
- if (gNumOfPendingIPC) {
- XP_STOA(gNumOfPendingIPC, numOfPendingIPCBuffer, 10);
- if (gTopPendingIPCCount) {
- XP_STOA(gTopPendingIPCCount, topPendingIPCCountBuffer, 10);
- }
- if (gTopPendingIPCType) {
- XP_STOA(gTopPendingIPCType, &topPendingIPCTypeBuffer[2], 16);
- }
- }
-
- if (numOfPendingIPCBuffer[0]) {
- WriteAnnotation(apiData, "NumberOfPendingIPC", numOfPendingIPCBuffer);
- if (topPendingIPCCountBuffer[0]) {
- WriteAnnotation(apiData, "TopPendingIPCCount", topPendingIPCCountBuffer);
- }
- if (gTopPendingIPCName) {
- WriteAnnotation(apiData, "TopPendingIPCName", gTopPendingIPCName);
- }
- if (topPendingIPCTypeBuffer[2]) {
- WriteAnnotation(apiData, "TopPendingIPCType", topPendingIPCTypeBuffer);
- }
- }
-
std::function<void(const char*)> getThreadAnnotationCB =
[&] (const char * aAnnotation) -> void {
if (aAnnotation) {
WriteLiteral(apiData, "ThreadIdNameMapping=");
WriteString(apiData, aAnnotation);
WriteLiteral(apiData, "\n");
}
};
@@ -1509,17 +1434,18 @@ ChildFPEFilter(void* context, EXCEPTION_
{
bool result = FPEFilter(context, exinfo, assertion);
if (result) {
PrepareChildExceptionTimeAnnotations();
}
return result;
}
-MINIDUMP_TYPE GetMinidumpType()
+static MINIDUMP_TYPE
+GetMinidumpType()
{
MINIDUMP_TYPE minidump_type = MiniDumpWithFullMemoryInfo;
#ifdef NIGHTLY_BUILD
// This is Nightly only because this doubles the size of minidumps based
// on the experimental data.
minidump_type = static_cast<MINIDUMP_TYPE>(minidump_type |
MiniDumpWithUnloadedModules |
@@ -1565,17 +1491,18 @@ ChildFilter(void* context)
{
bool result = Filter(context);
if (result) {
PrepareChildExceptionTimeAnnotations();
}
return result;
}
-void TerminateHandler()
+static void
+TerminateHandler()
{
MOZ_CRASH("Unhandled exception");
}
#if !defined(MOZ_WIDGET_ANDROID)
// Locate the specified executable and store its path as a native string in
// the |aPathPtr| so we can later invoke it from within the exception handler.
@@ -2023,18 +1950,17 @@ SetupCrashReporterDirectory(nsIFile* aAp
return NS_OK;
}
// Annotate the crash report with a Unique User ID and time
// since install. Also do some prep work for recording
// time since last crash, which must be calculated at
// crash time.
// If any piece of data doesn't exist, initialize it first.
-nsresult SetupExtraData(nsIFile* aAppDataDirectory,
- const nsACString& aBuildID)
+nsresult SetupExtraData(nsIFile* aAppDataDirectory, const nsACString& aBuildID)
{
nsCOMPtr<nsIFile> dataDirectory;
nsresult rv = SetupCrashReporterDirectory(
aAppDataDirectory,
"Crash Reports",
XP_TEXT("MOZ_CRASHREPORTER_DATA_DIRECTORY"),
getter_AddRefs(dataDirectory)
);
@@ -2228,20 +2154,16 @@ static void ReplaceChar(nsCString& str,
str.Replace(pos - 1, 1, replacement);
str.BeginReading(iter);
iter.advance(pos + replacement.Length() - 1);
str.EndReading(end);
}
}
-// This function is miscompiled with MSVC 2005/2008 when PGO is on.
-#ifdef _MSC_VER
-#pragma optimize("", off)
-#endif
static nsresult
EscapeAnnotation(const nsACString& key, const nsACString& data, nsCString& escapedData)
{
if (FindInReadable(NS_LITERAL_CSTRING("="), key) ||
FindInReadable(NS_LITERAL_CSTRING("\n"), key))
return NS_ERROR_INVALID_ARG;
if (FindInReadable(NS_LITERAL_CSTRING("\0"), data))
@@ -2252,19 +2174,16 @@ EscapeAnnotation(const nsACString& key,
// escape backslashes
ReplaceChar(escapedData, NS_LITERAL_CSTRING("\\"),
NS_LITERAL_CSTRING("\\\\"));
// escape newlines
ReplaceChar(escapedData, NS_LITERAL_CSTRING("\n"),
NS_LITERAL_CSTRING("\\n"));
return NS_OK;
}
-#ifdef _MSC_VER
-#pragma optimize("", on)
-#endif
class DelayedNote
{
public:
DelayedNote(const nsACString& aKey, const nsACString& aData)
: mKey(aKey), mData(aData), mType(Annotation) {}
explicit DelayedNote(const nsACString& aData)
@@ -2404,17 +2323,18 @@ nsresult AppendAppNotesToCrashReport(con
MutexAutoLock lock(*notesFieldLock);
notesField->Append(data);
return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
}
// Returns true if found, false if not found.
-bool GetAnnotation(const nsACString& key, nsACString& data)
+static bool
+GetAnnotation(const nsACString& key, nsACString& data)
{
if (!gExceptionHandler)
return false;
nsAutoCString entry;
if (!crashReporterAPIData_Hash->Get(key, &entry))
return false;
@@ -3126,17 +3046,17 @@ WriteAnnotation(PRFileDesc* fd, const ns
{
PR_Write(fd, key.BeginReading(), key.Length());
PR_Write(fd, "=", 1);
PR_Write(fd, value.BeginReading(), value.Length());
PR_Write(fd, "\n", 1);
}
template<int N>
-void
+static void
WriteLiteral(PRFileDesc* fd, const char (&str)[N])
{
PR_Write(fd, str, N - 1);
}
static bool
WriteExtraData(nsIFile* extraFile,
const AnnotationTable& data,
@@ -3671,17 +3591,17 @@ UnregisterInjectorCallback(DWORD process
return;
MutexAutoLock lock(*dumpMapLock);
pidToMinidump->RemoveEntry(processID);
}
#endif // MOZ_CRASHREPORTER_INJECTOR
-bool
+static bool
CheckForLastRunCrash()
{
if (lastRunCrashID)
return true;
// The exception handler callback leaves the filename of the
// last minidump in a known file.
nsCOMPtr<nsIFile> lastCrashFile;
@@ -4074,17 +3994,17 @@ bool TakeMinidump(nsIFile** aResult, boo
}
if (aMoveToPending) {
MoveToPending(*aResult, nullptr, nullptr);
}
return true;
}
-inline void
+static inline void
NotifyDumpResult(bool aResult,
bool aAsync,
std::function<void(bool)>&& aCallback,
RefPtr<nsIThread>&& aCallbackThread)
{
std::function<void()> runnable = [&](){
aCallback(aResult);
};
@@ -4094,17 +4014,17 @@ NotifyDumpResult(bool aResult,
Unused << aCallbackThread->Dispatch(NS_NewRunnableFunction("CrashReporter::InvokeCallback",
Move(runnable)),
NS_DISPATCH_SYNC);
} else {
runnable();
}
}
-void
+static void
CreatePairedChildMinidumpAsync(ProcessHandle aTargetPid,
ThreadId aTargetBlamedThread,
nsCString aIncomingPairName,
nsCOMPtr<nsIFile> aIncomingDumpToPair,
nsIFile** aMainDumpOut,
xpstring aDumpPath,
std::function<void(bool)>&& aCallback,
RefPtr<nsIThread>&& aCallbackThread,