mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
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 <mark@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
f130822b9f
commit
2b05eb522f
@ -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
|
||||
|
@ -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 <link.h>
|
||||
#include <zircon/syscalls.h>
|
||||
@ -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::Module>& ProcessReader::Modules() {
|
||||
const std::vector<ProcessReaderFuchsia::Module>&
|
||||
ProcessReaderFuchsia::Modules() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
if (!initialized_modules_) {
|
||||
@ -57,7 +58,8 @@ const std::vector<ProcessReader::Module>& ProcessReader::Modules() {
|
||||
return modules_;
|
||||
}
|
||||
|
||||
const std::vector<ProcessReader::Thread>& ProcessReader::Threads() {
|
||||
const std::vector<ProcessReaderFuchsia::Thread>&
|
||||
ProcessReaderFuchsia::Threads() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
if (!initialized_threads_) {
|
||||
@ -67,7 +69,7 @@ const std::vector<ProcessReader::Thread>& 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
|
@ -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
|
@ -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 <zircon/process.h>
|
||||
#include <zircon/syscalls.h>
|
||||
@ -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();
|
||||
}
|
@ -171,7 +171,8 @@ std::vector<const MemorySnapshot*> 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<internal::ModuleSnapshotElf>(
|
||||
reader_module.name, reader_module.reader, reader_module.type);
|
||||
if (module->Initialize()) {
|
||||
|
@ -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<std::unique_ptr<internal::ModuleSnapshotElf>> modules_;
|
||||
ProcessReader process_reader_;
|
||||
ProcessReaderFuchsia process_reader_;
|
||||
std::map<std::string, std::string> annotations_simple_map_;
|
||||
InitializationStateDcheck initialized_;
|
||||
|
||||
|
@ -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<ContextTraits32>(
|
||||
ProcessReader* reader,
|
||||
ProcessReaderLinux* reader,
|
||||
LinuxVMAddress context_address) {
|
||||
UContext<ContextTraits32> ucontext;
|
||||
if (!reader->Memory()->Read(context_address, sizeof(ucontext), &ucontext)) {
|
||||
@ -79,7 +79,7 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
|
||||
|
||||
template <>
|
||||
bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
|
||||
ProcessReader* reader,
|
||||
ProcessReaderLinux* reader,
|
||||
LinuxVMAddress context_address) {
|
||||
UContext<ContextTraits64> ucontext;
|
||||
if (!reader->Memory()->Read(context_address, sizeof(ucontext), &ucontext)) {
|
||||
@ -99,7 +99,7 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
|
||||
|
||||
template <>
|
||||
bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
|
||||
ProcessReader* reader,
|
||||
ProcessReaderLinux* reader,
|
||||
LinuxVMAddress context_address) {
|
||||
context_.architecture = kCPUArchitectureARM;
|
||||
context_.arm = &context_union_.arm;
|
||||
@ -179,7 +179,7 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
|
||||
|
||||
template <>
|
||||
bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
|
||||
ProcessReader* reader,
|
||||
ProcessReaderLinux* reader,
|
||||
LinuxVMAddress context_address) {
|
||||
context_.architecture = kCPUArchitectureARM64;
|
||||
context_.arm64 = &context_union_.arm64;
|
||||
@ -253,7 +253,7 @@ bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
|
||||
|
||||
#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 <typename Traits>
|
||||
bool ExceptionSnapshotLinux::ReadSiginfo(ProcessReader* reader,
|
||||
bool ExceptionSnapshotLinux::ReadSiginfo(ProcessReaderLinux* reader,
|
||||
LinuxVMAddress siginfo_address) {
|
||||
Siginfo<Traits> siginfo;
|
||||
if (!reader->Memory()->Read(siginfo_address, sizeof(siginfo), &siginfo)) {
|
||||
|
@ -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 <typename Traits>
|
||||
bool ReadSiginfo(ProcessReader* reader, LinuxVMAddress siginfo_address);
|
||||
bool ReadSiginfo(ProcessReaderLinux* reader, LinuxVMAddress siginfo_address);
|
||||
|
||||
template <typename Traits>
|
||||
bool ReadContext(ProcessReader* reader, LinuxVMAddress context_address);
|
||||
bool ReadContext(ProcessReaderLinux* reader, LinuxVMAddress context_address);
|
||||
|
||||
union {
|
||||
#if defined(ARCH_CPU_X86_FAMILY)
|
||||
|
@ -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;
|
||||
|
@ -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 <elf.h>
|
||||
#include <errno.h>
|
||||
@ -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::Thread>& ProcessReader::Threads() {
|
||||
const std::vector<ProcessReaderLinux::Thread>& ProcessReaderLinux::Threads() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
if (!initialized_threads_) {
|
||||
InitializeThreads();
|
||||
@ -261,7 +263,7 @@ const std::vector<ProcessReader::Thread>& ProcessReader::Threads() {
|
||||
return threads_;
|
||||
}
|
||||
|
||||
const std::vector<ProcessReader::Module>& ProcessReader::Modules() {
|
||||
const std::vector<ProcessReaderLinux::Module>& ProcessReaderLinux::Modules() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
if (!initialized_modules_) {
|
||||
InitializeModules();
|
||||
@ -269,7 +271,7 @@ const std::vector<ProcessReader::Module>& 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;
|
@ -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 <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
@ -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_
|
@ -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 <errno.h>
|
||||
#include <link.h>
|
||||
@ -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<pid_t, TestThreadPool::ThreadExpectation>;
|
||||
|
||||
void ExpectThreads(const ThreadMap& thread_map,
|
||||
const std::vector<ProcessReader::Thread>& threads,
|
||||
const std::vector<ProcessReaderLinux::Thread>& 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<ProcessReader::Thread>& threads =
|
||||
const std::vector<ProcessReaderLinux::Thread>& 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<ProcessReader::Thread>& threads =
|
||||
const std::vector<ProcessReaderLinux::Thread>& 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<LinuxVMAddress>(info->dlpi_phdr)));
|
||||
auto modules =
|
||||
reinterpret_cast<const std::vector<ProcessReader::Module>*>(data);
|
||||
reinterpret_cast<const std::vector<ProcessReaderLinux::Module>*>(data);
|
||||
|
||||
auto phdr_addr = FromPointerCast<LinuxVMAddress>(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<ProcessReader::Module>& modules) {
|
||||
void ExpectModulesFromSelf(
|
||||
const std::vector<ProcessReaderLinux::Module>& 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<ProcessReader::Module>& 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<void*>(
|
||||
const_cast<std::vector<ProcessReader::Module>*>(&modules))),
|
||||
0);
|
||||
EXPECT_EQ(
|
||||
dl_iterate_phdr(
|
||||
ExpectFindModule,
|
||||
reinterpret_cast<void*>(
|
||||
const_cast<std::vector<ProcessReaderLinux::Module>*>(&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();
|
||||
}
|
@ -213,9 +213,9 @@ std::vector<const MemorySnapshot*> ProcessSnapshotLinux::ExtraMemory() const {
|
||||
}
|
||||
|
||||
void ProcessSnapshotLinux::InitializeThreads() {
|
||||
const std::vector<ProcessReader::Thread>& process_reader_threads =
|
||||
const std::vector<ProcessReaderLinux::Thread>& 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<internal::ThreadSnapshotLinux>();
|
||||
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<internal::ModuleSnapshotElf>(
|
||||
reader_module.name, reader_module.elf_reader, reader_module.type);
|
||||
if (module->Initialize()) {
|
||||
|
@ -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<std::unique_ptr<internal::ModuleSnapshotElf>> modules_;
|
||||
std::unique_ptr<internal::ExceptionSnapshotLinux> exception_;
|
||||
internal::SystemSnapshotLinux system_;
|
||||
ProcessReader process_reader_;
|
||||
ProcessReaderLinux process_reader_;
|
||||
InitializationStateDcheck initialized_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotLinux);
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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<ProcessReader> stack_;
|
||||
MemorySnapshotGeneric<ProcessReaderLinux> stack_;
|
||||
LinuxVMAddress thread_specific_data_address_;
|
||||
pid_t thread_id_;
|
||||
int priority_;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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<std::string> MachOImageAnnotationsReader::Vector() const {
|
||||
std::vector<std::string> vector_annotations;
|
||||
|
@ -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<AnnotationSnapshot>* vector_annotations) const;
|
||||
|
||||
std::string name_;
|
||||
ProcessReader* process_reader_; // weak
|
||||
ProcessReaderMac* process_reader_; // weak
|
||||
const MachOImageReader* image_reader_; // weak
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MachOImageAnnotationsReader);
|
||||
|
@ -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<ProcessReader::Module>& modules =
|
||||
const std::vector<ProcessReaderMac::Module>& modules =
|
||||
process_reader.Modules();
|
||||
std::vector<std::string> 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<ProcessReader::Module>& modules =
|
||||
const std::vector<ProcessReaderMac::Module>& modules =
|
||||
process_reader.Modules();
|
||||
std::map<std::string, std::string> all_annotations_simple_map;
|
||||
std::vector<AnnotationSnapshot> 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<std::string, std::string> module_annotations_simple_map =
|
||||
|
@ -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_);
|
||||
|
@ -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<MachOImageSymbolTableReader> symbol_table_;
|
||||
|
||||
std::unique_ptr<process_types::dylib_command> id_dylib_command_;
|
||||
ProcessReader* process_reader_; // weak
|
||||
ProcessReaderMac* process_reader_; // weak
|
||||
uint32_t file_type_;
|
||||
InitializationStateDcheck initialized_;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 <AvailabilityMacros.h>
|
||||
#include <mach/mach_vm.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <mach/mach_vm.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
@ -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::Thread>& ProcessReader::Threads() {
|
||||
const std::vector<ProcessReaderMac::Thread>& ProcessReaderMac::Threads() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
if (!initialized_threads_) {
|
||||
@ -187,7 +184,7 @@ const std::vector<ProcessReader::Thread>& ProcessReader::Threads() {
|
||||
return threads_;
|
||||
}
|
||||
|
||||
const std::vector<ProcessReader::Module>& ProcessReader::Modules() {
|
||||
const std::vector<ProcessReaderMac::Module>& ProcessReaderMac::Modules() {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
if (!initialized_modules_) {
|
||||
@ -197,7 +194,7 @@ const std::vector<ProcessReader::Module>& 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,
|
@ -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 <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
@ -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_
|
@ -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 <AvailabilityMacros.h>
|
||||
#include <OpenCL/opencl.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/dyld_images.h>
|
||||
#include <mach/mach.h>
|
||||
#include <OpenCL/opencl.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -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<ProcessReader::Thread>& threads = process_reader.Threads();
|
||||
const std::vector<ProcessReaderMac::Thread>& 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>());
|
||||
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<uint64_t, TestThreadPool::ThreadExpectation>;
|
||||
|
||||
// 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<ProcessReader::Thread>& threads,
|
||||
const std::vector<ProcessReaderMac::Thread>& 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<ProcessReader::Thread>& threads = process_reader.Threads();
|
||||
const std::vector<ProcessReaderMac::Thread>& 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<ProcessReader::Thread>& threads = process_reader.Threads();
|
||||
const std::vector<ProcessReaderMac::Thread>& 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 <OpenGL/CGLDevice.h>,
|
||||
// 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 <OpenGL/CGLDevice.h>,
|
||||
// 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<ProcessReader::Module>& modules = process_reader.Modules();
|
||||
const std::vector<ProcessReaderMac::Module>& 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<ProcessReader::Module>& modules =
|
||||
const std::vector<ProcessReaderMac::Module>& 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());
|
||||
|
@ -218,9 +218,9 @@ std::vector<const MemorySnapshot*> ProcessSnapshotMac::ExtraMemory() const {
|
||||
}
|
||||
|
||||
void ProcessSnapshotMac::InitializeThreads() {
|
||||
const std::vector<ProcessReader::Thread>& process_reader_threads =
|
||||
const std::vector<ProcessReaderMac::Thread>& 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<internal::ThreadSnapshotMac>();
|
||||
if (thread->Initialize(&process_reader_, process_reader_thread)) {
|
||||
@ -230,9 +230,9 @@ void ProcessSnapshotMac::InitializeThreads() {
|
||||
}
|
||||
|
||||
void ProcessSnapshotMac::InitializeModules() {
|
||||
const std::vector<ProcessReader::Module>& process_reader_modules =
|
||||
const std::vector<ProcessReaderMac::Module>& 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<internal::ModuleSnapshotMac>();
|
||||
if (module->Initialize(&process_reader_, process_reader_module)) {
|
||||
|
@ -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<std::unique_ptr<internal::ThreadSnapshotMac>> threads_;
|
||||
std::vector<std::unique_ptr<internal::ModuleSnapshotMac>> modules_;
|
||||
std::unique_ptr<internal::ExceptionSnapshotMac> exception_;
|
||||
ProcessReader process_reader_;
|
||||
ProcessReaderMac process_reader_;
|
||||
UUID report_id_;
|
||||
UUID client_id_;
|
||||
std::map<std::string, std::string> annotations_simple_map_;
|
||||
|
@ -94,7 +94,7 @@ inline void Assign<UInt64Array4, UInt32Array4>(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<internal::Traits32>::Size(); \
|
||||
} else { \
|
||||
@ -103,7 +103,7 @@ inline void Assign<UInt64Array4, UInt32Array4>(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, UInt32Array4>(UInt64Array4* destination,
|
||||
\
|
||||
/* static */ \
|
||||
template <typename T> \
|
||||
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, UInt32Array4>(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 <typename Traits> \
|
||||
bool struct_name<Traits>::ReadInto(ProcessReader* process_reader, \
|
||||
mach_vm_address_t address, \
|
||||
struct_name<Traits>* 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 <typename Traits> \
|
||||
bool struct_name<Traits>::ReadInto(ProcessReaderMac* process_reader, \
|
||||
mach_vm_address_t address, \
|
||||
struct_name<Traits>* 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, UInt32Array4>(UInt64Array4* destination,
|
||||
\
|
||||
/* static */ \
|
||||
template <typename Traits> \
|
||||
bool struct_name<Traits>::ReadArrayInto(ProcessReader* process_reader, \
|
||||
bool struct_name<Traits>::ReadArrayInto(ProcessReaderMac* process_reader, \
|
||||
mach_vm_address_t address, \
|
||||
size_t count, \
|
||||
struct_name<Traits>* specific) { \
|
||||
@ -225,7 +225,7 @@ inline void Assign<UInt64Array4, UInt32Array4>(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, UInt32Array4>(UInt64Array4* destination,
|
||||
\
|
||||
/* static */ \
|
||||
template <typename T> \
|
||||
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, UInt32Array4>(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, UInt32Array4>(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, UInt32Array4>(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<internal::Traits32>::MinimumSize(); \
|
||||
} else { \
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#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 <typename T> \
|
||||
static bool ReadIntoInternal(ProcessReader* process_reader, \
|
||||
mach_vm_address_t address, \
|
||||
struct_name* generic); \
|
||||
template <typename T> \
|
||||
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 <typename T> \
|
||||
static bool ReadIntoInternal(ProcessReaderMac* process_reader, \
|
||||
mach_vm_address_t address, \
|
||||
struct_name* generic); \
|
||||
template <typename T> \
|
||||
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 <typename Traits> \
|
||||
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<Traits>* specific); \
|
||||
static size_t Size() { return sizeof(struct_name<Traits>); } \
|
||||
\
|
||||
/* 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 <typename Traits> \
|
||||
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<Traits>* specific); \
|
||||
static size_t Size() { return sizeof(struct_name<Traits>); } \
|
||||
\
|
||||
/* 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<Traits>* 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<Traits>* specific); \
|
||||
} \
|
||||
; \
|
||||
} /* namespace internal */ \
|
||||
} /* namespace process_types */ \
|
||||
} /* namespace crashpad */
|
||||
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool FieldAddressIfInRange(mach_vm_address_t address,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
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<Traits>::ExpectedSizeForVersion(
|
||||
// static
|
||||
template <typename Traits>
|
||||
bool dyld_all_image_infos<Traits>::ReadInto(
|
||||
ProcessReader* process_reader,
|
||||
ProcessReaderMac* process_reader,
|
||||
mach_vm_address_t address,
|
||||
dyld_all_image_infos<Traits>* specific) {
|
||||
return ReadIntoVersioned(process_reader, address, specific);
|
||||
@ -178,7 +178,7 @@ size_t crashreporter_annotations_t<Traits>::ExpectedSizeForVersion(
|
||||
// static
|
||||
template <typename Traits>
|
||||
bool crashreporter_annotations_t<Traits>::ReadInto(
|
||||
ProcessReader* process_reader,
|
||||
ProcessReaderMac* process_reader,
|
||||
mach_vm_address_t address,
|
||||
crashreporter_annotations_t<Traits>* specific) {
|
||||
return ReadIntoVersioned(process_reader, address, specific);
|
||||
@ -186,30 +186,30 @@ bool crashreporter_annotations_t<Traits>::ReadInto(
|
||||
|
||||
// static
|
||||
template <typename Traits>
|
||||
bool CrashpadInfo<Traits>::ReadInto(ProcessReader* process_reader,
|
||||
bool CrashpadInfo<Traits>::ReadInto(ProcessReaderMac* process_reader,
|
||||
mach_vm_address_t address,
|
||||
CrashpadInfo<Traits>* 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<Traits##lp_bits>::ExpectedSizeForVersion( \
|
||||
decltype(dyld_all_image_infos<Traits##lp_bits>::version)); \
|
||||
template bool dyld_all_image_infos<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReader*, \
|
||||
mach_vm_address_t, \
|
||||
dyld_all_image_infos<Traits##lp_bits>*); \
|
||||
template size_t \
|
||||
crashreporter_annotations_t<Traits##lp_bits>::ExpectedSizeForVersion( \
|
||||
decltype(crashreporter_annotations_t<Traits##lp_bits>::version)); \
|
||||
template bool crashreporter_annotations_t<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReader*, \
|
||||
mach_vm_address_t, \
|
||||
crashreporter_annotations_t<Traits##lp_bits>*); \
|
||||
template bool CrashpadInfo<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReader*, mach_vm_address_t, CrashpadInfo<Traits##lp_bits>*);
|
||||
#define PROCESS_TYPE_FLAVOR_TRAITS(lp_bits) \
|
||||
template size_t \
|
||||
dyld_all_image_infos<Traits##lp_bits>::ExpectedSizeForVersion( \
|
||||
decltype(dyld_all_image_infos<Traits##lp_bits>::version)); \
|
||||
template bool dyld_all_image_infos<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReaderMac*, \
|
||||
mach_vm_address_t, \
|
||||
dyld_all_image_infos<Traits##lp_bits>*); \
|
||||
template size_t \
|
||||
crashreporter_annotations_t<Traits##lp_bits>::ExpectedSizeForVersion( \
|
||||
decltype(crashreporter_annotations_t<Traits##lp_bits>::version)); \
|
||||
template bool crashreporter_annotations_t<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReaderMac*, \
|
||||
mach_vm_address_t, \
|
||||
crashreporter_annotations_t<Traits##lp_bits>*); \
|
||||
template bool CrashpadInfo<Traits##lp_bits>::ReadInto( \
|
||||
ProcessReaderMac*, mach_vm_address_t, CrashpadInfo<Traits##lp_bits>*);
|
||||
|
||||
#include "snapshot/mac/process_types/flavors.h"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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_);
|
||||
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<ProcessReader> stack_;
|
||||
MemorySnapshotGeneric<ProcessReaderMac> stack_;
|
||||
uint64_t thread_id_;
|
||||
uint64_t thread_specific_data_address_;
|
||||
thread_t thread_;
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user