1 #include <stdio.h> 2 #include <unwind.h> 3 4 extern "C" void arm_function_3(int* p); 5 extern "C" void thumb_function_1(int* p); 6 extern "C" void thumb_function_2(int* p); 7 8 extern "C" _Unwind_Reason_Code trace_function(_Unwind_Context* context, void *) { 9 printf("0x%x\n", _Unwind_GetIP(context)); 10 fflush(stdout); 11 return _URC_NO_REASON; 12 } 13 14 void thumb_function_1(int*) { 15 int a = 0; 16 arm_function_3(&a); 17 } 18 19 void thumb_function_2(int*) { 20 printf("unwinding...\n"); 21 _Unwind_Backtrace(trace_function, (void*) "backtrace!"); 22 } 23