From d85f898a696a5b44042a7772690352f7e89ad591 Mon Sep 17 00:00:00 2001 From: Clark DuVall Date: Mon, 10 Jun 2019 12:15:46 -0700 Subject: [PATCH] Refactor MemorySnapshotGeneric to use ProcessMemory instead of ProcessReader Also remove MemorySnapshotWin since the code is identical to MemorySnapshotGeneric now. Bug: crashpad:95 Change-Id: I9a631f8eb206dd72a69158021db87e8db41c5913 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1642148 Reviewed-by: Mark Mentovai Reviewed-by: Vlad Tsyrklevich Commit-Queue: Clark DuVall --- snapshot/BUILD.gn | 2 - snapshot/fuchsia/thread_snapshot_fuchsia.cc | 4 +- snapshot/fuchsia/thread_snapshot_fuchsia.h | 2 +- snapshot/linux/thread_snapshot_linux.cc | 5 +- snapshot/linux/thread_snapshot_linux.h | 2 +- snapshot/mac/thread_snapshot_mac.cc | 2 +- snapshot/mac/thread_snapshot_mac.h | 2 +- snapshot/memory_snapshot.h | 25 ------- snapshot/memory_snapshot_generic.h | 36 ++++++---- snapshot/snapshot.gyp | 2 - snapshot/win/capture_memory_delegate_win.cc | 10 +-- snapshot/win/capture_memory_delegate_win.h | 10 +-- snapshot/win/exception_snapshot_win.cc | 4 +- snapshot/win/exception_snapshot_win.h | 4 +- snapshot/win/memory_snapshot_win.cc | 75 --------------------- snapshot/win/memory_snapshot_win.h | 75 --------------------- snapshot/win/module_snapshot_win.cc | 8 +-- snapshot/win/process_snapshot_win.cc | 12 ++-- snapshot/win/process_snapshot_win.h | 12 ++-- snapshot/win/thread_snapshot_win.cc | 9 +-- snapshot/win/thread_snapshot_win.h | 8 +-- 21 files changed, 72 insertions(+), 237 deletions(-) delete mode 100644 snapshot/win/memory_snapshot_win.cc delete mode 100644 snapshot/win/memory_snapshot_win.h diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 25805c23..ae5b9cef 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -170,8 +170,6 @@ static_library("snapshot") { "win/exception_snapshot_win.h", "win/memory_map_region_snapshot_win.cc", "win/memory_map_region_snapshot_win.h", - "win/memory_snapshot_win.cc", - "win/memory_snapshot_win.h", "win/module_snapshot_win.cc", "win/module_snapshot_win.h", "win/pe_image_annotations_reader.cc", diff --git a/snapshot/fuchsia/thread_snapshot_fuchsia.cc b/snapshot/fuchsia/thread_snapshot_fuchsia.cc index b3a4cec1..462cdb1f 100644 --- a/snapshot/fuchsia/thread_snapshot_fuchsia.cc +++ b/snapshot/fuchsia/thread_snapshot_fuchsia.cc @@ -52,9 +52,9 @@ bool ThreadSnapshotFuchsia::Initialize( #endif if (thread.stack_regions.empty()) { - stack_.Initialize(process_reader, 0, 0); + stack_.Initialize(process_reader->Memory(), 0, 0); } else { - stack_.Initialize(process_reader, + stack_.Initialize(process_reader->Memory(), thread.stack_regions[0].base(), thread.stack_regions[0].size()); // TODO(scottmg): Handle split stack by adding other parts to ExtraMemory(). diff --git a/snapshot/fuchsia/thread_snapshot_fuchsia.h b/snapshot/fuchsia/thread_snapshot_fuchsia.h index db975976..45d4f117 100644 --- a/snapshot/fuchsia/thread_snapshot_fuchsia.h +++ b/snapshot/fuchsia/thread_snapshot_fuchsia.h @@ -67,7 +67,7 @@ class ThreadSnapshotFuchsia final : public ThreadSnapshot { #error Port. #endif CPUContext context_; - MemorySnapshotGeneric stack_; + MemorySnapshotGeneric stack_; zx_koid_t thread_id_; zx_vaddr_t thread_specific_data_address_; InitializationStateDcheck initialized_; diff --git a/snapshot/linux/thread_snapshot_linux.cc b/snapshot/linux/thread_snapshot_linux.cc index f40c78e8..e3e2bebd 100644 --- a/snapshot/linux/thread_snapshot_linux.cc +++ b/snapshot/linux/thread_snapshot_linux.cc @@ -190,8 +190,9 @@ bool ThreadSnapshotLinux::Initialize(ProcessReaderLinux* process_reader, #error Port. #endif - stack_.Initialize( - process_reader, thread.stack_region_address, thread.stack_region_size); + stack_.Initialize(process_reader->Memory(), + thread.stack_region_address, + thread.stack_region_size); thread_specific_data_address_ = thread.thread_info.thread_specific_data_address; diff --git a/snapshot/linux/thread_snapshot_linux.h b/snapshot/linux/thread_snapshot_linux.h index 17e471f3..44cc6f6d 100644 --- a/snapshot/linux/thread_snapshot_linux.h +++ b/snapshot/linux/thread_snapshot_linux.h @@ -73,7 +73,7 @@ class ThreadSnapshotLinux final : public ThreadSnapshot { #endif // ARCH_CPU_X86_FAMILY } context_union_; CPUContext context_; - MemorySnapshotGeneric stack_; + MemorySnapshotGeneric stack_; LinuxVMAddress thread_specific_data_address_; pid_t thread_id_; int priority_; diff --git a/snapshot/mac/thread_snapshot_mac.cc b/snapshot/mac/thread_snapshot_mac.cc index f45fc418..8fbb3e70 100644 --- a/snapshot/mac/thread_snapshot_mac.cc +++ b/snapshot/mac/thread_snapshot_mac.cc @@ -49,7 +49,7 @@ bool ThreadSnapshotMac::Initialize( thread_specific_data_address_ = process_reader_thread.thread_specific_data_address; - stack_.Initialize(process_reader, + stack_.Initialize(process_reader->Memory(), process_reader_thread.stack_region_address, process_reader_thread.stack_region_size); diff --git a/snapshot/mac/thread_snapshot_mac.h b/snapshot/mac/thread_snapshot_mac.h index 8f5d722b..946b0085 100644 --- a/snapshot/mac/thread_snapshot_mac.h +++ b/snapshot/mac/thread_snapshot_mac.h @@ -70,7 +70,7 @@ class ThreadSnapshotMac final : public ThreadSnapshot { } context_union_; #endif CPUContext context_; - MemorySnapshotGeneric stack_; + MemorySnapshotGeneric stack_; uint64_t thread_id_; uint64_t thread_specific_data_address_; thread_t thread_; diff --git a/snapshot/memory_snapshot.h b/snapshot/memory_snapshot.h index 9e274a0e..5dbac5ad 100644 --- a/snapshot/memory_snapshot.h +++ b/snapshot/memory_snapshot.h @@ -111,31 +111,6 @@ bool DetermineMergedRange(const MemorySnapshot* a, const MemorySnapshot* b, CheckedRange* merged); -namespace internal { - -//! \brief A standard implementation of MemorySnapshot::MergeWithOtherSnapshot() -//! for concrete MemorySnapshot implementations that use a -//! `process_reader_`. -template -const MemorySnapshot* MergeWithOtherSnapshotImpl(const T* self, - const MemorySnapshot* other) { - const T* other_as_memory_snapshot_concrete = - reinterpret_cast(other); - if (self->process_reader_ != - other_as_memory_snapshot_concrete->process_reader_) { - LOG(ERROR) << "different process_reader_ for snapshots"; - return nullptr; - } - CheckedRange merged(0, 0); - if (!LoggingDetermineMergedRange(self, other, &merged)) - return nullptr; - - std::unique_ptr result(new T()); - result->Initialize(self->process_reader_, merged.base(), merged.size()); - return result.release(); -} - -} // namespace internal } // namespace crashpad #endif // CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_H_ diff --git a/snapshot/memory_snapshot_generic.h b/snapshot/memory_snapshot_generic.h index 402e913e..1a74d4e4 100644 --- a/snapshot/memory_snapshot_generic.h +++ b/snapshot/memory_snapshot_generic.h @@ -19,6 +19,7 @@ #include #include "base/macros.h" +#include "base/numerics/safe_math.h" #include "snapshot/memory_snapshot.h" #include "util/misc/address_types.h" #include "util/misc/initialization_state_dcheck.h" @@ -30,7 +31,6 @@ namespace internal { //! \brief A MemorySnapshot of a memory region in a process on the running //! system. Used on Mac, Linux, Android, and Fuchsia, templated on the //! platform-specific ProcessReader type. -template class MemorySnapshotGeneric final : public MemorySnapshot { public: MemorySnapshotGeneric() = default; @@ -42,25 +42,25 @@ class MemorySnapshotGeneric final : public MemorySnapshot { //! until Read() is called, and the memory snapshot data is discared when //! Read() returns. //! - //! \param[in] process_reader A reader for the process being snapshotted. + //! \param[in] process_memory A reader for the process being snapshotted. //! \param[in] address The base address of the memory region to snapshot, in //! the snapshot process’ address space. //! \param[in] size The size of the memory region to snapshot. - void Initialize(ProcessReaderType* process_reader, + void Initialize(const ProcessMemory* process_memory, VMAddress address, VMSize size) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - process_reader_ = process_reader; + process_memory_ = process_memory; address_ = address; - size_ = size; + size_ = base::checked_cast(size); INITIALIZATION_STATE_SET_VALID(initialized_); } // MemorySnapshot: uint64_t Address() const override { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return address_; + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + return address_; } size_t Size() const override { @@ -76,7 +76,7 @@ class MemorySnapshotGeneric final : public MemorySnapshot { } std::unique_ptr buffer(new uint8_t[size_]); - if (!process_reader_->Memory()->Read(address_, size_, buffer.get())) { + if (!process_memory_->Read(address_, size_, buffer.get())) { return false; } return delegate->MemorySnapshotDelegateRead(buffer.get(), size_); @@ -84,7 +84,19 @@ class MemorySnapshotGeneric final : public MemorySnapshot { const MemorySnapshot* MergeWithOtherSnapshot( const MemorySnapshot* other) const override { - return MergeWithOtherSnapshotImpl(this, other); + const MemorySnapshotGeneric* other_as_memory_snapshot_concrete = + reinterpret_cast(other); + if (process_memory_ != other_as_memory_snapshot_concrete->process_memory_) { + LOG(ERROR) << "different process_memory_ for snapshots"; + return nullptr; + } + CheckedRange merged(0, 0); + if (!LoggingDetermineMergedRange(this, other, &merged)) + return nullptr; + + auto result = std::make_unique(); + result->Initialize(process_memory_, merged.base(), merged.size()); + return result.release(); } private: @@ -93,9 +105,9 @@ class MemorySnapshotGeneric final : public MemorySnapshot { const T* self, const MemorySnapshot* other); - ProcessReaderType* process_reader_; // weak - uint64_t address_; - uint64_t size_; + const ProcessMemory* process_memory_; // weak + VMAddress address_; + size_t size_; InitializationStateDcheck initialized_; DISALLOW_COPY_AND_ASSIGN(MemorySnapshotGeneric); diff --git a/snapshot/snapshot.gyp b/snapshot/snapshot.gyp index 0b4e157b..c4b7d52e 100644 --- a/snapshot/snapshot.gyp +++ b/snapshot/snapshot.gyp @@ -155,8 +155,6 @@ 'win/capture_memory_delegate_win.h', 'win/memory_map_region_snapshot_win.cc', 'win/memory_map_region_snapshot_win.h', - 'win/memory_snapshot_win.cc', - 'win/memory_snapshot_win.h', 'win/module_snapshot_win.cc', 'win/module_snapshot_win.h', 'win/pe_image_annotations_reader.cc', diff --git a/snapshot/win/capture_memory_delegate_win.cc b/snapshot/win/capture_memory_delegate_win.cc index b652f4a4..ee5e5d64 100644 --- a/snapshot/win/capture_memory_delegate_win.cc +++ b/snapshot/win/capture_memory_delegate_win.cc @@ -17,7 +17,7 @@ #include #include "base/numerics/safe_conversions.h" -#include "snapshot/win/memory_snapshot_win.h" +#include "snapshot/memory_snapshot_generic.h" namespace crashpad { namespace internal { @@ -25,7 +25,7 @@ namespace internal { CaptureMemoryDelegateWin::CaptureMemoryDelegateWin( ProcessReaderWin* process_reader, const ProcessReaderWin::Thread& thread, - std::vector>* snapshots, + std::vector>* snapshots, uint32_t* budget_remaining) : stack_(thread.stack_region_address, thread.stack_region_size), process_reader_(process_reader), @@ -57,9 +57,9 @@ void CaptureMemoryDelegateWin::AddNewMemorySnapshot( return; if (budget_remaining_ && *budget_remaining_ == 0) return; - snapshots_->push_back(std::make_unique()); - internal::MemorySnapshotWin* snapshot = snapshots_->back().get(); - snapshot->Initialize(process_reader_, range.base(), range.size()); + snapshots_->push_back(std::make_unique()); + internal::MemorySnapshotGeneric* snapshot = snapshots_->back().get(); + snapshot->Initialize(process_reader_->Memory(), range.base(), range.size()); if (budget_remaining_) { if (!base::IsValueInRangeForNumericType(range.size())) { *budget_remaining_ = 0; diff --git a/snapshot/win/capture_memory_delegate_win.h b/snapshot/win/capture_memory_delegate_win.h index 175b4c95..85c3db97 100644 --- a/snapshot/win/capture_memory_delegate_win.h +++ b/snapshot/win/capture_memory_delegate_win.h @@ -28,7 +28,7 @@ namespace crashpad { namespace internal { -class MemorySnapshotWin; +class MemorySnapshotGeneric; class CaptureMemoryDelegateWin : public CaptureMemory::Delegate { public: @@ -38,15 +38,15 @@ class CaptureMemoryDelegateWin : public CaptureMemory::Delegate { //! \param[in] thread The thread being inspected. Memory ranges overlapping //! this thread's stack will be ignored on the assumption that they're //! already captured elsewhere. - //! \param[in] snapshots A vector of MemorySnapshotWin to which the captured - //! memory will be added. + //! \param[in] snapshots A vector of MemorySnapshotGeneric to which the + //! captured memory will be added. //! \param[in] budget_remaining If non-null, a pointer to the remaining number //! of bytes to capture. If this is `0`, no further memory will be //! captured. CaptureMemoryDelegateWin( ProcessReaderWin* process_reader, const ProcessReaderWin::Thread& thread, - std::vector>* snapshots, + std::vector>* snapshots, uint32_t* budget_remaining); // MemoryCaptureDelegate: @@ -60,7 +60,7 @@ class CaptureMemoryDelegateWin : public CaptureMemory::Delegate { private: CheckedRange stack_; ProcessReaderWin* process_reader_; // weak - std::vector>* snapshots_; // weak + std::vector>* snapshots_; // weak uint32_t* budget_remaining_; }; diff --git a/snapshot/win/exception_snapshot_win.cc b/snapshot/win/exception_snapshot_win.cc index e8ea1e89..3413a403 100644 --- a/snapshot/win/exception_snapshot_win.cc +++ b/snapshot/win/exception_snapshot_win.cc @@ -17,9 +17,9 @@ #include "client/crashpad_client.h" #include "snapshot/capture_memory.h" #include "snapshot/memory_snapshot.h" -#include "snapshot/win/cpu_context_win.h" +#include "snapshot/memory_snapshot_generic.h" #include "snapshot/win/capture_memory_delegate_win.h" -#include "snapshot/win/memory_snapshot_win.h" +#include "snapshot/win/cpu_context_win.h" #include "snapshot/win/process_reader_win.h" #include "util/win/nt_internals.h" diff --git a/snapshot/win/exception_snapshot_win.h b/snapshot/win/exception_snapshot_win.h index 1eed538c..fd4e8543 100644 --- a/snapshot/win/exception_snapshot_win.h +++ b/snapshot/win/exception_snapshot_win.h @@ -36,7 +36,7 @@ class ProcessReaderWin; namespace internal { -class MemorySnapshotWin; +class MemorySnapshotGeneric; union CPUContextUnion { #if defined(ARCH_CPU_X86_FAMILY) @@ -96,7 +96,7 @@ class ExceptionSnapshotWin final : public ExceptionSnapshot { CPUContextUnion context_union_; CPUContext context_; std::vector codes_; - std::vector> extra_memory_; + std::vector> extra_memory_; uint64_t thread_id_; uint64_t exception_address_; uint32_t exception_flags_; diff --git a/snapshot/win/memory_snapshot_win.cc b/snapshot/win/memory_snapshot_win.cc deleted file mode 100644 index d56b9520..00000000 --- a/snapshot/win/memory_snapshot_win.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 The Crashpad Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "snapshot/win/memory_snapshot_win.h" - -namespace crashpad { -namespace internal { - -MemorySnapshotWin::MemorySnapshotWin() - : MemorySnapshot(), - process_reader_(nullptr), - address_(0), - size_(0), - initialized_() { -} - -MemorySnapshotWin::~MemorySnapshotWin() { -} - -void MemorySnapshotWin::Initialize(ProcessReaderWin* process_reader, - uint64_t address, - uint64_t size) { - INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - process_reader_ = process_reader; - address_ = address; - DLOG_IF(WARNING, size >= std::numeric_limits::max()) - << "size overflow"; - size_ = static_cast(size); - INITIALIZATION_STATE_SET_VALID(initialized_); -} - -uint64_t MemorySnapshotWin::Address() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return address_; -} - -size_t MemorySnapshotWin::Size() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return size_; -} - -bool MemorySnapshotWin::Read(Delegate* delegate) const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - - if (size_ == 0) { - return delegate->MemorySnapshotDelegateRead(nullptr, size_); - } - - std::unique_ptr buffer(new uint8_t[size_]); - if (!process_reader_->Memory()->Read(address_, size_, buffer.get())) { - return false; - } - return delegate->MemorySnapshotDelegateRead(buffer.get(), size_); -} - -const MemorySnapshot* MemorySnapshotWin::MergeWithOtherSnapshot( - const MemorySnapshot* other) const { - return MergeWithOtherSnapshotImpl(this, other); -} - -} // namespace internal -} // namespace crashpad diff --git a/snapshot/win/memory_snapshot_win.h b/snapshot/win/memory_snapshot_win.h deleted file mode 100644 index ebc878b8..00000000 --- a/snapshot/win/memory_snapshot_win.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 The Crashpad Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRASHPAD_SNAPSHOT_WIN_MEMORY_SNAPSHOT_WIN_H_ -#define CRASHPAD_SNAPSHOT_WIN_MEMORY_SNAPSHOT_WIN_H_ - -#include -#include - -#include "base/macros.h" -#include "snapshot/memory_snapshot.h" -#include "snapshot/win/process_reader_win.h" -#include "util/misc/initialization_state_dcheck.h" - -namespace crashpad { -namespace internal { - -//! \brief A MemorySnapshot of a memory region in a process on the running -//! system, when the system runs Windows. -class MemorySnapshotWin final : public MemorySnapshot { - public: - MemorySnapshotWin(); - ~MemorySnapshotWin() override; - - //! \brief Initializes the object. - //! - //! Memory is read lazily. No attempt is made to read the memory snapshot data - //! until Read() is called, and the memory snapshot data is discared when - //! Read() returns. - //! - //! \param[in] process_reader A reader for the process being snapshotted. - //! \param[in] address The base address of the memory region to snapshot, in - //! the snapshot process' address space. - //! \param[in] size The size of the memory region to snapshot. - void Initialize(ProcessReaderWin* process_reader, - uint64_t address, - uint64_t size); - - // MemorySnapshot: - - uint64_t Address() const override; - size_t Size() const override; - bool Read(Delegate* delegate) const override; - const MemorySnapshot* MergeWithOtherSnapshot( - const MemorySnapshot* other) const override; - - private: - template - friend const MemorySnapshot* MergeWithOtherSnapshotImpl( - const T* self, - const MemorySnapshot* other); - - ProcessReaderWin* process_reader_; // weak - uint64_t address_; - size_t size_; - InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(MemorySnapshotWin); -}; - -} // namespace internal -} // namespace crashpad - -#endif // CRASHPAD_SNAPSHOT_WIN_MEMORY_SNAPSHOT_WIN_H_ diff --git a/snapshot/win/module_snapshot_win.cc b/snapshot/win/module_snapshot_win.cc index 49d178a8..c7aaad8d 100644 --- a/snapshot/win/module_snapshot_win.cc +++ b/snapshot/win/module_snapshot_win.cc @@ -19,7 +19,7 @@ #include "base/strings/utf_string_conversions.h" #include "client/crashpad_info.h" #include "client/simple_address_range_bag.h" -#include "snapshot/win/memory_snapshot_win.h" +#include "snapshot/memory_snapshot_generic.h" #include "snapshot/win/pe_image_annotations_reader.h" #include "snapshot/win/pe_image_reader.h" #include "util/misc/tri_state.h" @@ -327,10 +327,10 @@ void ModuleSnapshotWin::GetCrashpadUserMinidumpStreams( } if (list_entry.size != 0) { - std::unique_ptr memory( - new internal::MemorySnapshotWin()); + std::unique_ptr memory( + new internal::MemorySnapshotGeneric()); memory->Initialize( - process_reader_, list_entry.base_address, list_entry.size); + process_reader_->Memory(), list_entry.base_address, list_entry.size); streams->push_back(std::make_unique( list_entry.stream_type, memory.release())); } diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc index d2eef49a..cafe7b42 100644 --- a/snapshot/win/process_snapshot_win.cc +++ b/snapshot/win/process_snapshot_win.cc @@ -459,7 +459,7 @@ void ProcessSnapshotWin::InitializePebData( void ProcessSnapshotWin::AddMemorySnapshot( WinVMAddress address, WinVMSize size, - std::vector>* into) { + std::vector>* into) { if (size == 0) return; @@ -480,14 +480,14 @@ void ProcessSnapshotWin::AddMemorySnapshot( } } - into->push_back(std::make_unique()); - into->back()->Initialize(&process_reader_, address, size); + into->push_back(std::make_unique()); + into->back()->Initialize(process_reader_.Memory(), address, size); } template void ProcessSnapshotWin::AddMemorySnapshotForUNICODE_STRING( const process_types::UNICODE_STRING& us, - std::vector>* into) { + std::vector>* into) { AddMemorySnapshot(us.Buffer, us.Length, into); } @@ -495,7 +495,7 @@ template void ProcessSnapshotWin::AddMemorySnapshotForLdrLIST_ENTRY( const process_types::LIST_ENTRY& le, size_t offset_of_member, - std::vector>* into) { + std::vector>* into) { // Walk the doubly-linked list of entries, adding the list memory itself, as // well as pointed-to strings. typename Traits::Pointer last = le.Blink; @@ -545,7 +545,7 @@ WinVMSize ProcessSnapshotWin::DetermineSizeOfEnvironmentBlock( template void ProcessSnapshotWin::ReadLock( WinVMAddress start, - std::vector>* into) { + std::vector>* into) { // We're walking the RTL_CRITICAL_SECTION_DEBUG ProcessLocksList, but starting // from an actual RTL_CRITICAL_SECTION, so start by getting to the first // RTL_CRITICAL_SECTION_DEBUG. diff --git a/snapshot/win/process_snapshot_win.h b/snapshot/win/process_snapshot_win.h index 4acfe398..8b0bf526 100644 --- a/snapshot/win/process_snapshot_win.h +++ b/snapshot/win/process_snapshot_win.h @@ -31,6 +31,7 @@ #include "snapshot/exception_snapshot.h" #include "snapshot/memory_map_region_snapshot.h" #include "snapshot/memory_snapshot.h" +#include "snapshot/memory_snapshot_generic.h" #include "snapshot/module_snapshot.h" #include "snapshot/process_snapshot.h" #include "snapshot/system_snapshot.h" @@ -38,7 +39,6 @@ #include "snapshot/unloaded_module_snapshot.h" #include "snapshot/win/exception_snapshot_win.h" #include "snapshot/win/memory_map_region_snapshot_win.h" -#include "snapshot/win/memory_snapshot_win.h" #include "snapshot/win/module_snapshot_win.h" #include "snapshot/win/system_snapshot_win.h" #include "snapshot/win/thread_snapshot_win.h" @@ -154,18 +154,18 @@ class ProcessSnapshotWin final : public ProcessSnapshot { void AddMemorySnapshot( WinVMAddress address, WinVMSize size, - std::vector>* into); + std::vector>* into); template void AddMemorySnapshotForUNICODE_STRING( const process_types::UNICODE_STRING& us, - std::vector>* into); + std::vector>* into); template void AddMemorySnapshotForLdrLIST_ENTRY( const process_types::LIST_ENTRY& le, size_t offset_of_member, - std::vector>* into); + std::vector>* into); WinVMSize DetermineSizeOfEnvironmentBlock( WinVMAddress start_of_environment_block); @@ -175,10 +175,10 @@ class ProcessSnapshotWin final : public ProcessSnapshot { template void ReadLock( WinVMAddress start, - std::vector>* into); + std::vector>* into); internal::SystemSnapshotWin system_; - std::vector> extra_memory_; + std::vector> extra_memory_; std::vector> threads_; std::vector> modules_; std::vector unloaded_modules_; diff --git a/snapshot/win/thread_snapshot_win.cc b/snapshot/win/thread_snapshot_win.cc index f381a4b9..02cc63c5 100644 --- a/snapshot/win/thread_snapshot_win.cc +++ b/snapshot/win/thread_snapshot_win.cc @@ -48,19 +48,20 @@ bool ThreadSnapshotWin::Initialize( if (process_reader->GetProcessInfo().LoggingRangeIsFullyReadable( CheckedRange(thread_.stack_region_address, thread_.stack_region_size))) { - stack_.Initialize(process_reader, + stack_.Initialize(process_reader->Memory(), thread_.stack_region_address, thread_.stack_region_size); } else { - stack_.Initialize(process_reader, 0, 0); + stack_.Initialize(process_reader->Memory(), 0, 0); } if (process_reader->GetProcessInfo().LoggingRangeIsFullyReadable( CheckedRange(thread_.teb_address, thread_.teb_size))) { - teb_.Initialize(process_reader, thread_.teb_address, thread_.teb_size); + teb_.Initialize( + process_reader->Memory(), thread_.teb_address, thread_.teb_size); } else { - teb_.Initialize(process_reader, 0, 0); + teb_.Initialize(process_reader->Memory(), 0, 0); } #if defined(ARCH_CPU_X86) diff --git a/snapshot/win/thread_snapshot_win.h b/snapshot/win/thread_snapshot_win.h index 63465803..64ec43de 100644 --- a/snapshot/win/thread_snapshot_win.h +++ b/snapshot/win/thread_snapshot_win.h @@ -24,8 +24,8 @@ #include "build/build_config.h" #include "snapshot/cpu_context.h" #include "snapshot/memory_snapshot.h" +#include "snapshot/memory_snapshot_generic.h" #include "snapshot/thread_snapshot.h" -#include "snapshot/win/memory_snapshot_win.h" #include "snapshot/win/process_reader_win.h" #include "util/misc/initialization_state_dcheck.h" @@ -82,11 +82,11 @@ class ThreadSnapshotWin final : public ThreadSnapshot { #endif } context_union_; CPUContext context_; - MemorySnapshotWin stack_; - MemorySnapshotWin teb_; + MemorySnapshotGeneric stack_; + MemorySnapshotGeneric teb_; ProcessReaderWin::Thread thread_; InitializationStateDcheck initialized_; - std::vector> pointed_to_memory_; + std::vector> pointed_to_memory_; DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotWin); };