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

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

Merge "Update for libunwindstack shared_ptr MapInfos." am: e88e9922

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

Change-Id: Ic71c2753d62886294316e9e20c3aa747859fb00d
parents 715c99c0 e88e9922
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


#pragma once
#pragma once


#include <memory>

#include <unwindstack/MapInfo.h>
#include <unwindstack/MapInfo.h>
#include <unwindstack/Maps.h>
#include <unwindstack/Maps.h>
#include <unwindstack/Unwinder.h>
#include <unwindstack/Unwinder.h>
@@ -31,7 +33,7 @@ class UnwinderMock : public unwindstack::Unwinder {
  }
  }


  void MockSetBuildID(uint64_t offset, const std::string& build_id) {
  void MockSetBuildID(uint64_t offset, const std::string& build_id) {
    unwindstack::MapInfo* map_info = GetMaps()->Find(offset);
    std::shared_ptr<unwindstack::MapInfo> map_info = GetMaps()->Find(offset);
    if (map_info != nullptr) {
    if (map_info != nullptr) {
      map_info->SetBuildID(std::string(build_id));
      map_info->SetBuildID(std::string(build_id));
    }
    }
+3 −3
Original line number Original line Diff line number Diff line
@@ -107,7 +107,7 @@ static std::string get_stack_overflow_cause(uint64_t fault_addr, uint64_t sp,
    // In this case, the sp will be in either an invalid map if triggered
    // In this case, the sp will be in either an invalid map if triggered
    // on the main thread, or in a guard map if in another thread, which
    // on the main thread, or in a guard map if in another thread, which
    // will be the first case or second case from below.
    // will be the first case or second case from below.
    unwindstack::MapInfo* map_info = maps->Find(sp);
    auto map_info = maps->Find(sp);
    if (map_info == nullptr) {
    if (map_info == nullptr) {
      return "stack pointer is in a non-existent map; likely due to stack overflow.";
      return "stack pointer is in a non-existent map; likely due to stack overflow.";
    } else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
    } else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
@@ -158,7 +158,7 @@ static void dump_probable_cause(log_t* log, unwindstack::Unwinder* unwinder,
    }
    }
  } else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
  } else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
    uint64_t fault_addr = reinterpret_cast<uint64_t>(si->si_addr);
    uint64_t fault_addr = reinterpret_cast<uint64_t>(si->si_addr);
    unwindstack::MapInfo* map_info = maps->Find(fault_addr);
    auto map_info = maps->Find(fault_addr);
    if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
    if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
      cause = "execute-only (no-read) memory access error; likely due to data in .text.";
      cause = "execute-only (no-read) memory access error; likely due to data in .text.";
    } else {
    } else {
@@ -396,7 +396,7 @@ void dump_memory_and_code(log_t* log, unwindstack::Maps* maps, unwindstack::Memo
  regs->IterateRegisters([log, maps, memory](const char* reg_name, uint64_t reg_value) {
  regs->IterateRegisters([log, maps, memory](const char* reg_name, uint64_t reg_value) {
    std::string label{"memory near "s + reg_name};
    std::string label{"memory near "s + reg_name};
    if (maps) {
    if (maps) {
      unwindstack::MapInfo* map_info = maps->Find(untag_address(reg_value));
      auto map_info = maps->Find(untag_address(reg_value));
      if (map_info != nullptr && !map_info->name().empty()) {
      if (map_info != nullptr && !map_info->name().empty()) {
        label += " (" + map_info->name() + ")";
        label += " (" + map_info->name() + ")";
      }
      }
+5 −5
Original line number Original line Diff line number Diff line
@@ -103,7 +103,7 @@ static std::optional<std::string> get_stack_overflow_cause(uint64_t fault_addr,
    // In this case, the sp will be in either an invalid map if triggered
    // In this case, the sp will be in either an invalid map if triggered
    // on the main thread, or in a guard map if in another thread, which
    // on the main thread, or in a guard map if in another thread, which
    // will be the first case or second case from below.
    // will be the first case or second case from below.
    unwindstack::MapInfo* map_info = maps->Find(sp);
    std::shared_ptr<unwindstack::MapInfo> map_info = maps->Find(sp);
    if (map_info == nullptr) {
    if (map_info == nullptr) {
      return "stack pointer is in a non-existent map; likely due to stack overflow.";
      return "stack pointer is in a non-existent map; likely due to stack overflow.";
    } else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
    } else if ((map_info->flags() & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
@@ -226,7 +226,7 @@ static void dump_probable_cause(Tombstone* tombstone, unwindstack::Unwinder* unw
      cause = get_stack_overflow_cause(fault_addr, main_thread.registers->sp(), maps);
      cause = get_stack_overflow_cause(fault_addr, main_thread.registers->sp(), maps);
    }
    }
  } else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
  } else if (si->si_signo == SIGSEGV && si->si_code == SEGV_ACCERR) {
    unwindstack::MapInfo* map_info = maps->Find(fault_addr);
    auto map_info = maps->Find(fault_addr);
    if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
    if (map_info != nullptr && map_info->flags() == PROT_EXEC) {
      cause = "execute-only (no-read) memory access error; likely due to data in .text.";
      cause = "execute-only (no-read) memory access error; likely due to data in .text.";
    } else {
    } else {
@@ -342,8 +342,8 @@ void fill_in_backtrace_frame(BacktraceFrame* f, const unwindstack::FrameData& fr


  f->set_file_map_offset(frame.map_elf_start_offset);
  f->set_file_map_offset(frame.map_elf_start_offset);


  unwindstack::MapInfo* map_info = maps->Find(frame.map_start);
  auto map_info = maps->Find(frame.map_start);
  if (map_info) {
  if (map_info.get() != nullptr) {
    f->set_build_id(map_info->GetPrintableBuildID());
    f->set_build_id(map_info->GetPrintableBuildID());
  }
  }
}
}
@@ -370,7 +370,7 @@ static void dump_thread(Tombstone* tombstone, unwindstack::Unwinder* unwinder,
          MemoryDump dump;
          MemoryDump dump;


          dump.set_register_name(name);
          dump.set_register_name(name);
          unwindstack::MapInfo* map_info = maps->Find(untag_address(value));
          std::shared_ptr<unwindstack::MapInfo> map_info = maps->Find(untag_address(value));
          if (map_info) {
          if (map_info) {
            dump.set_mapping_name(map_info->name());
            dump.set_mapping_name(map_info->name());
          }
          }