summaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2019-04-06 17:09:10 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-04-06 17:09:10 +0000
commit7b115b388cc2573611c78d6775841c82206b5561 (patch)
treeddd6daebf11a3b2d96cea86b9bf20f077ed4a8cf /libbacktrace
parent7551c245cd13265e7173dc19ed4e5baa4d62b72c (diff)
parent6ce5c6a31e1f9b16c9654fec3db37c319f4a8e7e (diff)
downloadunwinding-7b115b388cc2573611c78d6775841c82206b5561.tar.gz
Merge "Revert "Check for data races when reading JIT/DEX entries.""
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/UnwindStack.cpp11
-rw-r--r--libbacktrace/UnwindStackMap.cpp7
-rw-r--r--libbacktrace/UnwindStackMap.h14
3 files changed, 32 insertions, 0 deletions
diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp
index ff19833..f5f9b2a 100644
--- a/libbacktrace/UnwindStack.cpp
+++ b/libbacktrace/UnwindStack.cpp
@@ -32,6 +32,9 @@
#include <unwindstack/Regs.h>
#include <unwindstack/RegsGetLocal.h>
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+#include <unwindstack/DexFiles.h>
+#endif
#include <unwindstack/Unwinder.h>
#include "BacktraceLog.h"
@@ -47,6 +50,14 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
regs, stack_map->process_memory());
unwinder.SetResolveNames(stack_map->ResolveNames());
stack_map->SetArch(regs->Arch());
+ if (stack_map->GetJitDebug() != nullptr) {
+ unwinder.SetJitDebug(stack_map->GetJitDebug(), regs->Arch());
+ }
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+ if (stack_map->GetDexFiles() != nullptr) {
+ unwinder.SetDexFiles(stack_map->GetDexFiles(), regs->Arch());
+ }
+#endif
unwinder.Unwind(skip_names, &stack_map->GetSuffixesToIgnore());
if (error != nullptr) {
switch (unwinder.LastErrorCode()) {
diff --git a/libbacktrace/UnwindStackMap.cpp b/libbacktrace/UnwindStackMap.cpp
index 726fdfa..4518891 100644
--- a/libbacktrace/UnwindStackMap.cpp
+++ b/libbacktrace/UnwindStackMap.cpp
@@ -43,6 +43,13 @@ bool UnwindStackMap::Build() {
// Create the process memory object.
process_memory_ = unwindstack::Memory::CreateProcessMemory(pid_);
+ // Create a JitDebug object for getting jit unwind information.
+ std::vector<std::string> search_libs_{"libart.so", "libartd.so"};
+ jit_debug_.reset(new unwindstack::JitDebug(process_memory_, search_libs_));
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+ dex_files_.reset(new unwindstack::DexFiles(process_memory_, search_libs_));
+#endif
+
if (!stack_maps_->Parse()) {
return false;
}
diff --git a/libbacktrace/UnwindStackMap.h b/libbacktrace/UnwindStackMap.h
index 9bb9709..e19b605 100644
--- a/libbacktrace/UnwindStackMap.h
+++ b/libbacktrace/UnwindStackMap.h
@@ -27,6 +27,9 @@
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+#include <unwindstack/DexFiles.h>
+#endif
#include <unwindstack/Elf.h>
#include <unwindstack/JitDebug.h>
#include <unwindstack/Maps.h>
@@ -50,6 +53,12 @@ class UnwindStackMap : public BacktraceMap {
const std::shared_ptr<unwindstack::Memory>& process_memory() { return process_memory_; }
+ unwindstack::JitDebug* GetJitDebug() { return jit_debug_.get(); }
+
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+ unwindstack::DexFiles* GetDexFiles() { return dex_files_.get(); }
+#endif
+
void SetArch(unwindstack::ArchEnum arch) { arch_ = arch; }
protected:
@@ -57,6 +66,11 @@ class UnwindStackMap : public BacktraceMap {
std::unique_ptr<unwindstack::Maps> stack_maps_;
std::shared_ptr<unwindstack::Memory> process_memory_;
+ std::unique_ptr<unwindstack::JitDebug> jit_debug_;
+#if !defined(NO_LIBDEXFILE_SUPPORT)
+ std::unique_ptr<unwindstack::DexFiles> dex_files_;
+#endif
+
unwindstack::ArchEnum arch_ = unwindstack::ARCH_UNKNOWN;
};