mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:16:13 +00:00
Add a ProcessSnapshot::Memory method
Add a method to the ProcessSnapshot to expose a ProcessMemory object to allow reading memory directly from the underlying process. CQ-DEPEND=CL:1278830 BUG=crashpad:262 Change-Id: Ied2a5510a9b051c7ac8c41cdd060e8daa531086e Reviewed-on: https://chromium-review.googlesource.com/c/1315428 Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
656fa55c74
commit
1c4c1277e8
@ -109,7 +109,7 @@ class ProcessReaderFuchsia {
|
||||
const std::vector<Thread>& Threads();
|
||||
|
||||
//! \brief Return a memory reader for the target process.
|
||||
ProcessMemory* Memory() { return process_memory_.get(); }
|
||||
const ProcessMemory* Memory() const { return process_memory_.get(); }
|
||||
|
||||
private:
|
||||
//! Performs lazy initialization of the \a modules_ vector on behalf of
|
||||
|
@ -188,6 +188,11 @@ std::vector<const MemorySnapshot*> ProcessSnapshotFuchsia::ExtraMemory() const {
|
||||
return std::vector<const MemorySnapshot*>();
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotFuchsia::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
return process_reader_.Memory();
|
||||
}
|
||||
|
||||
void ProcessSnapshotFuchsia::InitializeThreads() {
|
||||
const std::vector<ProcessReaderFuchsia::Thread>& process_reader_threads =
|
||||
process_reader_.Threads();
|
||||
|
@ -121,6 +121,7 @@ class ProcessSnapshotFuchsia : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
// Initializes threads_ on behalf of Initialize().
|
||||
|
@ -120,7 +120,7 @@ class ProcessReaderLinux {
|
||||
pid_t ParentProcessID() const { return process_info_.ParentProcessID(); }
|
||||
|
||||
//! \brief Return a memory reader for the target process.
|
||||
ProcessMemory* Memory() { return connection_->Memory(); }
|
||||
const ProcessMemory* Memory() const { return connection_->Memory(); }
|
||||
|
||||
//! \brief Return a memory map of the target process.
|
||||
MemoryMap* GetMemoryMap() { return &memory_map_; }
|
||||
|
@ -234,6 +234,11 @@ std::vector<const MemorySnapshot*> ProcessSnapshotLinux::ExtraMemory() const {
|
||||
return std::vector<const MemorySnapshot*>();
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotLinux::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
return process_reader_.Memory();
|
||||
}
|
||||
|
||||
void ProcessSnapshotLinux::InitializeThreads() {
|
||||
const std::vector<ProcessReaderLinux::Thread>& process_reader_threads =
|
||||
process_reader_.Threads();
|
||||
|
@ -115,6 +115,7 @@ class ProcessSnapshotLinux final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
void InitializeThreads();
|
||||
|
@ -217,6 +217,12 @@ std::vector<const MemorySnapshot*> ProcessSnapshotMac::ExtraMemory() const {
|
||||
return std::vector<const MemorySnapshot*>();
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotMac::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
NOTREACHED(); // https://crashpad.chromium.org/bug/263
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ProcessSnapshotMac::InitializeThreads() {
|
||||
const std::vector<ProcessReaderMac::Thread>& process_reader_threads =
|
||||
process_reader_.Threads();
|
||||
|
@ -131,6 +131,7 @@ class ProcessSnapshotMac final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
// Initializes threads_ on behalf of Initialize().
|
||||
|
@ -229,6 +229,11 @@ std::vector<const MemorySnapshot*> ProcessSnapshotMinidump::ExtraMemory()
|
||||
return std::vector<const MemorySnapshot*>();
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotMinidump::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ProcessSnapshotMinidump::InitializeCrashpadInfo() {
|
||||
const auto& stream_it = stream_map_.find(kMinidumpStreamTypeCrashpadInfo);
|
||||
if (stream_it == stream_map_.end()) {
|
||||
|
@ -81,6 +81,7 @@ class ProcessSnapshotMinidump final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
// Initializes data carried in a MinidumpCrashpadInfo stream on behalf of
|
||||
|
@ -31,6 +31,7 @@ class ExceptionSnapshot;
|
||||
class MemoryMapRegionSnapshot;
|
||||
class MemorySnapshot;
|
||||
class ModuleSnapshot;
|
||||
class ProcessMemory;
|
||||
class SystemSnapshot;
|
||||
class ThreadSnapshot;
|
||||
class UnloadedModuleSnapshot;
|
||||
@ -193,6 +194,14 @@ class ProcessSnapshot {
|
||||
//! are scoped to the lifetime of the ProcessSnapshot object that they
|
||||
//! were obtained from.
|
||||
virtual std::vector<const MemorySnapshot*> ExtraMemory() const = 0;
|
||||
|
||||
//! \brief Returns a ProcessMemory object that allows accessing the process'
|
||||
//! memory directly.
|
||||
//!
|
||||
//! \return A ProcessMemory object. The caller does not take ownership of this
|
||||
//! object, it is scoped to the lifetime of the ProcessSnapshot object
|
||||
//! that it was obtained from.
|
||||
virtual const ProcessMemory* Memory() const = 0;
|
||||
};
|
||||
|
||||
} // namespace crashpad
|
||||
|
@ -262,4 +262,10 @@ std::vector<const MemorySnapshot*> ProcessSnapshotSanitized::ExtraMemory()
|
||||
return snapshot_->ExtraMemory();
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotSanitized::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
NOTREACHED(); // https://crashpad.chromium.org/bug/263
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace crashpad
|
||||
|
@ -83,6 +83,7 @@ class ProcessSnapshotSanitized final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
// Only used when annotations_whitelist_ != nullptr.
|
||||
|
@ -35,7 +35,8 @@ TestProcessSnapshot::TestProcessSnapshot()
|
||||
exception_(),
|
||||
memory_map_(),
|
||||
handles_(),
|
||||
extra_memory_() {
|
||||
extra_memory_(),
|
||||
process_memory_() {
|
||||
}
|
||||
|
||||
TestProcessSnapshot::~TestProcessSnapshot() {
|
||||
@ -126,5 +127,9 @@ std::vector<const MemorySnapshot*> TestProcessSnapshot::ExtraMemory() const {
|
||||
return extra_memory;
|
||||
}
|
||||
|
||||
const ProcessMemory* TestProcessSnapshot::Memory() const {
|
||||
return process_memory_.get();
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace crashpad
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "snapshot/thread_snapshot.h"
|
||||
#include "snapshot/unloaded_module_snapshot.h"
|
||||
#include "util/misc/uuid.h"
|
||||
#include "util/process/process_memory.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@ -134,6 +135,15 @@ class TestProcessSnapshot final : public ProcessSnapshot {
|
||||
extra_memory_.push_back(std::move(extra_memory));
|
||||
}
|
||||
|
||||
//! \brief Add a process memory object to be returned by Memory().
|
||||
//!
|
||||
//! \param[in] process_memory The memory object that will be returned by
|
||||
//! Memory(). The TestProcessSnapshot object takes ownership of \a
|
||||
//! extra_memory.
|
||||
void SetProcessMemory(std::unique_ptr<ProcessMemory> process_memory) {
|
||||
process_memory_ = std::move(process_memory);
|
||||
}
|
||||
|
||||
// ProcessSnapshot:
|
||||
|
||||
pid_t ProcessID() const override;
|
||||
@ -153,6 +163,7 @@ class TestProcessSnapshot final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
pid_t process_id_;
|
||||
@ -172,6 +183,7 @@ class TestProcessSnapshot final : public ProcessSnapshot {
|
||||
std::vector<std::unique_ptr<MemoryMapRegionSnapshot>> memory_map_;
|
||||
std::vector<HandleSnapshot> handles_;
|
||||
std::vector<std::unique_ptr<MemorySnapshot>> extra_memory_;
|
||||
std::unique_ptr<ProcessMemory> process_memory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TestProcessSnapshot);
|
||||
};
|
||||
|
@ -232,6 +232,11 @@ std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const {
|
||||
return extra_memory;
|
||||
}
|
||||
|
||||
const ProcessMemory* ProcessSnapshotWin::Memory() const {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
return process_reader_.Memory();
|
||||
}
|
||||
|
||||
void ProcessSnapshotWin::InitializeThreads(
|
||||
bool gather_indirectly_referenced_memory,
|
||||
uint32_t indirectly_referenced_memory_cap) {
|
||||
|
@ -129,6 +129,7 @@ class ProcessSnapshotWin final : public ProcessSnapshot {
|
||||
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
||||
std::vector<HandleSnapshot> Handles() const override;
|
||||
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
||||
const ProcessMemory* Memory() const override;
|
||||
|
||||
private:
|
||||
// Initializes threads_ on behalf of Initialize().
|
||||
|
Loading…
x
Reference in New Issue
Block a user