bug 1264242 - Write memory info streams for Windows Minidumps of child processes. r=bsmedberg

MozReview-Commit-ID: COHFdNiJIqm

--HG--
rename : toolkit/crashreporter/test/unit/test_crashreporter_crash.js => toolkit/crashreporter/test/unit_ipc/test_content_memory_list.js
extra : rebase_source : b8cd3465d10438116a10553ba3eedf5e4cf23f32
This commit is contained in:
Ted Mielczarek 2016-04-13 08:05:46 -04:00
parent f269e60c82
commit 9dd47ee41b
4 changed files with 62 additions and 37 deletions

View File

@ -1364,6 +1364,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()
@ -1521,36 +1556,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
@ -1594,7 +1599,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
nullptr,
#ifdef XP_WIN32
google_breakpad::ExceptionHandler::HANDLER_ALL,
minidump_type,
GetMinidumpType(),
(const wchar_t*) nullptr,
nullptr);
#else
@ -3482,7 +3487,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

@ -11,3 +11,5 @@ support-files =
[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'