Loading debuggerd/libdebuggerd/tombstone.cpp +15 −14 Original line number Original line Diff line number Diff line Loading @@ -417,7 +417,7 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p "memory map (%zu entr%s):", "memory map (%zu entr%s):", map->size(), map->size() == 1 ? "y" : "ies"); map->size(), map->size() == 1 ? "y" : "ies"); if (print_fault_address_marker) { if (print_fault_address_marker) { if (map->begin() != map->end() && addr < map->begin()->start) { if (map->begin() != map->end() && addr < (*map->begin())->start) { _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n", _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n", get_addr_string(addr).c_str()); get_addr_string(addr).c_str()); print_fault_address_marker = false; print_fault_address_marker = false; Loading @@ -429,49 +429,50 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p } } std::string line; std::string line; for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { for (auto it = map->begin(); it != map->end(); ++it) { const backtrace_map_t* entry = *it; line = " "; line = " "; if (print_fault_address_marker) { if (print_fault_address_marker) { if (addr < it->start) { if (addr < entry->start) { _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", get_addr_string(addr).c_str()); get_addr_string(addr).c_str()); print_fault_address_marker = false; print_fault_address_marker = false; } else if (addr >= it->start && addr < it->end) { } else if (addr >= entry->start && addr < entry->end) { line = "--->"; line = "--->"; print_fault_address_marker = false; print_fault_address_marker = false; } } } } line += get_addr_string(it->start) + '-' + get_addr_string(it->end - 1) + ' '; line += get_addr_string(entry->start) + '-' + get_addr_string(entry->end - 1) + ' '; if (it->flags & PROT_READ) { if (entry->flags & PROT_READ) { line += 'r'; line += 'r'; } else { } else { line += '-'; line += '-'; } } if (it->flags & PROT_WRITE) { if (entry->flags & PROT_WRITE) { line += 'w'; line += 'w'; } else { } else { line += '-'; line += '-'; } } if (it->flags & PROT_EXEC) { if (entry->flags & PROT_EXEC) { line += 'x'; line += 'x'; } else { } else { line += '-'; line += '-'; } } line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, it->offset, it->end - it->start); line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, entry->offset, entry->end - entry->start); bool space_needed = true; bool space_needed = true; if (it->name.length() > 0) { if (entry->name.length() > 0) { space_needed = false; space_needed = false; line += " " + it->name; line += " " + entry->name; std::string build_id; std::string build_id; if ((it->flags & PROT_READ) && elf_get_build_id(backtrace, it->start, &build_id)) { if ((entry->flags & PROT_READ) && elf_get_build_id(backtrace, entry->start, &build_id)) { line += " (BuildId: " + build_id + ")"; line += " (BuildId: " + build_id + ")"; } } } } if (it->load_bias != 0) { if (entry->load_bias != 0) { if (space_needed) { if (space_needed) { line += ' '; line += ' '; } } line += StringPrintf(" (load bias 0x%" PRIxPTR ")", it->load_bias); line += StringPrintf(" (load bias 0x%" PRIxPTR ")", entry->load_bias); } } _LOG(log, logtype::MAPS, "%s\n", line.c_str()); _LOG(log, logtype::MAPS, "%s\n", line.c_str()); } } Loading libbacktrace/BacktraceMap.cpp +4 −3 Original line number Original line Diff line number Diff line Loading @@ -40,9 +40,10 @@ BacktraceMap::~BacktraceMap() { void BacktraceMap::FillIn(uintptr_t addr, backtrace_map_t* map) { void BacktraceMap::FillIn(uintptr_t addr, backtrace_map_t* map) { ScopedBacktraceMapIteratorLock lock(this); ScopedBacktraceMapIteratorLock lock(this); for (BacktraceMap::const_iterator it = begin(); it != end(); ++it) { for (auto it = begin(); it != end(); ++it) { if (addr >= it->start && addr < it->end) { const backtrace_map_t* entry = *it; *map = *it; if (addr >= entry->start && addr < entry->end) { *map = *entry; return; return; } } } } Loading libbacktrace/UnwindStackMap.cpp +13 −2 Original line number Original line Diff line number Diff line Loading @@ -71,8 +71,19 @@ void UnwindStackMap::FillIn(uintptr_t addr, backtrace_map_t* map) { if (map_info == nullptr) { if (map_info == nullptr) { return; return; } } unwindstack::Elf* elf = map_info->GetElf(process_memory_, true); map->load_bias = map_info->GetLoadBias(process_memory_); map->load_bias = elf->GetLoadBias(); } uint64_t UnwindStackMap::GetLoadBias(size_t index) { if (index >= stack_maps_->Total()) { return 0; } unwindstack::MapInfo* map_info = stack_maps_->Get(index); if (map_info == nullptr) { return 0; } return map_info->GetLoadBias(process_memory_); } } std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) { std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) { Loading libbacktrace/UnwindStackMap.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,8 @@ class UnwindStackMap : public BacktraceMap { const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; } const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; } protected: protected: uint64_t GetLoadBias(size_t index) override; std::unique_ptr<unwindstack::Maps> stack_maps_; std::unique_ptr<unwindstack::Maps> stack_maps_; std::shared_ptr<unwindstack::Memory> process_memory_; std::shared_ptr<unwindstack::Memory> process_memory_; }; }; Loading libbacktrace/backtrace_offline_test.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -171,10 +171,12 @@ TEST(libbacktrace, DISABLED_generate_offline_testdata) { testdata += android::base::StringPrintf("pid: %d tid: %d\n", getpid(), arg.tid); testdata += android::base::StringPrintf("pid: %d tid: %d\n", getpid(), arg.tid); // 2. Dump maps // 2. Dump maps for (auto it = map->begin(); it != map->end(); ++it) { for (auto it = map->begin(); it != map->end(); ++it) { testdata += android::base::StringPrintf( const backtrace_map_t* entry = *it; "map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR " load_bias: %" PRIxPTR testdata += " flags: %d name: %s\n", android::base::StringPrintf("map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR it->start, it->end, it->offset, it->load_bias, it->flags, it->name.c_str()); " load_bias: %" PRIxPTR " flags: %d name: %s\n", entry->start, entry->end, entry->offset, entry->load_bias, entry->flags, entry->name.c_str()); } } // 3. Dump registers // 3. Dump registers testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context)); testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context)); Loading Loading
debuggerd/libdebuggerd/tombstone.cpp +15 −14 Original line number Original line Diff line number Diff line Loading @@ -417,7 +417,7 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p "memory map (%zu entr%s):", "memory map (%zu entr%s):", map->size(), map->size() == 1 ? "y" : "ies"); map->size(), map->size() == 1 ? "y" : "ies"); if (print_fault_address_marker) { if (print_fault_address_marker) { if (map->begin() != map->end() && addr < map->begin()->start) { if (map->begin() != map->end() && addr < (*map->begin())->start) { _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n", _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n", get_addr_string(addr).c_str()); get_addr_string(addr).c_str()); print_fault_address_marker = false; print_fault_address_marker = false; Loading @@ -429,49 +429,50 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p } } std::string line; std::string line; for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { for (auto it = map->begin(); it != map->end(); ++it) { const backtrace_map_t* entry = *it; line = " "; line = " "; if (print_fault_address_marker) { if (print_fault_address_marker) { if (addr < it->start) { if (addr < entry->start) { _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", get_addr_string(addr).c_str()); get_addr_string(addr).c_str()); print_fault_address_marker = false; print_fault_address_marker = false; } else if (addr >= it->start && addr < it->end) { } else if (addr >= entry->start && addr < entry->end) { line = "--->"; line = "--->"; print_fault_address_marker = false; print_fault_address_marker = false; } } } } line += get_addr_string(it->start) + '-' + get_addr_string(it->end - 1) + ' '; line += get_addr_string(entry->start) + '-' + get_addr_string(entry->end - 1) + ' '; if (it->flags & PROT_READ) { if (entry->flags & PROT_READ) { line += 'r'; line += 'r'; } else { } else { line += '-'; line += '-'; } } if (it->flags & PROT_WRITE) { if (entry->flags & PROT_WRITE) { line += 'w'; line += 'w'; } else { } else { line += '-'; line += '-'; } } if (it->flags & PROT_EXEC) { if (entry->flags & PROT_EXEC) { line += 'x'; line += 'x'; } else { } else { line += '-'; line += '-'; } } line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, it->offset, it->end - it->start); line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, entry->offset, entry->end - entry->start); bool space_needed = true; bool space_needed = true; if (it->name.length() > 0) { if (entry->name.length() > 0) { space_needed = false; space_needed = false; line += " " + it->name; line += " " + entry->name; std::string build_id; std::string build_id; if ((it->flags & PROT_READ) && elf_get_build_id(backtrace, it->start, &build_id)) { if ((entry->flags & PROT_READ) && elf_get_build_id(backtrace, entry->start, &build_id)) { line += " (BuildId: " + build_id + ")"; line += " (BuildId: " + build_id + ")"; } } } } if (it->load_bias != 0) { if (entry->load_bias != 0) { if (space_needed) { if (space_needed) { line += ' '; line += ' '; } } line += StringPrintf(" (load bias 0x%" PRIxPTR ")", it->load_bias); line += StringPrintf(" (load bias 0x%" PRIxPTR ")", entry->load_bias); } } _LOG(log, logtype::MAPS, "%s\n", line.c_str()); _LOG(log, logtype::MAPS, "%s\n", line.c_str()); } } Loading
libbacktrace/BacktraceMap.cpp +4 −3 Original line number Original line Diff line number Diff line Loading @@ -40,9 +40,10 @@ BacktraceMap::~BacktraceMap() { void BacktraceMap::FillIn(uintptr_t addr, backtrace_map_t* map) { void BacktraceMap::FillIn(uintptr_t addr, backtrace_map_t* map) { ScopedBacktraceMapIteratorLock lock(this); ScopedBacktraceMapIteratorLock lock(this); for (BacktraceMap::const_iterator it = begin(); it != end(); ++it) { for (auto it = begin(); it != end(); ++it) { if (addr >= it->start && addr < it->end) { const backtrace_map_t* entry = *it; *map = *it; if (addr >= entry->start && addr < entry->end) { *map = *entry; return; return; } } } } Loading
libbacktrace/UnwindStackMap.cpp +13 −2 Original line number Original line Diff line number Diff line Loading @@ -71,8 +71,19 @@ void UnwindStackMap::FillIn(uintptr_t addr, backtrace_map_t* map) { if (map_info == nullptr) { if (map_info == nullptr) { return; return; } } unwindstack::Elf* elf = map_info->GetElf(process_memory_, true); map->load_bias = map_info->GetLoadBias(process_memory_); map->load_bias = elf->GetLoadBias(); } uint64_t UnwindStackMap::GetLoadBias(size_t index) { if (index >= stack_maps_->Total()) { return 0; } unwindstack::MapInfo* map_info = stack_maps_->Get(index); if (map_info == nullptr) { return 0; } return map_info->GetLoadBias(process_memory_); } } std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) { std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) { Loading
libbacktrace/UnwindStackMap.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,8 @@ class UnwindStackMap : public BacktraceMap { const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; } const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; } protected: protected: uint64_t GetLoadBias(size_t index) override; std::unique_ptr<unwindstack::Maps> stack_maps_; std::unique_ptr<unwindstack::Maps> stack_maps_; std::shared_ptr<unwindstack::Memory> process_memory_; std::shared_ptr<unwindstack::Memory> process_memory_; }; }; Loading
libbacktrace/backtrace_offline_test.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -171,10 +171,12 @@ TEST(libbacktrace, DISABLED_generate_offline_testdata) { testdata += android::base::StringPrintf("pid: %d tid: %d\n", getpid(), arg.tid); testdata += android::base::StringPrintf("pid: %d tid: %d\n", getpid(), arg.tid); // 2. Dump maps // 2. Dump maps for (auto it = map->begin(); it != map->end(); ++it) { for (auto it = map->begin(); it != map->end(); ++it) { testdata += android::base::StringPrintf( const backtrace_map_t* entry = *it; "map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR " load_bias: %" PRIxPTR testdata += " flags: %d name: %s\n", android::base::StringPrintf("map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR it->start, it->end, it->offset, it->load_bias, it->flags, it->name.c_str()); " load_bias: %" PRIxPTR " flags: %d name: %s\n", entry->start, entry->end, entry->offset, entry->load_bias, entry->flags, entry->name.c_str()); } } // 3. Dump registers // 3. Dump registers testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context)); testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context)); Loading