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

Commit 2d651eda authored by Christopher Ferris's avatar Christopher Ferris Committed by Android Git Automerger
Browse files

am e0ab2322: Display the map offset for each frame.

* commit 'e0ab2322':
  Display the map offset for each frame.
parents d227679b e0ab2322
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -102,6 +102,11 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
  uintptr_t relative_pc = BacktraceMap::GetRelativePc(frame->map, 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));
  std::string line(StringPrintf("#%02zu pc %" PRIPTR "  %s", frame->num, relative_pc, map_name));
  // Special handling for non-zero offset maps, we need to print that
  // information.
  if (frame->map.offset != 0) {
    line += " (offset " + StringPrintf("0x%" PRIxPTR, frame->map.offset) + ")";
  }
  if (!frame->func_name.empty()) {
  if (!frame->func_name.empty()) {
    line += " (" + frame->func_name;
    line += " (" + frame->func_name;
    if (frame->func_offset) {
    if (frame->func_offset) {
+9 −0
Original line number Original line Diff line number Diff line
@@ -823,6 +823,15 @@ TEST(libbacktrace, format_test) {
  EXPECT_EQ("#01 pc 00000000123456dc  MapFake (ProcFake+645)",
  EXPECT_EQ("#01 pc 00000000123456dc  MapFake (ProcFake+645)",
#else
#else
  EXPECT_EQ("#01 pc 123456dc  MapFake (ProcFake+645)",
  EXPECT_EQ("#01 pc 123456dc  MapFake (ProcFake+645)",
#endif
            backtrace->FormatFrameData(&frame));

  // Check a non-zero map offset.
  frame.map.offset = 0x1000;
#if defined(__LP64__)
  EXPECT_EQ("#01 pc 00000000123456dc  MapFake (offset 0x1000) (ProcFake+645)",
#else
  EXPECT_EQ("#01 pc 123456dc  MapFake (offset 0x1000) (ProcFake+645)",
#endif
#endif
            backtrace->FormatFrameData(&frame));
            backtrace->FormatFrameData(&frame));
}
}