diff --git a/debuggerd/libdebuggerd/test/UnwinderMock.h b/debuggerd/libdebuggerd/test/UnwinderMock.h index 8f84346af..1e3c55952 100644 --- a/debuggerd/libdebuggerd/test/UnwinderMock.h +++ b/debuggerd/libdebuggerd/test/UnwinderMock.h @@ -16,6 +16,8 @@ #pragma once +#include + #include #include #include @@ -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 map_info = GetMaps()->Find(offset); if (map_info != nullptr) { map_info->SetBuildID(std::string(build_id)); } diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index 534d7be8c..1835f0efc 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -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(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() + ")"; } diff --git a/debuggerd/libdebuggerd/tombstone_proto.cpp b/debuggerd/libdebuggerd/tombstone_proto.cpp index 6c380a122..b1c4ef365 100644 --- a/debuggerd/libdebuggerd/tombstone_proto.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto.cpp @@ -103,7 +103,7 @@ static std::optional 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 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 map_info = maps->Find(untag_address(value)); if (map_info) { dump.set_mapping_name(map_info->name()); }