EXCEPT_HANDLING_RESULT ExceptionHandler(THREADID tid, EXCEPTION_INFO *pExceptInfo, PHYSICAL_CONTEXT *pPhysCtxt, VOID *v){ MYINFO("ECC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); MYINFO("%s",PIN_ExceptionToString(pExceptInfo).c_str()); MYINFO("ECC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); return EHR_CONTINUE_SEARCH; }
EXCEPT_HANDLING_RESULT DivideHandler(THREADID tid, EXCEPTION_INFO * pExceptInfo, PHYSICAL_CONTEXT * pPhysCtxt, VOID *appContextArg) { if(PIN_GetExceptionCode(pExceptInfo) == EXCEPTCODE_INT_DIVIDE_BY_ZERO) { #if 1 //Temporary work-around, Remove when Mantis #1986 is resolved string str = PIN_ExceptionToString(pExceptInfo); printf("GlobalHandler: Caught divide by zero exception. %s\n", str.c_str()); #else cout << "GlobalHandler: Caught divide by zero exception. " << PIN_ExceptionToString(pExceptInfo) << endl; #endif CONTEXT * appCtxt = (CONTEXT *)appContextArg; ADDRINT faultIp = PIN_GetContextReg(appCtxt, REG_INST_PTR); PIN_SetExceptionAddress(pExceptInfo, faultIp); PIN_RaiseException(appCtxt, tid, pExceptInfo); //never returns } return EHR_CONTINUE_SEARCH; }
inline EXCEPT_HANDLING_RESULT handle_exception (THREADID tid, OASIS::Pin::Exception & ex, PHYSICAL_CONTEXT * pctx) { if (ex.exception_code () == EXCEPTCODE_INT_DIVIDE_BY_ZERO) { #if 1 //Temporary work-around, Remove when Mantis #1986 is resolved string str = ex.to_string (); printf ("GlobalHandler: Caught divide by zero exception. %s\n", str.c_str ()); #else std::cout << "GlobalHandler: Caught divide by zero exception. " << PIN_ExceptionToString (info) << endl; #endif ADDRINT faultIp = PIN_GetContextReg (this->ctx_, REG_INST_PTR); ex.exception_address (faultIp); ex.raise (this->ctx_, tid); // never returns } return EHR_CONTINUE_SEARCH; }
// - if an exception is found returns all the information about it (DEBUG purposes) EXCEPT_HANDLING_RESULT ExceptionHandler(THREADID tid, EXCEPTION_INFO *pExceptInfo, PHYSICAL_CONTEXT *pPhysCtxt, VOID *v){ MYINFO("******Caught Exception:******\n"); MYINFO("%s",PIN_ExceptionToString(pExceptInfo).c_str()); MYINFO("*****Continue to search a valid exception handler******\n"); return EHR_CONTINUE_SEARCH; }
EXCEPT_HANDLING_RESULT GlobalHandler(THREADID threadIndex, EXCEPTION_INFO * pExceptInfo, PHYSICAL_CONTEXT * pPhysCtxt, VOID *v) { cout << "GlobalHandler: Caught unexpected exception. " << PIN_ExceptionToString(pExceptInfo) << endl; return EHR_UNHANDLED; }