// ------------------------------------------------------------- // Function exit event // ------------------------------------------------------------- VOID PIN_FAST_ANALYSIS_CALL A_ProcessReturn(ADDRINT sp, THREADID threadid) { _STool_TThreadRec* tdata = getTLS(threadid); // roll back stack in case of longjmp AdjustStack(tdata, sp); if ( tdata->stackTop < 1 ) graceful_exit(threadid, "Internal error: stack bottomed out"); // call routine exit callback (if any was specified by the analysis tool) if (gSetup.rtnExit) gSetup.rtnExit(tdata + 1); // pop activation tdata->stackTop--; #if DEBUG printf("[TID=%u] Leaving %s\n", threadid, Target2RtnName(tdata->activationStack[tdata->stackTop].target).c_str()); #endif #if DEBUG if (tdata->stackTop > 0) printf("[TID=%u] Back to %s - # activations = %d - stack size = %d\n", threadid, Target2RtnName(tdata->activationStack[tdata->stackTop-1].target).c_str(), tdata->stackTop, tdata->stackSize); else printf("[TID=%u] Back to stack bottom\n", threadid); #endif }
bool gmByteCodeGen::Emit(gmByteCode a_instruction) { if(m_emitCallback) m_emitCallback(Tell(), m_context); AdjustStack(a_instruction); *this << (gmuint32) a_instruction; return true; }
bool gmByteCodeGen::EmitPtr(gmByteCode a_instruction, gmptr a_operand) { if(m_emitCallback) m_emitCallback(Tell(), m_context); AdjustStack(a_instruction); *this << ((gmuint32) a_instruction); *this << a_operand; return true; }
// ------------------------------------------------------------- // Function direct call event (with calling site info) // ------------------------------------------------------------- VOID PIN_FAST_ANALYSIS_CALL A_ProcessDirectCallCS(ADDRINT ip, ADDRINT target, ADDRINT sp, THREADID threadid) { // get thread local data _STool_TThreadRec* tdata = getTLS(threadid); // roll back stack in case of longjmp AdjustStack(tdata, sp); // possibly expand stack if (tdata->stackTop >= tdata->stackMaxSize) { // double stack size tdata->stackMaxSize <<= 1; // expand activation stack tdata->activationStack = (_STool_TActivationRec*)realloc(tdata->activationStack, tdata->stackMaxSize*sizeof(_STool_TActivationRec)); if (tdata->activationStack == NULL) graceful_exit(threadid, "Can't expand activation stack"); // expand user stack (if any is needed) if (tdata->userStack) { tdata->userStack = (char*)realloc(tdata->userStack, tdata->stackMaxSize*gSetup.activationRecSize); if (tdata->userStack == NULL) graceful_exit(threadid, "Can't expand user stack"); } } // push current activation record to stack _ActivationAt(tdata, tdata->stackTop).currentSP = sp; _ActivationAt(tdata, tdata->stackTop).target = target; // increase activations counter tdata->stackTop++; #if DEBUG printf("[TID=%u] Entering %s - # activations = %d - stack size = %d\n", threadid, Target2RtnName(target).c_str(), tdata->stackTop, tdata->stackSize); #endif // call routine enter callback (if any was specified by the analysis tool) if (gSetup.rtnEnter) gSetup.rtnEnter(tdata + 1, ip); }