mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
fuchsia: Pass more data out of module snapshot
After https://chromium-review.googlesource.com/c/crashpad/crashpad/+/927355 image annotations can be read. Plumb those through ModuleSnapshotFuchsia. Bug: crashpad:196 Change-Id: Iba0730fd88c60cbad8a721ddcaf8f60860f76b77 Reviewed-on: https://chromium-review.googlesource.com/927704 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
3dd85dc126
commit
cab259330f
@ -14,8 +14,9 @@
|
|||||||
|
|
||||||
#include "snapshot/fuchsia/module_snapshot_fuchsia.h"
|
#include "snapshot/fuchsia/module_snapshot_fuchsia.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "client/crashpad_info.h"
|
|
||||||
#include "snapshot/crashpad_types/image_annotation_reader.h"
|
#include "snapshot/crashpad_types/image_annotation_reader.h"
|
||||||
#include "util/misc/elf_note_types.h"
|
#include "util/misc/elf_note_types.h"
|
||||||
|
|
||||||
@ -27,13 +28,12 @@ ModuleSnapshotFuchsia::ModuleSnapshotFuchsia() = default;
|
|||||||
ModuleSnapshotFuchsia::~ModuleSnapshotFuchsia() = default;
|
ModuleSnapshotFuchsia::~ModuleSnapshotFuchsia() = default;
|
||||||
|
|
||||||
bool ModuleSnapshotFuchsia::Initialize(
|
bool ModuleSnapshotFuchsia::Initialize(
|
||||||
ProcessReader* process_reader,
|
|
||||||
const ProcessReader::Module& process_reader_module) {
|
const ProcessReader::Module& process_reader_module) {
|
||||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||||
|
|
||||||
process_reader_ = process_reader;
|
|
||||||
name_ = process_reader_module.name;
|
name_ = process_reader_module.name;
|
||||||
elf_image_reader_ = process_reader_module.reader;
|
elf_image_reader_ = process_reader_module.reader;
|
||||||
|
type_ = process_reader_module.type;
|
||||||
if (!elf_image_reader_) {
|
if (!elf_image_reader_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -128,14 +128,21 @@ void ModuleSnapshotFuchsia::SourceVersion(uint16_t* version_0,
|
|||||||
|
|
||||||
ModuleSnapshot::ModuleType ModuleSnapshotFuchsia::GetModuleType() const {
|
ModuleSnapshot::ModuleType ModuleSnapshotFuchsia::GetModuleType() const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
return type_;
|
||||||
return kModuleTypeUnknown;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleSnapshotFuchsia::UUIDAndAge(crashpad::UUID* uuid,
|
void ModuleSnapshotFuchsia::UUIDAndAge(crashpad::UUID* uuid,
|
||||||
uint32_t* age) const {
|
uint32_t* age) const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
*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 {
|
std::string ModuleSnapshotFuchsia::DebugFileName() const {
|
||||||
@ -153,15 +160,23 @@ std::vector<std::string> ModuleSnapshotFuchsia::AnnotationsVector() const {
|
|||||||
std::map<std::string, std::string> ModuleSnapshotFuchsia::AnnotationsSimpleMap()
|
std::map<std::string, std::string> ModuleSnapshotFuchsia::AnnotationsSimpleMap()
|
||||||
const {
|
const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
std::map<std::string, std::string> annotations;
|
||||||
return std::map<std::string, std::string>();
|
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()
|
std::vector<AnnotationSnapshot> ModuleSnapshotFuchsia::AnnotationObjects()
|
||||||
const {
|
const {
|
||||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
|
std::vector<AnnotationSnapshot> annotations;
|
||||||
return std::vector<AnnotationSnapshot>();
|
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()
|
std::set<CheckedRange<uint64_t>> ModuleSnapshotFuchsia::ExtraMemoryRanges()
|
||||||
|
@ -44,15 +44,12 @@ class ModuleSnapshotFuchsia final : public ModuleSnapshot {
|
|||||||
|
|
||||||
//! \brief Initializes the object.
|
//! \brief Initializes the object.
|
||||||
//!
|
//!
|
||||||
//! \param[in] process_reader A ProcessReader for the process containing the
|
|
||||||
//! module.
|
|
||||||
//! \param[in] process_reader_module The module within the ProcessReader for
|
//! \param[in] process_reader_module The module within the ProcessReader for
|
||||||
//! which the snapshot should be created.
|
//! 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(ProcessReader* process_reader,
|
bool Initialize(const ProcessReader::Module& process_reader_module);
|
||||||
const ProcessReader::Module& process_reader_module);
|
|
||||||
|
|
||||||
//! \brief Returns options from the module’s CrashpadInfo structure.
|
//! \brief Returns options from the module’s CrashpadInfo structure.
|
||||||
//!
|
//!
|
||||||
@ -87,8 +84,8 @@ class ModuleSnapshotFuchsia final : public ModuleSnapshot {
|
|||||||
private:
|
private:
|
||||||
std::string name_;
|
std::string name_;
|
||||||
ElfImageReader* elf_image_reader_; // weak
|
ElfImageReader* elf_image_reader_; // weak
|
||||||
ProcessReader* process_reader_; // weak
|
|
||||||
std::unique_ptr<CrashpadInfoReader> crashpad_info_;
|
std::unique_ptr<CrashpadInfoReader> crashpad_info_;
|
||||||
|
ModuleType type_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotFuchsia);
|
DISALLOW_COPY_AND_ASSIGN(ModuleSnapshotFuchsia);
|
||||||
|
@ -137,7 +137,14 @@ void ProcessReader::InitializeModules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Module module;
|
Module module;
|
||||||
module.name = dsoname.empty() ? app_name : dsoname;
|
if (dsoname.empty()) {
|
||||||
|
module.name = app_name;
|
||||||
|
module.type = ModuleSnapshot::kModuleTypeExecutable;
|
||||||
|
} else {
|
||||||
|
module.name = dsoname;
|
||||||
|
// TODO(scottmg): Handle kModuleTypeDynamicLoader.
|
||||||
|
module.type = ModuleSnapshot::kModuleTypeSharedLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<ElfImageReader> reader(new ElfImageReader());
|
std::unique_ptr<ElfImageReader> reader(new ElfImageReader());
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "snapshot/elf/elf_image_reader.h"
|
#include "snapshot/elf/elf_image_reader.h"
|
||||||
|
#include "snapshot/module_snapshot.h"
|
||||||
#include "util/misc/initialization_state_dcheck.h"
|
#include "util/misc/initialization_state_dcheck.h"
|
||||||
#include "util/process/process_memory_fuchsia.h"
|
#include "util/process/process_memory_fuchsia.h"
|
||||||
#include "util/process/process_memory_range.h"
|
#include "util/process/process_memory_range.h"
|
||||||
@ -48,6 +49,9 @@ class ProcessReader {
|
|||||||
//! This field may be `nullptr` if a reader could not be created for the
|
//! This field may be `nullptr` if a reader could not be created for the
|
||||||
//! module.
|
//! module.
|
||||||
ElfImageReader* reader;
|
ElfImageReader* reader;
|
||||||
|
|
||||||
|
//! \brief The module's type.
|
||||||
|
ModuleSnapshot::ModuleType type = ModuleSnapshot::kModuleTypeUnknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessReader();
|
ProcessReader();
|
||||||
|
@ -173,7 +173,7 @@ void ProcessSnapshotFuchsia::InitializeModules() {
|
|||||||
for (const ProcessReader::Module& process_reader_module :
|
for (const ProcessReader::Module& process_reader_module :
|
||||||
process_reader_modules) {
|
process_reader_modules) {
|
||||||
auto module = std::make_unique<internal::ModuleSnapshotFuchsia>();
|
auto module = std::make_unique<internal::ModuleSnapshotFuchsia>();
|
||||||
if (module->Initialize(&process_reader_, process_reader_module)) {
|
if (module->Initialize(process_reader_module)) {
|
||||||
modules_.push_back(std::move(module));
|
modules_.push_back(std::move(module));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user