libunwindstack: expose static version of BuildFrameFromPcOnly.
Bug: http://b/165206592
Test: unit tests and treehugger
Change-Id: Ic357ee6160281c5986570de5536b3247b231bc6f
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index e0edc59..57806c1 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -397,19 +397,20 @@
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 == nullptr || regs_ == nullptr) {
+ if (map_info == nullptr || arch == ARCH_UNKNOWN) {
frame.pc = pc;
frame.rel_pc = pc;
return frame;
}
- ArchEnum arch = regs_->Arch();
- Elf* elf = map_info->GetElf(GetProcessMemory(), arch);
+ Elf* elf = map_info->GetElf(process_memory, arch);
uint64_t relative_pc = elf->GetRelPc(pc, map_info);
@@ -419,9 +420,9 @@
uint64_t debug_pc = relative_pc;
// If we don't have a valid ELF file, check the JIT.
- if (!elf->valid() && jit_debug_ != nullptr) {
+ 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;
@@ -439,7 +440,7 @@
frame.map_flags = map_info->flags;
frame.map_load_bias = elf->GetLoadBias();
- if (!resolve_names_ ||
+ if (!resolve_names ||
!elf->GetFunctionName(debug_pc, &frame.function_name, &frame.function_offset)) {
frame.function_name = "";
frame.function_offset = 0;
@@ -447,4 +448,9 @@
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
diff --git a/libunwindstack/include/unwindstack/Unwinder.h b/libunwindstack/include/unwindstack/Unwinder.h
index a974b63..3df8aad 100644
--- a/libunwindstack/include/unwindstack/Unwinder.h
+++ b/libunwindstack/include/unwindstack/Unwinder.h
@@ -120,6 +120,8 @@
// frames collected by frame-pointer unwinding that's done outside of
// libunwindstack. This is used by tombstoned to symbolize frame pointer-based
// stack traces that are collected by tools such as GWP-ASan and MTE.
+ static FrameData BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps, JitDebug* jit_debug,
+ std::shared_ptr<Memory> process_memory, bool resolve_names);
FrameData BuildFrameFromPcOnly(uint64_t pc);
protected: