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

Commit d391c9b4 authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "Re-enable libunwind for arm."

parents d2acdd82 df290618
Loading
Loading
Loading
Loading
+3 −9
Original line number Original line 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);
    dump_fault_addr(log, tid, signal);
  }
  }


  BacktraceMap* map = NULL;
  UniquePtr<BacktraceMap> map(BacktraceMap::Create(pid));
  UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, tid));
  UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, tid, map.get()));
  if (backtrace->Unwind(0)) {
  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_abort_message(backtrace.get(), log, abort_msg_address);
    dump_thread(backtrace.get(), log, SCOPE_AT_FAULT, total_sleep_time_usec);
    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;
  bool detach_failed = false;
  if (dump_sibling_threads) {
  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) {
  if (want_logs) {
    dump_logs(log, pid, 0);
    dump_logs(log, pid, 0);
  }
  }
+0 −4
Original line number Original line Diff line number Diff line
@@ -64,10 +64,6 @@ public:
  // Find the map associated with the given pc.
  // Find the map associated with the given pc.
  virtual const backtrace_map_t* FindMap(uintptr_t 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.
  // Read the data at a specific address.
  virtual bool ReadWord(uintptr_t ptr, uint32_t* out_value) = 0;
  virtual bool ReadWord(uintptr_t ptr, uint32_t* out_value) = 0;


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


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


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


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

  virtual ~BacktraceMap();
  virtual ~BacktraceMap();


  // Get the map data structure for the given address.
  // 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 IsWritable(uintptr_t pc) { return GetFlags(pc) & PROT_WRITE; }
  bool IsExecutable(uintptr_t pc) { return GetFlags(pc) & PROT_EXEC; }
  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 begin() { return maps_.begin(); }
  iterator end() { return maps_.end(); }
  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 begin() const { return maps_.begin(); }
  const_iterator end() const { return maps_.end(); }
  const_iterator end() const { return maps_.end(); }


  virtual bool Build();
  virtual bool Build();


protected:
protected:
  BacktraceMap(pid_t pid);

  virtual bool ParseLine(const char* line, backtrace_map_t* map);
  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_;
  pid_t pid_;
};
};


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


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


# To enable using libunwind on each arch, add it to this list.
# 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)))
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures)))


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


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


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


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


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


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

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

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


bool Backtrace::Unwind(size_t num_ignore_frames) {
bool Backtrace::Unwind(size_t num_ignore_frames) {
@@ -129,30 +129,10 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
  return buf;
  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) {
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);
  return map_->Find(pc);
}
}


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

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