summaryrefslogtreecommitdiff
path: root/libunwindstack/Unwinder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/Unwinder.cpp')
-rw-r--r--libunwindstack/Unwinder.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index 2d867cd5e..57806c157 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -75,6 +75,7 @@ void Unwinder::FillInDexFrame() {
frame->rel_pc = dex_pc - info->start;
} else {
frame->rel_pc = dex_pc;
+ warnings_ |= WARNING_DEX_PC_NOT_IN_MAP;
return;
}
@@ -142,6 +143,7 @@ static bool ShouldStop(const std::vector<std::string>* map_suffixes_to_ignore,
void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip,
const std::vector<std::string>* map_suffixes_to_ignore) {
frames_.clear();
+ warnings_ = WARNING_NONE;
last_error_.code = ERROR_NONE;
last_error_.address = 0;
elf_from_memory_not_file_ = false;
@@ -395,18 +397,20 @@ bool UnwinderFromPid::Init(ArchEnum arch) {
return true;
}
-FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
+FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps,
+ JitDebug* jit_debug,
+ std::shared_ptr<Memory> process_memory,
+ bool resolve_names) {
FrameData frame;
- Maps* maps = GetMaps();
MapInfo* map_info = maps->Find(pc);
- if (!map_info) {
+ if (map_info == nullptr || arch == ARCH_UNKNOWN) {
+ frame.pc = pc;
frame.rel_pc = pc;
return frame;
}
- ArchEnum arch = Regs::CurrentArch();
- Elf* elf = map_info->GetElf(GetProcessMemory(), arch);
+ Elf* elf = map_info->GetElf(process_memory, arch);
uint64_t relative_pc = elf->GetRelPc(pc, map_info);
@@ -416,10 +420,9 @@ FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
uint64_t debug_pc = relative_pc;
// If we don't have a valid ELF file, check the JIT.
- if (!elf->valid()) {
- JitDebug jit_debug(GetProcessMemory());
+ if (!elf->valid() && jit_debug != nullptr) {
uint64_t jit_pc = pc - pc_adjustment;
- Elf* jit_elf = jit_debug.GetElf(maps, jit_pc);
+ Elf* jit_elf = jit_debug->GetElf(maps, jit_pc);
if (jit_elf != nullptr) {
debug_pc = jit_pc;
elf = jit_elf;
@@ -437,12 +440,17 @@ FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
frame.map_flags = map_info->flags;
frame.map_load_bias = elf->GetLoadBias();
- if (!resolve_names_ ||
- !elf->GetFunctionName(relative_pc, &frame.function_name, &frame.function_offset)) {
+ if (!resolve_names ||
+ !elf->GetFunctionName(debug_pc, &frame.function_name, &frame.function_offset)) {
frame.function_name = "";
frame.function_offset = 0;
}
return frame;
}
+FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
+ return BuildFrameFromPcOnly(pc, regs_ ? regs_->Arch() : ARCH_UNKNOWN, maps_, jit_debug_,
+ process_memory_, resolve_names_);
+}
+
} // namespace unwindstack