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

Commit 36eb8007 authored by Christopher Ferris's avatar Christopher Ferris Committed by android-build-merger
Browse files

Merge "Add BuildId to frame information." am: 3da5fcbf

am: 95b9ea1d

Change-Id: I82c95aa7d16f4705e7119167f1c93de28fc22e41
parents 216aabea 95b9ea1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder,
    return;
  }

  unwinder->SetDisplayBuildID(true);
  for (size_t i = 0; i < unwinder->NumFrames(); i++) {
    _LOG(&log, logtype::BACKTRACE, "  %s\n", unwinder->FormatFrame(i).c_str());
  }
+1 −0
Original line number Diff line number Diff line
@@ -371,6 +371,7 @@ static void dump_all_maps(log_t* log, unwindstack::Unwinder* unwinder, uint64_t
}

void dump_backtrace(log_t* log, unwindstack::Unwinder* unwinder, const char* prefix) {
  unwinder->SetDisplayBuildID(true);
  for (size_t i = 0; i < unwinder->NumFrames(); i++) {
    _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, unwinder->FormatFrame(i).c_str());
  }
+17 −10
Original line number Diff line number Diff line
@@ -284,17 +284,9 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip,
  }
}

std::string Unwinder::FormatFrame(size_t frame_num) {
  if (frame_num >= frames_.size()) {
    return "";
  }
  return FormatFrame(frames_[frame_num], regs_->Is32Bit());
}

std::string Unwinder::FormatFrame(const FrameData& frame, bool is32bit) {
std::string Unwinder::FormatFrame(const FrameData& frame) {
  std::string data;

  if (is32bit) {
  if (regs_->Is32Bit()) {
    data += android::base::StringPrintf("  #%02zu pc %08" PRIx64, frame.num, frame.rel_pc);
  } else {
    data += android::base::StringPrintf("  #%02zu pc %016" PRIx64, frame.num, frame.rel_pc);
@@ -320,9 +312,24 @@ std::string Unwinder::FormatFrame(const FrameData& frame, bool is32bit) {
    }
    data += ')';
  }

  MapInfo* map_info = maps_->Find(frame.map_start);
  if (map_info != nullptr && display_build_id_) {
    std::string build_id = map_info->GetPrintableBuildID();
    if (!build_id.empty()) {
      data += " (BuildId: " + build_id + ')';
    }
  }
  return data;
}

std::string Unwinder::FormatFrame(size_t frame_num) {
  if (frame_num >= frames_.size()) {
    return "";
  }
  return FormatFrame(frames_[frame_num]);
}

void Unwinder::SetJitDebug(JitDebug* jit_debug, ArchEnum arch) {
  jit_debug->SetArch(arch);
  jit_debug_ = jit_debug;
+4 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class Unwinder {
  }

  std::string FormatFrame(size_t frame_num);
  static std::string FormatFrame(const FrameData& frame, bool is32bit);
  std::string FormatFrame(const FrameData& frame);

  void SetJitDebug(JitDebug* jit_debug, ArchEnum arch);

@@ -105,6 +105,8 @@ class Unwinder {
  // NOTE: This does nothing unless resolving names is enabled.
  void SetEmbeddedSoname(bool embedded_soname) { embedded_soname_ = embedded_soname; }

  void SetDisplayBuildID(bool display_build_id) { display_build_id_ = display_build_id; }

#if !defined(NO_LIBDEXFILE_SUPPORT)
  void SetDexFiles(DexFiles* dex_files, ArchEnum arch);
#endif
@@ -130,6 +132,7 @@ class Unwinder {
#endif
  bool resolve_names_ = true;
  bool embedded_soname_ = true;
  bool display_build_id_ = false;
  ErrorData last_error_;
};

+6 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
#include <unwindstack/Memory.h>
#include <unwindstack/Regs.h>

#include "Check.h"

namespace unwindstack {

class RegsFake : public Regs {
@@ -47,7 +49,10 @@ class RegsFake : public Regs {

  void IterateRegisters(std::function<void(const char*, uint64_t)>) override {}

  bool Is32Bit() { return false; }
  bool Is32Bit() {
    CHECK(fake_arch_ != ARCH_UNKNOWN);
    return fake_arch_ == ARCH_ARM || fake_arch_ == ARCH_X86 || fake_arch_ == ARCH_MIPS;
  }

  uint64_t GetPcAdjustment(uint64_t, Elf*) override { return 2; }

Loading