Make CrashpadClient::DumpAndCrashTargetProcess static

Noticed during discussion for
https://chromium-review.googlesource.com/c/chromium/src/+/896638 and the
linked bug that there's no need for this to be an instance method. Make
it static as it's easier to use.

Bug: chromium:806661
Change-Id: I24b893e58a47b5256b3b1b43dd5f1fc2d7cc6be8
Reviewed-on: https://chromium-review.googlesource.com/898439
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Scott Graham 2018-02-02 12:47:44 -08:00 committed by Commit Bot
parent 9b6c69cbb5
commit 885fb47a0d
3 changed files with 10 additions and 8 deletions

View File

@ -304,9 +304,9 @@ class CrashpadClient {
//! used as the exception code in the exception record.
//!
//! \return `true` if the exception was triggered successfully.
bool DumpAndCrashTargetProcess(HANDLE process,
HANDLE blame_thread,
DWORD exception_code) const;
static bool DumpAndCrashTargetProcess(HANDLE process,
HANDLE blame_thread,
DWORD exception_code);
enum : uint32_t {
//! \brief The exception code (roughly "Client called") used when

View File

@ -790,9 +790,10 @@ void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) {
UnhandledExceptionHandler(exception_pointers);
}
// static
bool CrashpadClient::DumpAndCrashTargetProcess(HANDLE process,
HANDLE blame_thread,
DWORD exception_code) const {
DWORD exception_code) {
// Confirm we're on Vista or later.
const DWORD version = GetVersion();
const DWORD major_version = LOBYTE(LOWORD(version));

View File

@ -33,7 +33,7 @@ namespace {
constexpr DWORD kCrashAndDumpTargetExitCode = 0xdeadbea7;
bool CrashAndDumpTarget(const CrashpadClient& client, HANDLE process) {
bool CrashAndDumpTarget(HANDLE process) {
DWORD target_pid = GetProcessId(process);
ScopedFileHANDLE thread_snap(CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0));
@ -61,7 +61,7 @@ bool CrashAndDumpTarget(const CrashpadClient& client, HANDLE process) {
PLOG(ERROR) << "OpenThread";
return false;
}
if (!client.DumpAndCrashTargetProcess(
if (!CrashpadClient::DumpAndCrashTargetProcess(
process, thread.get(), kCrashAndDumpTargetExitCode)) {
return false;
}
@ -109,11 +109,12 @@ int CrashOtherProgram(int argc, wchar_t* argv[]) {
DWORD expect_exit_code;
if (argc == 3 && wcscmp(argv[2], L"noexception") == 0) {
expect_exit_code = CrashpadClient::kTriggeredExceptionCode;
if (!client.DumpAndCrashTargetProcess(child.process_handle(), 0, 0))
if (!CrashpadClient::DumpAndCrashTargetProcess(
child.process_handle(), 0, 0))
return EXIT_FAILURE;
} else {
expect_exit_code = kCrashAndDumpTargetExitCode;
if (!CrashAndDumpTarget(client, child.process_handle())) {
if (!CrashAndDumpTarget(child.process_handle())) {
return EXIT_FAILURE;
}
}