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

Commit fb36dd62 authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "Add load base to map for relocation packing."

parents b74d8892 2106f4ba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -379,6 +379,9 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p
        line += " (BuildId: " + build_id + ")";
      }
    }
    if (it->load_base != 0) {
      line += android::base::StringPrintf(" (load base 0x%" PRIxPTR ")", it->load_base);
    }
    _LOG(log, logtype::MAPS, "%s\n", line.c_str());
  }
  if (print_fault_address_marker) {
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ struct backtrace_map_t {

  uintptr_t start;
  uintptr_t end;
  uintptr_t load_base;
  int flags;
  std::string name;
};
@@ -82,6 +83,14 @@ public:
    return map.end > 0;
  }

  static uintptr_t GetRelativePc(const backtrace_map_t& map, uintptr_t pc) {
    if (IsValid(map)) {
      return pc - map.start + map.load_base;
    } else {
      return pc;
    }
  }

protected:
  BacktraceMap(pid_t pid);

+1 −6
Original line number Diff line number Diff line
@@ -99,12 +99,7 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
    map_name = "<unknown>";
  }

  uintptr_t relative_pc;
  if (BacktraceMap::IsValid(frame->map)) {
    relative_pc = frame->pc - frame->map.start;
  } else {
    relative_pc = frame->pc;
  }
  uintptr_t relative_pc = BacktraceMap::GetRelativePc(frame->map, frame->pc);

  std::string line(StringPrintf("#%02zu pc %" PRIPTR "  %s", frame->num, relative_pc, map_name));
  if (!frame->func_name.empty()) {
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ bool UnwindMap::GenerateMap() {

    map.start = unw_map.start;
    map.end = unw_map.end;
    map.load_base = unw_map.load_base;
    map.flags = unw_map.flags;
    map.name = unw_map.path;

@@ -91,6 +92,7 @@ bool UnwindMapLocal::GenerateMap() {

      map.start = unw_map.start;
      map.end = unw_map.end;
      map.load_base = unw_map.load_base;
      map.flags = unw_map.flags;
      map.name = unw_map.path;

+11 −0
Original line number Diff line number Diff line
@@ -772,6 +772,7 @@ TEST(libbacktrace, format_test) {
  // Check map name empty, but exists.
  frame.map.start = 1;
  frame.map.end = 1;
  frame.map.load_base = 0;
#if defined(__LP64__)
  EXPECT_EQ("#01 pc 0000000000000001  <unknown>",
#else
@@ -807,6 +808,16 @@ TEST(libbacktrace, format_test) {
  EXPECT_EQ("#01 pc 0000000012345678  MapFake (ProcFake+645)",
#else
  EXPECT_EQ("#01 pc 12345678  MapFake (ProcFake+645)",
#endif
            backtrace->FormatFrameData(&frame));

  // Check func_name is set, func offset is non-zero, and load_base is non-zero.
  frame.func_offset = 645;
  frame.map.load_base = 100;
#if defined(__LP64__)
  EXPECT_EQ("#01 pc 00000000123456dc  MapFake (ProcFake+645)",
#else
  EXPECT_EQ("#01 pc 123456dc  MapFake (ProcFake+645)",
#endif
            backtrace->FormatFrameData(&frame));
}