Example #1
0
int main(int argc, char * argv[])
{
    int i = 0;
    PIN_InitSymbols();

    if (PIN_Init(argc, argv))
	return 1;
    for (i = 0; i<MAX_THREADS; i++)
	data_ar[i] = new set<ADDRINT>();

    OutFile.open(OUT_FILE);

    TRACE_AddInstrumentFunction(Trace, 0);

    INS_AddInstrumentFunction(Instruction, 0);

    PIN_AddFiniFunction(Fini, 0);

    PIN_StartProgram();

    return 0;
}
Example #2
0
int main(int argc, char *argv[])
{

    if (PIN_Init(argc, argv))
        return usage();


    outfile.open("arqsimucache.out");

    INS_AddInstrumentFunction(instrument_instruction, 0);
    PIN_AddFiniFunction(finalize, 0);

    RAM *ram = new RAM();
    Cache *l2 = new Cache("L2", ram, 1000*1024, 2, 16);
    Cache *l1 = new Cache("L1", l2, 64*1024, 2, 16);

    front_memory = l1;

    // start program and never return
    PIN_StartProgram();

    return 0;
}
int main(int argc, char *argv[])
{
    
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    string filename =  KnobOutputFile.Value();
    if( KnobPid )        
        filename += "." + decstr( getpid_portable() );
    out = new std::ofstream(filename.c_str());

        
    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns

    PIN_StartProgram();
    
    return 0;
}
int main(int argc, char *argv[])
{	
	// sometimes PIN wasn't printing to console...
	//std::ofstream outta("out.txt"); 
    //std::cout.rdbuf(outta.rdbuf());
	//std::cerr.rdbuf(outta.rdbuf());
	
	cerr << "Pintool loaded ... " << endl;


	if (PIN_Init(argc, argv)) return Usage();

	TRACE_AddInstrumentFunction(trace_cb, 0);
    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    cerr << "Starting instrumentation .... " << endl;

	PIN_StartProgram();
    
    return 0;
}
Example #5
0
// argc, argv are the entire command line, including pin -t <toolname> -- ...
int main(int argc, char * argv[])
{
    // Initialize pin
    PIN_Init(argc, argv);

    if (KnobLog)
    {
        out = fopen("emu_stack.txt", "w");
        if (!out)
            fprintf(stderr, "Can't open log file emu_stack.txt\n");
    }

    // Register instruction instrumentation callback.
    INS_AddInstrumentFunction(Ins, 0);

    // Register Fini to be called when the application exits
    PIN_AddFiniFunction(Fini, 0);
    
    // Start the program, never returns
    PIN_StartProgram();
    
    return 0;
}
int main(int argc, char * argv[])
{
    ADDRINT dummy = 0xa5a5a5a5;

    // Initialize pin
    if (PIN_Init(argc, argv)) return Usage();

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

    // Register Instruction to be called to instrument instructions
    INS_AddInstrumentFunction(Instruction, 0);

    // Verify that the PIN API is null before registration
    if (PIN_GetMemoryAddressTransFunction())
    {
        cout << "Test memory_addr_callback found PIN API callback not null before registration " << endl;
        PIN_ExitProcess(-1);
    }

    // Register memory callback
    PIN_AddMemoryAddressTransFunction(memoryCallback,(VOID*)dummy);

    // Verify that the PIN API is not null after registration
    if (!PIN_GetMemoryAddressTransFunction())
    {
        cout << "Test memory_addr_callback found PIN API callback null after registration " << endl;
        PIN_ExitProcess(-1);
    }

    // Register Fini to be called when the application exits
    PIN_AddFiniFunction(Fini, 0);

    // Start the program, never returns
    PIN_StartProgram();
    
    return errors;
}
Example #7
0
int main(int argc, char * argv[]){

	//If we want to debug the program manually setup the proper options in order to attach an external debugger
	if(Config::ATTACH_DEBUGGER){
		initDebug();
	}
	
	//get the start time of the execution (benchmark)
	tStart = clock();	
	// Initialize pin
	PIN_InitSymbols();
	if (PIN_Init(argc, argv)) return Usage();
	//Register PIN Callbacks
	INS_AddInstrumentFunction(Instruction,0);
	PIN_AddThreadStartFunction(OnThreadStart, 0);
	IMG_AddInstrumentFunction(imageLoadCallback, 0);
	PIN_AddFiniFunction(Fini, 0);
	PIN_AddInternalExceptionHandler(ExceptionHandler,NULL);
	PIN_AddFollowChildProcessFunction(followChild, NULL);
	
	printf("[INFO] Configuring Pintool\n");
	//get theknob args
	ConfigureTool();	
	if(Config::getInstance()->POLYMORPHIC_CODE_PATCH){
		TRACE_AddInstrumentFunction(Trace,0);
	}
	proc_info->addProcAddresses();

	//init the hooking system
	HookSyscalls::enumSyscalls();
	HookSyscalls::initHooks();
	printf("[INFO] Starting instrumented program\n\n");
	//MYINFO(" knob inizio %d %d %d",Config::getInstance()->getDumpNumber(), Config::getInstance()->getDumpNumber(),Config::getInstance()->WRITEINTERVAL_MAX_NUMBER_JMP);
	PIN_StartProgram();	
	return 0;
	
}
int main(int argc, char * argv[])
{
    InitLock(&lock);
    // Initialize pin
    if (PIN_Init(argc, argv)) return Usage();

    //OutFile.open(KnobOutputFile.Value().c_str());
    mlog_key = PIN_CreateThreadDataKey(0);
    //trace = fopen("mem.trace", "w");

    // Register Instruction to be called to instrument instructions
    INS_AddInstrumentFunction(Instruction, 0);

    // Register Fini to be called when the application exits
 //   PIN_AddFiniFunction(Fini, 0);
    
 // add callbacks
    PIN_AddThreadStartFunction(ThreadStart, 0);
    PIN_AddThreadFiniFunction(ThreadFini, 0);
    // Start the program, never returns
    PIN_StartProgram();
    
    return 0;
}
int main(int argc, char * argv[])
{
    // Initialize pin
    if (PIN_Init(argc, argv)) {return Usage();}


    OutFile.open(KnobOutputFile.Value().c_str());
           OutFile.setf(ios::showbase);
    PIN_InitSymbols();

    // Register ImageLoad to be called to instrument instructions
    IMG_AddInstrumentFunction(Image, 0);

    // Register Instruction to be called to instrument instructions
    INS_AddInstrumentFunction(Instruction, 0);

    // Register Fini to be called when the application exits
    PIN_AddFiniFunction(Fini, 0);

    // Start the program, never returns
    PIN_StartProgram();

    return 0;
}
int main(int argc, char * argv[])
{


	MYLOG("Strating prototype ins\n");
	FilterHandler *filterH = FilterHandler::getInstance();
	filterH->setFilters("teb");

	tStart = clock();
	
	// Initialize pin
	PIN_InitSymbols();

	if (PIN_Init(argc, argv)) return Usage();
	
	//	TRACE_AddInstrumentFunction(Trace,0);
	INS_AddInstrumentFunction(Instruction,0);
	PIN_AddThreadStartFunction(OnThreadStart, 0);
	// Register ImageLoad to be called when an image is loaded

	IMG_AddInstrumentFunction(imageLoadCallback, 0);

	// Register ImageUnload to be called when an image is unloaded
	IMG_AddUnloadFunction(ImageUnloadCallback, 0);

	//PIN_AddApplicationStartFunction(bootstrap, 0);

	// Register Fini to be called when the application exits
	PIN_AddFiniFunction(Fini, 0);
	
	// Start the program, never returns
	PIN_StartProgram();
	
	return 0;

}
Example #11
0
int main(int argc, char * argv[])
{
    int i = 0;
    stringstream fn;
    PIN_InitSymbols();

    if (PIN_Init(argc, argv))
	return 1;
    
    for (i = 0; i<MAX_THREADS; i++) {
//	fn.str("");
//	fn << "cnt.out" << i;
//	OutFile[i].open(fn.str().c_str());
	data_ar[i] = new list<ADDRINT>();
    }

    OutFile.open(OUT_FILE);
      Stat.open(STAT_FILE);
//    CallFile.open(CALL_FILE);


    // Register ThreadStart to be called when a thread starts.
//    PIN_AddThreadStartFunction(ThreadStart, 0);

    TRACE_AddInstrumentFunction(Trace, 0);

    IMG_AddInstrumentFunction(ImageLoad, 0);

    INS_AddInstrumentFunction(Instruction, 0);

    PIN_AddFiniFunction(Fini, 0);

    PIN_StartProgram();

    return 0;
}
int main(int argc, char * argv[])
{
    // Initialize pin
    if (PIN_Init(argc, argv)) return Usage();

    printf ("Pin supports PROCESSOR_STATE_X87 %d\n", PIN_SupportsProcessorState(PROCESSOR_STATE_X87));
    if (!PIN_SupportsProcessorState(PROCESSOR_STATE_X87))
    {
        printf ("***Error Pin does NOT support PROCESSOR_STATE_X87\n");
        exit (-1);
    }
    printf ("Pin supports PROCESSOR_STATE_XMM %d\n", PIN_SupportsProcessorState(PROCESSOR_STATE_XMM));
    if (!PIN_SupportsProcessorState(PROCESSOR_STATE_XMM))
    {
        printf ("***Error Pin does NOT support PROCESSOR_STATE_XMM\n");
        exit (-1);
    }
    printf ("Pin supports PROCESSOR_STATE_YMM %d\n", PIN_SupportsProcessorState(PROCESSOR_STATE_YMM));
    if (!PIN_SupportsProcessorState(PROCESSOR_STATE_YMM) && ProcessorSupportsAvx())
    {
        printf ("***Error Pin does NOT support PROCESSOR_STATE_YMM\n");
        exit (-1);
    }
    if (PIN_SupportsProcessorState(PROCESSOR_STATE_YMM) && !ProcessorSupportsAvx())
    {
        printf ("***Error Pin does support PROCESSOR_STATE_YMM, but processor does not\n");
        exit (-1);
    }
    // Register Instruction to be called to instrument instructions
    INS_AddInstrumentFunction(Instruction, 0);
    
    // Start the program, never returns
    PIN_StartProgram();
    
    return 0;
}
Example #13
0
/* 
 * Tool used for verifying that libdft propagates taint correctly.
 */
int main(int argc, char **argv) {
	/* initialize symbol processing */
	PIN_InitSymbols();

	if (unlikely(PIN_Init(argc, argv)))
		goto err;

	IMG_AddInstrumentFunction(ImageLoad, 0);
	PIN_AddFiniFunction(OnExit, 0);

#ifdef DTRACKER_DEBUG
	INS_AddInstrumentFunction(CheckMagicValue, 0);
#endif
	
	LOG("Initializing libdft.\n");
	if (unlikely(libdft_init() != 0))
		goto err;

	// reset counters
	bzero(stdcount, sizeof(stdcount));

	// Open raw prov file.
	// This file is to be post-processed to get the data in a proper format.
	rawProvStream.open(ProvRawKnob.Value().c_str());


	/*
	 * Install taint sources and sinks.
	 * syscall_set_{pre, post}() set the callbacks in the libdft
	 * syscall description struct.
	 * These callbacks are respectively invoked through
	 * sysenter_save() and sysexit_save() function of libdft.
	 * In turn, these libdft functions are hooked to run before/after
	 * every syscall using PIN_AddSyscall{Entry, Exit}Function().
	 */

	/* dtracker_openclose.cpp: open(2), creat(2), close(2) */
	(void)syscall_set_pre(&syscall_desc[__NR_open], pre_open_hook);
	(void)syscall_set_pre(&syscall_desc[__NR_creat], pre_open_hook);
	(void)syscall_set_post(&syscall_desc[__NR_open], post_open_hook);
	(void)syscall_set_post(&syscall_desc[__NR_creat], post_open_hook);
	(void)syscall_set_post(&syscall_desc[__NR_close], post_close_hook);

	/* dtracker_read.cpp: read(2), readv(2) */
	(void)syscall_set_post(&syscall_desc[__NR_read], post_read_hook);
	(void)syscall_set_post(&syscall_desc[__NR_readv], post_readv_hook);

	/* dtracker_write.cpp: write(2), writev(2) */
	(void)syscall_set_post(&syscall_desc[__NR_write], post_write_hook);
	(void)syscall_set_post(&syscall_desc[__NR_writev], post_writev_hook);

	/* dtracker_mmap.cpp: mmap2(2), munmap(2) */
	(void)syscall_set_post(&syscall_desc[__NR_mmap2], post_mmap2_hook);
	(void)syscall_set_post(&syscall_desc[__NR_munmap], post_munmap_hook);


	/* start the program and return something to make the compiler happy */
	LOG("Starting program.\n");
	PIN_StartProgram();	
	return EXIT_SUCCESS;

err:
	/* error handling */

	/* detach from the process */
	libdft_die();

	/* return */
	return EXIT_FAILURE;
}
Example #14
0
int main(int argc, CHAR *argv[])
{
    PIN_InitSymbols();

	pagesize = getpagesize();

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

    //Initialize
    char *buf = (char*)malloc(sizeof(char)*200);
    char *buf2 = (char*)malloc(sizeof(char)*200);
    assert(buf);
    assert(buf2);

    int len = readlink("/proc/self/exe", buf, 200);
    buf[len] = '\0';
    int i;
    for(i=0; i<len; i++)
    {
    	if(buf[i] == '/')
    		buf[i] = '_';
    }
    /*
     * Output log file path
     * Some proccesses change working directory, so output file name should be absolute path
     */
    sprintf(buf2, "/home/jungjae/pin-2.13-61206-gcc.4.4.7-linux/source/tools/MyPinTool/obj-intel64/log");
    strcat(buf2, buf);
    pid = getpid();
    sprintf(buf, "_%x", pid);
    strcat(buf2, buf);

    trace = fopen(buf2, "a");
    assert(trace);
    free(buf);
    free(buf2);
    buf = NULL;
    buf2 = NULL;

    readid = 0;

	PIN_RWMutexInit(&malloc_lock);
	PIN_RWMutexInit(&thread_lock);
	PIN_RWMutexInit(&data_lock);
	PIN_MutexInit(&readid_lock);

	//Add Instrumentation Functions
    IMG_AddInstrumentFunction(ImageLoad, 0);
	INS_AddInstrumentFunction(Instruction, 0);
	PIN_AddSyscallEntryFunction(SyscallEntry, 0);
	PIN_AddThreadStartFunction(ThreadStart, 0);
	PIN_AddThreadFiniFunction(ThreadFini, 0);
	PIN_AddFiniFunction(Fini, 0);

	//Program Start. Never Returns
    PIN_StartProgram();

    return 0;
}
Example #15
0
int main(int argc, char * argv[]) {
    PIN_Init(argc, argv);
    INS_AddInstrumentFunction(convert_load_addr, 0);
    PIN_StartProgram();    // Never returns
    return 0;
}
Example #16
0
File: mica.cpp Project: ucmsuri/ilp
/************
 *   MAIN   *
 ************/
int main(int argc, char* argv[]){

	int i;
	setup_mica_log(&log);
	MODE mode;
	read_config(&log,&mode, &_ilp_win_size, &_block_size, &_page_size, &_itypes_spec_file);

	
	for(i=0; i < MAX_MEM_TABLE_ENTRIES; i++){
		ins_buffer[i] = (ins_buffer_entry*)NULL;
	}

	switch(mode){
	/*	case MODE_ALL:
			init_all();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_all, 0);
    			PIN_AddFiniFunction(Fini_all, 0);
			break;
		case MODE_ILP:
			init_ilp_all();
			PIN_InitSymbols();
			PIN_Init(argc, argv);
			InitLock(&lock);
			// Obtain  a key for TLS storage.
		    	tls_key = PIN_CreateThreadDataKey(0);
		        // Register ThreadStart to be called when a thread starts.
		        PIN_AddThreadStartFunction(ThreadStart, 0);
			INS_AddInstrumentFunction(Instruction_ilp_all_only, 0);
    			PIN_AddFiniFunction(Fini_ilp_all_only, 0);
			break;*/
		case MODE_ILP_ONE:
			//init_ilp_one();
			PIN_InitSymbols();
			PIN_Init(argc, argv);
			InitLock(&lock);
			// Obtain  a key for TLS storage.
		    	tls_key = PIN_CreateThreadDataKey(0);
		        // Register ThreadStart to be called when a thread starts.
		        PIN_AddThreadStartFunction(ThreadStart, 0);
			INS_AddInstrumentFunction(Instruction_ilp_one_only, 0);
    			PIN_AddFiniFunction(Fini_ilp_one_only, 0);
			break;
	/*	case MODE_ITYPES:
			init_itypes();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_itypes_only, 0);
    			PIN_AddFiniFunction(Fini_itypes_only, 0);
			break;
		case MODE_PPM:
			init_ppm();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_ppm_only, 0);
    			PIN_AddFiniFunction(Fini_ppm_only, 0);
			break;
		case MODE_REG:
			init_reg();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_reg_only, 0);
    			PIN_AddFiniFunction(Fini_reg_only, 0);
			break;
		case MODE_STRIDE:
			init_stride();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_stride_only, 0);
    			PIN_AddFiniFunction(Fini_stride_only, 0);
			break;
		case MODE_MEMFOOTPRINT:
			init_memfootprint();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_memfootprint_only, 0);
    			PIN_AddFiniFunction(Fini_memfootprint_only, 0);
			break;
		case MODE_MEMREUSEDIST:
			init_memreusedist();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_memreusedist_only, 0);
    			PIN_AddFiniFunction(Fini_memreusedist_only, 0);
			break;
		case MODE_CUSTOM:
			init_custom();
			PIN_Init(argc, argv);
			INS_AddInstrumentFunction(Instruction_custom, 0);
    			PIN_AddFiniFunction(Fini_custom, 0);
			break;*/
		default:
			cerr << "FATAL ERROR: Unknown mode while trying to allocate memory for Pin tool!" << endl;
			log << "FATAL ERROR: Unknown mode while trying to allocate memory for Pin tool!" << endl;
			exit(1);
	}

	// starts program, never returns
	PIN_StartProgram();
}