From 2b05eb522fa43501179b31893fb18f8f2ea222e2 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Thu, 22 Feb 2018 12:12:26 -0800 Subject: [PATCH] Rename ProcessReader to platform-suffixed versions Mac's ProcessReader becomes ProcessReaderMac. Linux/Android's ProcessReader becomes ProcessReaderLinux. Fuchsia's ProcessReader becomes ProcessReaderFuchsia. No intended change in behavior. Bug: crashpad:196, crashpad:30 Change-Id: I7ec8d72f79533bd78189173261ade2ad99010bad Reviewed-on: https://chromium-review.googlesource.com/930321 Reviewed-by: Mark Mentovai Commit-Queue: Scott Graham --- snapshot/BUILD.gn | 18 +- ...ss_reader.cc => process_reader_fuchsia.cc} | 28 +-- ...cess_reader.h => process_reader_fuchsia.h} | 10 +- ...test.cc => process_reader_fuchsia_test.cc} | 10 +- snapshot/fuchsia/process_snapshot_fuchsia.cc | 3 +- snapshot/fuchsia/process_snapshot_fuchsia.h | 4 +- snapshot/linux/exception_snapshot_linux.cc | 14 +- snapshot/linux/exception_snapshot_linux.h | 11 +- .../linux/exception_snapshot_linux_test.cc | 8 +- ...cess_reader.cc => process_reader_linux.cc} | 34 ++-- ...rocess_reader.h => process_reader_linux.h} | 20 +-- ...r_test.cc => process_reader_linux_test.cc} | 50 +++--- snapshot/linux/process_snapshot_linux.cc | 7 +- snapshot/linux/process_snapshot_linux.h | 4 +- snapshot/linux/system_snapshot_linux.cc | 2 +- snapshot/linux/system_snapshot_linux.h | 13 +- snapshot/linux/system_snapshot_linux_test.cc | 4 +- snapshot/linux/thread_snapshot_linux.cc | 5 +- snapshot/linux/thread_snapshot_linux.h | 14 +- snapshot/mac/exception_snapshot_mac.cc | 9 +- snapshot/mac/exception_snapshot_mac.h | 8 +- .../mac/mach_o_image_annotations_reader.cc | 7 +- .../mac/mach_o_image_annotations_reader.h | 6 +- .../mach_o_image_annotations_reader_test.cc | 14 +- snapshot/mac/mach_o_image_reader.cc | 4 +- snapshot/mac/mach_o_image_reader.h | 6 +- snapshot/mac/mach_o_image_reader_test.cc | 6 +- snapshot/mac/mach_o_image_segment_reader.cc | 4 +- snapshot/mac/mach_o_image_segment_reader.h | 2 +- .../mac/mach_o_image_symbol_table_reader.cc | 6 +- .../mac/mach_o_image_symbol_table_reader.h | 4 +- snapshot/mac/module_snapshot_mac.cc | 4 +- snapshot/mac/module_snapshot_mac.h | 14 +- ...rocess_reader.cc => process_reader_mac.cc} | 59 +++---- ...{process_reader.h => process_reader_mac.h} | 16 +- ...der_test.cc => process_reader_mac_test.cc} | 131 +++++++------- snapshot/mac/process_snapshot_mac.cc | 8 +- snapshot/mac/process_snapshot_mac.h | 4 +- snapshot/mac/process_types.cc | 52 +++--- snapshot/mac/process_types.h | 160 +++++++++--------- snapshot/mac/process_types/custom.cc | 44 ++--- snapshot/mac/process_types_test.cc | 2 +- snapshot/mac/system_snapshot_mac.cc | 4 +- snapshot/mac/system_snapshot_mac.h | 13 +- snapshot/mac/system_snapshot_mac_test.cc | 6 +- snapshot/mac/thread_snapshot_mac.cc | 6 +- snapshot/mac/thread_snapshot_mac.h | 16 +- snapshot/snapshot.gyp | 8 +- snapshot/snapshot_test.gyp | 4 +- snapshot/win/exception_snapshot_win.h | 4 +- snapshot/win/module_snapshot_win.h | 8 +- test/mac/dyld.cc | 4 +- 52 files changed, 451 insertions(+), 451 deletions(-) rename snapshot/fuchsia/{process_reader.cc => process_reader_fuchsia.cc} (91%) rename snapshot/fuchsia/{process_reader.h => process_reader_fuchsia.h} (95%) rename snapshot/fuchsia/{process_reader_test.cc => process_reader_fuchsia_test.cc} (92%) rename snapshot/linux/{process_reader.cc => process_reader_linux.cc} (91%) rename snapshot/linux/{process_reader.h => process_reader_linux.h} (91%) rename snapshot/linux/{process_reader_test.cc => process_reader_linux_test.cc} (93%) rename snapshot/mac/{process_reader.cc => process_reader_mac.cc} (94%) rename snapshot/mac/{process_reader.h => process_reader_mac.h} (96%) rename snapshot/mac/{process_reader_test.cc => process_reader_mac_test.cc} (88%) diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 53311b88..84df23f1 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -79,8 +79,8 @@ static_library("snapshot") { "mac/mach_o_image_symbol_table_reader.h", "mac/module_snapshot_mac.cc", "mac/module_snapshot_mac.h", - "mac/process_reader.cc", - "mac/process_reader.h", + "mac/process_reader_mac.cc", + "mac/process_reader_mac.h", "mac/process_snapshot_mac.cc", "mac/process_snapshot_mac.h", "mac/process_types.cc", @@ -111,8 +111,8 @@ static_library("snapshot") { "linux/debug_rendezvous.h", "linux/exception_snapshot_linux.cc", "linux/exception_snapshot_linux.h", - "linux/process_reader.cc", - "linux/process_reader.h", + "linux/process_reader_linux.cc", + "linux/process_reader_linux.h", "linux/process_snapshot_linux.cc", "linux/process_snapshot_linux.h", "linux/signal_context.h", @@ -175,8 +175,8 @@ static_library("snapshot") { if (crashpad_is_fuchsia) { sources += [ - "fuchsia/process_reader.cc", - "fuchsia/process_reader.h", + "fuchsia/process_reader_fuchsia.cc", + "fuchsia/process_reader_fuchsia.h", "fuchsia/process_snapshot_fuchsia.cc", "fuchsia/process_snapshot_fuchsia.h", ] @@ -294,7 +294,7 @@ source_set("snapshot_test") { "mac/mach_o_image_annotations_reader_test.cc", "mac/mach_o_image_reader_test.cc", "mac/mach_o_image_segment_reader_test.cc", - "mac/process_reader_test.cc", + "mac/process_reader_mac_test.cc", "mac/process_types_test.cc", "mac/system_snapshot_mac_test.cc", ] @@ -304,7 +304,7 @@ source_set("snapshot_test") { sources += [ "linux/debug_rendezvous_test.cc", "linux/exception_snapshot_linux_test.cc", - "linux/process_reader_test.cc", + "linux/process_reader_linux_test.cc", "linux/system_snapshot_linux_test.cc", ] } else { @@ -342,7 +342,7 @@ source_set("snapshot_test") { } if (crashpad_is_fuchsia) { - sources += [ "fuchsia/process_reader_test.cc" ] + sources += [ "fuchsia/process_reader_fuchsia_test.cc" ] } # public_configs isn’t quite right. snapshot_test_link sets ldflags, and diff --git a/snapshot/fuchsia/process_reader.cc b/snapshot/fuchsia/process_reader_fuchsia.cc similarity index 91% rename from snapshot/fuchsia/process_reader.cc rename to snapshot/fuchsia/process_reader_fuchsia.cc index be9fa775..1ace0d13 100644 --- a/snapshot/fuchsia/process_reader.cc +++ b/snapshot/fuchsia/process_reader_fuchsia.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/fuchsia/process_reader.h" +#include "snapshot/fuchsia/process_reader_fuchsia.h" #include #include @@ -23,19 +23,19 @@ namespace crashpad { -ProcessReader::Module::Module() = default; +ProcessReaderFuchsia::Module::Module() = default; -ProcessReader::Module::~Module() = default; +ProcessReaderFuchsia::Module::~Module() = default; -ProcessReader::Thread::Thread() = default; +ProcessReaderFuchsia::Thread::Thread() = default; -ProcessReader::Thread::~Thread() = default; +ProcessReaderFuchsia::Thread::~Thread() = default; -ProcessReader::ProcessReader() = default; +ProcessReaderFuchsia::ProcessReaderFuchsia() = default; -ProcessReader::~ProcessReader() = default; +ProcessReaderFuchsia::~ProcessReaderFuchsia() = default; -bool ProcessReader::Initialize(zx_handle_t process) { +bool ProcessReaderFuchsia::Initialize(zx_handle_t process) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); process_ = process; @@ -47,7 +47,8 @@ bool ProcessReader::Initialize(zx_handle_t process) { return true; } -const std::vector& ProcessReader::Modules() { +const std::vector& +ProcessReaderFuchsia::Modules() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_modules_) { @@ -57,7 +58,8 @@ const std::vector& ProcessReader::Modules() { return modules_; } -const std::vector& ProcessReader::Threads() { +const std::vector& +ProcessReaderFuchsia::Threads() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_threads_) { @@ -67,7 +69,7 @@ const std::vector& ProcessReader::Threads() { return threads_; } -void ProcessReader::InitializeModules() { +void ProcessReaderFuchsia::InitializeModules() { DCHECK(!initialized_modules_); DCHECK(modules_.empty()); @@ -181,7 +183,7 @@ void ProcessReader::InitializeModules() { } } -void ProcessReader::InitializeThreads() { +void ProcessReaderFuchsia::InitializeThreads() { DCHECK(!initialized_threads_); DCHECK(threads_.empty()); @@ -220,7 +222,7 @@ void ProcessReader::InitializeThreads() { for (const zx_koid_t thread_koid : threads) { zx_handle_t raw_handle; zx_status_t status = zx_object_get_child( - process_, thread_koid, ZX_RIGHT_SAME_RIGHTS, &raw_handle); + process_, thread_koid, ZX_RIGHT_SAME_RIGHTS, &raw_handle); if (status != ZX_OK) { ZX_LOG(ERROR, status) << "zx_object_get_child"; // TODO(scottmg): Decide if it's worthwhile adding a mostly-empty Thread diff --git a/snapshot/fuchsia/process_reader.h b/snapshot/fuchsia/process_reader_fuchsia.h similarity index 95% rename from snapshot/fuchsia/process_reader.h rename to snapshot/fuchsia/process_reader_fuchsia.h index 0e83fba7..d0811cfe 100644 --- a/snapshot/fuchsia/process_reader.h +++ b/snapshot/fuchsia/process_reader_fuchsia.h @@ -30,7 +30,7 @@ namespace crashpad { //! \brief Accesses information about another process, identified by a Fuchsia //! process. -class ProcessReader { +class ProcessReaderFuchsia { public: //! \brief Contains information about a module loaded into a process. struct Module { @@ -44,7 +44,7 @@ class ProcessReader { //! \brief An image reader for the module. //! //! The lifetime of this ElfImageReader is scoped to the lifetime of the - //! ProcessReader that created it. + //! ProcessReaderFuchsia that created it. //! //! This field may be `nullptr` if a reader could not be created for the //! module. @@ -70,8 +70,8 @@ class ProcessReader { std::string name; }; - ProcessReader(); - ~ProcessReader(); + ProcessReaderFuchsia(); + ~ProcessReaderFuchsia(); //! \brief Initializes this object. This method must be called before any //! other. @@ -113,7 +113,7 @@ class ProcessReader { bool initialized_threads_ = false; InitializationStateDcheck initialized_; - DISALLOW_COPY_AND_ASSIGN(ProcessReader); + DISALLOW_COPY_AND_ASSIGN(ProcessReaderFuchsia); }; } // namespace crashpad diff --git a/snapshot/fuchsia/process_reader_test.cc b/snapshot/fuchsia/process_reader_fuchsia_test.cc similarity index 92% rename from snapshot/fuchsia/process_reader_test.cc rename to snapshot/fuchsia/process_reader_fuchsia_test.cc index 8a89b97a..35af291c 100644 --- a/snapshot/fuchsia/process_reader_test.cc +++ b/snapshot/fuchsia/process_reader_fuchsia_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/fuchsia/process_reader.h" +#include "snapshot/fuchsia/process_reader_fuchsia.h" #include #include @@ -24,8 +24,8 @@ namespace crashpad { namespace test { namespace { -TEST(ProcessReader, SelfBasic) { - ProcessReader process_reader; +TEST(ProcessReaderFuchsia, SelfBasic) { + ProcessReaderFuchsia process_reader; ASSERT_TRUE(process_reader.Initialize(zx_process_self())); static constexpr char kTestMemory[] = "Some test memory"; @@ -73,7 +73,7 @@ class BasicChildTest : public MultiprocessExec { private: void MultiprocessParent() override { - ProcessReader process_reader; + ProcessReaderFuchsia process_reader; ASSERT_TRUE(process_reader.Initialize(zx_process_self())); std::string read_string; @@ -85,7 +85,7 @@ class BasicChildTest : public MultiprocessExec { DISALLOW_COPY_AND_ASSIGN(BasicChildTest); }; -TEST(ProcessReader, ChildBasic) { +TEST(ProcessReaderFuchsia, ChildBasic) { BasicChildTest test; test.Run(); } diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.cc b/snapshot/fuchsia/process_snapshot_fuchsia.cc index ce8b0ea8..f3d22907 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.cc +++ b/snapshot/fuchsia/process_snapshot_fuchsia.cc @@ -171,7 +171,8 @@ std::vector ProcessSnapshotFuchsia::ExtraMemory() const { } void ProcessSnapshotFuchsia::InitializeModules() { - for (const ProcessReader::Module& reader_module : process_reader_.Modules()) { + for (const ProcessReaderFuchsia::Module& reader_module : + process_reader_.Modules()) { auto module = std::make_unique( reader_module.name, reader_module.reader, reader_module.type); if (module->Initialize()) { diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.h b/snapshot/fuchsia/process_snapshot_fuchsia.h index 04e2d29d..d94dec7b 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.h +++ b/snapshot/fuchsia/process_snapshot_fuchsia.h @@ -24,7 +24,7 @@ #include "snapshot/crashpad_info_client_options.h" #include "snapshot/elf/elf_image_reader.h" #include "snapshot/elf/module_snapshot_elf.h" -#include "snapshot/fuchsia/process_reader.h" +#include "snapshot/fuchsia/process_reader_fuchsia.h" #include "snapshot/process_snapshot.h" #include "snapshot/unloaded_module_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -77,7 +77,7 @@ class ProcessSnapshotFuchsia : public ProcessSnapshot { void InitializeModules(); std::vector> modules_; - ProcessReader process_reader_; + ProcessReaderFuchsia process_reader_; std::map annotations_simple_map_; InitializationStateDcheck initialized_; diff --git a/snapshot/linux/exception_snapshot_linux.cc b/snapshot/linux/exception_snapshot_linux.cc index 498b1f79..fa2e8f94 100644 --- a/snapshot/linux/exception_snapshot_linux.cc +++ b/snapshot/linux/exception_snapshot_linux.cc @@ -18,7 +18,7 @@ #include "base/logging.h" #include "snapshot/linux/cpu_context_linux.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/linux/signal_context.h" #include "util/linux/traits.h" #include "util/misc/reinterpret_bytes.h" @@ -43,7 +43,7 @@ ExceptionSnapshotLinux::~ExceptionSnapshotLinux() {} #if defined(ARCH_CPU_X86_FAMILY) template <> bool ExceptionSnapshotLinux::ReadContext( - ProcessReader* reader, + ProcessReaderLinux* reader, LinuxVMAddress context_address) { UContext ucontext; if (!reader->Memory()->Read(context_address, sizeof(ucontext), &ucontext)) { @@ -79,7 +79,7 @@ bool ExceptionSnapshotLinux::ReadContext( template <> bool ExceptionSnapshotLinux::ReadContext( - ProcessReader* reader, + ProcessReaderLinux* reader, LinuxVMAddress context_address) { UContext ucontext; if (!reader->Memory()->Read(context_address, sizeof(ucontext), &ucontext)) { @@ -99,7 +99,7 @@ bool ExceptionSnapshotLinux::ReadContext( template <> bool ExceptionSnapshotLinux::ReadContext( - ProcessReader* reader, + ProcessReaderLinux* reader, LinuxVMAddress context_address) { context_.architecture = kCPUArchitectureARM; context_.arm = &context_union_.arm; @@ -179,7 +179,7 @@ bool ExceptionSnapshotLinux::ReadContext( template <> bool ExceptionSnapshotLinux::ReadContext( - ProcessReader* reader, + ProcessReaderLinux* reader, LinuxVMAddress context_address) { context_.architecture = kCPUArchitectureARM64; context_.arm64 = &context_union_.arm64; @@ -253,7 +253,7 @@ bool ExceptionSnapshotLinux::ReadContext( #endif // ARCH_CPU_X86_FAMILY -bool ExceptionSnapshotLinux::Initialize(ProcessReader* process_reader, +bool ExceptionSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, LinuxVMAddress siginfo_address, LinuxVMAddress context_address, pid_t thread_id) { @@ -278,7 +278,7 @@ bool ExceptionSnapshotLinux::Initialize(ProcessReader* process_reader, } template -bool ExceptionSnapshotLinux::ReadSiginfo(ProcessReader* reader, +bool ExceptionSnapshotLinux::ReadSiginfo(ProcessReaderLinux* reader, LinuxVMAddress siginfo_address) { Siginfo siginfo; if (!reader->Memory()->Read(siginfo_address, sizeof(siginfo), &siginfo)) { diff --git a/snapshot/linux/exception_snapshot_linux.h b/snapshot/linux/exception_snapshot_linux.h index 73949668..0dcead7b 100644 --- a/snapshot/linux/exception_snapshot_linux.h +++ b/snapshot/linux/exception_snapshot_linux.h @@ -24,7 +24,7 @@ #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/exception_snapshot.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/memory_snapshot.h" #include "util/linux/address_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -41,7 +41,8 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the process that received + //! \param[in] process_reader A ProcessReaderLinux for the process that + //! received //! the signal. //! \param[in] siginfo_address The address in the target process' address //! space of the siginfo_t passed to the signal handler. @@ -51,7 +52,7 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot { //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(ProcessReader* process_reader, + bool Initialize(ProcessReaderLinux* process_reader, LinuxVMAddress siginfo_address, LinuxVMAddress context_address, pid_t thread_id); @@ -68,10 +69,10 @@ class ExceptionSnapshotLinux final : public ExceptionSnapshot { private: template - bool ReadSiginfo(ProcessReader* reader, LinuxVMAddress siginfo_address); + bool ReadSiginfo(ProcessReaderLinux* reader, LinuxVMAddress siginfo_address); template - bool ReadContext(ProcessReader* reader, LinuxVMAddress context_address); + bool ReadContext(ProcessReaderLinux* reader, LinuxVMAddress context_address); union { #if defined(ARCH_CPU_X86_FAMILY) diff --git a/snapshot/linux/exception_snapshot_linux_test.cc b/snapshot/linux/exception_snapshot_linux_test.cc index 24f0ef52..4add607d 100644 --- a/snapshot/linux/exception_snapshot_linux_test.cc +++ b/snapshot/linux/exception_snapshot_linux_test.cc @@ -25,7 +25,7 @@ #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "snapshot/cpu_architecture.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/linux/signal_context.h" #include "sys/syscall.h" #include "test/errors.h" @@ -271,7 +271,7 @@ TEST(ExceptionSnapshotLinux, SelfBasic) { FakePtraceConnection connection; ASSERT_TRUE(connection.Initialize(getpid())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); siginfo_t siginfo; @@ -348,7 +348,7 @@ class RaiseTest { FakePtraceConnection connection; ASSERT_TRUE(connection.Initialize(getpid())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); internal::ExceptionSnapshotLinux exception; @@ -411,7 +411,7 @@ class TimerTest { FakePtraceConnection connection; ASSERT_TRUE(connection.Initialize(getpid())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); internal::ExceptionSnapshotLinux exception; diff --git a/snapshot/linux/process_reader.cc b/snapshot/linux/process_reader_linux.cc similarity index 91% rename from snapshot/linux/process_reader.cc rename to snapshot/linux/process_reader_linux.cc index 0f196c63..40b14068 100644 --- a/snapshot/linux/process_reader.cc +++ b/snapshot/linux/process_reader_linux.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include #include @@ -46,7 +46,7 @@ bool ShouldMergeStackMappings(const MemoryMap::Mapping& stack_mapping, } // namespace -ProcessReader::Thread::Thread() +ProcessReaderLinux::Thread::Thread() : thread_info(), stack_region_address(0), stack_region_size(0), @@ -54,9 +54,10 @@ ProcessReader::Thread::Thread() static_priority(-1), nice_value(-1) {} -ProcessReader::Thread::~Thread() {} +ProcessReaderLinux::Thread::~Thread() {} -bool ProcessReader::Thread::InitializePtrace(PtraceConnection* connection) { +bool ProcessReaderLinux::Thread::InitializePtrace( + PtraceConnection* connection) { if (!connection->GetThreadInfo(tid, &thread_info)) { return false; } @@ -89,7 +90,7 @@ bool ProcessReader::Thread::InitializePtrace(PtraceConnection* connection) { return true; } -void ProcessReader::Thread::InitializeStack(ProcessReader* reader) { +void ProcessReaderLinux::Thread::InitializeStack(ProcessReaderLinux* reader) { LinuxVMAddress stack_pointer; #if defined(ARCH_CPU_X86_FAMILY) stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.rsp @@ -169,12 +170,12 @@ void ProcessReader::Thread::InitializeStack(ProcessReader* reader) { } } -ProcessReader::Module::Module() +ProcessReaderLinux::Module::Module() : name(), elf_reader(nullptr), type(ModuleSnapshot::kModuleTypeUnknown) {} -ProcessReader::Module::~Module() = default; +ProcessReaderLinux::Module::~Module() = default; -ProcessReader::ProcessReader() +ProcessReaderLinux::ProcessReaderLinux() : connection_(), process_info_(), memory_map_(), @@ -187,9 +188,9 @@ ProcessReader::ProcessReader() initialized_modules_(false), initialized_() {} -ProcessReader::~ProcessReader() {} +ProcessReaderLinux::~ProcessReaderLinux() {} -bool ProcessReader::Initialize(PtraceConnection* connection) { +bool ProcessReaderLinux::Initialize(PtraceConnection* connection) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); DCHECK(connection); connection_ = connection; @@ -213,12 +214,13 @@ bool ProcessReader::Initialize(PtraceConnection* connection) { return true; } -bool ProcessReader::StartTime(timeval* start_time) const { +bool ProcessReaderLinux::StartTime(timeval* start_time) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return process_info_.StartTime(start_time); } -bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { +bool ProcessReaderLinux::CPUTimes(timeval* user_time, + timeval* system_time) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); timerclear(user_time); timerclear(system_time); @@ -253,7 +255,7 @@ bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { return true; } -const std::vector& ProcessReader::Threads() { +const std::vector& ProcessReaderLinux::Threads() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_threads_) { InitializeThreads(); @@ -261,7 +263,7 @@ const std::vector& ProcessReader::Threads() { return threads_; } -const std::vector& ProcessReader::Modules() { +const std::vector& ProcessReaderLinux::Modules() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_modules_) { InitializeModules(); @@ -269,7 +271,7 @@ const std::vector& ProcessReader::Modules() { return modules_; } -void ProcessReader::InitializeThreads() { +void ProcessReaderLinux::InitializeThreads() { DCHECK(threads_.empty()); pid_t pid = ProcessID(); @@ -326,7 +328,7 @@ void ProcessReader::InitializeThreads() { DCHECK(main_thread_found); } -void ProcessReader::InitializeModules() { +void ProcessReaderLinux::InitializeModules() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); AuxiliaryVector aux; diff --git a/snapshot/linux/process_reader.h b/snapshot/linux/process_reader_linux.h similarity index 91% rename from snapshot/linux/process_reader.h rename to snapshot/linux/process_reader_linux.h index 59a3c7ef..2e89655e 100644 --- a/snapshot/linux/process_reader.h +++ b/snapshot/linux/process_reader_linux.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_H_ -#define CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_H_ +#ifndef CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_LINUX_H_ +#define CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_LINUX_H_ #include #include @@ -38,7 +38,7 @@ namespace crashpad { //! \brief Accesses information about another process, identified by a process //! ID. -class ProcessReader { +class ProcessReaderLinux { public: //! \brief Contains information about a thread that belongs to a process. struct Thread { @@ -54,10 +54,10 @@ class ProcessReader { int nice_value; private: - friend class ProcessReader; + friend class ProcessReaderLinux; bool InitializePtrace(PtraceConnection* connection); - void InitializeStack(ProcessReader* reader); + void InitializeStack(ProcessReaderLinux* reader); }; //! \brief Contains information about a module loaded into a process. @@ -71,7 +71,7 @@ class ProcessReader { //! \brief An image reader for the module. //! //! The lifetime of this ElfImageReader is scoped to the lifetime of the - //! ProcessReader that created it. + //! ProcessReaderLinux that created it. //! //! This field may be `nullptr` if a reader could not be created for the //! module. @@ -81,8 +81,8 @@ class ProcessReader { ModuleSnapshot::ModuleType type; }; - ProcessReader(); - ~ProcessReader(); + ProcessReaderLinux(); + ~ProcessReaderLinux(); //! \brief Initializes this object. //! @@ -152,9 +152,9 @@ class ProcessReader { bool initialized_modules_; InitializationStateDcheck initialized_; - DISALLOW_COPY_AND_ASSIGN(ProcessReader); + DISALLOW_COPY_AND_ASSIGN(ProcessReaderLinux); }; } // namespace crashpad -#endif // CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_H_ +#endif // CRASHPAD_SNAPSHOT_LINUX_PROCESS_READER_LINUX_H_ diff --git a/snapshot/linux/process_reader_test.cc b/snapshot/linux/process_reader_linux_test.cc similarity index 93% rename from snapshot/linux/process_reader_test.cc rename to snapshot/linux/process_reader_linux_test.cc index a8190b39..11a606a9 100644 --- a/snapshot/linux/process_reader_test.cc +++ b/snapshot/linux/process_reader_linux_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include #include @@ -55,11 +55,11 @@ pid_t gettid() { return syscall(SYS_gettid); } -TEST(ProcessReader, SelfBasic) { +TEST(ProcessReaderLinux, SelfBasic) { FakePtraceConnection connection; connection.Initialize(getpid()); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); #if defined(ARCH_CPU_64_BITS) @@ -92,7 +92,7 @@ class BasicChildTest : public Multiprocess { DirectPtraceConnection connection; ASSERT_TRUE(connection.Initialize(ChildPID())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); #if !defined(ARCH_CPU_64_BITS) @@ -115,7 +115,7 @@ class BasicChildTest : public Multiprocess { DISALLOW_COPY_AND_ASSIGN(BasicChildTest); }; -TEST(ProcessReader, ChildBasic) { +TEST(ProcessReaderLinux, ChildBasic) { BasicChildTest test; test.Run(); } @@ -241,7 +241,7 @@ class TestThreadPool { using ThreadMap = std::map; void ExpectThreads(const ThreadMap& thread_map, - const std::vector& threads, + const std::vector& threads, const pid_t pid) { ASSERT_EQ(threads.size(), thread_map.size()); MemoryMap memory_map; @@ -302,9 +302,9 @@ class ChildThreadTest : public Multiprocess { DirectPtraceConnection connection; ASSERT_TRUE(connection.Initialize(ChildPID())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); - const std::vector& threads = + const std::vector& threads = process_reader.Threads(); ExpectThreads(thread_map, threads, ChildPID()); } @@ -350,12 +350,12 @@ class ChildThreadTest : public Multiprocess { DISALLOW_COPY_AND_ASSIGN(ChildThreadTest); }; -TEST(ProcessReader, ChildWithThreads) { +TEST(ProcessReaderLinux, ChildWithThreads) { ChildThreadTest test; test.Run(); } -TEST(ProcessReader, ChildThreadsWithSmallUserStacks) { +TEST(ProcessReaderLinux, ChildThreadsWithSmallUserStacks) { ChildThreadTest test(PTHREAD_STACK_MIN); test.Run(); } @@ -379,10 +379,10 @@ class ChildWithSplitStackTest : public Multiprocess { DirectPtraceConnection connection; ASSERT_TRUE(connection.Initialize(ChildPID())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); - const std::vector& threads = + const std::vector& threads = process_reader.Threads(); ASSERT_EQ(threads.size(), 1u); @@ -440,7 +440,7 @@ class ChildWithSplitStackTest : public Multiprocess { DISALLOW_COPY_AND_ASSIGN(ChildWithSplitStackTest); }; -TEST(ProcessReader, ChildWithSplitStack) { +TEST(ProcessReaderLinux, ChildWithSplitStack) { ChildWithSplitStackTest test; test.Run(); } @@ -454,7 +454,7 @@ int ExpectFindModule(dl_phdr_info* info, size_t size, void* data) { LinuxVMAddress{info->dlpi_addr}, FromPointerCast(info->dlpi_phdr))); auto modules = - reinterpret_cast*>(data); + reinterpret_cast*>(data); auto phdr_addr = FromPointerCast(info->dlpi_phdr); @@ -482,7 +482,8 @@ int ExpectFindModule(dl_phdr_info* info, size_t size, void* data) { } #endif // !OS_ANDROID || !ARCH_CPU_ARMEL || __ANDROID_API__ >= 21 -void ExpectModulesFromSelf(const std::vector& modules) { +void ExpectModulesFromSelf( + const std::vector& modules) { for (const auto& module : modules) { EXPECT_FALSE(module.name.empty()); EXPECT_NE(module.type, ModuleSnapshot::kModuleTypeUnknown); @@ -490,19 +491,20 @@ void ExpectModulesFromSelf(const std::vector& modules) { // Android doesn't provide dl_iterate_phdr on ARM until API 21. #if !defined(OS_ANDROID) || !defined(ARCH_CPU_ARMEL) || __ANDROID_API__ >= 21 - EXPECT_EQ(dl_iterate_phdr( - ExpectFindModule, - reinterpret_cast( - const_cast*>(&modules))), - 0); + EXPECT_EQ( + dl_iterate_phdr( + ExpectFindModule, + reinterpret_cast( + const_cast*>(&modules))), + 0); #endif // !OS_ANDROID || !ARCH_CPU_ARMEL || __ANDROID_API__ >= 21 } -TEST(ProcessReader, SelfModules) { +TEST(ProcessReaderLinux, SelfModules) { FakePtraceConnection connection; connection.Initialize(getpid()); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); ExpectModulesFromSelf(process_reader.Modules()); @@ -518,7 +520,7 @@ class ChildModuleTest : public Multiprocess { DirectPtraceConnection connection; ASSERT_TRUE(connection.Initialize(ChildPID())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); ExpectModulesFromSelf(process_reader.Modules()); @@ -529,7 +531,7 @@ class ChildModuleTest : public Multiprocess { DISALLOW_COPY_AND_ASSIGN(ChildModuleTest); }; -TEST(ProcessReader, ChildModules) { +TEST(ProcessReaderLinux, ChildModules) { ChildModuleTest test; test.Run(); } diff --git a/snapshot/linux/process_snapshot_linux.cc b/snapshot/linux/process_snapshot_linux.cc index ecb4eb0e..9e212445 100644 --- a/snapshot/linux/process_snapshot_linux.cc +++ b/snapshot/linux/process_snapshot_linux.cc @@ -213,9 +213,9 @@ std::vector ProcessSnapshotLinux::ExtraMemory() const { } void ProcessSnapshotLinux::InitializeThreads() { - const std::vector& process_reader_threads = + const std::vector& process_reader_threads = process_reader_.Threads(); - for (const ProcessReader::Thread& process_reader_thread : + for (const ProcessReaderLinux::Thread& process_reader_thread : process_reader_threads) { auto thread = std::make_unique(); if (thread->Initialize(&process_reader_, process_reader_thread)) { @@ -225,7 +225,8 @@ void ProcessSnapshotLinux::InitializeThreads() { } void ProcessSnapshotLinux::InitializeModules() { - for (const ProcessReader::Module& reader_module : process_reader_.Modules()) { + for (const ProcessReaderLinux::Module& reader_module : + process_reader_.Modules()) { auto module = std::make_unique( reader_module.name, reader_module.elf_reader, reader_module.type); if (module->Initialize()) { diff --git a/snapshot/linux/process_snapshot_linux.h b/snapshot/linux/process_snapshot_linux.h index 613913ce..25c414db 100644 --- a/snapshot/linux/process_snapshot_linux.h +++ b/snapshot/linux/process_snapshot_linux.h @@ -27,7 +27,7 @@ #include "snapshot/crashpad_info_client_options.h" #include "snapshot/elf/module_snapshot_elf.h" #include "snapshot/linux/exception_snapshot_linux.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/linux/system_snapshot_linux.h" #include "snapshot/linux/thread_snapshot_linux.h" #include "snapshot/memory_map_region_snapshot.h" @@ -127,7 +127,7 @@ class ProcessSnapshotLinux final : public ProcessSnapshot { std::vector> modules_; std::unique_ptr exception_; internal::SystemSnapshotLinux system_; - ProcessReader process_reader_; + ProcessReaderLinux process_reader_; InitializationStateDcheck initialized_; DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotLinux); diff --git a/snapshot/linux/system_snapshot_linux.cc b/snapshot/linux/system_snapshot_linux.cc index c9c64383..4c392888 100644 --- a/snapshot/linux/system_snapshot_linux.cc +++ b/snapshot/linux/system_snapshot_linux.cc @@ -151,7 +151,7 @@ SystemSnapshotLinux::SystemSnapshotLinux() SystemSnapshotLinux::~SystemSnapshotLinux() {} -void SystemSnapshotLinux::Initialize(ProcessReader* process_reader, +void SystemSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, const timeval* snapshot_time) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); process_reader_ = process_reader; diff --git a/snapshot/linux/system_snapshot_linux.h b/snapshot/linux/system_snapshot_linux.h index a9914500..d22c49a6 100644 --- a/snapshot/linux/system_snapshot_linux.h +++ b/snapshot/linux/system_snapshot_linux.h @@ -22,7 +22,7 @@ #include "base/macros.h" #include "build/build_config.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/system_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -44,9 +44,9 @@ class SystemSnapshotLinux final : public SystemSnapshot { //! \param[in] process_reader A reader for the process being snapshotted. //! \n\n //! It seems odd that a system snapshot implementation would need a - //! ProcessReader, but some of the information reported about the system - //! depends on the process it’s being reported for. For example, the - //! architecture returned by GetCPUArchitecture() should be the + //! ProcessReaderLinux, but some of the information reported about the + //! system depends on the process it’s being reported for. For example, + //! the architecture returned by GetCPUArchitecture() should be the //! architecture of the process, which may be different than the native //! architecture of the system: an x86_64 system can run both x86_64 and //! 32-bit x86 processes. @@ -57,7 +57,8 @@ class SystemSnapshotLinux final : public SystemSnapshot { //! Otherwise, it would need to base its determination on the current //! time, which may be different than the snapshot time for snapshots //! generated around the daylight saving transition time. - void Initialize(ProcessReader* process_reader, const timeval* snapshot_time); + void Initialize(ProcessReaderLinux* process_reader, + const timeval* snapshot_time); // SystemSnapshot: @@ -91,7 +92,7 @@ class SystemSnapshotLinux final : public SystemSnapshot { std::string os_version_full_; std::string os_version_build_; - ProcessReader* process_reader_; // weak + ProcessReaderLinux* process_reader_; // weak const timeval* snapshot_time_; // weak #if defined(ARCH_CPU_X86_FAMILY) CpuidReader cpuid_; diff --git a/snapshot/linux/system_snapshot_linux_test.cc b/snapshot/linux/system_snapshot_linux_test.cc index a91dfa41..46d3845f 100644 --- a/snapshot/linux/system_snapshot_linux_test.cc +++ b/snapshot/linux/system_snapshot_linux_test.cc @@ -21,7 +21,7 @@ #include "build/build_config.h" #include "gtest/gtest.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "test/errors.h" #include "test/linux/fake_ptrace_connection.h" @@ -33,7 +33,7 @@ TEST(SystemSnapshotLinux, Basic) { FakePtraceConnection connection; ASSERT_TRUE(connection.Initialize(getpid())); - ProcessReader process_reader; + ProcessReaderLinux process_reader; ASSERT_TRUE(process_reader.Initialize(&connection)); timeval snapshot_time; diff --git a/snapshot/linux/thread_snapshot_linux.cc b/snapshot/linux/thread_snapshot_linux.cc index f465a59c..084ed73a 100644 --- a/snapshot/linux/thread_snapshot_linux.cc +++ b/snapshot/linux/thread_snapshot_linux.cc @@ -37,9 +37,8 @@ ThreadSnapshotLinux::ThreadSnapshotLinux() ThreadSnapshotLinux::~ThreadSnapshotLinux() { } -bool ThreadSnapshotLinux::Initialize( - ProcessReader* process_reader, - const ProcessReader::Thread& thread) { +bool ThreadSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread& thread) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); #if defined(ARCH_CPU_X86_FAMILY) diff --git a/snapshot/linux/thread_snapshot_linux.h b/snapshot/linux/thread_snapshot_linux.h index 5741b0cb..8fc7e17e 100644 --- a/snapshot/linux/thread_snapshot_linux.h +++ b/snapshot/linux/thread_snapshot_linux.h @@ -20,7 +20,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" -#include "snapshot/linux/process_reader.h" +#include "snapshot/linux/process_reader_linux.h" #include "snapshot/memory_snapshot.h" #include "snapshot/memory_snapshot_generic.h" #include "snapshot/thread_snapshot.h" @@ -37,15 +37,15 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the process containing the - //! thread. - //! \param[in] thread The thread within the ProcessReader for + //! \param[in] process_reader A ProcessReaderLinux for the process containing + //! the thread. + //! \param[in] thread The thread within the ProcessReaderLinux for //! which the snapshot should be created. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! a message logged. - bool Initialize(ProcessReader* process_reader, - const ProcessReader::Thread& thread); + bool Initialize(ProcessReaderLinux* process_reader, + const ProcessReaderLinux::Thread& thread); // ThreadSnapshot: @@ -70,7 +70,7 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { #endif // ARCH_CPU_X86_FAMILY } context_union_; CPUContext context_; - MemorySnapshotGeneric stack_; + MemorySnapshotGeneric stack_; LinuxVMAddress thread_specific_data_address_; pid_t thread_id_; int priority_; diff --git a/snapshot/mac/exception_snapshot_mac.cc b/snapshot/mac/exception_snapshot_mac.cc index 92c8450b..50d1a121 100644 --- a/snapshot/mac/exception_snapshot_mac.cc +++ b/snapshot/mac/exception_snapshot_mac.cc @@ -17,7 +17,7 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" #include "snapshot/mac/cpu_context_mac.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "util/mach/exception_behaviors.h" #include "util/mach/exception_types.h" #include "util/mach/symbolic_constants_mach.h" @@ -41,7 +41,7 @@ ExceptionSnapshotMac::ExceptionSnapshotMac() ExceptionSnapshotMac::~ExceptionSnapshotMac() { } -bool ExceptionSnapshotMac::Initialize(ProcessReader* process_reader, +bool ExceptionSnapshotMac::Initialize(ProcessReaderMac* process_reader, exception_behavior_t behavior, thread_t exception_thread, exception_type_t exception, @@ -126,8 +126,9 @@ bool ExceptionSnapshotMac::Initialize(ProcessReader* process_reader, exception_code_0_ = unsigned_exception_code_0; } - const ProcessReader::Thread* thread = nullptr; - for (const ProcessReader::Thread& loop_thread : process_reader->Threads()) { + const ProcessReaderMac::Thread* thread = nullptr; + for (const ProcessReaderMac::Thread& loop_thread : + process_reader->Threads()) { if (exception_thread == loop_thread.port) { thread = &loop_thread; break; diff --git a/snapshot/mac/exception_snapshot_mac.h b/snapshot/mac/exception_snapshot_mac.h index 9a6ddcaa..52ef519b 100644 --- a/snapshot/mac/exception_snapshot_mac.h +++ b/snapshot/mac/exception_snapshot_mac.h @@ -29,7 +29,7 @@ namespace crashpad { -class ProcessReader; +class ProcessReaderMac; namespace internal { @@ -45,8 +45,8 @@ class ExceptionSnapshotMac final : public ExceptionSnapshot { //! Other than \a process_reader, the parameters may be passed directly //! through from a Mach exception handler. //! - //! \param[in] process_reader A ProcessReader for the task that sustained the - //! exception. + //! \param[in] process_reader A ProcessReaderMac for the task that sustained + //! the exception. //! \param[in] behavior //! \param[in] exception_thread //! \param[in] exception @@ -58,7 +58,7 @@ class ExceptionSnapshotMac final : public ExceptionSnapshot { //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(ProcessReader* process_reader, + bool Initialize(ProcessReaderMac* process_reader, exception_behavior_t behavior, thread_t exception_thread, exception_type_t exception, diff --git a/snapshot/mac/mach_o_image_annotations_reader.cc b/snapshot/mac/mach_o_image_annotations_reader.cc index bb8f7e2b..b02acaea 100644 --- a/snapshot/mac/mach_o_image_annotations_reader.cc +++ b/snapshot/mac/mach_o_image_annotations_reader.cc @@ -24,7 +24,7 @@ #include "client/crashpad_info.h" #include "client/simple_string_dictionary.h" #include "snapshot/mac/mach_o_image_reader.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/snapshot_constants.h" #include "util/mach/task_memory.h" #include "util/stdlib/strnlen.h" @@ -32,13 +32,12 @@ namespace crashpad { MachOImageAnnotationsReader::MachOImageAnnotationsReader( - ProcessReader* process_reader, + ProcessReaderMac* process_reader, const MachOImageReader* image_reader, const std::string& name) : name_(name), process_reader_(process_reader), - image_reader_(image_reader) { -} + image_reader_(image_reader) {} std::vector MachOImageAnnotationsReader::Vector() const { std::vector vector_annotations; diff --git a/snapshot/mac/mach_o_image_annotations_reader.h b/snapshot/mac/mach_o_image_annotations_reader.h index 06d2bea9..a56b073b 100644 --- a/snapshot/mac/mach_o_image_annotations_reader.h +++ b/snapshot/mac/mach_o_image_annotations_reader.h @@ -26,7 +26,7 @@ namespace crashpad { class MachOImageReader; -class ProcessReader; +class ProcessReaderMac; //! \brief A reader for annotations stored in a Mach-O image mapped into another //! process. @@ -54,7 +54,7 @@ class MachOImageAnnotationsReader { //! contained within the remote process. //! \param[in] name The module’s name, a string to be used in logged messages. //! This string is for diagnostic purposes only, and may be empty. - MachOImageAnnotationsReader(ProcessReader* process_reader, + MachOImageAnnotationsReader(ProcessReaderMac* process_reader, const MachOImageReader* image_reader, const std::string& name); @@ -91,7 +91,7 @@ class MachOImageAnnotationsReader { std::vector* vector_annotations) const; std::string name_; - ProcessReader* process_reader_; // weak + ProcessReaderMac* process_reader_; // weak const MachOImageReader* image_reader_; // weak DISALLOW_COPY_AND_ASSIGN(MachOImageAnnotationsReader); diff --git a/snapshot/mac/mach_o_image_annotations_reader_test.cc b/snapshot/mac/mach_o_image_annotations_reader_test.cc index f486c1d5..69302503 100644 --- a/snapshot/mac/mach_o_image_annotations_reader_test.cc +++ b/snapshot/mac/mach_o_image_annotations_reader_test.cc @@ -33,7 +33,7 @@ #include "client/crashpad_info.h" #include "client/simple_string_dictionary.h" #include "gtest/gtest.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "test/errors.h" #include "test/mac/mach_errors.h" #include "test/mac/mach_multiprocess.h" @@ -161,15 +161,15 @@ class TestMachOImageAnnotationsReader final EXPECT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "pid_for_task"); EXPECT_EQ(task_pid, ChildPID()); - ProcessReader process_reader; + ProcessReaderMac process_reader; bool rv = process_reader.Initialize(task); if (!rv) { ADD_FAILURE(); } else { - const std::vector& modules = + const std::vector& modules = process_reader.Modules(); std::vector all_annotations_vector; - for (const ProcessReader::Module& module : modules) { + for (const ProcessReaderMac::Module& module : modules) { if (module.reader) { MachOImageAnnotationsReader module_annotations_reader( &process_reader, module.reader, module.name); @@ -271,7 +271,7 @@ class TestMachOImageAnnotationsReader final // MachMultiprocess: void MachMultiprocessParent() override { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(ChildTask())); // Wait for the child process to indicate that it’s done setting up its @@ -281,11 +281,11 @@ class TestMachOImageAnnotationsReader final // Verify the “simple map” and object-based annotations set via the // CrashpadInfo interface. - const std::vector& modules = + const std::vector& modules = process_reader.Modules(); std::map all_annotations_simple_map; std::vector all_annotations; - for (const ProcessReader::Module& module : modules) { + for (const ProcessReaderMac::Module& module : modules) { MachOImageAnnotationsReader module_annotations_reader( &process_reader, module.reader, module.name); std::map module_annotations_simple_map = diff --git a/snapshot/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc index 8a657264..6baee770 100644 --- a/snapshot/mac/mach_o_image_reader.cc +++ b/snapshot/mac/mach_o_image_reader.cc @@ -26,7 +26,7 @@ #include "client/crashpad_info.h" #include "snapshot/mac/mach_o_image_segment_reader.h" #include "snapshot/mac/mach_o_image_symbol_table_reader.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "util/mac/checked_mach_address_range.h" #include "util/misc/implicit_cast.h" @@ -62,7 +62,7 @@ MachOImageReader::MachOImageReader() MachOImageReader::~MachOImageReader() { } -bool MachOImageReader::Initialize(ProcessReader* process_reader, +bool MachOImageReader::Initialize(ProcessReaderMac* process_reader, mach_vm_address_t address, const std::string& name) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); diff --git a/snapshot/mac/mach_o_image_reader.h b/snapshot/mac/mach_o_image_reader.h index c16cce99..aded956c 100644 --- a/snapshot/mac/mach_o_image_reader.h +++ b/snapshot/mac/mach_o_image_reader.h @@ -33,7 +33,7 @@ namespace crashpad { class MachOImageSegmentReader; class MachOImageSymbolTableReader; -class ProcessReader; +class ProcessReaderMac; //! \brief A reader for Mach-O images mapped into another process. //! @@ -64,7 +64,7 @@ class MachOImageReader { //! //! \return `true` if the image was read successfully, including all load //! commands. `false` otherwise, with an appropriate message logged. - bool Initialize(ProcessReader* process_reader, + bool Initialize(ProcessReaderMac* process_reader, mach_vm_address_t address, const std::string& name); @@ -337,7 +337,7 @@ class MachOImageReader { mutable std::unique_ptr symbol_table_; std::unique_ptr id_dylib_command_; - ProcessReader* process_reader_; // weak + ProcessReaderMac* process_reader_; // weak uint32_t file_type_; InitializationStateDcheck initialized_; diff --git a/snapshot/mac/mach_o_image_reader_test.cc b/snapshot/mac/mach_o_image_reader_test.cc index d6b801f8..625f8a70 100644 --- a/snapshot/mac/mach_o_image_reader_test.cc +++ b/snapshot/mac/mach_o_image_reader_test.cc @@ -29,7 +29,7 @@ #include "client/crashpad_info.h" #include "gtest/gtest.h" #include "snapshot/mac/mach_o_image_segment_reader.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/mac/process_types.h" #include "test/mac/dyld.h" #include "util/misc/from_pointer_cast.h" @@ -496,7 +496,7 @@ void ExpectSymbolTable(const MachHeader* expect_image, } TEST(MachOImageReader, Self_MainExecutable) { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); const MachHeader* mh_execute_header = @@ -531,7 +531,7 @@ TEST(MachOImageReader, Self_MainExecutable) { } TEST(MachOImageReader, Self_DyldImages) { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); uint32_t count = _dyld_image_count(); diff --git a/snapshot/mac/mach_o_image_segment_reader.cc b/snapshot/mac/mach_o_image_segment_reader.cc index 06e1daf4..1be829dc 100644 --- a/snapshot/mac/mach_o_image_segment_reader.cc +++ b/snapshot/mac/mach_o_image_segment_reader.cc @@ -20,7 +20,7 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "util/mac/checked_mach_address_range.h" #include "util/mac/mac_util.h" #include "util/stdlib/strnlen.h" @@ -47,7 +47,7 @@ MachOImageSegmentReader::MachOImageSegmentReader() MachOImageSegmentReader::~MachOImageSegmentReader() { } -bool MachOImageSegmentReader::Initialize(ProcessReader* process_reader, +bool MachOImageSegmentReader::Initialize(ProcessReaderMac* process_reader, mach_vm_address_t load_command_address, const std::string& load_command_info, const std::string& module_name, diff --git a/snapshot/mac/mach_o_image_segment_reader.h b/snapshot/mac/mach_o_image_segment_reader.h index 20f891da..bdd57716 100644 --- a/snapshot/mac/mach_o_image_segment_reader.h +++ b/snapshot/mac/mach_o_image_segment_reader.h @@ -62,7 +62,7 @@ class MachOImageSegmentReader { //! //! \return `true` if the load command was read successfully. `false` //! otherwise, with an appropriate message logged. - bool Initialize(ProcessReader* process_reader, + bool Initialize(ProcessReaderMac* process_reader, mach_vm_address_t load_command_address, const std::string& load_command_info, const std::string& module_name, diff --git a/snapshot/mac/mach_o_image_symbol_table_reader.cc b/snapshot/mac/mach_o_image_symbol_table_reader.cc index c5eb1969..361253ce 100644 --- a/snapshot/mac/mach_o_image_symbol_table_reader.cc +++ b/snapshot/mac/mach_o_image_symbol_table_reader.cc @@ -39,7 +39,7 @@ namespace internal { class MachOImageSymbolTableReaderInitializer { public: MachOImageSymbolTableReaderInitializer( - ProcessReader* process_reader, + ProcessReaderMac* process_reader, const MachOImageSegmentReader* linkedit_segment, const std::string& module_info) : module_info_(module_info), @@ -243,7 +243,7 @@ class MachOImageSymbolTableReaderInitializer { std::string module_info_; CheckedMachAddressRange linkedit_range_; - ProcessReader* process_reader_; // weak + ProcessReaderMac* process_reader_; // weak const MachOImageSegmentReader* linkedit_segment_; // weak DISALLOW_COPY_AND_ASSIGN(MachOImageSymbolTableReaderInitializer); @@ -259,7 +259,7 @@ MachOImageSymbolTableReader::~MachOImageSymbolTableReader() { } bool MachOImageSymbolTableReader::Initialize( - ProcessReader* process_reader, + ProcessReaderMac* process_reader, const process_types::symtab_command* symtab_command, const process_types::dysymtab_command* dysymtab_command, const MachOImageSegmentReader* linkedit_segment, diff --git a/snapshot/mac/mach_o_image_symbol_table_reader.h b/snapshot/mac/mach_o_image_symbol_table_reader.h index a097854b..841b479a 100644 --- a/snapshot/mac/mach_o_image_symbol_table_reader.h +++ b/snapshot/mac/mach_o_image_symbol_table_reader.h @@ -23,7 +23,7 @@ #include "base/macros.h" #include "snapshot/mac/mach_o_image_segment_reader.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/mac/process_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -92,7 +92,7 @@ class MachOImageSymbolTableReader { //! //! \return `true` if the symbol table was read successfully. `false` //! otherwise, with an appropriate message logged. - bool Initialize(ProcessReader* process_reader, + bool Initialize(ProcessReaderMac* process_reader, const process_types::symtab_command* symtab_command, const process_types::dysymtab_command* dysymtab_command, const MachOImageSegmentReader* linkedit_segment, diff --git a/snapshot/mac/module_snapshot_mac.cc b/snapshot/mac/module_snapshot_mac.cc index 19c4759d..41608978 100644 --- a/snapshot/mac/module_snapshot_mac.cc +++ b/snapshot/mac/module_snapshot_mac.cc @@ -41,8 +41,8 @@ ModuleSnapshotMac::~ModuleSnapshotMac() { } bool ModuleSnapshotMac::Initialize( - ProcessReader* process_reader, - const ProcessReader::Module& process_reader_module) { + ProcessReaderMac* process_reader, + const ProcessReaderMac::Module& process_reader_module) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); process_reader_ = process_reader; diff --git a/snapshot/mac/module_snapshot_mac.h b/snapshot/mac/module_snapshot_mac.h index 44c07910..fe2d40a1 100644 --- a/snapshot/mac/module_snapshot_mac.h +++ b/snapshot/mac/module_snapshot_mac.h @@ -25,7 +25,7 @@ #include "base/macros.h" #include "client/crashpad_info.h" #include "snapshot/crashpad_info_client_options.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/module_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -45,15 +45,15 @@ class ModuleSnapshotMac final : public ModuleSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the task containing the + //! \param[in] process_reader A ProcessReaderMac for the task containing the //! module. - //! \param[in] process_reader_module The module within the ProcessReader for - //! which the snapshot should be created. + //! \param[in] process_reader_module The module within the ProcessReaderMac + //! for which the snapshot should be created. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(ProcessReader* process_reader, - const ProcessReader::Module& process_reader_module); + bool Initialize(ProcessReaderMac* process_reader, + const ProcessReaderMac::Module& process_reader_module); //! \brief Returns options from the module’s CrashpadInfo structure. //! @@ -87,7 +87,7 @@ class ModuleSnapshotMac final : public ModuleSnapshot { std::string name_; time_t timestamp_; const MachOImageReader* mach_o_image_reader_; // weak - ProcessReader* process_reader_; // weak + ProcessReaderMac* process_reader_; // weak InitializationStateDcheck initialized_; DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotMac); diff --git a/snapshot/mac/process_reader.cc b/snapshot/mac/process_reader_mac.cc similarity index 94% rename from snapshot/mac/process_reader.cc rename to snapshot/mac/process_reader_mac.cc index 6ddcff05..e142fd2e 100644 --- a/snapshot/mac/process_reader.cc +++ b/snapshot/mac/process_reader_mac.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include -#include #include +#include #include #include @@ -71,7 +71,7 @@ kern_return_t MachVMRegionRecurseDeepest(task_t task, namespace crashpad { -ProcessReader::Thread::Thread() +ProcessReaderMac::Thread::Thread() : thread_context(), float_context(), debug_context(), @@ -81,16 +81,13 @@ ProcessReader::Thread::Thread() thread_specific_data_address(0), port(THREAD_NULL), suspend_count(0), - priority(0) { -} + priority(0) {} -ProcessReader::Module::Module() : name(), reader(nullptr), timestamp(0) { -} +ProcessReaderMac::Module::Module() : name(), reader(nullptr), timestamp(0) {} -ProcessReader::Module::~Module() { -} +ProcessReaderMac::Module::~Module() {} -ProcessReader::ProcessReader() +ProcessReaderMac::ProcessReaderMac() : process_info_(), threads_(), modules_(), @@ -100,17 +97,16 @@ ProcessReader::ProcessReader() initialized_(), is_64_bit_(false), initialized_threads_(false), - initialized_modules_(false) { -} + initialized_modules_(false) {} -ProcessReader::~ProcessReader() { +ProcessReaderMac::~ProcessReaderMac() { for (const Thread& thread : threads_) { kern_return_t kr = mach_port_deallocate(mach_task_self(), thread.port); MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; } } -bool ProcessReader::Initialize(task_t task) { +bool ProcessReaderMac::Initialize(task_t task) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); if (!process_info_.InitializeWithTask(task)) { @@ -126,12 +122,13 @@ bool ProcessReader::Initialize(task_t task) { return true; } -void ProcessReader::StartTime(timeval* start_time) const { +void ProcessReaderMac::StartTime(timeval* start_time) const { bool rv = process_info_.StartTime(start_time); DCHECK(rv); } -bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { +bool ProcessReaderMac::CPUTimes(timeval* user_time, + timeval* system_time) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); // Calculate user and system time the same way the kernel does for @@ -177,7 +174,7 @@ bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { return true; } -const std::vector& ProcessReader::Threads() { +const std::vector& ProcessReaderMac::Threads() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_threads_) { @@ -187,7 +184,7 @@ const std::vector& ProcessReader::Threads() { return threads_; } -const std::vector& ProcessReader::Modules() { +const std::vector& ProcessReaderMac::Modules() { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!initialized_modules_) { @@ -197,7 +194,7 @@ const std::vector& ProcessReader::Modules() { return modules_; } -mach_vm_address_t ProcessReader::DyldAllImageInfo( +mach_vm_address_t ProcessReaderMac::DyldAllImageInfo( mach_vm_size_t* all_image_info_size) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); @@ -210,9 +207,9 @@ mach_vm_address_t ProcessReader::DyldAllImageInfo( return 0; } - // TODO(mark): Deal with statically linked executables which don’t use dyld. - // This may look for the module that matches the executable path in the same - // data set that vmmap uses. +// TODO(mark): Deal with statically linked executables which don’t use dyld. +// This may look for the module that matches the executable path in the same +// data set that vmmap uses. #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 // The task_dyld_info_data_t struct grew in 10.7, adding the format field. @@ -237,7 +234,7 @@ mach_vm_address_t ProcessReader::DyldAllImageInfo( return dyld_info.all_image_info_addr; } -void ProcessReader::InitializeThreads() { +void ProcessReaderMac::InitializeThreads() { DCHECK(!initialized_threads_); DCHECK(threads_.empty()); @@ -378,7 +375,7 @@ void ProcessReader::InitializeThreads() { threads_need_owners.Disarm(); } -void ProcessReader::InitializeModules() { +void ProcessReaderMac::InitializeModules() { DCHECK(!initialized_modules_); DCHECK(modules_.empty()); @@ -465,8 +462,8 @@ void ProcessReader::InitializeModules() { image_info.imageLoadAddress == all_image_infos.dyldImageLoadAddress) { found_dyld = true; LOG(WARNING) << base::StringPrintf( - "found dylinker (%s) in dyld_all_image_infos::infoArray", - module.name.c_str()); + "found dylinker (%s) in dyld_all_image_infos::infoArray", + module.name.c_str()); LOG_IF(WARNING, file_type != MH_DYLINKER) << base::StringPrintf("dylinker (%s) has unexpected Mach-O type %d", @@ -563,7 +560,7 @@ void ProcessReader::InitializeModules() { } } -mach_vm_address_t ProcessReader::CalculateStackRegion( +mach_vm_address_t ProcessReaderMac::CalculateStackRegion( mach_vm_address_t stack_pointer, mach_vm_size_t* stack_region_size) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); @@ -675,10 +672,10 @@ mach_vm_address_t ProcessReader::CalculateStackRegion( return region_base; } -void ProcessReader::LocateRedZone(mach_vm_address_t* const start_address, - mach_vm_address_t* const region_base, - mach_vm_address_t* const region_size, - const unsigned int user_tag) { +void ProcessReaderMac::LocateRedZone(mach_vm_address_t* const start_address, + mach_vm_address_t* const region_base, + mach_vm_address_t* const region_size, + const unsigned int user_tag) { #if defined(ARCH_CPU_X86_FAMILY) if (Is64Bit()) { // x86_64 has a red zone. See AMD64 ABI 0.99.8, diff --git a/snapshot/mac/process_reader.h b/snapshot/mac/process_reader_mac.h similarity index 96% rename from snapshot/mac/process_reader.h rename to snapshot/mac/process_reader_mac.h index ecca2a5a..91836dbb 100644 --- a/snapshot/mac/process_reader.h +++ b/snapshot/mac/process_reader_mac.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_ -#define CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_ +#ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_MAC_H_ +#define CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_MAC_H_ #include #include @@ -37,7 +37,7 @@ class MachOImageReader; //! \brief Accesses information about another process, identified by a Mach //! task. -class ProcessReader { +class ProcessReaderMac { public: //! \brief Contains information about a thread that belongs to a task //! (process). @@ -83,7 +83,7 @@ class ProcessReader { //! \brief An image reader for the module. //! //! The lifetime of this MachOImageReader is scoped to the lifetime of the - //! ProcessReader that created it. + //! ProcessReaderMac that created it. //! //! This field may be `nullptr` if a reader could not be created for the //! module. @@ -97,8 +97,8 @@ class ProcessReader { time_t timestamp; }; - ProcessReader(); - ~ProcessReader(); + ProcessReaderMac(); + ~ProcessReaderMac(); //! \brief Initializes this object. This method must be called before any //! other. @@ -244,9 +244,9 @@ class ProcessReader { bool initialized_threads_; bool initialized_modules_; - DISALLOW_COPY_AND_ASSIGN(ProcessReader); + DISALLOW_COPY_AND_ASSIGN(ProcessReaderMac); }; } // namespace crashpad -#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_ +#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_MAC_H_ diff --git a/snapshot/mac/process_reader_test.cc b/snapshot/mac/process_reader_mac_test.cc similarity index 88% rename from snapshot/mac/process_reader_test.cc rename to snapshot/mac/process_reader_mac_test.cc index c9f39e71..faec1472 100644 --- a/snapshot/mac/process_reader_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include +#include #include #include #include -#include #include #include @@ -48,8 +48,8 @@ namespace { constexpr char kDyldPath[] = "/usr/lib/dyld"; -TEST(ProcessReader, SelfBasic) { - ProcessReader process_reader; +TEST(ProcessReaderMac, SelfBasic) { + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); #if !defined(ARCH_CPU_64_BITS) @@ -80,7 +80,7 @@ class ProcessReaderChild final : public MachMultiprocess { private: void MachMultiprocessParent() override { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(ChildTask())); #if !defined(ARCH_CPU_64_BITS) @@ -116,7 +116,7 @@ class ProcessReaderChild final : public MachMultiprocess { DISALLOW_COPY_AND_ASSIGN(ProcessReaderChild); }; -TEST(ProcessReader, ChildBasic) { +TEST(ProcessReaderMac, ChildBasic) { ProcessReaderChild process_reader_child; process_reader_child.Run(); } @@ -131,11 +131,12 @@ uint64_t PthreadToThreadID(pthread_t pthread) { return thread_id; } -TEST(ProcessReader, SelfOneThread) { - ProcessReader process_reader; +TEST(ProcessReaderMac, SelfOneThread) { + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); - const std::vector& threads = process_reader.Threads(); + const std::vector& threads = + process_reader.Threads(); // If other tests ran in this process previously, threads may have been // created and may still be running. This check must look for at least one @@ -157,8 +158,7 @@ class TestThreadPool { int suspend_count; }; - TestThreadPool() : thread_infos_() { - } + TestThreadPool() : thread_infos_() {} // Resumes suspended threads, signals each thread’s exit semaphore asking it // to exit, and joins each thread, blocking until they have all exited. @@ -192,10 +192,8 @@ class TestThreadPool { thread_infos_.push_back(std::make_unique()); ThreadInfo* thread_info = thread_infos_.back().get(); - int rv = pthread_create(&thread_info->pthread, - nullptr, - ThreadMain, - thread_info); + int rv = pthread_create( + &thread_info->pthread, nullptr, ThreadMain, thread_info); ASSERT_EQ(rv, 0); } @@ -210,8 +208,7 @@ class TestThreadPool { ++thread_index) { thread_t thread_port = pthread_mach_thread_np(thread_infos_[thread_index]->pthread); - for (size_t suspend_count = 0; - suspend_count < thread_index; + for (size_t suspend_count = 0; suspend_count < thread_index; ++suspend_count) { kern_return_t kr = thread_suspend(thread_port); EXPECT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "thread_suspend"); @@ -222,8 +219,7 @@ class TestThreadPool { } } - uint64_t GetThreadInfo(size_t thread_index, - ThreadExpectation* expectation) { + uint64_t GetThreadInfo(size_t thread_index, ThreadExpectation* expectation) { CHECK_LT(thread_index, thread_infos_.size()); const auto& thread_info = thread_infos_[thread_index]; @@ -240,8 +236,7 @@ class TestThreadPool { stack_address(0), ready_semaphore(0), exit_semaphore(0), - suspend_count(0) { - } + suspend_count(0) {} ~ThreadInfo() {} @@ -294,14 +289,14 @@ class TestThreadPool { using ThreadMap = std::map; -// Verifies that all of the threads in |threads|, obtained from ProcessReader, -// agree with the expectation in |thread_map|. If |tolerate_extra_threads| is -// true, |threads| is allowed to contain threads that are not listed in -// |thread_map|. This is useful when testing situations where code outside of -// the test’s control (such as system libraries) may start threads, or may have -// started threads prior to a test’s execution. +// Verifies that all of the threads in |threads|, obtained from +// ProcessReaderMac, agree with the expectation in |thread_map|. If +// |tolerate_extra_threads| is true, |threads| is allowed to contain threads +// that are not listed in |thread_map|. This is useful when testing situations +// where code outside of the test’s control (such as system libraries) may start +// threads, or may have started threads prior to a test’s execution. void ExpectSeveralThreads(ThreadMap* thread_map, - const std::vector& threads, + const std::vector& threads, const bool tolerate_extra_threads) { if (tolerate_extra_threads) { ASSERT_GE(threads.size(), thread_map->size()); @@ -310,7 +305,7 @@ void ExpectSeveralThreads(ThreadMap* thread_map, } for (size_t thread_index = 0; thread_index < threads.size(); ++thread_index) { - const ProcessReader::Thread& thread = threads[thread_index]; + const ProcessReaderMac::Thread& thread = threads[thread_index]; mach_vm_address_t thread_stack_region_end = thread.stack_region_address + thread.stack_region_size; @@ -336,26 +331,26 @@ void ExpectSeveralThreads(ThreadMap* thread_map, // with any other thread’s. Each thread should have a unique value for its // ID and port, and each should have its own stack that doesn’t touch any // other thread’s stack. - for (size_t other_thread_index = 0; - other_thread_index < threads.size(); + for (size_t other_thread_index = 0; other_thread_index < threads.size(); ++other_thread_index) { if (other_thread_index == thread_index) { continue; } - const ProcessReader::Thread& other_thread = threads[other_thread_index]; + const ProcessReaderMac::Thread& other_thread = + threads[other_thread_index]; EXPECT_NE(other_thread.id, thread.id); EXPECT_NE(other_thread.port, thread.port); mach_vm_address_t other_thread_stack_region_end = other_thread.stack_region_address + other_thread.stack_region_size; - EXPECT_FALSE( - thread.stack_region_address >= other_thread.stack_region_address && - thread.stack_region_address < other_thread_stack_region_end); - EXPECT_FALSE( - thread_stack_region_end > other_thread.stack_region_address && - thread_stack_region_end <= other_thread_stack_region_end); + EXPECT_FALSE(thread.stack_region_address >= + other_thread.stack_region_address && + thread.stack_region_address < other_thread_stack_region_end); + EXPECT_FALSE(thread_stack_region_end > + other_thread.stack_region_address && + thread_stack_region_end <= other_thread_stack_region_end); } } @@ -363,12 +358,12 @@ void ExpectSeveralThreads(ThreadMap* thread_map, EXPECT_TRUE(thread_map->empty()); } -TEST(ProcessReader, SelfSeveralThreads) { - // Set up the ProcessReader here, before any other threads are running. This - // tests that the threads it returns are lazily initialized as a snapshot of - // the threads at the time of the first call to Threads(), and not at the +TEST(ProcessReaderMac, SelfSeveralThreads) { + // Set up the ProcessReaderMac here, before any other threads are running. + // This tests that the threads it returns are lazily initialized as a snapshot + // of the threads at the time of the first call to Threads(), and not at the // time the ProcessReader was created or initialized. - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); TestThreadPool thread_pool; @@ -392,7 +387,8 @@ TEST(ProcessReader, SelfSeveralThreads) { thread_map[thread_id] = expectation; } - const std::vector& threads = process_reader.Threads(); + const std::vector& threads = + process_reader.Threads(); // Other tests that have run previously may have resulted in the creation of // threads that still exist, so pass true for |tolerate_extra_threads|. @@ -403,7 +399,7 @@ TEST(ProcessReader, SelfSeveralThreads) { // shows up once. thread_t thread_self = MachThreadSelf(); bool found_thread_self = false; - for (const ProcessReader::Thread& thread : threads) { + for (const ProcessReaderMac::Thread& thread : threads) { if (thread.port == thread_self) { EXPECT_FALSE(found_thread_self); found_thread_self = true; @@ -416,15 +412,13 @@ TEST(ProcessReader, SelfSeveralThreads) { class ProcessReaderThreadedChild final : public MachMultiprocess { public: explicit ProcessReaderThreadedChild(size_t thread_count) - : MachMultiprocess(), - thread_count_(thread_count) { - } + : MachMultiprocess(), thread_count_(thread_count) {} ~ProcessReaderThreadedChild() {} private: void MachMultiprocessParent() override { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(ChildTask())); FileHandle read_handle = ReadPipeHandle(); @@ -433,8 +427,7 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { // addresses that should lie somewhere within each thread’s stack as values. // These IDs and addresses all come from the child process via the pipe. ThreadMap thread_map; - for (size_t thread_index = 0; - thread_index < thread_count_ + 1; + for (size_t thread_index = 0; thread_index < thread_count_ + 1; ++thread_index) { uint64_t thread_id; CheckedReadFileExactly(read_handle, &thread_id, sizeof(thread_id)); @@ -453,7 +446,8 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { thread_map[thread_id] = expectation; } - const std::vector& threads = process_reader.Threads(); + const std::vector& threads = + process_reader.Threads(); // The child shouldn’t have any threads other than its main thread and the // ones it created in its pool, so pass false for |tolerate_extra_threads|. @@ -484,8 +478,7 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { sizeof(expectation.suspend_count)); // Write an entry for everything in the thread pool. - for (size_t thread_index = 0; - thread_index < thread_count_; + for (size_t thread_index = 0; thread_index < thread_count_; ++thread_index) { uint64_t thread_id = thread_pool.GetThreadInfo(thread_index, &expectation); @@ -509,14 +502,14 @@ class ProcessReaderThreadedChild final : public MachMultiprocess { DISALLOW_COPY_AND_ASSIGN(ProcessReaderThreadedChild); }; -TEST(ProcessReader, ChildOneThread) { +TEST(ProcessReaderMac, ChildOneThread) { // The main thread plus zero child threads equals one thread. constexpr size_t kChildThreads = 0; ProcessReaderThreadedChild process_reader_threaded_child(kChildThreads); process_reader_threaded_child.Run(); } -TEST(ProcessReader, ChildSeveralThreads) { +TEST(ProcessReaderMac, ChildSeveralThreads) { constexpr size_t kChildThreads = 64; ProcessReaderThreadedChild process_reader_threaded_child(kChildThreads); process_reader_threaded_child.Run(); @@ -537,10 +530,7 @@ TEST(ProcessReader, ChildSeveralThreads) { class ScopedOpenCLNoOpKernel { public: ScopedOpenCLNoOpKernel() - : context_(nullptr), - program_(nullptr), - kernel_(nullptr) { - } + : context_(nullptr), program_(nullptr), kernel_(nullptr) {} ~ScopedOpenCLNoOpKernel() { if (kernel_) { @@ -566,10 +556,10 @@ class ScopedOpenCLNoOpKernel { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 && \ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 - // cl_device_id is really available in OpenCL.framework back to 10.5, but in - // the 10.10 SDK and later, OpenCL.framework includes , - // which has its own cl_device_id that was introduced in 10.10. That - // triggers erroneous availability warnings. +// cl_device_id is really available in OpenCL.framework back to 10.5, but in +// the 10.10 SDK and later, OpenCL.framework includes , +// which has its own cl_device_id that was introduced in 10.10. That +// triggers erroneous availability warnings. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability" #define DISABLED_WUNGUARDED_AVAILABILITY @@ -642,15 +632,16 @@ bool ExpectCLKernels() { #endif } -TEST(ProcessReader, SelfModules) { +TEST(ProcessReaderMac, SelfModules) { ScopedOpenCLNoOpKernel ensure_cl_kernels; ASSERT_NO_FATAL_FAILURE(ensure_cl_kernels.SetUp()); - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); uint32_t dyld_image_count = _dyld_image_count(); - const std::vector& modules = process_reader.Modules(); + const std::vector& modules = + process_reader.Modules(); // There needs to be at least an entry for the main executable, for a dylib, // and for dyld. @@ -718,10 +709,10 @@ class ProcessReaderModulesChild final : public MachMultiprocess { private: void MachMultiprocessParent() override { - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(ChildTask())); - const std::vector& modules = + const std::vector& modules = process_reader.Modules(); // There needs to be at least an entry for the main executable, for a dylib, @@ -829,7 +820,7 @@ class ProcessReaderModulesChild final : public MachMultiprocess { DISALLOW_COPY_AND_ASSIGN(ProcessReaderModulesChild); }; -TEST(ProcessReader, ChildModules) { +TEST(ProcessReaderMac, ChildModules) { ScopedOpenCLNoOpKernel ensure_cl_kernels; ASSERT_NO_FATAL_FAILURE(ensure_cl_kernels.SetUp()); diff --git a/snapshot/mac/process_snapshot_mac.cc b/snapshot/mac/process_snapshot_mac.cc index eaaf3dca..cf5233a9 100644 --- a/snapshot/mac/process_snapshot_mac.cc +++ b/snapshot/mac/process_snapshot_mac.cc @@ -218,9 +218,9 @@ std::vector ProcessSnapshotMac::ExtraMemory() const { } void ProcessSnapshotMac::InitializeThreads() { - const std::vector& process_reader_threads = + const std::vector& process_reader_threads = process_reader_.Threads(); - for (const ProcessReader::Thread& process_reader_thread : + for (const ProcessReaderMac::Thread& process_reader_thread : process_reader_threads) { auto thread = std::make_unique(); if (thread->Initialize(&process_reader_, process_reader_thread)) { @@ -230,9 +230,9 @@ void ProcessSnapshotMac::InitializeThreads() { } void ProcessSnapshotMac::InitializeModules() { - const std::vector& process_reader_modules = + const std::vector& process_reader_modules = process_reader_.Modules(); - for (const ProcessReader::Module& process_reader_module : + for (const ProcessReaderMac::Module& process_reader_module : process_reader_modules) { auto module = std::make_unique(); if (module->Initialize(&process_reader_, process_reader_module)) { diff --git a/snapshot/mac/process_snapshot_mac.h b/snapshot/mac/process_snapshot_mac.h index e7195d94..06bac749 100644 --- a/snapshot/mac/process_snapshot_mac.h +++ b/snapshot/mac/process_snapshot_mac.h @@ -30,7 +30,7 @@ #include "snapshot/exception_snapshot.h" #include "snapshot/mac/exception_snapshot_mac.h" #include "snapshot/mac/module_snapshot_mac.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/mac/system_snapshot_mac.h" #include "snapshot/mac/thread_snapshot_mac.h" #include "snapshot/memory_map_region_snapshot.h" @@ -143,7 +143,7 @@ class ProcessSnapshotMac final : public ProcessSnapshot { std::vector> threads_; std::vector> modules_; std::unique_ptr exception_; - ProcessReader process_reader_; + ProcessReaderMac process_reader_; UUID report_id_; UUID client_id_; std::map annotations_simple_map_; diff --git a/snapshot/mac/process_types.cc b/snapshot/mac/process_types.cc index 35d81db1..65c39ea5 100644 --- a/snapshot/mac/process_types.cc +++ b/snapshot/mac/process_types.cc @@ -94,7 +94,7 @@ inline void Assign(UInt64Array4* destination, namespace process_types { \ \ /* static */ \ - size_t struct_name::ExpectedSize(ProcessReader* process_reader) { \ + size_t struct_name::ExpectedSize(ProcessReaderMac* process_reader) { \ if (!process_reader->Is64Bit()) { \ return internal::struct_name::Size(); \ } else { \ @@ -103,7 +103,7 @@ inline void Assign(UInt64Array4* destination, } \ \ /* static */ \ - bool struct_name::ReadInto(ProcessReader* process_reader, \ + bool struct_name::ReadInto(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ struct_name* generic) { \ if (!process_reader->Is64Bit()) { \ @@ -117,7 +117,7 @@ inline void Assign(UInt64Array4* destination, \ /* static */ \ template \ - bool struct_name::ReadIntoInternal(ProcessReader* process_reader, \ + bool struct_name::ReadIntoInternal(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ struct_name* generic) { \ T specific; \ @@ -166,22 +166,22 @@ inline void Assign(UInt64Array4* destination, // implementations in snapshot/mac/process_types/custom.cc. #define PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO 1 -#define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ - namespace crashpad { \ - namespace process_types { \ - namespace internal { \ - \ - /* static */ \ - template \ - bool struct_name::ReadInto(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - struct_name* specific) { \ - return process_reader->Memory()->Read( \ - address, sizeof(*specific), specific); \ - } \ - } /* namespace internal */ \ - } /* namespace process_types */ \ - } /* namespace crashpad */ +#define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ + namespace crashpad { \ + namespace process_types { \ + namespace internal { \ + \ + /* static */ \ + template \ + bool struct_name::ReadInto(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + struct_name* specific) { \ + return process_reader->Memory()->Read( \ + address, sizeof(*specific), specific); \ + } \ + } /* namespace internal */ \ + } /* namespace process_types */ \ + } /* namespace crashpad */ #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) @@ -214,7 +214,7 @@ inline void Assign(UInt64Array4* destination, \ /* static */ \ template \ - bool struct_name::ReadArrayInto(ProcessReader* process_reader, \ + bool struct_name::ReadArrayInto(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ size_t count, \ struct_name* specific) { \ @@ -225,7 +225,7 @@ inline void Assign(UInt64Array4* destination, } /* namespace internal */ \ \ /* static */ \ - bool struct_name::ReadArrayInto(ProcessReader* process_reader, \ + bool struct_name::ReadArrayInto(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ size_t count, \ struct_name* generic) { \ @@ -241,7 +241,7 @@ inline void Assign(UInt64Array4* destination, \ /* static */ \ template \ - bool struct_name::ReadArrayIntoInternal(ProcessReader* process_reader, \ + bool struct_name::ReadArrayIntoInternal(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ size_t count, \ struct_name* generic) { \ @@ -293,7 +293,7 @@ inline void Assign(UInt64Array4* destination, \ /* static */ \ size_t struct_name::ExpectedSizeForVersion( \ - ProcessReader* process_reader, \ + ProcessReaderMac* process_reader, \ decltype(struct_name::version_field) version) { \ if (!process_reader->Is64Bit()) { \ return internal::struct_name< \ @@ -304,8 +304,8 @@ inline void Assign(UInt64Array4* destination, } \ } \ \ - } /* namespace process_types */ \ - } /* namespace crashpad */ + } /* namespace process_types */ \ + } /* namespace crashpad */ #define PROCESS_TYPE_STRUCT_SIZED(struct_name, size_field) @@ -354,7 +354,7 @@ inline void Assign(UInt64Array4* destination, } /* namespace internal */ \ \ /* static */ \ - size_t struct_name::MinimumSize(ProcessReader* process_reader) { \ + size_t struct_name::MinimumSize(ProcessReaderMac* process_reader) { \ if (!process_reader->Is64Bit()) { \ return internal::struct_name::MinimumSize(); \ } else { \ diff --git a/snapshot/mac/process_types.h b/snapshot/mac/process_types.h index 350b4060..6a5f9c1c 100644 --- a/snapshot/mac/process_types.h +++ b/snapshot/mac/process_types.h @@ -21,7 +21,7 @@ #include #include -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" namespace crashpad { namespace process_types { @@ -80,14 +80,14 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64) \ /* Initializes an object with data read from |process_reader| at \ * |address|, properly genericized. */ \ - bool Read(ProcessReader* process_reader, mach_vm_address_t address) { \ + bool Read(ProcessReaderMac* process_reader, mach_vm_address_t address) { \ return ReadInto(process_reader, address, this); \ } \ \ /* Reads |count| objects from |process_reader| beginning at |address|, and \ * genericizes the objects. The caller must provide storage for |count| \ * objects in |generic|. */ \ - static bool ReadArrayInto(ProcessReader* process_reader, \ + static bool ReadArrayInto(ProcessReaderMac* process_reader, \ mach_vm_address_t address, \ size_t count, \ struct_name* generic); \ @@ -102,47 +102,48 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64) * on the process’ bitness. This can be used prior to reading any data \ * from a process. For versioned and sized structures, \ * ExpectedSizeForVersion() and MinimumSize() may also be useful. */ \ - static size_t ExpectedSize(ProcessReader* process_reader); + static size_t ExpectedSize(ProcessReaderMac* process_reader); #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ member_type member_name __VA_ARGS__; -#define PROCESS_TYPE_STRUCT_VERSIONED(struct_name, version_field) \ - /* Similar to ExpectedSize(), but computes the expected size of a \ - * structure based on the process’ bitness and a custom value, such as a \ - * structure version number. This can be used prior to reading any data \ - * from a process. */ \ - static size_t ExpectedSizeForVersion( \ - ProcessReader* process_reader, \ - decltype(struct_name::version_field) version); +#define PROCESS_TYPE_STRUCT_VERSIONED(struct_name, version_field) \ + /* Similar to ExpectedSize(), but computes the expected size of a \ + * structure based on the process’ bitness and a custom value, such as a \ + * structure version number. This can be used prior to reading any data \ + * from a process. */ \ + static size_t ExpectedSizeForVersion( \ + ProcessReaderMac* process_reader, \ + decltype(struct_name::version_field) version); -#define PROCESS_TYPE_STRUCT_SIZED(struct_name, size_field) \ - /* Similar to ExpectedSize(), but computes the minimum size of a \ - * structure based on the process’ bitness, typically including enough of \ - * a structure to contain its size field. This can be used prior to \ - * reading any data from a process. */ \ - static size_t MinimumSize(ProcessReader* process_reader); +#define PROCESS_TYPE_STRUCT_SIZED(struct_name, size_field) \ + /* Similar to ExpectedSize(), but computes the minimum size of a \ + * structure based on the process’ bitness, typically including enough of \ + * a structure to contain its size field. This can be used prior to \ + * reading any data from a process. */ \ + static size_t MinimumSize(ProcessReaderMac* process_reader); -#define PROCESS_TYPE_STRUCT_END(struct_name) \ - private: \ - /* The static form of Read(). Populates the struct at |generic|. */ \ - static bool ReadInto(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - struct_name* generic); \ - \ - template \ - static bool ReadIntoInternal(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - struct_name* generic); \ - template \ - static bool ReadArrayIntoInternal(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - size_t count, \ - struct_name* generic); \ - size_t size_; \ - }; \ - } /* namespace process_types */ \ - } /* namespace crashpad */ +#define PROCESS_TYPE_STRUCT_END(struct_name) \ + private: \ + /* The static form of Read(). Populates the struct at |generic|. */ \ + static bool ReadInto(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + struct_name* generic); \ + \ + template \ + static bool ReadIntoInternal(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + struct_name* generic); \ + template \ + static bool ReadArrayIntoInternal(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + size_t count, \ + struct_name* generic); \ + size_t size_; \ + } \ + ; \ + } /* namespace process_types */ \ + } /* namespace crashpad */ #include "snapshot/mac/process_types/all.proctype" @@ -163,37 +164,37 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64) // remote process into the generic form. #define PROCESS_TYPE_STRUCT_DECLARE_INTERNAL 1 -#define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ - namespace crashpad { \ - namespace process_types { \ - namespace internal { \ - template \ - struct struct_name { \ - public: \ - using Long = typename Traits::Long; \ - using ULong = typename Traits::ULong; \ - using Pointer = typename Traits::Pointer; \ - using IntPtr = typename Traits::IntPtr; \ - using UIntPtr = typename Traits::UIntPtr; \ - using Reserved32_32Only = typename Traits::Reserved32_32Only; \ - using Reserved32_64Only = typename Traits::Reserved32_64Only; \ - using Reserved64_64Only = typename Traits::Reserved64_64Only; \ - using Nothing = typename Traits::Nothing; \ - \ - /* Read(), ReadArrayInto(), and Size() are as in the generic user-visible \ - * struct above. */ \ - bool Read(ProcessReader* process_reader, mach_vm_address_t address) { \ - return ReadInto(process_reader, address, this); \ - } \ - static bool ReadArrayInto(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - size_t count, \ - struct_name* specific); \ - static size_t Size() { return sizeof(struct_name); } \ - \ - /* Translates a struct from the representation used in the remote process \ - * into the generic form. */ \ - void GenericizeInto(process_types::struct_name* generic, \ +#define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \ + namespace crashpad { \ + namespace process_types { \ + namespace internal { \ + template \ + struct struct_name { \ + public: \ + using Long = typename Traits::Long; \ + using ULong = typename Traits::ULong; \ + using Pointer = typename Traits::Pointer; \ + using IntPtr = typename Traits::IntPtr; \ + using UIntPtr = typename Traits::UIntPtr; \ + using Reserved32_32Only = typename Traits::Reserved32_32Only; \ + using Reserved32_64Only = typename Traits::Reserved32_64Only; \ + using Reserved64_64Only = typename Traits::Reserved64_64Only; \ + using Nothing = typename Traits::Nothing; \ + \ + /* Read(), ReadArrayInto(), and Size() are as in the generic user-visible \ + * struct above. */ \ + bool Read(ProcessReaderMac* process_reader, mach_vm_address_t address) { \ + return ReadInto(process_reader, address, this); \ + } \ + static bool ReadArrayInto(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + size_t count, \ + struct_name* specific); \ + static size_t Size() { return sizeof(struct_name); } \ + \ + /* Translates a struct from the representation used in the remote process \ + * into the generic form. */ \ + void GenericizeInto(process_types::struct_name* generic, \ size_t* specific_size); #define PROCESS_TYPE_STRUCT_MEMBER(member_type, member_name, ...) \ @@ -209,16 +210,17 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64) /* MinimumSize() is as in the generic user-visible struct above. */ \ static size_t MinimumSize(); -#define PROCESS_TYPE_STRUCT_END(struct_name) \ - private: \ - /* ReadInto() is as in the generic user-visible struct above. */ \ - static bool ReadInto(ProcessReader* process_reader, \ - mach_vm_address_t address, \ - struct_name* specific); \ - }; \ - } /* namespace internal */ \ - } /* namespace process_types */ \ - } /* namespace crashpad */ +#define PROCESS_TYPE_STRUCT_END(struct_name) \ + private: \ + /* ReadInto() is as in the generic user-visible struct above. */ \ + static bool ReadInto(ProcessReaderMac* process_reader, \ + mach_vm_address_t address, \ + struct_name* specific); \ + } \ + ; \ + } /* namespace internal */ \ + } /* namespace process_types */ \ + } /* namespace crashpad */ #include "snapshot/mac/process_types/all.proctype" diff --git a/snapshot/mac/process_types/custom.cc b/snapshot/mac/process_types/custom.cc index b9cb0e79..7c7b172a 100644 --- a/snapshot/mac/process_types/custom.cc +++ b/snapshot/mac/process_types/custom.cc @@ -75,7 +75,7 @@ bool FieldAddressIfInRange(mach_vm_address_t address, } template -bool ReadIntoVersioned(ProcessReader* process_reader, +bool ReadIntoVersioned(ProcessReaderMac* process_reader, mach_vm_address_t address, T* specific) { mach_vm_address_t field_address; @@ -95,7 +95,7 @@ bool ReadIntoVersioned(ProcessReader* process_reader, } template -bool ReadIntoSized(ProcessReader* process_reader, +bool ReadIntoSized(ProcessReaderMac* process_reader, mach_vm_address_t address, T* specific) { mach_vm_address_t field_address; @@ -156,7 +156,7 @@ size_t dyld_all_image_infos::ExpectedSizeForVersion( // static template bool dyld_all_image_infos::ReadInto( - ProcessReader* process_reader, + ProcessReaderMac* process_reader, mach_vm_address_t address, dyld_all_image_infos* specific) { return ReadIntoVersioned(process_reader, address, specific); @@ -178,7 +178,7 @@ size_t crashreporter_annotations_t::ExpectedSizeForVersion( // static template bool crashreporter_annotations_t::ReadInto( - ProcessReader* process_reader, + ProcessReaderMac* process_reader, mach_vm_address_t address, crashreporter_annotations_t* specific) { return ReadIntoVersioned(process_reader, address, specific); @@ -186,30 +186,30 @@ bool crashreporter_annotations_t::ReadInto( // static template -bool CrashpadInfo::ReadInto(ProcessReader* process_reader, +bool CrashpadInfo::ReadInto(ProcessReaderMac* process_reader, mach_vm_address_t address, CrashpadInfo* specific) { return ReadIntoSized(process_reader, address, specific); } // Explicit template instantiation of the above. -#define PROCESS_TYPE_FLAVOR_TRAITS(lp_bits) \ - template size_t \ - dyld_all_image_infos::ExpectedSizeForVersion( \ - decltype(dyld_all_image_infos::version)); \ - template bool dyld_all_image_infos::ReadInto( \ - ProcessReader*, \ - mach_vm_address_t, \ - dyld_all_image_infos*); \ - template size_t \ - crashreporter_annotations_t::ExpectedSizeForVersion( \ - decltype(crashreporter_annotations_t::version)); \ - template bool crashreporter_annotations_t::ReadInto( \ - ProcessReader*, \ - mach_vm_address_t, \ - crashreporter_annotations_t*); \ - template bool CrashpadInfo::ReadInto( \ - ProcessReader*, mach_vm_address_t, CrashpadInfo*); +#define PROCESS_TYPE_FLAVOR_TRAITS(lp_bits) \ + template size_t \ + dyld_all_image_infos::ExpectedSizeForVersion( \ + decltype(dyld_all_image_infos::version)); \ + template bool dyld_all_image_infos::ReadInto( \ + ProcessReaderMac*, \ + mach_vm_address_t, \ + dyld_all_image_infos*); \ + template size_t \ + crashreporter_annotations_t::ExpectedSizeForVersion( \ + decltype(crashreporter_annotations_t::version)); \ + template bool crashreporter_annotations_t::ReadInto( \ + ProcessReaderMac*, \ + mach_vm_address_t, \ + crashreporter_annotations_t*); \ + template bool CrashpadInfo::ReadInto( \ + ProcessReaderMac*, mach_vm_address_t, CrashpadInfo*); #include "snapshot/mac/process_types/flavors.h" diff --git a/snapshot/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc index 8ab15c8d..f116c4dd 100644 --- a/snapshot/mac/process_types_test.cc +++ b/snapshot/mac/process_types_test.cc @@ -101,7 +101,7 @@ TEST(ProcessTypes, DyldImagesSelf) { } #endif - ProcessReader process_reader; + ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 diff --git a/snapshot/mac/system_snapshot_mac.cc b/snapshot/mac/system_snapshot_mac.cc index 140e7f49..21f254ee 100644 --- a/snapshot/mac/system_snapshot_mac.cc +++ b/snapshot/mac/system_snapshot_mac.cc @@ -25,7 +25,7 @@ #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/posix/timezone.h" #include "util/mac/mac_util.h" #include "util/numeric/in_range_cast.h" @@ -104,7 +104,7 @@ SystemSnapshotMac::SystemSnapshotMac() SystemSnapshotMac::~SystemSnapshotMac() { } -void SystemSnapshotMac::Initialize(ProcessReader* process_reader, +void SystemSnapshotMac::Initialize(ProcessReaderMac* process_reader, const timeval* snapshot_time) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); diff --git a/snapshot/mac/system_snapshot_mac.h b/snapshot/mac/system_snapshot_mac.h index 2ac2ef90..62b2ae61 100644 --- a/snapshot/mac/system_snapshot_mac.h +++ b/snapshot/mac/system_snapshot_mac.h @@ -25,7 +25,7 @@ namespace crashpad { -class ProcessReader; +class ProcessReaderMac; namespace internal { @@ -40,9 +40,9 @@ class SystemSnapshotMac final : public SystemSnapshot { //! \param[in] process_reader A reader for the process being snapshotted. //! \n\n //! It seems odd that a system snapshot implementation would need a - //! ProcessReader, but some of the information reported about the system - //! depends on the process it’s being reported for. For example, the - //! architecture returned by GetCPUArchitecture() should be the + //! ProcessReaderMac, but some of the information reported about the + //! system depends on the process it’s being reported for. For example, + //! the architecture returned by GetCPUArchitecture() should be the //! architecture of the process, which may be different than the native //! architecture of the system: an x86_64 system can run both x86_64 and //! 32-bit x86 processes. @@ -53,7 +53,8 @@ class SystemSnapshotMac final : public SystemSnapshot { //! Otherwise, it would need to base its determination on the current //! time, which may be different than the snapshot time for snapshots //! generated around the daylight saving transition time. - void Initialize(ProcessReader* process_reader, const timeval* snapshot_time); + void Initialize(ProcessReaderMac* process_reader, + const timeval* snapshot_time); // SystemSnapshot: @@ -83,7 +84,7 @@ class SystemSnapshotMac final : public SystemSnapshot { private: std::string os_version_full_; std::string os_version_build_; - ProcessReader* process_reader_; // weak + ProcessReaderMac* process_reader_; // weak const timeval* snapshot_time_; // weak int os_version_major_; int os_version_minor_; diff --git a/snapshot/mac/system_snapshot_mac_test.cc b/snapshot/mac/system_snapshot_mac_test.cc index 646021b3..69048eb0 100644 --- a/snapshot/mac/system_snapshot_mac_test.cc +++ b/snapshot/mac/system_snapshot_mac_test.cc @@ -20,7 +20,7 @@ #include "build/build_config.h" #include "gtest/gtest.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "test/errors.h" #include "util/mac/mac_util.h" @@ -30,7 +30,7 @@ namespace { // SystemSnapshotMac objects would be cumbersome to construct in each test that // requires one, because of the repetitive and mechanical work necessary to set -// up a ProcessReader and timeval, along with the checks to verify that these +// up a ProcessReaderMac and timeval, along with the checks to verify that these // operations succeed. This test fixture class handles the initialization work // so that individual tests don’t have to. class SystemSnapshotMacTest : public testing::Test { @@ -55,7 +55,7 @@ class SystemSnapshotMacTest : public testing::Test { } private: - ProcessReader process_reader_; + ProcessReaderMac process_reader_; timeval snapshot_time_; internal::SystemSnapshotMac system_snapshot_; diff --git a/snapshot/mac/thread_snapshot_mac.cc b/snapshot/mac/thread_snapshot_mac.cc index b042f758..f45fc418 100644 --- a/snapshot/mac/thread_snapshot_mac.cc +++ b/snapshot/mac/thread_snapshot_mac.cc @@ -16,7 +16,7 @@ #include "base/logging.h" #include "snapshot/mac/cpu_context_mac.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" namespace crashpad { namespace internal { @@ -38,8 +38,8 @@ ThreadSnapshotMac::~ThreadSnapshotMac() { } bool ThreadSnapshotMac::Initialize( - ProcessReader* process_reader, - const ProcessReader::Thread& process_reader_thread) { + ProcessReaderMac* process_reader, + const ProcessReaderMac::Thread& process_reader_thread) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); thread_ = process_reader_thread.port; diff --git a/snapshot/mac/thread_snapshot_mac.h b/snapshot/mac/thread_snapshot_mac.h index 03ca0fb5..8f5d722b 100644 --- a/snapshot/mac/thread_snapshot_mac.h +++ b/snapshot/mac/thread_snapshot_mac.h @@ -21,7 +21,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "snapshot/cpu_context.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "snapshot/memory_snapshot.h" #include "snapshot/memory_snapshot_generic.h" #include "snapshot/thread_snapshot.h" @@ -29,7 +29,7 @@ namespace crashpad { -class ProcessReader; +class ProcessReaderMac; namespace internal { @@ -42,15 +42,15 @@ class ThreadSnapshotMac final : public ThreadSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the task containing the + //! \param[in] process_reader A ProcessReaderMac for the task containing the //! thread. - //! \param[in] process_reader_thread The thread within the ProcessReader for - //! which the snapshot should be created. + //! \param[in] process_reader_thread The thread within the ProcessReaderMac + //! for which the snapshot should be created. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(ProcessReader* process_reader, - const ProcessReader::Thread& process_reader_thread); + bool Initialize(ProcessReaderMac* process_reader, + const ProcessReaderMac::Thread& process_reader_thread); // ThreadSnapshot: @@ -70,7 +70,7 @@ class ThreadSnapshotMac final : public ThreadSnapshot { } context_union_; #endif CPUContext context_; - MemorySnapshotGeneric stack_; + MemorySnapshotGeneric stack_; uint64_t thread_id_; uint64_t thread_specific_data_address_; thread_t thread_; diff --git a/snapshot/snapshot.gyp b/snapshot/snapshot.gyp index 15fc34b3..b199841b 100644 --- a/snapshot/snapshot.gyp +++ b/snapshot/snapshot.gyp @@ -60,8 +60,8 @@ 'linux/debug_rendezvous.h', 'linux/exception_snapshot_linux.cc', 'linux/exception_snapshot_linux.h', - 'linux/process_reader.cc', - 'linux/process_reader.h', + 'linux/process_reader_linux.cc', + 'linux/process_reader_linux.h', 'linux/process_snapshot_linux.cc', 'linux/process_snapshot_linux.h', 'linux/signal_context.h', @@ -83,8 +83,8 @@ 'mac/mach_o_image_symbol_table_reader.h', 'mac/module_snapshot_mac.cc', 'mac/module_snapshot_mac.h', - 'mac/process_reader.cc', - 'mac/process_reader.h', + 'mac/process_reader_mac.cc', + 'mac/process_reader_mac.h', 'mac/process_snapshot_mac.cc', 'mac/process_snapshot_mac.h', 'mac/process_types.cc', diff --git a/snapshot/snapshot_test.gyp b/snapshot/snapshot_test.gyp index d8c0c08f..6f0fc90e 100644 --- a/snapshot/snapshot_test.gyp +++ b/snapshot/snapshot_test.gyp @@ -81,13 +81,13 @@ 'elf/elf_image_reader_test_note.S', 'linux/debug_rendezvous_test.cc', 'linux/exception_snapshot_linux_test.cc', - 'linux/process_reader_test.cc', + 'linux/process_reader_linux_test.cc', 'linux/system_snapshot_linux_test.cc', 'mac/cpu_context_mac_test.cc', 'mac/mach_o_image_annotations_reader_test.cc', 'mac/mach_o_image_reader_test.cc', 'mac/mach_o_image_segment_reader_test.cc', - 'mac/process_reader_test.cc', + 'mac/process_reader_mac_test.cc', 'mac/process_types_test.cc', 'mac/system_snapshot_mac_test.cc', 'minidump/process_snapshot_minidump_test.cc', diff --git a/snapshot/win/exception_snapshot_win.h b/snapshot/win/exception_snapshot_win.h index 0d216683..f6e29d9f 100644 --- a/snapshot/win/exception_snapshot_win.h +++ b/snapshot/win/exception_snapshot_win.h @@ -52,8 +52,8 @@ class ExceptionSnapshotWin final : public ExceptionSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the process that sustained - //! the exception. + //! \param[in] process_reader A ProcessReaderWin for the process that + //! sustained the exception. //! \param[in] thread_id The thread ID in which the exception occurred. //! \param[in] exception_pointers The address of an `EXCEPTION_POINTERS` //! record in the target process, passed through from the exception diff --git a/snapshot/win/module_snapshot_win.h b/snapshot/win/module_snapshot_win.h index 414f0a4d..693588db 100644 --- a/snapshot/win/module_snapshot_win.h +++ b/snapshot/win/module_snapshot_win.h @@ -47,10 +47,10 @@ class ModuleSnapshotWin final : public ModuleSnapshot { //! \brief Initializes the object. //! - //! \param[in] process_reader A ProcessReader for the task containing the - //! module. - //! \param[in] process_reader_module The module within the ProcessReader for - //! which the snapshot should be created. + //! \param[in] process_reader A ProcessReaderWin for the process containing + //! the module. + //! \param[in] process_reader_module The module within the ProcessReaderWin + //! for which the snapshot should be created. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. diff --git a/test/mac/dyld.cc b/test/mac/dyld.cc index 6fa2176a..fb2156ed 100644 --- a/test/mac/dyld.cc +++ b/test/mac/dyld.cc @@ -21,7 +21,7 @@ #include #include "base/logging.h" -#include "snapshot/mac/process_reader.h" +#include "snapshot/mac/process_reader_mac.h" #include "test/scoped_module_handle.h" #include "util/numeric/safe_assignment.h" @@ -74,7 +74,7 @@ const dyld_all_image_infos* DyldGetAllImageInfos() { #endif // On 10.13 and later, do it the hard way. - ProcessReader process_reader; + ProcessReaderMac process_reader; if (!process_reader.Initialize(mach_task_self())) { return nullptr; }