Re-enable libunwind for arm.
Update to handle the new optimized way that libunwind works.
In addition, a small refactor of the BacktraceMap code.
A few new tests of for good measure.
Change-Id: I2f9b4f5ad5a0dfe907b31febee76e4b9b94fb76f
diff --git a/libbacktrace/UnwindPtrace.cpp b/libbacktrace/UnwindPtrace.cpp
index e45c5f8..732dae8 100644
--- a/libbacktrace/UnwindPtrace.cpp
+++ b/libbacktrace/UnwindPtrace.cpp
@@ -25,6 +25,7 @@
#include <libunwind.h>
#include <libunwind-ptrace.h>
+#include "UnwindMap.h"
#include "UnwindPtrace.h"
UnwindPtrace::UnwindPtrace() : addr_space_(NULL), upt_info_(NULL) {
@@ -36,6 +37,10 @@
upt_info_ = NULL;
}
if (addr_space_) {
+ // Remove the map from the address space before destroying it.
+ // It will be freed in the UnwindMap destructor.
+ unw_map_set(addr_space_, NULL);
+
unw_destroy_addr_space(addr_space_);
addr_space_ = NULL;
}
@@ -48,7 +53,10 @@
return false;
}
- upt_info_ = reinterpret_cast<struct UPT_info*>(_UPT_create(backtrace_obj_->Tid()));
+ UnwindMap* map = static_cast<UnwindMap*>(GetMap());
+ unw_map_set(addr_space_, map->GetMapCursor());
+
+ upt_info_ = reinterpret_cast<struct UPT_info*>(_UPT_create(Tid()));
if (!upt_info_) {
BACK_LOGW("Failed to create upt info.");
return false;
@@ -91,9 +99,9 @@
prev->stack_size = frame->sp - prev->sp;
}
- frame->func_name = backtrace_obj_->GetFunctionName(frame->pc, &frame->func_offset);
+ frame->func_name = GetFunctionName(frame->pc, &frame->func_offset);
- frame->map = backtrace_obj_->FindMap(frame->pc);
+ frame->map = FindMap(frame->pc);
num_frames++;
} else {