From 1aae5cedaf1e759fd05270ccb09642224bcfa555 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Tue, 20 Feb 2018 16:11:41 -0800 Subject: [PATCH] Refactor ModuleSnapshot(Linux|Fuchsia) into ModuleSnapshotElf They were largely the same after recent changes, so with a bit at initialization time the whole class can be de-duplicated. Bug: crashpad:196, crashpad:30 Change-Id: I2f5df797dfe36e120090e570273b48ee03f660a5 Reviewed-on: https://chromium-review.googlesource.com/927611 Reviewed-by: Joshua Peraza Reviewed-by: Mark Mentovai Commit-Queue: Scott Graham --- snapshot/BUILD.gn | 6 +- .../module_snapshot_elf.cc} | 76 ++++--- .../module_snapshot_elf.h} | 27 +-- snapshot/fuchsia/module_snapshot_fuchsia.cc | 197 ------------------ snapshot/fuchsia/module_snapshot_fuchsia.h | 97 --------- snapshot/fuchsia/process_snapshot_fuchsia.cc | 10 +- snapshot/fuchsia/process_snapshot_fuchsia.h | 4 +- snapshot/linux/process_snapshot_linux.cc | 5 +- snapshot/linux/process_snapshot_linux.h | 4 +- snapshot/snapshot.gyp | 4 +- 10 files changed, 64 insertions(+), 366 deletions(-) rename snapshot/{linux/module_snapshot_linux.cc => elf/module_snapshot_elf.cc} (73%) rename snapshot/{linux/module_snapshot_linux.h => elf/module_snapshot_elf.h} (80%) delete mode 100644 snapshot/fuchsia/module_snapshot_fuchsia.cc delete mode 100644 snapshot/fuchsia/module_snapshot_fuchsia.h diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 24de0efd..96df03d6 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -114,8 +114,6 @@ static_library("snapshot") { "linux/exception_snapshot_linux.h", "linux/memory_snapshot_linux.cc", "linux/memory_snapshot_linux.h", - "linux/module_snapshot_linux.cc", - "linux/module_snapshot_linux.h", "linux/process_reader.cc", "linux/process_reader.h", "linux/process_snapshot_linux.cc", @@ -140,6 +138,8 @@ static_library("snapshot") { "elf/elf_image_reader.h", "elf/elf_symbol_table_reader.cc", "elf/elf_symbol_table_reader.h", + "elf/module_snapshot_elf.cc", + "elf/module_snapshot_elf.h", ] } @@ -178,8 +178,6 @@ static_library("snapshot") { if (crashpad_is_fuchsia) { sources += [ - "fuchsia/module_snapshot_fuchsia.cc", - "fuchsia/module_snapshot_fuchsia.h", "fuchsia/process_reader.cc", "fuchsia/process_reader.h", "fuchsia/process_snapshot_fuchsia.cc", diff --git a/snapshot/linux/module_snapshot_linux.cc b/snapshot/elf/module_snapshot_elf.cc similarity index 73% rename from snapshot/linux/module_snapshot_linux.cc rename to snapshot/elf/module_snapshot_elf.cc index 17a03c1f..5c5039ee 100644 --- a/snapshot/linux/module_snapshot_linux.cc +++ b/snapshot/elf/module_snapshot_elf.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/linux/module_snapshot_linux.h" +#include "snapshot/elf/module_snapshot_elf.h" #include @@ -23,29 +23,26 @@ namespace crashpad { namespace internal { -ModuleSnapshotLinux::ModuleSnapshotLinux() +ModuleSnapshotElf::ModuleSnapshotElf(const std::string& name, + ElfImageReader* elf_reader, + ModuleSnapshot::ModuleType type) : ModuleSnapshot(), - name_(), - elf_reader_(nullptr), + name_(name), + elf_reader_(elf_reader), crashpad_info_(), - type_(kModuleTypeUnknown), + type_(type), initialized_() {} -ModuleSnapshotLinux::~ModuleSnapshotLinux() = default; +ModuleSnapshotElf::~ModuleSnapshotElf() = default; -bool ModuleSnapshotLinux::Initialize( - const ProcessReader::Module& process_reader_module) { +bool ModuleSnapshotElf::Initialize() { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - if (!process_reader_module.elf_reader) { + if (!elf_reader_) { LOG(ERROR) << "no elf reader"; return false; } - name_ = process_reader_module.name; - elf_reader_ = process_reader_module.elf_reader; - type_ = process_reader_module.type; - // The data payload is only sizeof(VMAddress) in the note, but add a bit to // account for the name, header, and padding. constexpr ssize_t kMaxNoteSize = 256; @@ -72,8 +69,7 @@ bool ModuleSnapshotLinux::Initialize( return true; } -bool ModuleSnapshotLinux::GetCrashpadOptions( - CrashpadInfoClientOptions* options) { +bool ModuleSnapshotElf::GetCrashpadOptions(CrashpadInfoClientOptions* options) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); if (!crashpad_info_) { @@ -91,27 +87,38 @@ bool ModuleSnapshotLinux::GetCrashpadOptions( return true; } -std::string ModuleSnapshotLinux::Name() const { +std::string ModuleSnapshotElf::Name() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return name_; } -uint64_t ModuleSnapshotLinux::Address() const { +uint64_t ModuleSnapshotElf::Address() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return elf_reader_->Address(); } -uint64_t ModuleSnapshotLinux::Size() const { +uint64_t ModuleSnapshotElf::Size() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return elf_reader_->Size(); } -time_t ModuleSnapshotLinux::Timestamp() const { +time_t ModuleSnapshotElf::Timestamp() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return 0; } -void ModuleSnapshotLinux::FileVersion(uint16_t* version_0, +void ModuleSnapshotElf::FileVersion(uint16_t* version_0, + uint16_t* version_1, + uint16_t* version_2, + uint16_t* version_3) const { + INITIALIZATION_STATE_DCHECK_VALID(initialized_); + *version_0 = 0; + *version_1 = 0; + *version_2 = 0; + *version_3 = 0; +} + +void ModuleSnapshotElf::SourceVersion(uint16_t* version_0, uint16_t* version_1, uint16_t* version_2, uint16_t* version_3) const { @@ -122,24 +129,12 @@ void ModuleSnapshotLinux::FileVersion(uint16_t* version_0, *version_3 = 0; } -void ModuleSnapshotLinux::SourceVersion(uint16_t* version_0, - uint16_t* version_1, - uint16_t* version_2, - uint16_t* version_3) const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - *version_0 = 0; - *version_1 = 0; - *version_2 = 0; - *version_3 = 0; -} - -ModuleSnapshot::ModuleType ModuleSnapshotLinux::GetModuleType() const { +ModuleSnapshot::ModuleType ModuleSnapshotElf::GetModuleType() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return type_; } -void ModuleSnapshotLinux::UUIDAndAge(crashpad::UUID* uuid, - uint32_t* age) const { +void ModuleSnapshotElf::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); *age = 0; @@ -151,17 +146,17 @@ void ModuleSnapshotLinux::UUIDAndAge(crashpad::UUID* uuid, uuid->InitializeFromBytes(reinterpret_cast(&desc[0])); } -std::string ModuleSnapshotLinux::DebugFileName() const { +std::string ModuleSnapshotElf::DebugFileName() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return base::FilePath(Name()).BaseName().value(); } -std::vector ModuleSnapshotLinux::AnnotationsVector() const { +std::vector ModuleSnapshotElf::AnnotationsVector() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return std::vector(); } -std::map ModuleSnapshotLinux::AnnotationsSimpleMap() +std::map ModuleSnapshotElf::AnnotationsSimpleMap() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); std::map annotations; @@ -172,7 +167,7 @@ std::map ModuleSnapshotLinux::AnnotationsSimpleMap() return annotations; } -std::vector ModuleSnapshotLinux::AnnotationObjects() const { +std::vector ModuleSnapshotElf::AnnotationObjects() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); std::vector annotations; if (crashpad_info_ && crashpad_info_->AnnotationsList()) { @@ -182,14 +177,13 @@ std::vector ModuleSnapshotLinux::AnnotationObjects() const { return annotations; } -std::set> ModuleSnapshotLinux::ExtraMemoryRanges() - const { +std::set> ModuleSnapshotElf::ExtraMemoryRanges() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return std::set>(); } std::vector -ModuleSnapshotLinux::CustomMinidumpStreams() const { +ModuleSnapshotElf::CustomMinidumpStreams() const { return std::vector(); } diff --git a/snapshot/linux/module_snapshot_linux.h b/snapshot/elf/module_snapshot_elf.h similarity index 80% rename from snapshot/linux/module_snapshot_linux.h rename to snapshot/elf/module_snapshot_elf.h index b277ff7a..1f7cf651 100644 --- a/snapshot/linux/module_snapshot_linux.h +++ b/snapshot/elf/module_snapshot_elf.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_ -#define CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_ +#ifndef CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_ +#define CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_ #include #include @@ -27,7 +27,6 @@ #include "snapshot/crashpad_info_client_options.h" #include "snapshot/crashpad_types/crashpad_info_reader.h" #include "snapshot/elf/elf_image_reader.h" -#include "snapshot/linux/process_reader.h" #include "snapshot/module_snapshot.h" #include "util/misc/initialization_state_dcheck.h" @@ -36,20 +35,22 @@ namespace crashpad { namespace internal { //! \brief A ModuleSnapshot of a code module (binary image) loaded into a -//! running (or crashed) process on a Linux system. -class ModuleSnapshotLinux final : public ModuleSnapshot { +//! running (or crashed) process on a system that uses ELF modules. +class ModuleSnapshotElf final : public ModuleSnapshot { public: - ModuleSnapshotLinux(); - ~ModuleSnapshotLinux() override; + //! \param[in] name The pathname used to load the module from disk. + //! \param[in] elf_reader An image reader for the module. + //! \param[in] type The module's type. + ModuleSnapshotElf(const std::string& name, + ElfImageReader* elf_reader, + ModuleSnapshot::ModuleType type); + ~ModuleSnapshotElf() override; //! \brief Initializes the object. //! - //! \param[in] process_reader_module The module within the ProcessReader for - //! which the snapshot should be created. - //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. - bool Initialize(const ProcessReader::Module& process_reader_module); + bool Initialize(); //! \brief Returns options from the module’s CrashpadInfo structure. //! @@ -87,10 +88,10 @@ class ModuleSnapshotLinux final : public ModuleSnapshot { ModuleType type_; InitializationStateDcheck initialized_; - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotLinux); + DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotElf); }; } // namespace internal } // namespace crashpad -#endif // CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_ +#endif // CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_ diff --git a/snapshot/fuchsia/module_snapshot_fuchsia.cc b/snapshot/fuchsia/module_snapshot_fuchsia.cc deleted file mode 100644 index 6a90edd0..00000000 --- a/snapshot/fuchsia/module_snapshot_fuchsia.cc +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2018 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 "snapshot/fuchsia/module_snapshot_fuchsia.h" - -#include - -#include "base/logging.h" -#include "snapshot/crashpad_types/image_annotation_reader.h" -#include "util/misc/elf_note_types.h" - -namespace crashpad { -namespace internal { - -ModuleSnapshotFuchsia::ModuleSnapshotFuchsia() = default; - -ModuleSnapshotFuchsia::~ModuleSnapshotFuchsia() = default; - -bool ModuleSnapshotFuchsia::Initialize( - const ProcessReader::Module& process_reader_module) { - INITIALIZATION_STATE_SET_INITIALIZING(initialized_); - - name_ = process_reader_module.name; - elf_image_reader_ = process_reader_module.reader; - type_ = process_reader_module.type; - if (!elf_image_reader_) { - return false; - } - - // The data payload is only sizeof(VMAddress) in the note, but add a bit to - // account for the name, header, and padding. - constexpr ssize_t kMaxNoteSize = 256; - std::unique_ptr notes = - elf_image_reader_->NotesWithNameAndType( - CRASHPAD_ELF_NOTE_NAME, - CRASHPAD_ELF_NOTE_TYPE_CRASHPAD_INFO, - kMaxNoteSize); - std::string desc; - VMAddress info_address; - if (notes->NextNote(nullptr, nullptr, &desc) == - ElfImageReader::NoteReader::Result::kSuccess) { - info_address = *reinterpret_cast(&desc[0]); - - ProcessMemoryRange range; - if (range.Initialize(*elf_image_reader_->Memory())) { - auto info = std::make_unique(); - if (info->Initialize(&range, info_address)) { - crashpad_info_ = std::move(info); - } - } - } - - INITIALIZATION_STATE_SET_VALID(initialized_); - return true; -} - -bool ModuleSnapshotFuchsia::GetCrashpadOptions( - CrashpadInfoClientOptions* options) { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - - if (!crashpad_info_) { - return false; - } - - options->crashpad_handler_behavior = - crashpad_info_->CrashpadHandlerBehavior(); - options->system_crash_reporter_forwarding = - crashpad_info_->SystemCrashReporterForwarding(); - options->gather_indirectly_referenced_memory = - crashpad_info_->GatherIndirectlyReferencedMemory(); - options->indirectly_referenced_memory_cap = - crashpad_info_->IndirectlyReferencedMemoryCap(); - return true; -} - -std::string ModuleSnapshotFuchsia::Name() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return name_; -} - -uint64_t ModuleSnapshotFuchsia::Address() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return elf_image_reader_->Address(); -} - -uint64_t ModuleSnapshotFuchsia::Size() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return elf_image_reader_->Address(); -} - -time_t ModuleSnapshotFuchsia::Timestamp() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return 0; -} - -void ModuleSnapshotFuchsia::FileVersion(uint16_t* version_0, - uint16_t* version_1, - uint16_t* version_2, - uint16_t* version_3) const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - *version_0 = 0; - *version_1 = 0; - *version_2 = 0; - *version_3 = 0; -} - -void ModuleSnapshotFuchsia::SourceVersion(uint16_t* version_0, - uint16_t* version_1, - uint16_t* version_2, - uint16_t* version_3) const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - *version_0 = 0; - *version_1 = 0; - *version_2 = 0; - *version_3 = 0; -} - -ModuleSnapshot::ModuleType ModuleSnapshotFuchsia::GetModuleType() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - return type_; -} - -void ModuleSnapshotFuchsia::UUIDAndAge(crashpad::UUID* uuid, - uint32_t* age) const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - *age = 0; - - std::unique_ptr notes = - elf_image_reader_->NotesWithNameAndType( - ELF_NOTE_GNU, NT_GNU_BUILD_ID, 64); - std::string desc; - notes->NextNote(nullptr, nullptr, &desc); - desc.insert(desc.end(), 16 - std::min(desc.size(), size_t{16}), '\0'); - uuid->InitializeFromBytes(reinterpret_cast(&desc[0])); -} - -std::string ModuleSnapshotFuchsia::DebugFileName() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 - return std::string(); -} - -std::vector ModuleSnapshotFuchsia::AnnotationsVector() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 - return std::vector(); -} - -std::map ModuleSnapshotFuchsia::AnnotationsSimpleMap() - const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - std::map annotations; - if (crashpad_info_ && crashpad_info_->SimpleAnnotations()) { - ImageAnnotationReader reader(elf_image_reader_->Memory()); - reader.SimpleMap(crashpad_info_->SimpleAnnotations(), &annotations); - } - return annotations; -} - -std::vector ModuleSnapshotFuchsia::AnnotationObjects() - const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - std::vector annotations; - if (crashpad_info_ && crashpad_info_->AnnotationsList()) { - ImageAnnotationReader reader(elf_image_reader_->Memory()); - reader.AnnotationsList(crashpad_info_->AnnotationsList(), &annotations); - } - return annotations; -} - -std::set> ModuleSnapshotFuchsia::ExtraMemoryRanges() - const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 - return std::set>(); -} - -std::vector -ModuleSnapshotFuchsia::CustomMinidumpStreams() const { - INITIALIZATION_STATE_DCHECK_VALID(initialized_); - NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196 - return std::vector(); -} - -} // namespace internal -} // namespace crashpad diff --git a/snapshot/fuchsia/module_snapshot_fuchsia.h b/snapshot/fuchsia/module_snapshot_fuchsia.h deleted file mode 100644 index 6d66fd23..00000000 --- a/snapshot/fuchsia/module_snapshot_fuchsia.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2018 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_FUCHSIA_MODULE_SNAPSHOT_FUCHSIA_H_ -#define CRASHPAD_SNAPSHOT_FUCHSIA_MODULE_SNAPSHOT_FUCHSIA_H_ - -#include -#include - -#include -#include -#include -#include - -#include "base/macros.h" -#include "client/crashpad_info.h" -#include "snapshot/crashpad_info_client_options.h" -#include "snapshot/crashpad_types/crashpad_info_reader.h" -#include "snapshot/elf/elf_image_reader.h" -#include "snapshot/fuchsia/process_reader.h" -#include "snapshot/module_snapshot.h" -#include "util/misc/initialization_state_dcheck.h" - -namespace crashpad { -namespace internal { - -//! \brief A ModuleSnapshot of a code module (binary image) loaded into a -//! running (or crashed) process on a Fuchsia system. -class ModuleSnapshotFuchsia final : public ModuleSnapshot { - public: - ModuleSnapshotFuchsia(); - ~ModuleSnapshotFuchsia() override; - - //! \brief Initializes the object. - //! - //! \param[in] process_reader_module The module within the ProcessReader for - //! which the snapshot should be created. - //! - //! \return `true` if the snapshot could be created, `false` otherwise with - //! an appropriate message logged. - bool Initialize(const ProcessReader::Module& process_reader_module); - - //! \brief Returns options from the module’s CrashpadInfo structure. - //! - //! \param[out] options Options set in the module’s CrashpadInfo structure. - //! - //! \return `true` if there were options returned. Otherwise `false`. - bool GetCrashpadOptions(CrashpadInfoClientOptions* options); - - // ModuleSnapshot: - - std::string Name() const override; - uint64_t Address() const override; - uint64_t Size() const override; - time_t Timestamp() const override; - void FileVersion(uint16_t* version_0, - uint16_t* version_1, - uint16_t* version_2, - uint16_t* version_3) const override; - void SourceVersion(uint16_t* version_0, - uint16_t* version_1, - uint16_t* version_2, - uint16_t* version_3) const override; - ModuleType GetModuleType() const override; - void UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const override; - std::string DebugFileName() const override; - std::vector AnnotationsVector() const override; - std::map AnnotationsSimpleMap() const override; - std::vector AnnotationObjects() const override; - std::set> ExtraMemoryRanges() const override; - std::vector CustomMinidumpStreams() const override; - - private: - std::string name_; - ElfImageReader* elf_image_reader_; // weak - std::unique_ptr crashpad_info_; - ModuleType type_; - InitializationStateDcheck initialized_; - - DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotFuchsia); -}; - -} // namespace internal -} // namespace crashpad - -#endif // CRASHPAD_SNAPSHOT_FUCHSIA_MODULE_SNAPSHOT_FUCHSIA_H_ diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.cc b/snapshot/fuchsia/process_snapshot_fuchsia.cc index 02f8285d..e0070eac 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.cc +++ b/snapshot/fuchsia/process_snapshot_fuchsia.cc @@ -168,12 +168,10 @@ std::vector ProcessSnapshotFuchsia::ExtraMemory() const { } void ProcessSnapshotFuchsia::InitializeModules() { - const std::vector& process_reader_modules = - process_reader_.Modules(); - for (const ProcessReader::Module& process_reader_module : - process_reader_modules) { - auto module = std::make_unique(); - if (module->Initialize(process_reader_module)) { + for (const ProcessReader::Module& reader_module : process_reader_.Modules()) { + auto module = std::make_unique( + reader_module.name, reader_module.reader, reader_module.type); + if (module->Initialize()) { modules_.push_back(std::move(module)); } } diff --git a/snapshot/fuchsia/process_snapshot_fuchsia.h b/snapshot/fuchsia/process_snapshot_fuchsia.h index fa0167d3..04e2d29d 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia.h +++ b/snapshot/fuchsia/process_snapshot_fuchsia.h @@ -23,7 +23,7 @@ #include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" #include "snapshot/elf/elf_image_reader.h" -#include "snapshot/fuchsia/module_snapshot_fuchsia.h" +#include "snapshot/elf/module_snapshot_elf.h" #include "snapshot/fuchsia/process_reader.h" #include "snapshot/process_snapshot.h" #include "snapshot/unloaded_module_snapshot.h" @@ -76,7 +76,7 @@ class ProcessSnapshotFuchsia : public ProcessSnapshot { // Initializes modules_ on behalf of Initialize(). void InitializeModules(); - std::vector> modules_; + std::vector> modules_; ProcessReader process_reader_; std::map annotations_simple_map_; InitializationStateDcheck initialized_; diff --git a/snapshot/linux/process_snapshot_linux.cc b/snapshot/linux/process_snapshot_linux.cc index 8397ad9b..ecb4eb0e 100644 --- a/snapshot/linux/process_snapshot_linux.cc +++ b/snapshot/linux/process_snapshot_linux.cc @@ -226,8 +226,9 @@ void ProcessSnapshotLinux::InitializeThreads() { void ProcessSnapshotLinux::InitializeModules() { for (const ProcessReader::Module& reader_module : process_reader_.Modules()) { - auto module = std::make_unique(); - if (module->Initialize(reader_module)) { + auto module = std::make_unique( + reader_module.name, reader_module.elf_reader, reader_module.type); + if (module->Initialize()) { modules_.push_back(std::move(module)); } } diff --git a/snapshot/linux/process_snapshot_linux.h b/snapshot/linux/process_snapshot_linux.h index aa6964c4..613913ce 100644 --- a/snapshot/linux/process_snapshot_linux.h +++ b/snapshot/linux/process_snapshot_linux.h @@ -25,8 +25,8 @@ #include "base/macros.h" #include "snapshot/crashpad_info_client_options.h" +#include "snapshot/elf/module_snapshot_elf.h" #include "snapshot/linux/exception_snapshot_linux.h" -#include "snapshot/linux/module_snapshot_linux.h" #include "snapshot/linux/process_reader.h" #include "snapshot/linux/system_snapshot_linux.h" #include "snapshot/linux/thread_snapshot_linux.h" @@ -124,7 +124,7 @@ class ProcessSnapshotLinux final : public ProcessSnapshot { UUID report_id_; UUID client_id_; std::vector> threads_; - std::vector> modules_; + std::vector> modules_; std::unique_ptr exception_; internal::SystemSnapshotLinux system_; ProcessReader process_reader_; diff --git a/snapshot/snapshot.gyp b/snapshot/snapshot.gyp index da192341..f3364d13 100644 --- a/snapshot/snapshot.gyp +++ b/snapshot/snapshot.gyp @@ -49,6 +49,8 @@ 'elf/elf_image_reader.h', 'elf/elf_symbol_table_reader.cc', 'elf/elf_symbol_table_reader.h', + 'elf/module_snapshot_elf.cc', + 'elf/module_snapshot_elf.h', 'exception_snapshot.h', 'handle_snapshot.cc', 'handle_snapshot.h', @@ -60,8 +62,6 @@ 'linux/exception_snapshot_linux.h', 'linux/memory_snapshot_linux.cc', 'linux/memory_snapshot_linux.h', - 'linux/module_snapshot_linux.cc', - 'linux/module_snapshot_linux.h', 'linux/process_reader.cc', 'linux/process_reader.h', 'linux/process_snapshot_linux.cc',