Update for libunwindstack shared_ptr MapInfos.
Bug: 120606663
Test: Unit tests pass.
Change-Id: Ieae157388e8571345ed8968a2b5c2aa34464689f
Merged-In: Ieae157388e8571345ed8968a2b5c2aa34464689f
(cherry picked from commit 853733b627
)
This commit is contained in:
parent
6a58c59269
commit
c67760611c
3 changed files with 11 additions and 9 deletions
|
@ -16,6 +16,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <unwindstack/MapInfo.h>
|
||||
#include <unwindstack/Maps.h>
|
||||
#include <unwindstack/Unwinder.h>
|
||||
|
@ -31,7 +33,7 @@ class UnwinderMock : public unwindstack::Unwinder {
|
|||
}
|
||||
|
||||
void MockSetBuildID(uint64_t offset, const std::string& build_id) {
|
||||
unwindstack::MapInfo* map_info = GetMaps()->Find(offset);
|
||||
std::shared_ptr<unwindstack::MapInfo> map_info = GetMaps()->Find(offset);
|
||||
if (map_info != nullptr) {
|
||||
map_info->SetBuildID(std::string(build_id));
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ static std::string get_stack_overflow_cause(uint64_t fault_addr, uint64_t sp,
|
|||
// In this case, the sp will be in either an invalid map if triggered
|
||||
// on the main thread, or in a guard map if in another thread, which
|
||||
// will be the first case or second case from below.
|
||||
unwindstack::MapInfo* map_info = maps->Find(sp);
|
||||
auto map_info = maps->Find(sp);
|
||||
if (map_info == nullptr) {
|
||||
return "stack pointer is in a non-existent map; likely due to stack overflow.";
|
||||
} else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
|
||||
|
@ -158,7 +158,7 @@ static void dump_probable_cause(log_t* log, unwindstack::Unwinder* unwinder,
|
|||
}
|
||||
} else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
|
||||
uint64_t fault_addr = reinterpret_cast<uint64_t>(si->si_addr);
|
||||
unwindstack::MapInfo* map_info = maps->Find(fault_addr);
|
||||
auto map_info = maps->Find(fault_addr);
|
||||
if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
|
||||
cause = "execute-only (no-read) memory access error; likely due to data in .text.";
|
||||
} else {
|
||||
|
@ -396,7 +396,7 @@ void dump_memory_and_code(log_t* log, unwindstack::Maps* maps, unwindstack::Memo
|
|||
regs->IterateRegisters([log, maps, memory](const char* reg_name, uint64_t reg_value) {
|
||||
std::string label{"memory near "s + reg_name};
|
||||
if (maps) {
|
||||
unwindstack::MapInfo* map_info = maps->Find(untag_address(reg_value));
|
||||
auto map_info = maps->Find(untag_address(reg_value));
|
||||
if (map_info != nullptr && !map_info->name().empty()) {
|
||||
label += " (" + map_info->name() + ")";
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ static std::optional<std::string> get_stack_overflow_cause(uint64_t fault_addr,
|
|||
// In this case, the sp will be in either an invalid map if triggered
|
||||
// on the main thread, or in a guard map if in another thread, which
|
||||
// will be the first case or second case from below.
|
||||
unwindstack::MapInfo* map_info = maps->Find(sp);
|
||||
std::shared_ptr<unwindstack::MapInfo> map_info = maps->Find(sp);
|
||||
if (map_info == nullptr) {
|
||||
return "stack pointer is in a non-existent map; likely due to stack overflow.";
|
||||
} else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
|
||||
|
@ -226,7 +226,7 @@ static void dump_probable_cause(Tombstone* tombstone, unwindstack::Unwinder* unw
|
|||
cause = get_stack_overflow_cause(fault_addr, main_thread.registers->sp(), maps);
|
||||
}
|
||||
} else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
|
||||
unwindstack::MapInfo* map_info = maps->Find(fault_addr);
|
||||
auto map_info = maps->Find(fault_addr);
|
||||
if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
|
||||
cause = "execute-only (no-read) memory access error; likely due to data in .text.";
|
||||
} else {
|
||||
|
@ -342,8 +342,8 @@ void fill_in_backtrace_frame(BacktraceFrame* f, const unwindstack::FrameData& fr
|
|||
|
||||
f->set_file_map_offset(frame.map_elf_start_offset);
|
||||
|
||||
unwindstack::MapInfo* map_info = maps->Find(frame.map_start);
|
||||
if (map_info) {
|
||||
auto map_info = maps->Find(frame.map_start);
|
||||
if (map_info.get() != nullptr) {
|
||||
f->set_build_id(map_info->GetPrintableBuildID());
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ static void dump_thread(Tombstone* tombstone, unwindstack::Unwinder* unwinder,
|
|||
MemoryDump dump;
|
||||
|
||||
dump.set_register_name(name);
|
||||
unwindstack::MapInfo* map_info = maps->Find(untag_address(value));
|
||||
std::shared_ptr<unwindstack::MapInfo> map_info = maps->Find(untag_address(value));
|
||||
if (map_info) {
|
||||
dump.set_mapping_name(map_info->name());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue