From 885fb47a0de6e757cd0f427648534a9e653d879c Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Fri, 2 Feb 2018 12:47:44 -0800 Subject: [PATCH] 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 Reviewed-by: Mark Mentovai --- client/crashpad_client.h | 6 +++--- client/crashpad_client_win.cc | 3 ++- handler/win/crash_other_program.cc | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/crashpad_client.h b/client/crashpad_client.h index 1f5bae65..7cf2eb8a 100644 --- a/client/crashpad_client.h +++ b/client/crashpad_client.h @@ -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 diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc index 7d9c1fb2..dd25c9ef 100644 --- a/client/crashpad_client_win.cc +++ b/client/crashpad_client_win.cc @@ -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)); diff --git a/handler/win/crash_other_program.cc b/handler/win/crash_other_program.cc index 2b62aea2..55c06994 100644 --- a/handler/win/crash_other_program.cc +++ b/handler/win/crash_other_program.cc @@ -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; } }