| Index: third_party/crashpad/crashpad/minidump/minidump_memory_writer.cc
|
| diff --git a/third_party/crashpad/crashpad/minidump/minidump_memory_writer.cc b/third_party/crashpad/crashpad/minidump/minidump_memory_writer.cc
|
| index 064b6e94e5b41476bae691c891e0eb203cb39dc6..9513c73975c7fd81f3436a494d617e8306e9bfd3 100644
|
| --- a/third_party/crashpad/crashpad/minidump/minidump_memory_writer.cc
|
| +++ b/third_party/crashpad/crashpad/minidump/minidump_memory_writer.cc
|
| @@ -24,77 +24,45 @@
|
| #include "util/numeric/safe_assignment.h"
|
|
|
| namespace crashpad {
|
| -namespace {
|
| -
|
| -class SnapshotMinidumpMemoryWriter final : public MinidumpMemoryWriter,
|
| - public MemorySnapshot::Delegate {
|
| - public:
|
| - explicit SnapshotMinidumpMemoryWriter(const MemorySnapshot* memory_snapshot)
|
| - : MinidumpMemoryWriter(),
|
| - MemorySnapshot::Delegate(),
|
| - memory_snapshot_(memory_snapshot),
|
| - file_writer_(nullptr) {
|
| - }
|
| -
|
| - ~SnapshotMinidumpMemoryWriter() override {}
|
| -
|
| - // MemorySnapshot::Delegate:
|
| -
|
| - bool MemorySnapshotDelegateRead(void* data, size_t size) override {
|
| - DCHECK_EQ(state(), kStateWritable);
|
| - DCHECK_EQ(size, MemoryRangeSize());
|
| - return file_writer_->Write(data, size);
|
| - }
|
| -
|
| - protected:
|
| - // MinidumpMemoryWriter:
|
|
|
| - bool WriteObject(FileWriterInterface* file_writer) override {
|
| - DCHECK_EQ(state(), kStateWritable);
|
| - DCHECK(!file_writer_);
|
| -
|
| - base::AutoReset<FileWriterInterface*> file_writer_reset(&file_writer_,
|
| - file_writer);
|
| -
|
| - // This will result in MemorySnapshotDelegateRead() being called.
|
| - return memory_snapshot_->Read(this);
|
| - }
|
| -
|
| - uint64_t MemoryRangeBaseAddress() const override {
|
| - DCHECK_EQ(state(), kStateFrozen);
|
| - return memory_snapshot_->Address();
|
| - }
|
| -
|
| - size_t MemoryRangeSize() const override {
|
| - DCHECK_GE(state(), kStateFrozen);
|
| - return memory_snapshot_->Size();
|
| - }
|
| +SnapshotMinidumpMemoryWriter::SnapshotMinidumpMemoryWriter(
|
| + const MemorySnapshot* memory_snapshot)
|
| + : internal::MinidumpWritable(),
|
| + MemorySnapshot::Delegate(),
|
| + memory_descriptor_(),
|
| + registered_memory_descriptors_(),
|
| + memory_snapshot_(memory_snapshot),
|
| + file_writer_(nullptr) {}
|
|
|
| - private:
|
| - const MemorySnapshot* memory_snapshot_;
|
| - FileWriterInterface* file_writer_;
|
| +SnapshotMinidumpMemoryWriter::~SnapshotMinidumpMemoryWriter() {}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(SnapshotMinidumpMemoryWriter);
|
| -};
|
| +bool SnapshotMinidumpMemoryWriter::MemorySnapshotDelegateRead(void* data,
|
| + size_t size) {
|
| + DCHECK_EQ(state(), kStateWritable);
|
| + DCHECK_EQ(size, UnderlyingSnapshot().Size());
|
| + return file_writer_->Write(data, size);
|
| +}
|
|
|
| -} // namespace
|
| +bool SnapshotMinidumpMemoryWriter::WriteObject(
|
| + FileWriterInterface* file_writer) {
|
| + DCHECK_EQ(state(), kStateWritable);
|
| + DCHECK(!file_writer_);
|
|
|
| -MinidumpMemoryWriter::~MinidumpMemoryWriter() {
|
| -}
|
| + base::AutoReset<FileWriterInterface*> file_writer_reset(&file_writer_,
|
| + file_writer);
|
|
|
| -std::unique_ptr<MinidumpMemoryWriter> MinidumpMemoryWriter::CreateFromSnapshot(
|
| - const MemorySnapshot* memory_snapshot) {
|
| - return base::WrapUnique(new SnapshotMinidumpMemoryWriter(memory_snapshot));
|
| + // This will result in MemorySnapshotDelegateRead() being called.
|
| + return memory_snapshot_->Read(this);
|
| }
|
|
|
| const MINIDUMP_MEMORY_DESCRIPTOR*
|
| -MinidumpMemoryWriter::MinidumpMemoryDescriptor() const {
|
| +SnapshotMinidumpMemoryWriter::MinidumpMemoryDescriptor() const {
|
| DCHECK_EQ(state(), kStateWritable);
|
|
|
| return &memory_descriptor_;
|
| }
|
|
|
| -void MinidumpMemoryWriter::RegisterMemoryDescriptor(
|
| +void SnapshotMinidumpMemoryWriter::RegisterMemoryDescriptor(
|
| MINIDUMP_MEMORY_DESCRIPTOR* memory_descriptor) {
|
| DCHECK_LE(state(), kStateFrozen);
|
|
|
| @@ -102,13 +70,7 @@ void MinidumpMemoryWriter::RegisterMemoryDescriptor(
|
| RegisterLocationDescriptor(&memory_descriptor->Memory);
|
| }
|
|
|
| -MinidumpMemoryWriter::MinidumpMemoryWriter()
|
| - : MinidumpWritable(),
|
| - memory_descriptor_(),
|
| - registered_memory_descriptors_() {
|
| -}
|
| -
|
| -bool MinidumpMemoryWriter::Freeze() {
|
| +bool SnapshotMinidumpMemoryWriter::Freeze() {
|
| DCHECK_EQ(state(), kStateMutable);
|
|
|
| if (!MinidumpWritable::Freeze()) {
|
| @@ -120,26 +82,26 @@ bool MinidumpMemoryWriter::Freeze() {
|
| return true;
|
| }
|
|
|
| -size_t MinidumpMemoryWriter::Alignment() {
|
| +size_t SnapshotMinidumpMemoryWriter::Alignment() {
|
| DCHECK_GE(state(), kStateFrozen);
|
|
|
| return 16;
|
| }
|
|
|
| -size_t MinidumpMemoryWriter::SizeOfObject() {
|
| +size_t SnapshotMinidumpMemoryWriter::SizeOfObject() {
|
| DCHECK_GE(state(), kStateFrozen);
|
|
|
| - return MemoryRangeSize();
|
| + return UnderlyingSnapshot().Size();
|
| }
|
|
|
| -bool MinidumpMemoryWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
| +bool SnapshotMinidumpMemoryWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
| DCHECK_EQ(state(), kStateFrozen);
|
|
|
| // There will always be at least one registered descriptor, the one for this
|
| // object’s own memory_descriptor_ field.
|
| DCHECK_GE(registered_memory_descriptors_.size(), 1u);
|
|
|
| - uint64_t base_address = MemoryRangeBaseAddress();
|
| + uint64_t base_address = UnderlyingSnapshot().Address();
|
| decltype(registered_memory_descriptors_[0]->StartOfMemoryRange) local_address;
|
| if (!AssignIfInRange(&local_address, base_address)) {
|
| LOG(ERROR) << "base_address " << base_address << " out of range";
|
| @@ -154,7 +116,7 @@ bool MinidumpMemoryWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
| return MinidumpWritable::WillWriteAtOffsetImpl(offset);
|
| }
|
|
|
| -internal::MinidumpWritable::Phase MinidumpMemoryWriter::WritePhase() {
|
| +internal::MinidumpWritable::Phase SnapshotMinidumpMemoryWriter::WritePhase() {
|
| // Memory dumps are large and are unlikely to be consumed in their entirety.
|
| // Data accesses are expected to be sparse and sporadic, and are expected to
|
| // occur after all of the other structural and informational data from the
|
| @@ -178,14 +140,14 @@ void MinidumpMemoryListWriter::AddFromSnapshot(
|
| DCHECK_EQ(state(), kStateMutable);
|
|
|
| for (const MemorySnapshot* memory_snapshot : memory_snapshots) {
|
| - std::unique_ptr<MinidumpMemoryWriter> memory =
|
| - MinidumpMemoryWriter::CreateFromSnapshot(memory_snapshot);
|
| + std::unique_ptr<SnapshotMinidumpMemoryWriter> memory(
|
| + new SnapshotMinidumpMemoryWriter(memory_snapshot));
|
| AddMemory(std::move(memory));
|
| }
|
| }
|
|
|
| void MinidumpMemoryListWriter::AddMemory(
|
| - std::unique_ptr<MinidumpMemoryWriter> memory_writer) {
|
| + std::unique_ptr<SnapshotMinidumpMemoryWriter> memory_writer) {
|
| DCHECK_EQ(state(), kStateMutable);
|
|
|
| AddExtraMemory(memory_writer.get());
|
| @@ -193,7 +155,7 @@ void MinidumpMemoryListWriter::AddMemory(
|
| }
|
|
|
| void MinidumpMemoryListWriter::AddExtraMemory(
|
| - MinidumpMemoryWriter* memory_writer) {
|
| + SnapshotMinidumpMemoryWriter* memory_writer) {
|
| DCHECK_EQ(state(), kStateMutable);
|
|
|
| memory_writers_.push_back(memory_writer);
|
| @@ -232,7 +194,7 @@ std::vector<internal::MinidumpWritable*> MinidumpMemoryListWriter::Children() {
|
| DCHECK_LE(children_.size(), memory_writers_.size());
|
|
|
| std::vector<MinidumpWritable*> children;
|
| - for (MinidumpMemoryWriter* child : children_) {
|
| + for (SnapshotMinidumpMemoryWriter* child : children_) {
|
| children.push_back(child);
|
| }
|
|
|
| @@ -247,7 +209,7 @@ bool MinidumpMemoryListWriter::WriteObject(FileWriterInterface* file_writer) {
|
| iov.iov_len = sizeof(memory_list_base_);
|
| std::vector<WritableIoVec> iovecs(1, iov);
|
|
|
| - for (const MinidumpMemoryWriter* memory_writer : memory_writers_) {
|
| + for (const SnapshotMinidumpMemoryWriter* memory_writer : memory_writers_) {
|
| iov.iov_base = memory_writer->MinidumpMemoryDescriptor();
|
| iov.iov_len = sizeof(MINIDUMP_MEMORY_DESCRIPTOR);
|
| iovecs.push_back(iov);
|
|
|