libunwind: Fix unw_step() for ARM EHABI.
This commit fixes the unw_step() for ARM EHABI. However, this commit
also changes the implementation details for ARM EHABI.
The first change is that the personality function should call
__gnu_unwind_frame() for default (or de facto) frame unwinding based on
the ARM-defined unwind opcode. The function __gnu_unwind_frame() will
in turn calls unw_step() which actually unwinds the frame.
The second change is that the implementation _Unwind_Backtrace() should
no longer calls unw_step() to unwind the frame; since according to ARM
EHABI, the personality function should unwind the frame for us.
Special thanks to Anton for helpful suggestion on the initial version of
this patch.
llvm-svn: 238560
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 7fab97f364d2e2f0beb7fffa3e42885db72982d5
diff --git a/test/libunwind_01.pass.cpp b/test/libunwind_01.pass.cpp
new file mode 100644
index 0000000..6957d98
--- /dev/null
+++ b/test/libunwind_01.pass.cpp
@@ -0,0 +1,42 @@
+#include <libunwind.h>
+#include <stdlib.h>
+
+void backtrace(int lower_bound) {
+ unw_context_t context;
+ unw_getcontext(&context);
+
+ unw_cursor_t cursor;
+ unw_init_local(&cursor, &context);
+
+ int n = 0;
+ do {
+ ++n;
+ if (n > 100) {
+ abort();
+ }
+ } while (unw_step(&cursor) > 0);
+
+ if (n < lower_bound) {
+ abort();
+ }
+}
+
+void test1(int i) {
+ backtrace(i);
+}
+
+void test2(int i, int j) {
+ backtrace(i);
+ test1(j);
+}
+
+void test3(int i, int j, int k) {
+ backtrace(i);
+ test2(j, k);
+}
+
+int main() {
+ test1(1);
+ test2(1, 2);
+ test3(1, 2, 3);
+}