1 #include <new>
2 #include <exception>
3 #include <cstdio>
4
5 /* Stubbed out in libdl and defined in the dynamic linker.
6 * Same semantics as __gnu_Unwind_Find_exidx().
7 */
8 typedef long unsigned int *_Unwind_Ptr;
9 extern "C" _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int *pcount);
__gnu_Unwind_Find_exidx(_Unwind_Ptr pc,int * pcount)10 extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc, int *pcount)
11 {
12 _Unwind_Ptr ret_pc;
13 printf("%p -> ", pc);
14 ret_pc = dl_unwind_find_exidx(pc, pcount);
15 printf("%p %d\n", ret_pc, *pcount);
16 return ret_pc;
17 }
18 static void* g_func_ptr;
19
foo(void)20 static void foo(void)
21 {
22 try
23 {
24 ::printf("Hello ");
25 throw std::exception();
26 } catch (const std::exception &e)
27 {
28 ::printf(" World!\n");
29 }
30 }
31
main(int argc,char ** argv)32 int main(int argc, char** argv)
33 {
34 int count;
35 g_func_ptr = (void*)__gnu_Unwind_Find_exidx;
36
37 __gnu_Unwind_Find_exidx((_Unwind_Ptr)main, &count); // This one succeed
38
39 // This one crash on Android <= 2.1.
40 // The lcoal __gnu_Unwind_Find_exidx() isn't even called.
41 // Need to recompile Android 2.1 from source and debug platform from there
42 foo();
43 return 0;
44 }
45