/*************************************************************************************************** This file contains the entry point of the pintool. The main function here is actually different from the traditional main. This becomes the exported api of the dll which will be invoked by PIN. ****************************************************************************************************/ #include "pin.h" #include #include #include "SpecManager.h" #include "TraceManager.h" #define H_BEFORE 0 #define H_AFTER 1 #define TAU_WINDOWS #define PROFILING_ON #define TAU_DOT_H_LESS_HEADERS SpecManager* mySpec; TraceManager* myTracer; FILE *sout,*sin,*serr; INT32 Usage() { cout << "pin -t thisdll -r rule -f file -- executable.exe " << endl; myTracer->LogMessage("pin -t thisdll -r rule -f file -- executable.exe\n"); return -1; } VOID HookHandleBefore(RtnTrack* myrt) { //cerr<<"Intercept Before:"<rtn<BeforeExec(myrt); myrt->stage++; } VOID HookHandleAfter(RtnTrack* myrt) { if(myrt->stage<=0) { myrt->stage=0; return; } //cerr<<"Intercept After:"<rtn<AfterExec(myrt); myrt->stage--; } VOID HookHandle(RtnTrack* myrt) { cerr<<"Hookhandle"<stage==0) { cerr<<"Intercept Before:"<rtn<BeforeExec(myrt); }else { cerr<<"Intercept After:"<rtn<AfterExec(myrt); } delete myrt; } VOID ExitHandle(INT32 code, VOID *v) { //simply call into tracemanager DBG_TRACE(code); myTracer->EndTrace(); } VOID ImgInstrumentor( IMG img, VOID *v ) { //simply call into tracemanager DBG_TRACE(IMG_Name(img)); myTracer->InstApply(img); } bool InitLogging() { //sout=freopen( "taupin_out", "w", stdout); //if(sout==NULL) // return false; serr=freopen( "taupin_msg", "w", stderr ); if(serr==NULL) return false; return true; } int main(int argc, char *argv[]) { InitLogging(); // in the command line or the command line is invalid //for(int i=0;iPrintArgs(); //myargs->PrintRules(); //recompose the argument //so that PIN doesnt know about the arguments //PINTAU needs otherwise PIN fails char ** argvs=myargs->GetPinArgV(); //initialize PIN if( PIN_Init(myargs->GetPinArgC(),myargs->GetPinArgV())) { return Usage(); } cerr<<"Initialized PIN"<PrintInsts(); //Tracemanager Created here TraceManager* myTracer=new TraceManager(mySpec); cerr<<"Tracemanager Initialized"<