mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
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 <jperaza@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
cab259330f
commit
1aae5cedaf
@ -114,8 +114,6 @@ static_library("snapshot") {
|
|||||||
"linux/exception_snapshot_linux.h",
|
"linux/exception_snapshot_linux.h",
|
||||||
"linux/memory_snapshot_linux.cc",
|
"linux/memory_snapshot_linux.cc",
|
||||||
"linux/memory_snapshot_linux.h",
|
"linux/memory_snapshot_linux.h",
|
||||||
"linux/module_snapshot_linux.cc",
|
|
||||||
"linux/module_snapshot_linux.h",
|
|
||||||
"linux/process_reader.cc",
|
"linux/process_reader.cc",
|
||||||
"linux/process_reader.h",
|
"linux/process_reader.h",
|
||||||
"linux/process_snapshot_linux.cc",
|
"linux/process_snapshot_linux.cc",
|
||||||
@ -140,6 +138,8 @@ static_library("snapshot") {
|
|||||||
"elf/elf_image_reader.h",
|
"elf/elf_image_reader.h",
|
||||||
"elf/elf_symbol_table_reader.cc",
|
"elf/elf_symbol_table_reader.cc",
|
||||||
"elf/elf_symbol_table_reader.h",
|
"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) {
|
if (crashpad_is_fuchsia) {
|
||||||
sources += [
|
sources += [
|
||||||
"fuchsia/module_snapshot_fuchsia.cc",
|
|
||||||
"fuchsia/module_snapshot_fuchsia.h",
|
|
||||||
"fuchsia/process_reader.cc",
|
"fuchsia/process_reader.cc",
|
||||||
"fuchsia/process_reader.h",
|
"fuchsia/process_reader.h",
|
||||||
"fuchsia/process_snapshot_fuchsia.cc",
|
"fuchsia/process_snapshot_fuchsia.cc",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "snapshot/linux/module_snapshot_linux.h"
|
#include "snapshot/elf/module_snapshot_elf.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -23,29 +23,26 @@
|
|||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
ModuleSnapshotLinux::ModuleSnapshotLinux()
|
ModuleSnapshotElf::ModuleSnapshotElf(const std::string& name,
|
||||||
|
ElfImageReader* elf_reader,
|
||||||
|
ModuleSnapshot::ModuleType type)
|
||||||
: ModuleSnapshot(),
|
: ModuleSnapshot(),
|
||||||
name_(),
|
name_(name),
|
||||||
elf_reader_(nullptr),
|
elf_reader_(elf_reader),
|
||||||
crashpad_info_(),
|
crashpad_info_(),
|
||||||
type_(kModuleTypeUnknown),
|
type_(type),
|
||||||
initialized_() {}
|
initialized_() {}
|
||||||
|
|
||||||
ModuleSnapshotLinux::~ModuleSnapshotLinux() = default;
|
ModuleSnapshotElf::~ModuleSnapshotElf() = default;
|
||||||
|
|
||||||
bool ModuleSnapshotLinux::Initialize(
|
bool ModuleSnapshotElf::Initialize() {
|
||||||
const ProcessReader::Module& process_reader_module) {
|
|
||||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||||
|
|
||||||
if (!process_reader_module.elf_reader) {
|
if (!elf_reader_) {
|
||||||
LOG(ERROR) << "no elf reader";
|
LOG(ERROR) << "no elf reader";
|
||||||
return false;
|
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
|
// The data payload is only sizeof(VMAddress) in the note, but add a bit to
|
||||||
// account for the name, header, and padding.
|
// account for the name, header, and padding.
|
||||||
constexpr ssize_t kMaxNoteSize = 256;
|
constexpr ssize_t kMaxNoteSize = 256;
|
||||||
@ -72,8 +69,7 @@ bool ModuleSnapshotLinux::Initialize(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleSnapshotLinux::GetCrashpadOptions(
|
bool ModuleSnapshotElf::GetCrashpadOptions(CrashpadInfoClientOptions* options) {
|
||||||
CrashpadInfoClientOptions* options) {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
|
|
||||||
if (!crashpad_info_) {
|
if (!crashpad_info_) {
|
||||||
@ -91,27 +87,38 @@ bool ModuleSnapshotLinux::GetCrashpadOptions(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ModuleSnapshotLinux::Name() const {
|
std::string ModuleSnapshotElf::Name() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ModuleSnapshotLinux::Address() const {
|
uint64_t ModuleSnapshotElf::Address() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return elf_reader_->Address();
|
return elf_reader_->Address();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ModuleSnapshotLinux::Size() const {
|
uint64_t ModuleSnapshotElf::Size() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return elf_reader_->Size();
|
return elf_reader_->Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t ModuleSnapshotLinux::Timestamp() const {
|
time_t ModuleSnapshotElf::Timestamp() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return 0;
|
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_1,
|
||||||
uint16_t* version_2,
|
uint16_t* version_2,
|
||||||
uint16_t* version_3) const {
|
uint16_t* version_3) const {
|
||||||
@ -122,24 +129,12 @@ void ModuleSnapshotLinux::FileVersion(uint16_t* version_0,
|
|||||||
*version_3 = 0;
|
*version_3 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleSnapshotLinux::SourceVersion(uint16_t* version_0,
|
ModuleSnapshot::ModuleType ModuleSnapshotElf::GetModuleType() const {
|
||||||
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 {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return type_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleSnapshotLinux::UUIDAndAge(crashpad::UUID* uuid,
|
void ModuleSnapshotElf::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const {
|
||||||
uint32_t* age) const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
*age = 0;
|
*age = 0;
|
||||||
|
|
||||||
@ -151,17 +146,17 @@ void ModuleSnapshotLinux::UUIDAndAge(crashpad::UUID* uuid,
|
|||||||
uuid->InitializeFromBytes(reinterpret_cast<const uint8_t*>(&desc[0]));
|
uuid->InitializeFromBytes(reinterpret_cast<const uint8_t*>(&desc[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ModuleSnapshotLinux::DebugFileName() const {
|
std::string ModuleSnapshotElf::DebugFileName() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return base::FilePath(Name()).BaseName().value();
|
return base::FilePath(Name()).BaseName().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> ModuleSnapshotLinux::AnnotationsVector() const {
|
std::vector<std::string> ModuleSnapshotElf::AnnotationsVector() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::string> ModuleSnapshotLinux::AnnotationsSimpleMap()
|
std::map<std::string, std::string> ModuleSnapshotElf::AnnotationsSimpleMap()
|
||||||
const {
|
const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
std::map<std::string, std::string> annotations;
|
std::map<std::string, std::string> annotations;
|
||||||
@ -172,7 +167,7 @@ std::map<std::string, std::string> ModuleSnapshotLinux::AnnotationsSimpleMap()
|
|||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<AnnotationSnapshot> ModuleSnapshotLinux::AnnotationObjects() const {
|
std::vector<AnnotationSnapshot> ModuleSnapshotElf::AnnotationObjects() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
std::vector<AnnotationSnapshot> annotations;
|
std::vector<AnnotationSnapshot> annotations;
|
||||||
if (crashpad_info_ && crashpad_info_->AnnotationsList()) {
|
if (crashpad_info_ && crashpad_info_->AnnotationsList()) {
|
||||||
@ -182,14 +177,13 @@ std::vector<AnnotationSnapshot> ModuleSnapshotLinux::AnnotationObjects() const {
|
|||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<CheckedRange<uint64_t>> ModuleSnapshotLinux::ExtraMemoryRanges()
|
std::set<CheckedRange<uint64_t>> ModuleSnapshotElf::ExtraMemoryRanges() const {
|
||||||
const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
return std::set<CheckedRange<uint64_t>>();
|
return std::set<CheckedRange<uint64_t>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const UserMinidumpStream*>
|
std::vector<const UserMinidumpStream*>
|
||||||
ModuleSnapshotLinux::CustomMinidumpStreams() const {
|
ModuleSnapshotElf::CustomMinidumpStreams() const {
|
||||||
return std::vector<const UserMinidumpStream*>();
|
return std::vector<const UserMinidumpStream*>();
|
||||||
}
|
}
|
||||||
|
|
@ -12,8 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_
|
#ifndef CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_
|
||||||
#define CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_
|
#define CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -27,7 +27,6 @@
|
|||||||
#include "snapshot/crashpad_info_client_options.h"
|
#include "snapshot/crashpad_info_client_options.h"
|
||||||
#include "snapshot/crashpad_types/crashpad_info_reader.h"
|
#include "snapshot/crashpad_types/crashpad_info_reader.h"
|
||||||
#include "snapshot/elf/elf_image_reader.h"
|
#include "snapshot/elf/elf_image_reader.h"
|
||||||
#include "snapshot/linux/process_reader.h"
|
|
||||||
#include "snapshot/module_snapshot.h"
|
#include "snapshot/module_snapshot.h"
|
||||||
#include "util/misc/initialization_state_dcheck.h"
|
#include "util/misc/initialization_state_dcheck.h"
|
||||||
|
|
||||||
@ -36,20 +35,22 @@ namespace crashpad {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
//! \brief A ModuleSnapshot of a code module (binary image) loaded into a
|
//! \brief A ModuleSnapshot of a code module (binary image) loaded into a
|
||||||
//! running (or crashed) process on a Linux system.
|
//! running (or crashed) process on a system that uses ELF modules.
|
||||||
class ModuleSnapshotLinux final : public ModuleSnapshot {
|
class ModuleSnapshotElf final : public ModuleSnapshot {
|
||||||
public:
|
public:
|
||||||
ModuleSnapshotLinux();
|
//! \param[in] name The pathname used to load the module from disk.
|
||||||
~ModuleSnapshotLinux() override;
|
//! \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.
|
//! \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
|
//! \return `true` if the snapshot could be created, `false` otherwise with
|
||||||
//! an appropriate message logged.
|
//! an appropriate message logged.
|
||||||
bool Initialize(const ProcessReader::Module& process_reader_module);
|
bool Initialize();
|
||||||
|
|
||||||
//! \brief Returns options from the module’s CrashpadInfo structure.
|
//! \brief Returns options from the module’s CrashpadInfo structure.
|
||||||
//!
|
//!
|
||||||
@ -87,10 +88,10 @@ class ModuleSnapshotLinux final : public ModuleSnapshot {
|
|||||||
ModuleType type_;
|
ModuleType type_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotLinux);
|
DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotElf);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace crashpad
|
} // namespace crashpad
|
||||||
|
|
||||||
#endif // CRASHPAD_SNAPSHOT_LINUX_MODULE_SNAPSHOT_LINUX_H_
|
#endif // CRASHPAD_SNAPSHOT_ELF_MODULE_SNAPSHOT_ELF_H_
|
@ -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 <algorithm>
|
|
||||||
|
|
||||||
#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<ElfImageReader::NoteReader> 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<VMAddress*>(&desc[0]);
|
|
||||||
|
|
||||||
ProcessMemoryRange range;
|
|
||||||
if (range.Initialize(*elf_image_reader_->Memory())) {
|
|
||||||
auto info = std::make_unique<CrashpadInfoReader>();
|
|
||||||
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<ElfImageReader::NoteReader> 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<const uint8_t*>(&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<std::string> ModuleSnapshotFuchsia::AnnotationsVector() const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
|
||||||
return std::vector<std::string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, std::string> ModuleSnapshotFuchsia::AnnotationsSimpleMap()
|
|
||||||
const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
|
||||||
std::map<std::string, std::string> annotations;
|
|
||||||
if (crashpad_info_ && crashpad_info_->SimpleAnnotations()) {
|
|
||||||
ImageAnnotationReader reader(elf_image_reader_->Memory());
|
|
||||||
reader.SimpleMap(crashpad_info_->SimpleAnnotations(), &annotations);
|
|
||||||
}
|
|
||||||
return annotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<AnnotationSnapshot> ModuleSnapshotFuchsia::AnnotationObjects()
|
|
||||||
const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
|
||||||
std::vector<AnnotationSnapshot> annotations;
|
|
||||||
if (crashpad_info_ && crashpad_info_->AnnotationsList()) {
|
|
||||||
ImageAnnotationReader reader(elf_image_reader_->Memory());
|
|
||||||
reader.AnnotationsList(crashpad_info_->AnnotationsList(), &annotations);
|
|
||||||
}
|
|
||||||
return annotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<CheckedRange<uint64_t>> ModuleSnapshotFuchsia::ExtraMemoryRanges()
|
|
||||||
const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
|
||||||
return std::set<CheckedRange<uint64_t>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<const UserMinidumpStream*>
|
|
||||||
ModuleSnapshotFuchsia::CustomMinidumpStreams() const {
|
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
|
||||||
return std::vector<const UserMinidumpStream*>();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace crashpad
|
|
@ -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 <stdint.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#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<std::string> AnnotationsVector() const override;
|
|
||||||
std::map<std::string, std::string> AnnotationsSimpleMap() const override;
|
|
||||||
std::vector<AnnotationSnapshot> AnnotationObjects() const override;
|
|
||||||
std::set<CheckedRange<uint64_t>> ExtraMemoryRanges() const override;
|
|
||||||
std::vector<const UserMinidumpStream*> CustomMinidumpStreams() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string name_;
|
|
||||||
ElfImageReader* elf_image_reader_; // weak
|
|
||||||
std::unique_ptr<CrashpadInfoReader> crashpad_info_;
|
|
||||||
ModuleType type_;
|
|
||||||
InitializationStateDcheck initialized_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotFuchsia);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace crashpad
|
|
||||||
|
|
||||||
#endif // CRASHPAD_SNAPSHOT_FUCHSIA_MODULE_SNAPSHOT_FUCHSIA_H_
|
|
@ -168,12 +168,10 @@ std::vector<const MemorySnapshot*> ProcessSnapshotFuchsia::ExtraMemory() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProcessSnapshotFuchsia::InitializeModules() {
|
void ProcessSnapshotFuchsia::InitializeModules() {
|
||||||
const std::vector<ProcessReader::Module>& process_reader_modules =
|
for (const ProcessReader::Module& reader_module : process_reader_.Modules()) {
|
||||||
process_reader_.Modules();
|
auto module = std::make_unique<internal::ModuleSnapshotElf>(
|
||||||
for (const ProcessReader::Module& process_reader_module :
|
reader_module.name, reader_module.reader, reader_module.type);
|
||||||
process_reader_modules) {
|
if (module->Initialize()) {
|
||||||
auto module = std::make_unique<internal::ModuleSnapshotFuchsia>();
|
|
||||||
if (module->Initialize(process_reader_module)) {
|
|
||||||
modules_.push_back(std::move(module));
|
modules_.push_back(std::move(module));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "snapshot/crashpad_info_client_options.h"
|
#include "snapshot/crashpad_info_client_options.h"
|
||||||
#include "snapshot/elf/elf_image_reader.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/fuchsia/process_reader.h"
|
||||||
#include "snapshot/process_snapshot.h"
|
#include "snapshot/process_snapshot.h"
|
||||||
#include "snapshot/unloaded_module_snapshot.h"
|
#include "snapshot/unloaded_module_snapshot.h"
|
||||||
@ -76,7 +76,7 @@ class ProcessSnapshotFuchsia : public ProcessSnapshot {
|
|||||||
// Initializes modules_ on behalf of Initialize().
|
// Initializes modules_ on behalf of Initialize().
|
||||||
void InitializeModules();
|
void InitializeModules();
|
||||||
|
|
||||||
std::vector<std::unique_ptr<internal::ModuleSnapshotFuchsia>> modules_;
|
std::vector<std::unique_ptr<internal::ModuleSnapshotElf>> modules_;
|
||||||
ProcessReader process_reader_;
|
ProcessReader process_reader_;
|
||||||
std::map<std::string, std::string> annotations_simple_map_;
|
std::map<std::string, std::string> annotations_simple_map_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
@ -226,8 +226,9 @@ void ProcessSnapshotLinux::InitializeThreads() {
|
|||||||
|
|
||||||
void ProcessSnapshotLinux::InitializeModules() {
|
void ProcessSnapshotLinux::InitializeModules() {
|
||||||
for (const ProcessReader::Module& reader_module : process_reader_.Modules()) {
|
for (const ProcessReader::Module& reader_module : process_reader_.Modules()) {
|
||||||
auto module = std::make_unique<internal::ModuleSnapshotLinux>();
|
auto module = std::make_unique<internal::ModuleSnapshotElf>(
|
||||||
if (module->Initialize(reader_module)) {
|
reader_module.name, reader_module.elf_reader, reader_module.type);
|
||||||
|
if (module->Initialize()) {
|
||||||
modules_.push_back(std::move(module));
|
modules_.push_back(std::move(module));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "snapshot/crashpad_info_client_options.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/exception_snapshot_linux.h"
|
||||||
#include "snapshot/linux/module_snapshot_linux.h"
|
|
||||||
#include "snapshot/linux/process_reader.h"
|
#include "snapshot/linux/process_reader.h"
|
||||||
#include "snapshot/linux/system_snapshot_linux.h"
|
#include "snapshot/linux/system_snapshot_linux.h"
|
||||||
#include "snapshot/linux/thread_snapshot_linux.h"
|
#include "snapshot/linux/thread_snapshot_linux.h"
|
||||||
@ -124,7 +124,7 @@ class ProcessSnapshotLinux final : public ProcessSnapshot {
|
|||||||
UUID report_id_;
|
UUID report_id_;
|
||||||
UUID client_id_;
|
UUID client_id_;
|
||||||
std::vector<std::unique_ptr<internal::ThreadSnapshotLinux>> threads_;
|
std::vector<std::unique_ptr<internal::ThreadSnapshotLinux>> threads_;
|
||||||
std::vector<std::unique_ptr<internal::ModuleSnapshotLinux>> modules_;
|
std::vector<std::unique_ptr<internal::ModuleSnapshotElf>> modules_;
|
||||||
std::unique_ptr<internal::ExceptionSnapshotLinux> exception_;
|
std::unique_ptr<internal::ExceptionSnapshotLinux> exception_;
|
||||||
internal::SystemSnapshotLinux system_;
|
internal::SystemSnapshotLinux system_;
|
||||||
ProcessReader process_reader_;
|
ProcessReader process_reader_;
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
'elf/elf_image_reader.h',
|
'elf/elf_image_reader.h',
|
||||||
'elf/elf_symbol_table_reader.cc',
|
'elf/elf_symbol_table_reader.cc',
|
||||||
'elf/elf_symbol_table_reader.h',
|
'elf/elf_symbol_table_reader.h',
|
||||||
|
'elf/module_snapshot_elf.cc',
|
||||||
|
'elf/module_snapshot_elf.h',
|
||||||
'exception_snapshot.h',
|
'exception_snapshot.h',
|
||||||
'handle_snapshot.cc',
|
'handle_snapshot.cc',
|
||||||
'handle_snapshot.h',
|
'handle_snapshot.h',
|
||||||
@ -60,8 +62,6 @@
|
|||||||
'linux/exception_snapshot_linux.h',
|
'linux/exception_snapshot_linux.h',
|
||||||
'linux/memory_snapshot_linux.cc',
|
'linux/memory_snapshot_linux.cc',
|
||||||
'linux/memory_snapshot_linux.h',
|
'linux/memory_snapshot_linux.h',
|
||||||
'linux/module_snapshot_linux.cc',
|
|
||||||
'linux/module_snapshot_linux.h',
|
|
||||||
'linux/process_reader.cc',
|
'linux/process_reader.cc',
|
||||||
'linux/process_reader.h',
|
'linux/process_reader.h',
|
||||||
'linux/process_snapshot_linux.cc',
|
'linux/process_snapshot_linux.cc',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user