diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/tools/minidumpwriter | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/tools/minidumpwriter')
-rw-r--r-- | testing/tools/minidumpwriter/minidumpwriter.cpp | 59 | ||||
-rw-r--r-- | testing/tools/minidumpwriter/moz.build | 19 |
2 files changed, 78 insertions, 0 deletions
diff --git a/testing/tools/minidumpwriter/minidumpwriter.cpp b/testing/tools/minidumpwriter/minidumpwriter.cpp new file mode 100644 index 000000000..1335006ff --- /dev/null +++ b/testing/tools/minidumpwriter/minidumpwriter.cpp @@ -0,0 +1,59 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/* + * Given a PID and a path to a target file, write a minidump of the + * corresponding process in that file. This is taken more or less + * verbatim from mozcrash and translated to C++ to avoid problems + * writing a minidump of 64 bit Firefox from a 32 bit python. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> +#include <dbghelp.h> + +int wmain(int argc, wchar_t** argv) +{ + if (argc != 3) { + fprintf(stderr, "Usage: minidumpwriter <PID> <DUMP_FILE>\n"); + return 1; + } + + DWORD pid = (DWORD) _wtoi(argv[1]); + + if (pid <= 0) { + fprintf(stderr, "Usage: minidumpwriter <PID> <DUMP_FILE>\n"); + return 1; + } + + wchar_t* dumpfile = argv[2]; + int rv = 1; + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + 0, pid); + if (!hProcess) { + fprintf(stderr, "Couldn't get handle for %d\n", pid); + return rv; + } + + HANDLE file = CreateFileW(dumpfile, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); + if (file == INVALID_HANDLE_VALUE) { + fprintf(stderr, "Couldn't open dump file at %S\n", dumpfile); + CloseHandle(hProcess); + return rv; + } + + rv = 0; + if (!MiniDumpWriteDump(hProcess, pid, file, MiniDumpNormal, + nullptr, nullptr, nullptr)) { + fprintf(stderr, "Error 0x%X in MiniDumpWriteDump\n", GetLastError()); + rv = 1; + } + + CloseHandle(file); + CloseHandle(hProcess); + return rv; +} diff --git a/testing/tools/minidumpwriter/moz.build b/testing/tools/minidumpwriter/moz.build new file mode 100644 index 000000000..21cf9b416 --- /dev/null +++ b/testing/tools/minidumpwriter/moz.build @@ -0,0 +1,19 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +if CONFIG['ENABLE_TESTS'] and CONFIG['CPU_ARCH'] == 'x86_64' and CONFIG['OS_ARCH'] == 'WINNT': + Program('minidumpwriter') + OS_LIBS += [ + 'dbghelp', + ] + SOURCES += [ + 'minidumpwriter.cpp', + ] + USE_STATIC_LIBS = True + if CONFIG['GNU_CC']: + WIN32_EXE_LDFLAGS += ['-municode'] + +NO_PGO = True |