#include #include typedef enum { _URC_OK = 0, _URC_FOREIGN_EXCEPTION_CAUGHT = 1, _URC_END_OF_STACK = 5, _URC_HANDLER_FOUND = 6, _URC_INSTALL_CONTEXT = 7, _URC_CONTINUE_UNWIND = 8, _URC_FAILURE = 9 } _Unwind_Reason_Code; typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (void *, void *); _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*); _Unwind_Reason_Code callback(void *p, void *p1) { int *state = p1; printf ("%d\n", *state); (*state)++; return _URC_OK; } void *poo() { printf("Hello from the thread\n"); int state = 0; _Unwind_Backtrace (callback, &state); return NULL; } void *bar() { printf("Hello from the main thread\n"); int state = 0; _Unwind_Backtrace (callback, &state); return NULL; } void main () { pthread_t the_thread; pthread_attr_t attrs; bar(); pthread_attr_init(&attrs); int retval = pthread_create(&the_thread, &attrs, poo, NULL); pthread_join(the_thread, NULL); }