diff options
author | Josh Gao <jmgao@google.com> | 2017-09-06 22:16:09 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-10-20 13:52:56 -0700 |
commit | 358de18b2747828720e7f9dc538e724a66f02cba (patch) | |
tree | 60788722a9ace559fd55cc9e7a46b3fc59b10bfd /libbacktrace/UnwindStackMap.cpp | |
parent | 45c4a56f1d484ce60390bf48ab55076d4d601c9d (diff) |
libunwindstack: expose UnwindStackMap::GetFunctionName.
Test: mma
Change-Id: I8736ff5c2ed7c5e64eb68df5f4eccfed614612c7
Diffstat (limited to 'libbacktrace/UnwindStackMap.cpp')
-rw-r--r-- | libbacktrace/UnwindStackMap.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libbacktrace/UnwindStackMap.cpp b/libbacktrace/UnwindStackMap.cpp index d4a2444dc..a9121a800 100644 --- a/libbacktrace/UnwindStackMap.cpp +++ b/libbacktrace/UnwindStackMap.cpp @@ -75,6 +75,27 @@ void UnwindStackMap::FillIn(uintptr_t addr, backtrace_map_t* map) { map->load_bias = elf->GetLoadBias(); } +std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) { + *offset = 0; + unwindstack::Maps* maps = stack_maps(); + + // Get the map for this + unwindstack::MapInfo* map_info = maps->Find(pc); + if (map_info == nullptr || map_info->flags & PROT_DEVICE_MAP) { + return ""; + } + + unwindstack::Elf* elf = map_info->GetElf(process_memory(), true); + + std::string name; + uint64_t func_offset; + if (!elf->GetFunctionName(elf->GetRelPc(pc, map_info), &name, &func_offset)) { + return ""; + } + *offset = func_offset; + return name; +} + //------------------------------------------------------------------------- // BacktraceMap create function. //------------------------------------------------------------------------- |