int main(void) { int i, val, inner_loop, sum = 0; INIT(); print ("I think, therefore I am\n"); for (i = 0; i < NUM_TIMES; i++) { inner_loop = INNER_LOOP_COUNT; /* Get next_num() into a trace. */ val = call_with_retaddr((void*)next_num); do { sum += val; if (sum > MAX_SUM) { print(" ... in serious trouble!\n"); exit(-1); } } while (--inner_loop); } val = call_with_retaddr((void*)check_sum); print("error: check_sum returned %d unexpectedly\n", val); return 1; }
int invalid_ret(int x) { ptr_int_t bad_retaddr = x; /* Sign extend x on X64. */ where = SIGSETJMP(mark); if (where == 0) { call_with_retaddr((void *)ring, bad_retaddr); print("unexpectedly we came back!"); } else { print("fault caught on " PFX "\n", x); } return 0; }
int main() { ptr_int_t myaddr; #ifdef USE_DYNAMO dynamorio_app_init(); dynamorio_app_start(); #endif /* make sure dynamorio can handle this non-call */ myaddr = get_retaddr(); #if VERBOSE print("my address is something like "PFX"\n", myaddr); #endif call_with_retaddr((void*)foo); #ifdef USE_DYNAMO dynamorio_app_stop(); dynamorio_app_exit(); #endif return 0; }