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

Commit 76d617c8 authored by Christopher Ferris's avatar Christopher Ferris Committed by Automerger Merge Worker
Browse files

Merge "libunwindstack: expose static version of BuildFrameFromPcOnly." am:...

Merge "libunwindstack: expose static version of BuildFrameFromPcOnly." am: f60d4f9a am: ebd6a0f3

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1406430

Change-Id: Ie6fb977c9c79ae5c6343473f97b4b4f59bdb2f83
parents e0e6fc87 ebd6a0f3
Loading
Loading
Loading
Loading
+14 −8
Original line number Original line Diff line number Diff line
@@ -397,19 +397,20 @@ bool UnwinderFromPid::Init(ArchEnum arch) {
  return true;
  return true;
}
}


FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps,
                                         JitDebug* jit_debug,
                                         std::shared_ptr<Memory> process_memory,
                                         bool resolve_names) {
  FrameData frame;
  FrameData frame;


  Maps* maps = GetMaps();
  MapInfo* map_info = maps->Find(pc);
  MapInfo* map_info = maps->Find(pc);
  if (map_info == nullptr || regs_ == nullptr) {
  if (map_info == nullptr || arch == ARCH_UNKNOWN) {
    frame.pc = pc;
    frame.pc = pc;
    frame.rel_pc = pc;
    frame.rel_pc = pc;
    return frame;
    return frame;
  }
  }


  ArchEnum arch = regs_->Arch();
  Elf* elf = map_info->GetElf(process_memory, arch);
  Elf* elf = map_info->GetElf(GetProcessMemory(), arch);


  uint64_t relative_pc = elf->GetRelPc(pc, map_info);
  uint64_t relative_pc = elf->GetRelPc(pc, map_info);


@@ -419,9 +420,9 @@ FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
  uint64_t debug_pc = relative_pc;
  uint64_t debug_pc = relative_pc;


  // If we don't have a valid ELF file, check the JIT.
  // If we don't have a valid ELF file, check the JIT.
  if (!elf->valid() && jit_debug_ != nullptr) {
  if (!elf->valid() && jit_debug != nullptr) {
    uint64_t jit_pc = pc - pc_adjustment;
    uint64_t jit_pc = pc - pc_adjustment;
    Elf* jit_elf = jit_debug_->GetElf(maps, jit_pc);
    Elf* jit_elf = jit_debug->GetElf(maps, jit_pc);
    if (jit_elf != nullptr) {
    if (jit_elf != nullptr) {
      debug_pc = jit_pc;
      debug_pc = jit_pc;
      elf = jit_elf;
      elf = jit_elf;
@@ -439,7 +440,7 @@ FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
  frame.map_flags = map_info->flags;
  frame.map_flags = map_info->flags;
  frame.map_load_bias = elf->GetLoadBias();
  frame.map_load_bias = elf->GetLoadBias();


  if (!resolve_names_ ||
  if (!resolve_names ||
      !elf->GetFunctionName(debug_pc, &frame.function_name, &frame.function_offset)) {
      !elf->GetFunctionName(debug_pc, &frame.function_name, &frame.function_offset)) {
    frame.function_name = "";
    frame.function_name = "";
    frame.function_offset = 0;
    frame.function_offset = 0;
@@ -447,4 +448,9 @@ FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
  return frame;
  return frame;
}
}


FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
  return BuildFrameFromPcOnly(pc, regs_ ? regs_->Arch() : ARCH_UNKNOWN, maps_, jit_debug_,
                              process_memory_, resolve_names_);
}

}  // namespace unwindstack
}  // namespace unwindstack
+2 −0
Original line number Original line Diff line number Diff line
@@ -120,6 +120,8 @@ class Unwinder {
  // frames collected by frame-pointer unwinding that's done outside of
  // frames collected by frame-pointer unwinding that's done outside of
  // libunwindstack. This is used by tombstoned to symbolize frame pointer-based
  // libunwindstack. This is used by tombstoned to symbolize frame pointer-based
  // stack traces that are collected by tools such as GWP-ASan and MTE.
  // stack traces that are collected by tools such as GWP-ASan and MTE.
  static FrameData BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps, JitDebug* jit_debug,
                                        std::shared_ptr<Memory> process_memory, bool resolve_names);
  FrameData BuildFrameFromPcOnly(uint64_t pc);
  FrameData BuildFrameFromPcOnly(uint64_t pc);


 protected:
 protected: