Ejemplo n.º 1
0
int main( int argc, char *argv[] ) {

  if ( PIN_Init( argc, argv ) ) {
    return Usage();
  }
  PIN_InitSymbols();

  initRcdcSim();

  IMG_AddInstrumentFunction( instrumentImage, NULL );
  TRACE_AddInstrumentFunction( instrumentTrace, NULL );
  cerr << " Before this function\n";
  //INS_AddInstrumentFunction(Instruction, 0);
  cerr << " After this function\n";

  PIN_AddThreadStartFunction( threadBegin, NULL );
  PIN_AddThreadFiniFunction( threadEnd, NULL );

  PIN_AddContextChangeFunction( beforeSignal, NULL );
  PIN_AddSyscallEntryFunction( beforeSyscall, NULL );
  PIN_AddSyscallExitFunction( afterSyscall, NULL );

  PIN_AddFiniUnlockedFunction( pinFini, NULL );

  if ( !CODECACHE_ChangeMaxInsPerTrace( 4096 * 1024 ) ) {
    fprintf( stderr, "TLSProf::CODECACHE_ChangeMaxInsPerTrace failed.\n" );
  }

  THREADID tid = PIN_SpawnInternalThread( ioThread, NULL, 0, &s_IOThreadId );
  assert( tid != INVALID_THREADID );

  PIN_StartProgram();
  return 0;
}
Ejemplo n.º 2
0
    //! The pintool's entry point
    int main(int argc, char *argv[]) {
      PIN_InitSymbols();
      PIN_SetSyntaxIntel();
      if(PIN_Init(argc, argv))
          return Usage();

      /* Init the Triton module */
      triton::bindings::python::inittriton();

      /* Define Triton architecure */
      if (sizeof(void*) == QWORD_SIZE)
        tracer::pintool::api.setArchitecture(triton::arch::ARCH_X86_64);
      else
        tracer::pintool::api.setArchitecture(triton::arch::ARCH_X86);

      /* During the execution provide concrete values only if Triton needs them - cf #376, #632 and #645 */
      tracer::pintool::api.addCallback(tracer::pintool::context::needConcreteRegisterValue);
      tracer::pintool::api.addCallback(tracer::pintool::context::needConcreteMemoryValue);

      /* Image callback */
      IMG_AddInstrumentFunction(IMG_Instrumentation, nullptr);

      /* Instruction callback */
      TRACE_AddInstrumentFunction(TRACE_Instrumentation, nullptr);

      /* End instrumentation callback */
      PIN_AddFiniFunction(callbackFini, nullptr);

      /* Syscall entry callback */
      PIN_AddSyscallEntryFunction(callbackSyscallEntry, nullptr);

      /* Syscall exit callback */
      PIN_AddSyscallExitFunction(callbackSyscallExit, nullptr);

      /* Signals callback */
      PIN_InterceptSignal(SIGHUP,  callbackSignals, nullptr);
      PIN_InterceptSignal(SIGINT,  callbackSignals, nullptr);
      PIN_InterceptSignal(SIGQUIT, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGILL,  callbackSignals, nullptr);
      PIN_InterceptSignal(SIGABRT, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGFPE,  callbackSignals, nullptr);
      PIN_InterceptSignal(SIGKILL, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGSEGV, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGPIPE, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGALRM, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGTERM, callbackSignals, nullptr);
      PIN_InterceptSignal(SIGBUS,  callbackSignals, nullptr);

      /* Exec the Pin's python bindings */
      tracer::pintool::initBindings(argc, argv);
      tracer::pintool::execScript(KnobPythonModule.Value().c_str());

      return 0;
    }
Ejemplo n.º 3
0
int main(int argc, char * argv[])
{
    PIN_Init(argc, argv);

    Out.open(KnobOutputFile.Value().c_str());

    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddSyscallEntryFunction(SyscallEntry, 0);
    PIN_AddSyscallExitFunction(SyscallExit, 0);

    PIN_StartProgram();
    return 0;
}
Ejemplo n.º 4
0
int main(INT32 argc, CHAR **argv)
{
    PIN_Init(argc, argv);
    
    INS_AddInstrumentFunction(Instruction, 0);

    PIN_AddSyscallEntryFunction(SyscallEntry, 0);
    PIN_AddSyscallExitFunction(SyscallExit, 0);
    
    // Never returns
    PIN_StartProgram();
    
    return 0;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    if (PIN_Init(argc, argv)) return Usage();

    trace = fopen("strace.out", "w");

    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddSyscallEntryFunction(SyscallEntry, 0);
    PIN_AddSyscallExitFunction(SyscallExit, 0);

    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]) {
  prof_ctrl->Initialize();
  prof_ctrl->PreSetup();
  PIN_InitSymbols();
  PIN_Init(argc, argv);
  prof_ctrl->PostSetup();
  TRACE_AddInstrumentFunction(I_InstrumentTrace, NULL);
  IMG_AddInstrumentFunction(I_ImageLoad, NULL);
  IMG_AddUnloadFunction(I_ImageUnload, NULL);
  PIN_AddSyscallEntryFunction(I_SyscallEntry, NULL);
  PIN_AddSyscallExitFunction(I_SyscallExit, NULL);
  PIN_InterceptSignal(SIGUSR2, I_IntSignal, NULL);
  PIN_AddContextChangeFunction(I_ContextChange, NULL);
  PIN_AddFiniFunction(I_ProgramExit, NULL);
  PIN_AddThreadStartFunction(I_ThreadStart, NULL);
  PIN_AddThreadFiniFunction(I_ThreadExit, NULL);
  I_ProgramStart();
  // start the program
  PIN_StartProgram();
}
Ejemplo n.º 7
0
int main (int argc, char *argv[])
{
	char buff[20];

	if(PIN_Init(argc,argv)) {
		printf("command line error\n");
		return 1;
	}

	pid = PIN_GetPid();

	sprintf(buff, "ct%d.log", pid);
	logfp = fopen(buff, "w");
	if (logfp == NULL) {
		printf("cannot open '%s' for writing\n", buff);
		return 1;
	}

	sprintf(buff, "ct%d.trace", pid);
	if (tb_create(buff)) {
		fprintf(logfp, "tb_create() failed\n");
		fflush(logfp);
		return 1;
	}

	PIN_AddFiniFunction(fini, 0);
	PIN_AddThreadStartFunction(thread_start, 0);
	PIN_AddThreadFiniFunction(thread_fini, 0);
	IMG_AddInstrumentFunction(img_load, NULL);
	IMG_AddUnloadFunction(img_unload, NULL);
	TRACE_AddInstrumentFunction(trace, NULL);
	INS_AddInstrumentFunction(instruction, NULL);
	PIN_AddSyscallEntryFunction(sys_enter, NULL);
	PIN_AddSyscallExitFunction(sys_exit, NULL);
	PIN_AddContextChangeFunction(context_switch, NULL);

	PIN_InitSymbols();

	PIN_StartProgram(); // Never returns
	return 0;
}
Ejemplo n.º 8
0
int main(int argc, char *argv[]) {
	PIN_InitSymbols();
 	if(PIN_Init(argc, argv))
		return Usage();
	PIN_InitLock(&globalLock);

	standard_out = !strcmp(KnobOutputFile.Value().c_str(), "-");
	print_chars = KnobPrintChars;

	memset(mwrite_tracker, 0, sizeof(mwrite_tracker));

	IMG_AddInstrumentFunction(Image, 0);
	INS_AddInstrumentFunction(Instruction, 0);
	PIN_AddSyscallEntryFunction(SyscallEntry, 0);
	PIN_AddSyscallExitFunction(SyscallExit, 0);
	PIN_AddThreadStartFunction(ThreadStart, 0);
	PIN_AddForkFunction(FPOINT_AFTER_IN_CHILD, AfterForkInChild, 0);

	PIN_StartProgram();

	return 0;
}
Ejemplo n.º 9
0
/*
 * initialization of the core tagging engine;
 * it must be called before using everything else
 *
 * returns: 0 on success, 1 on error
 */
int
libdft_init()
{
	/* initialize thread contexts; optimized branch */
	if (unlikely(thread_ctx_init()))
		/* thread contexts failed */
		return 1;

	/* initialize the tagmap; optimized branch */
	if (unlikely(tagmap_alloc()))
		/* tagmap initialization failed */
		return 1;
    trace_tls_key = PIN_CreateThreadDataKey(0);

	/*
	 * syscall hooks; store the context of every syscall
	 * and invoke registered callbacks (if any)
	 */

	/* register sysenter_save() to be called before every syscall */
	PIN_AddSyscallEntryFunction(sysenter_save, NULL);

	/* register sysexit_save() to be called after every syscall */
	PIN_AddSyscallExitFunction(sysexit_save, NULL);

	/* initialize the ins descriptors */
	(void)memset(ins_desc, 0, sizeof(ins_desc));

	/* register trace_ins() to be called for every trace */
	TRACE_AddInstrumentFunction(trace_inspect, NULL);

	/* FIXME: ugly hack for bypassing unaligned address checks */
	PIN_AddInternalExceptionHandler(fix_eflags, NULL);

	/* success */
	return 0;
}
Ejemplo n.º 10
0
/* ========================================================================== */
VOID InitSyscallHandling() {
    PIN_AddSyscallEntryFunction(SyscallEntry, 0);
    PIN_AddSyscallExitFunction(SyscallExit, 0);
}