Merge "Untag addresses in registers before looking up the mapping."

This commit is contained in:
Treehugger Robot 2021-03-06 02:41:05 +00:00 committed by Gerrit Code Review
commit 3f24fefe29
3 changed files with 7 additions and 5 deletions

View file

@ -374,11 +374,11 @@ TEST_F(CrasherTest, heap_addr_in_register) {
ConsumeFd(std::move(output_fd), &result);
#if defined(__aarch64__)
ASSERT_MATCH(result, "memory near x0");
ASSERT_MATCH(result, "memory near x0 \\(\\[anon:");
#elif defined(__arm__)
ASSERT_MATCH(result, "memory near r0");
ASSERT_MATCH(result, "memory near r0 \\(\\[anon:");
#elif defined(__x86_64__)
ASSERT_MATCH(result, "memory near rdi");
ASSERT_MATCH(result, "memory near rdi \\(\\[anon:");
#else
ASSERT_TRUE(false) << "unsupported architecture";
#endif

View file

@ -42,6 +42,7 @@
#include <android-base/unique_fd.h>
#include <android/log.h>
#include <async_safe/log.h>
#include <bionic/macros.h>
#include <log/log.h>
#include <log/log_read.h>
#include <log/logprint.h>
@ -362,7 +363,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(reg_value);
unwindstack::MapInfo* map_info = maps->Find(untag_address(reg_value));
if (map_info != nullptr && !map_info->name.empty()) {
label += " (" + map_info->name + ")";
}

View file

@ -39,6 +39,7 @@
#include <android-base/unique_fd.h>
#include <android/log.h>
#include <bionic/macros.h>
#include <log/log.h>
#include <log/log_read.h>
#include <log/logprint.h>
@ -233,7 +234,7 @@ static void dump_thread(Tombstone* tombstone, unwindstack::Unwinder* unwinder,
dump.set_register_name(name);
unwindstack::MapInfo* map_info = maps->Find(value);
unwindstack::MapInfo* map_info = maps->Find(untag_address(value));
if (map_info) {
dump.set_mapping_name(map_info->name);
}