Bug 720444 - Add amount of free physical memory and free space in the page file to Windows crash reports. r=ted

--HG--
extra : rebase_source : 62470172fbcb49f7a1d19c45a1a6bf5dbf46fb4c
This commit is contained in:
Justin Lebar 2012-01-25 15:05:05 -05:00
parent c88126cdb1
commit 0540a38dc7
2 changed files with 36 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -214,6 +214,14 @@ static const char kOOMAllocationSizeParameter[] = "OOMAllocationSize=";
static const int kOOMAllocationSizeParameterLen =
sizeof(kOOMAllocationSizeParameter)-1;
static const char kAvailablePageFileParameter[] = "AvailablePageFile=";
static const int kAvailablePageFileParameterLen =
sizeof(kAvailablePageFileParameter)-1;
static const char kAvailablePhysicalMemoryParameter[] = "AvailablePhysicalMemory=";
static const int kAvailablePhysicalMemoryParameterLen =
sizeof(kAvailablePhysicalMemoryParameter)-1;
// this holds additional data sent via the API
static Mutex* crashReporterAPILock;
static Mutex* notesFieldLock;
@ -455,34 +463,31 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
&nBytes, NULL);
WriteFile(hFile, "\n", 1, &nBytes, NULL);
}
// Try to get some information about memory.
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
if (GlobalMemoryStatusEx(&statex)) {
char buffer[128];
int bufferLen;
WriteFile(hFile, kSysMemoryParameter,
kSysMemoryParameterLen, &nBytes, NULL);
ltoa(statex.dwMemoryLoad, buffer, 10);
bufferLen = strlen(buffer);
WriteFile(hFile, buffer, bufferLen,
&nBytes, NULL);
WriteFile(hFile, "\n", 1, &nBytes, NULL);
WriteFile(hFile, kTotalVirtualMemoryParameter,
kTotalVirtualMemoryParameterLen, &nBytes, NULL);
_ui64toa(statex.ullTotalVirtual, buffer, 10);
bufferLen = strlen(buffer);
WriteFile(hFile, buffer, bufferLen,
&nBytes, NULL);
WriteFile(hFile, "\n", 1, &nBytes, NULL);
WriteFile(hFile, kAvailableVirtualMemoryParameter,
kAvailableVirtualMemoryParameterLen, &nBytes, NULL);
_ui64toa(statex.ullAvailVirtual, buffer, 10);
bufferLen = strlen(buffer);
WriteFile(hFile, buffer, bufferLen,
&nBytes, NULL);
#define WRITE_STATEX_FIELD(field, paramName, conversionFunc) \
WriteFile(hFile, k##paramName##Parameter, \
k##paramName##ParameterLen, &nBytes, NULL); \
conversionFunc(statex.field, buffer, 10); \
bufferLen = strlen(buffer); \
WriteFile(hFile, buffer, bufferLen, &nBytes, NULL); \
WriteFile(hFile, "\n", 1, &nBytes, NULL);
WRITE_STATEX_FIELD(dwMemoryLoad, SysMemory, ltoa);
WRITE_STATEX_FIELD(ullTotalVirtual, TotalVirtualMemory, _ui64toa);
WRITE_STATEX_FIELD(ullAvailVirtual, AvailableVirtualMemory, _ui64toa);
WRITE_STATEX_FIELD(ullAvailPageFile, AvailablePageFile, _ui64toa);
WRITE_STATEX_FIELD(ullAvailPhys, AvailablePhysicalMemory, _ui64toa);
#undef WRITE_STATEX_FIELD
}
if (oomAllocationSizeBufferLen) {
WriteFile(hFile, kOOMAllocationSizeParameter,
kOOMAllocationSizeParameterLen, &nBytes, NULL);

View File

@ -6,9 +6,13 @@ function run_test()
}
var is_win7_or_newer = false;
var is_windows = false;
var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"]
.getService(Components.interfaces.nsIHttpProtocolHandler);
var match = ph.userAgent.match(/Windows NT (\d+).(\d+)/);
if (match) {
is_windows = true;
}
if (match && (parseInt(match[1]) > 6 ||
parseInt(match[1]) == 6 && parseInt(match[2]) >= 1)) {
is_win7_or_newer = true;
@ -22,6 +26,12 @@ function run_test()
do_check_true('CrashTime' in extra);
do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_THREAD_LIST_STREAM));
do_check_true(CrashTestUtils.dumpHasInstructionPointerMemory(mdump.path));
if (is_windows) {
['SystemMemoryUsePercentage', 'TotalVirtualMemory', 'AvailableVirtualMemory',
'AvailablePageFile', 'AvailablePhysicalMemory'].forEach(function(prop) {
do_check_true(extra[prop].toString().match(/^\d+$/));
});
}
if (is_win7_or_newer)
do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_MEMORY_INFO_LIST_STREAM));
});