mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-30 12:07:34 +00:00
7fab97f364
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
43 lines
568 B
C++
43 lines
568 B
C++
#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);
|
|
}
|