summaryrefslogtreecommitdiff
path: root/libbacktrace/UnwindStackMap.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-10-30 16:16:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-30 16:16:45 +0000
commitb31badf70f7734d1ef6d1a95ee73dc57ebd2b19d (patch)
treeb150ea58a97519c38abf33f0654eb709d0c9846f /libbacktrace/UnwindStackMap.cpp
parent1d0ee36de7af27ee43e5075b99e9427130a1f0f1 (diff)
parent4568f4bc0f116f097a13b1d931de93cf525ae204 (diff)
Merge "Verify that the elf matches the expected arch."
Diffstat (limited to 'libbacktrace/UnwindStackMap.cpp')
-rw-r--r--libbacktrace/UnwindStackMap.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/libbacktrace/UnwindStackMap.cpp b/libbacktrace/UnwindStackMap.cpp
index 52dd44192..9d15af2db 100644
--- a/libbacktrace/UnwindStackMap.cpp
+++ b/libbacktrace/UnwindStackMap.cpp
@@ -25,6 +25,7 @@
#include <unwindstack/Elf.h>
#include <unwindstack/MapInfo.h>
#include <unwindstack/Maps.h>
+#include <unwindstack/Regs.h>
#include "UnwindStackMap.h"
@@ -106,7 +107,17 @@ std::string UnwindStackMap::GetFunctionName(uint64_t pc, uint64_t* offset) {
return "";
}
- unwindstack::Elf* elf = map_info->GetElf(process_memory());
+ if (arch_ == unwindstack::ARCH_UNKNOWN) {
+ if (pid_ == getpid()) {
+ arch_ = unwindstack::Regs::CurrentArch();
+ } else {
+ // Create a remote regs, to figure out the architecture.
+ std::unique_ptr<unwindstack::Regs> regs(unwindstack::Regs::RemoteGet(pid_));
+ arch_ = regs->Arch();
+ }
+ }
+
+ unwindstack::Elf* elf = map_info->GetElf(process_memory(), arch_);
std::string name;
uint64_t func_offset;