VOID AnalyzeSegmentedMemAccessIndexDispl(VOID * ip, VOID * addr, UINT32 accessType, ADDRINT indexRegVal, UINT32 scale, UINT32 displacement, THREADID tid) { if (tid < MAX_THREADS) { if (!threadData[tid].threadTeb) threadData[tid].threadTeb = InitializeThreadData(); ADDRINT threadTeb = threadData[tid].threadTeb; ADDRINT memoryEA = reinterpret_cast<ADDRINT>(addr); threadData[tid].numEffectiveAddressesAnalyzed[accessType]++; if ((threadTeb + displacement + (indexRegVal*scale)) != memoryEA) {// memoryEA is the TEB of the thread + displacement that is in the segmented operand fprintf (trace, "TRACED_INST_ERROR %p: R %p (tid %x) (teb %p displacement %x indexRegVal %x scale %d expectedEA %p)\n", ip, addr, tid, reinterpret_cast<VOID *>(threadTeb), displacement, indexRegVal, scale, reinterpret_cast<VOID *>(threadTeb+displacement)); hadError = TRUE; } /* else { fprintf (trace, "TRACED_INST_OK %p: R %p (tid %x) (teb %p displacement %x expectedEA %p)\n", ip, addr, tid, reinterpret_cast<VOID *>(threadTeb), displacement, reinterpret_cast<VOID *>(threadTeb+displacement)); } */ } }
VOID AnalyzeMemAccessDispl(VOID * ip, VOID * addr, UINT32 accessType, UINT32 displacement, THREADID tid) { if (tid < MAX_THREADS) { if (!threadData[tid].threadTeb) threadData[tid].threadTeb = InitializeThreadData(); ADDRINT memoryEA = reinterpret_cast<ADDRINT>(addr); threadData[tid].numNonSegEffectiveAddressesAnalyzed[accessType]++; if ((displacement) != memoryEA) { fprintf (trace, "TRACED_INST_ERROR %p: R %p (tid %x) ( displacement %x expectedEA %p)\n", ip, addr, tid, displacement, reinterpret_cast<VOID *>(displacement)); fflush(trace); hadError = TRUE; } /* else { fprintf (trace, "TRACED_INST_OK %p: R %p (tid %x) (teb %p displacement %x expectedEA %p)\n", ip, addr, tid, reinterpret_cast<VOID *>(threadTeb), displacement, reinterpret_cast<VOID *>(threadTeb+displacement)); } */ } }
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) { PIN_GetLock(&lock, threadid+1); fprintf(trace, "thread begin %x %x\n",threadid, numThreads); numThreads++; if (threadid < MAX_THREADS) { #ifdef TARGET_WINDOWS threadData[threadid].threadTeb = InitializeThreadData(); if ((ADDRINT)PIN_GetContextReg( ctxt, TESTED_SEG_REG_BASE ) != InitializeThreadData()) { fprintf (trace, "ERROR - Initial value of tested segment base does not match TEB\n"); hadError = TRUE; } #endif } else { fprintf (trace, "ERROR - maximum #threads exceeded\n"); } fflush(trace); PIN_ReleaseLock(&lock); }
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) { PIN_InitLock(&lock); PIN_GetLock(&lock, threadid+1); fprintf(trace, "thread begin %x %x\n",threadid, numThreads); numThreads++; if (threadid < MAX_THREADS) { #ifndef TARGET_LINUX threadData[threadid].threadTeb = InitializeThreadData(); #endif } else { fprintf (trace, "ERROR - maximum #threads exceeded\n"); } fflush(trace); PIN_ReleaseLock(&lock); }