void calltest(int initial) { // Mark the extent of the continuation (root) root = getrbp(); printf("calling test() w/initial value %d and root %p\n", initial, root); test(initial); printf("test() returned\n", initial); }
isc_result_t isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { int i = 0; void **sp; /* Argument validation: see above. */ if (addrs == NULL || nframes == NULL) return (ISC_R_FAILURE); #ifdef __x86_64__ sp = (void **)getrbp(); if (sp == NULL) return (ISC_R_NOTFOUND); /* * sp is the frame ptr of this function itself due to the call to * getrbp(), so need to unwind one frame for consistency. */ sp = getnextframeptr(sp); #else /* * i386: the frame pointer is stored 2 words below the address for the * first argument. Note that the body of this function cannot be * inlined since it depends on the address of the function argument. */ sp = (void **)&addrs - 2; #endif while (sp != NULL && i < maxaddrs) { addrs[i++] = *(sp + 1); sp = getnextframeptr(sp); } *nframes = i; return (ISC_R_SUCCESS); }