mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
[Cleanup] Fix circular dependency on Windows.
Crashpad currently has a circular dependency: client->snapshot->client. The dependency from snapshot -> client only exists to pull in a single constant for Windows (CrashpadClient::kTriggeredExceptionCode), so this change breaks the dependency by splitting the constant out into a new file util/win/exception_codes.h. Change-Id: I6b74b367df716e097758e63a44c53cb92ea5e04d Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3450763 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
parent
4112c11b77
commit
e9937cb36c
@ -702,17 +702,6 @@ class CrashpadClient {
|
||||
static bool DumpAndCrashTargetProcess(HANDLE process,
|
||||
HANDLE blame_thread,
|
||||
DWORD exception_code);
|
||||
|
||||
enum : uint32_t {
|
||||
//! \brief The exception code (roughly "Client called") used when
|
||||
//! DumpAndCrashTargetProcess() triggers an exception in a target
|
||||
//! process.
|
||||
//!
|
||||
//! \note This value does not have any bits of the top nibble set, to avoid
|
||||
//! confusion with real exception codes which tend to have those bits
|
||||
//! set.
|
||||
kTriggeredExceptionCode = 0xcca11ed,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_APPLE) || DOXYGEN
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "util/win/command_line.h"
|
||||
#include "util/win/context_wrappers.h"
|
||||
#include "util/win/critical_section_with_debug_info.h"
|
||||
#include "util/win/exception_codes.h"
|
||||
#include "util/win/get_function.h"
|
||||
#include "util/win/handle.h"
|
||||
#include "util/win/initial_client_data.h"
|
||||
@ -926,7 +927,7 @@ bool CrashpadClient::DumpAndCrashTargetProcess(HANDLE process,
|
||||
|
||||
// ecx = kTriggeredExceptionCode for dwExceptionCode.
|
||||
data_to_write.push_back(0xb9);
|
||||
AddUint32(&data_to_write, kTriggeredExceptionCode);
|
||||
AddUint32(&data_to_write, ExceptionCodes::kTriggeredExceptionCode);
|
||||
|
||||
// jmp to RaiseException() via rax.
|
||||
data_to_write.push_back(0x48); // mov rax, imm.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "test/test_paths.h"
|
||||
#include "test/win/child_launcher.h"
|
||||
#include "util/file/file_io.h"
|
||||
#include "util/win/exception_codes.h"
|
||||
#include "util/win/scoped_handle.h"
|
||||
#include "util/win/xp_compat.h"
|
||||
|
||||
@ -108,7 +109,7 @@ 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;
|
||||
expect_exit_code = ExceptionCodes::kTriggeredExceptionCode;
|
||||
if (!CrashpadClient::DumpAndCrashTargetProcess(
|
||||
child.process_handle(), 0, 0))
|
||||
return EXIT_FAILURE;
|
||||
|
@ -254,7 +254,6 @@ crashpad_static_library("snapshot") {
|
||||
]
|
||||
|
||||
if (crashpad_is_win) {
|
||||
deps += [ "../client" ]
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
libs = [ "powrprof.lib" ]
|
||||
}
|
||||
@ -442,10 +441,6 @@ source_set("snapshot_test") {
|
||||
"../util",
|
||||
]
|
||||
|
||||
if (crashpad_is_win) {
|
||||
deps += [ "../client" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_ios) {
|
||||
deps += [
|
||||
":snapshot_test_ios_data",
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include "snapshot/win/exception_snapshot_win.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "client/crashpad_client.h"
|
||||
#include "snapshot/capture_memory.h"
|
||||
#include "snapshot/memory_snapshot.h"
|
||||
#include "snapshot/memory_snapshot_generic.h"
|
||||
#include "snapshot/win/capture_memory_delegate_win.h"
|
||||
#include "snapshot/win/cpu_context_win.h"
|
||||
#include "snapshot/win/process_reader_win.h"
|
||||
#include "util/win/exception_codes.h"
|
||||
#include "util/win/nt_internals.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -215,7 +215,7 @@ bool ExceptionSnapshotWin::InitializeFromExceptionPointers(
|
||||
}
|
||||
|
||||
const bool triggered_by_client =
|
||||
first_record.ExceptionCode == CrashpadClient::kTriggeredExceptionCode &&
|
||||
first_record.ExceptionCode == ExceptionCodes::kTriggeredExceptionCode &&
|
||||
first_record.NumberParameters == 2;
|
||||
if (triggered_by_client)
|
||||
process_reader->DecrementThreadSuspendCounts(exception_thread_id);
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "client/crashpad_client.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "snapshot/win/process_snapshot_win.h"
|
||||
#include "test/errors.h"
|
||||
|
@ -468,6 +468,7 @@ crashpad_static_library("util") {
|
||||
"win/critical_section_with_debug_info.h",
|
||||
"win/exception_handler_server.cc",
|
||||
"win/exception_handler_server.h",
|
||||
"win/exception_codes.h",
|
||||
"win/get_function.cc",
|
||||
"win/get_function.h",
|
||||
"win/get_module_information.cc",
|
||||
|
37
util/win/exception_codes.h
Normal file
37
util/win/exception_codes.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2022 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_WIN_EXCEPTION_CODES_H_
|
||||
#define CRASHPAD_UTIL_WIN_EXCEPTION_CODES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
//! \brief Crashpad-specific exception codes that are used as arguments to
|
||||
//! `RaiseException()` in unusual circumstances.
|
||||
enum ExceptionCodes : uint32_t {
|
||||
//! \brief The exception code (roughly "Client called") used when
|
||||
//! DumpAndCrashTargetProcess() triggers an exception in a target
|
||||
//! process.
|
||||
//!
|
||||
//! \note This value does not have any bits of the top nibble set, to avoid
|
||||
//! confusion with real exception codes which tend to have those bits
|
||||
//! set.
|
||||
kTriggeredExceptionCode = 0xcca11ed,
|
||||
};
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_WIN_EXCEPTION_CODES_H_
|
Loading…
x
Reference in New Issue
Block a user