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

Commit 45c4a56f authored by Josh Gao's avatar Josh Gao
Browse files

libbacktrace: expose libunwindstack Unwind routine.

Test: backtrace_test32/64 on hikey960
Change-Id: Iae6e342a8ffd13b4d5f76b39dd434c827f7a4d9e
parent d72d92ae
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ static std::string GetFunctionName(BacktraceMap* back_map, uintptr_t pc, uintptr
  return name;
}

static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
                       std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) {
  static std::set<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
  UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map);
@@ -127,7 +127,7 @@ bool UnwindStackCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t*
  }

  error_ = BACKTRACE_UNWIND_NO_ERROR;
  return ::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
  return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
}

UnwindStackPtrace::UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map)
@@ -147,7 +147,7 @@ bool UnwindStackPtrace::Unwind(size_t num_ignore_frames, ucontext_t* context) {
  }

  error_ = BACKTRACE_UNWIND_NO_ERROR;
  return ::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
  return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
}

Backtrace* Backtrace::CreateNew(pid_t pid, pid_t tid, BacktraceMap* map) {
+7 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ struct backtrace_stackinfo_t {
  const uint8_t* data;
};

namespace unwindstack {
class Regs;
}

class Backtrace {
public:
  // Create the correct Backtrace object based on what is to be unwound.
@@ -106,6 +110,9 @@ public:
  // Get the current stack trace and store in the backtrace_ structure.
  virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0;

  static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
                     std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames);

  // Get the function name and offset into the function given the pc.
  // If the string is empty, then no valid function name was found,
  // or the pc is not in any valid map.