Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ea08c2f authored by Peter Collingbourne's avatar Peter Collingbourne
Browse files

Untag addresses in registers before looking up the mapping.

Otherwise we can fail to find map entries for tagged addresses,
such as those of heap objects.

Bug: 135772972
Change-Id: Ia626b0587c8461eb575b2de5c08562c73ba4a66e
parent 7b204ac4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -373,11 +373,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
+2 −1
Original line number Diff line number Diff line
@@ -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 + ")";
      }
+2 −1
Original line number Diff line number Diff line
@@ -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);
          }