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

Commit 6fe31b2f authored by Christopher Ferris's avatar Christopher Ferris Committed by Android Git Automerger
Browse files

am d391c9b4: Merge "Re-enable libunwind for arm."

* commit 'd391c9b4':
  Re-enable libunwind for arm.
parents 0256e1f6 d391c9b4
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -625,12 +625,9 @@ static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal, uintptr_t a
    dump_fault_addr(log, tid, signal);
  }

  BacktraceMap* map = NULL;
  UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, tid));
  UniquePtr<BacktraceMap> map(BacktraceMap::Create(pid));
  UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, tid, map.get()));
  if (backtrace->Unwind(0)) {
    // Grab the map that was created and share it with the siblings.
    map = backtrace->TakeMapOwnership();

    dump_abort_message(backtrace.get(), log, abort_msg_address);
    dump_thread(backtrace.get(), log, SCOPE_AT_FAULT, total_sleep_time_usec);
  }
@@ -641,12 +638,9 @@ static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal, uintptr_t a

  bool detach_failed = false;
  if (dump_sibling_threads) {
    detach_failed = dump_sibling_thread_report(log, pid, tid, total_sleep_time_usec, map);
    detach_failed = dump_sibling_thread_report(log, pid, tid, total_sleep_time_usec, map.get());
  }

  // Destroy the BacktraceMap object.
  delete map;

  if (want_logs) {
    dump_logs(log, pid, 0);
  }
+0 −4
Original line number Diff line number Diff line
@@ -64,10 +64,6 @@ public:
  // Find the map associated with the given pc.
  virtual const backtrace_map_t* FindMap(uintptr_t pc);

  // Take ownership of the BacktraceMap object associated with the backtrace.
  // If this is called, the caller must handle deleting the object themselves.
  virtual BacktraceMap* TakeMapOwnership();

  // Read the data at a specific address.
  virtual bool ReadWord(uintptr_t ptr, uint32_t* out_value) = 0;

+8 −5
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@
#include <sys/mman.h>
#endif

#include <deque>
#include <string>
#include <vector>

struct backtrace_map_t {
  uintptr_t start;
@@ -40,7 +40,8 @@ struct backtrace_map_t {

class BacktraceMap {
public:
  BacktraceMap(pid_t pid);
  static BacktraceMap* Create(pid_t pid);

  virtual ~BacktraceMap();

  // Get the map data structure for the given address.
@@ -60,20 +61,22 @@ public:
  bool IsWritable(uintptr_t pc) { return GetFlags(pc) & PROT_WRITE; }
  bool IsExecutable(uintptr_t pc) { return GetFlags(pc) & PROT_EXEC; }

  typedef std::vector<backtrace_map_t>::iterator iterator;
  typedef std::deque<backtrace_map_t>::iterator iterator;
  iterator begin() { return maps_.begin(); }
  iterator end() { return maps_.end(); }

  typedef std::vector<backtrace_map_t>::const_iterator const_iterator;
  typedef std::deque<backtrace_map_t>::const_iterator const_iterator;
  const_iterator begin() const { return maps_.begin(); }
  const_iterator end() const { return maps_.end(); }

  virtual bool Build();

protected:
  BacktraceMap(pid_t pid);

  virtual bool ParseLine(const char* line, backtrace_map_t* map);

  std::vector<backtrace_map_t> maps_;
  std::deque<backtrace_map_t> maps_;
  pid_t pid_;
};

+3 −2
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)

common_src := \
	Backtrace.cpp \
	BacktraceImpl.cpp \
	BacktraceMap.cpp \
	BacktraceThread.cpp \
	thread_utils.c \
@@ -23,7 +23,7 @@ common_shared_libs := \
	liblog \

# To enable using libunwind on each arch, add it to this list.
libunwind_architectures := arm64
libunwind_architectures := arm arm64

ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures)))

@@ -35,6 +35,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
	$(common_src) \
	UnwindCurrent.cpp \
	UnwindMap.cpp \
	UnwindPtrace.cpp \

LOCAL_CFLAGS := \
+7 −27
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>

#include "Backtrace.h"
#include "BacktraceImpl.h"
#include "thread_utils.h"

//-------------------------------------------------------------------------
@@ -40,21 +40,21 @@ Backtrace::Backtrace(BacktraceImpl* impl, pid_t pid, BacktraceMap* map)
  impl_->SetParent(this);

  if (map_ == NULL) {
    // The map will be created when needed.
    map_ = BacktraceMap::Create(pid);
    map_shared_ = false;
  }
}

Backtrace::~Backtrace() {
  if (map_ && !map_shared_) {
    delete map_;
    map_ = NULL;
  }

  if (impl_) {
    delete impl_;
    impl_ = NULL;
  }

  if (map_ && !map_shared_) {
    delete map_;
    map_ = NULL;
  }
}

bool Backtrace::Unwind(size_t num_ignore_frames) {
@@ -129,30 +129,10 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
  return buf;
}

bool Backtrace::BuildMap() {
  map_ = impl_->CreateBacktraceMap(pid_);
  if (!map_->Build()) {
    BACK_LOGW("Failed to build map for process %d", pid_);
    return false;
  }
  return true;
}

const backtrace_map_t* Backtrace::FindMap(uintptr_t pc) {
  if (map_ == NULL) {
    // Lazy eval, time to build the map.
    if (!BuildMap()) {
      return NULL;
    }
  }
  return map_->Find(pc);
}

BacktraceMap* Backtrace::TakeMapOwnership() {
  map_shared_ = true;
  return map_;
}

//-------------------------------------------------------------------------
// BacktraceCurrent functions.
//-------------------------------------------------------------------------
Loading