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

Commit 14b964f5 authored by Christopher Ferris's avatar Christopher Ferris Committed by Android Git Automerger
Browse files

am e6ed63e6: am c9c401e6: Merge "Move map data into backtrace data proper."

* commit 'e6ed63e6':
  Move map data into backtrace data proper.
parents bc32de07 e6ed63e6
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -240,12 +240,13 @@ static void dump_stack_segment(
      break;
    }

    const backtrace_map_t* map = backtrace->FindMap(stack_content);
    backtrace_map_t map;
    backtrace->FillInMap(stack_content, &map);
    const char* map_name;
    if (!map) {
    if (BacktraceMap::IsValid(map)) {
      map_name = "";
    } else {
      map_name = map->name.c_str();
      map_name = map.name.c_str();
    }
    uintptr_t offset = 0;
    std::string func_name(backtrace->GetFunctionName(stack_content, &offset));
+3 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ struct backtrace_frame_data_t {
  uintptr_t pc;           // The absolute pc.
  uintptr_t sp;           // The top of the stack.
  size_t stack_size;      // The size of the stack, zero indicate an unknown stack size.
  const backtrace_map_t* map;   // The map associated with the given pc.
  backtrace_map_t map;    // The map associated with the given pc.
  std::string func_name;  // The function name associated with this pc, NULL if not found.
  uintptr_t func_offset;  // pc relative to the start of the function, only valid if func_name is not NULL.
};
@@ -78,8 +78,8 @@ public:
  // If the string is empty, then no valid function name was found.
  virtual std::string GetFunctionName(uintptr_t pc, uintptr_t* offset);

  // Find the map associated with the given pc.
  virtual const backtrace_map_t* FindMap(uintptr_t pc);
  // Fill in the map data associated with the given pc.
  virtual void FillInMap(uintptr_t pc, backtrace_map_t* map);

  // Read the data at a specific address.
  virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0;
+12 −5
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@
#include <string>

struct backtrace_map_t {
  backtrace_map_t(): start(0), end(0), flags(0) {}

  uintptr_t start;
  uintptr_t end;
  int flags;
@@ -48,15 +50,16 @@ public:

  virtual ~BacktraceMap();

  // Get the map data structure for the given address.
  virtual const backtrace_map_t* Find(uintptr_t addr);
  // Fill in the map data structure for the given address.
  virtual void FillIn(uintptr_t addr, backtrace_map_t* map);

  // The flags returned are the same flags as used by the mmap call.
  // The values are PROT_*.
  int GetFlags(uintptr_t pc) {
    const backtrace_map_t* map = Find(pc);
    if (map) {
      return map->flags;
    backtrace_map_t map;
    FillIn(pc, &map);
    if (IsValid(map)) {
      return map.flags;
    }
    return PROT_NONE;
  }
@@ -75,6 +78,10 @@ public:

  virtual bool Build();

  static inline bool IsValid(const backtrace_map_t& map) {
    return map.end > 0;
  }

protected:
  BacktraceMap(pid_t pid);

+9 −8
Original line number Diff line number Diff line
@@ -99,15 +99,15 @@ std::string Backtrace::FormatFrameData(size_t frame_num) {

std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
  const char* map_name;
  if (frame->map && !frame->map->name.empty()) {
    map_name = frame->map->name.c_str();
  if (BacktraceMap::IsValid(frame->map) && !frame->map.name.empty()) {
    map_name = frame->map.name.c_str();
  } else {
    map_name = "<unknown>";
  }

  uintptr_t relative_pc;
  if (frame->map) {
    relative_pc = frame->pc - frame->map->start;
  if (BacktraceMap::IsValid(frame->map)) {
    relative_pc = frame->pc - frame->map.start;
  } else {
    relative_pc = frame->pc;
  }
@@ -128,8 +128,8 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
  return buf;
}

const backtrace_map_t* Backtrace::FindMap(uintptr_t pc) {
  return map_->Find(pc);
void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) {
  map_->FillIn(pc, map);
}

//-------------------------------------------------------------------------
@@ -147,8 +147,9 @@ bool BacktraceCurrent::ReadWord(uintptr_t ptr, word_t* out_value) {
    return false;
  }

  const backtrace_map_t* map = FindMap(ptr);
  if (map && map->flags & PROT_READ) {
  backtrace_map_t map;
  FillInMap(ptr, &map);
  if (BacktraceMap::IsValid(map) && map.flags & PROT_READ) {
    *out_value = *reinterpret_cast<word_t*>(ptr);
    return true;
  } else {
+2 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ public:
  inline pid_t Pid() { return backtrace_obj_->Pid(); }
  inline pid_t Tid() { return backtrace_obj_->Tid(); }

  inline const backtrace_map_t* FindMap(uintptr_t addr) {
    return backtrace_obj_->FindMap(addr);
  inline void FillInMap(uintptr_t addr, backtrace_map_t* map) {
    backtrace_obj_->FillInMap(addr, map);
  }
  inline std::string GetFunctionName(uintptr_t pc, uintptr_t* offset) {
    return backtrace_obj_->GetFunctionName(pc, offset);
Loading