Bug 1264242 - Write memory info streams for Windows Minidumps of child processes. r=bsmedberg, a=ritu

MozReview-Commit-ID: COHFdNiJIqm
This commit is contained in:
Ted Mielczarek 2016-04-13 08:05:46 -04:00
parent f4c951ca48
commit 0ee2bee94f
4 changed files with 62 additions and 37 deletions

View File

@ -1356,6 +1356,41 @@ ChildFPEFilter(void* context, EXCEPTION_POINTERS* exinfo,
return result;
}
MINIDUMP_TYPE GetMinidumpType()
{
MINIDUMP_TYPE minidump_type = MiniDumpNormal;
// Try to determine what version of dbghelp.dll we're using.
// MinidumpWithFullMemoryInfo is only available in 6.1.x or newer.
DWORD version_size = GetFileVersionInfoSizeW(L"dbghelp.dll", nullptr);
if (version_size > 0) {
std::vector<BYTE> buffer(version_size);
if (GetFileVersionInfoW(L"dbghelp.dll",
0,
version_size,
&buffer[0])) {
UINT len;
VS_FIXEDFILEINFO* file_info;
VerQueryValue(&buffer[0], L"\\", (void**)&file_info, &len);
WORD major = HIWORD(file_info->dwFileVersionMS),
minor = LOWORD(file_info->dwFileVersionMS),
revision = HIWORD(file_info->dwFileVersionLS);
if (major > 6 || (major == 6 && minor > 1) ||
(major == 6 && minor == 1 && revision >= 7600)) {
minidump_type = MiniDumpWithFullMemoryInfo;
}
}
}
const char* e = PR_GetEnv("MOZ_CRASHREPORTER_FULLDUMP");
if (e && *e) {
minidump_type = MiniDumpWithFullMemory;
}
return minidump_type;
}
#endif // XP_WIN
static bool ShouldReport()
@ -1513,36 +1548,6 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
#ifdef XP_WIN32
ReserveBreakpadVM();
MINIDUMP_TYPE minidump_type = MiniDumpNormal;
// Try to determine what version of dbghelp.dll we're using.
// MinidumpWithFullMemoryInfo is only available in 6.1.x or newer.
DWORD version_size = GetFileVersionInfoSizeW(L"dbghelp.dll", nullptr);
if (version_size > 0) {
std::vector<BYTE> buffer(version_size);
if (GetFileVersionInfoW(L"dbghelp.dll",
0,
version_size,
&buffer[0])) {
UINT len;
VS_FIXEDFILEINFO* file_info;
VerQueryValue(&buffer[0], L"\\", (void**)&file_info, &len);
WORD major = HIWORD(file_info->dwFileVersionMS),
minor = LOWORD(file_info->dwFileVersionMS),
revision = HIWORD(file_info->dwFileVersionLS);
if (major > 6 || (major == 6 && minor > 1) ||
(major == 6 && minor == 1 && revision >= 7600)) {
minidump_type = MiniDumpWithFullMemoryInfo;
}
}
}
const char* e = PR_GetEnv("MOZ_CRASHREPORTER_FULLDUMP");
if (e && *e) {
minidump_type = MiniDumpWithFullMemory;
}
#endif // XP_WIN32
#ifdef MOZ_WIDGET_ANDROID
@ -1586,7 +1591,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
nullptr,
#ifdef XP_WIN32
google_breakpad::ExceptionHandler::HANDLER_ALL,
minidump_type,
GetMinidumpType(),
(const wchar_t*) nullptr,
nullptr);
#else
@ -3474,7 +3479,7 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)
nullptr, // no minidump callback
nullptr, // no callback context
google_breakpad::ExceptionHandler::HANDLER_ALL,
MiniDumpNormal,
GetMinidumpType(),
NS_ConvertASCIItoUTF16(crashPipe).get(),
nullptr);
gExceptionHandler->set_handle_debug_exceptions(true);

View File

@ -1,10 +1,5 @@
function run_test()
{
if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
dump("INFO | test_crashreporter.js | Can't test crashreporter in a non-libxul build.\n");
return;
}
var is_win7_or_newer = false;
var is_windows = false;
var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"]

View File

@ -0,0 +1,23 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
load("../unit/head_crashreporter.js");
function run_test()
{
var is_win7_or_newer = 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 && (parseInt(match[1]) > 6 ||
parseInt(match[1]) == 6 && parseInt(match[2]) >= 1)) {
is_win7_or_newer = true;
}
do_content_crash(null, function(mdump, extra) {
do_check_true(mdump.exists());
do_check_true(mdump.fileSize > 0);
if (is_win7_or_newer)
do_check_true(CrashTestUtils.dumpHasStream(mdump.path, CrashTestUtils.MD_MEMORY_INFO_LIST_STREAM));
});
}

View File

@ -7,3 +7,5 @@ skip-if = toolkit == 'android' || toolkit == 'gonk'
[test_content_exception_time_annotation.js]
[test_content_oom_annotation_windows.js]
skip-if = os != 'win'
[test_content_memory_list.js]
skip-if = os != 'win'