Пример #1
0
void
writeLog(void* drcontext){
	char logname[MAXIMUM_PATH];
	char *dirsep;
    	int len;
	len = dr_snprintf(logname, sizeof(logname)/sizeof(logname[0]),
                      "%s", dr_get_client_path(client_id));
	DR_ASSERT(len > 0);
	for (dirsep = logname + len; *dirsep != '/'; dirsep--)
        DR_ASSERT(dirsep > logname);
    	len = dr_snprintf(dirsep + 1,
                      (sizeof(logname) - (dirsep - logname))/sizeof(logname[0]),
                      "floatingpoint.%d.log", dr_get_thread_id(drcontext));
    	DR_ASSERT(len > 0);
    	NULL_TERMINATE(logname);
    	logF = dr_open_file(logname, 
                             DR_FILE_WRITE_OVERWRITE | DR_FILE_ALLOW_LARGE);
    	DR_ASSERT(logF != INVALID_FILE);
    	dr_log(drcontext, LOG_ALL, 1, 
           "floating point: log for thread %d is fp.%03d\n",
           dr_get_thread_id(drcontext), dr_get_thread_id(drcontext));
	#ifdef SHOW_RESULTS
    	if (dr_is_notify_on()) {
//        	dr_fprintf(STDERR, "<floating point instruction operands for thread %d in %s>\n",
//                  dr_get_thread_id(drcontext), logname);
    	}
	#endif	
	thread_id_for_log = dr_get_thread_id(drcontext);
}
Пример #2
0
static void
event_exit(void)
{
#ifdef SHOW_RESULTS
    char msg[512];
    int len;
    uint64 total_count = app_count + lib_count;
    /* We only instrument indirect calls/jmps, and assume that
     * there would be a return paired with indirect calls/jmps.
     */
    uint64 total_xfer  = (app2lib + lib2app);
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results:\n"
                      "\t%10llu instructions executed\n"
                      "\t%10llu (%2.3f%%) in app\n"
                      "\t%10llu (%2.3f%%) in lib,\n"
                      "\t%10llu (%2.3f%%) call/jmp between app and lib\n"
                      "\t%10u app call/jmp to lib\n"
                      "\t%10u lib call/jmp to app\n",
                      total_count,
                      app_count,  100*(float)app_count/total_count,
                      lib_count,  100*(float)lib_count/total_count,
                      total_xfer, 100*(float)total_xfer/total_count,
                      app2lib, lib2app);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */
}
Пример #3
0
static void
exit_event(void)
{
#ifdef SHOW_RESULTS
    char msg[512];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results:\n"
                      "Processed %d  instructions\n"
                      ,fp_count);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */

    dr_mutex_destroy(count_mutex);

#ifdef SHOW_SYMBOLS
    if (drsym_exit() != DRSYM_SUCCESS) {
        dr_log(NULL, LOG_ALL, 1, "WARNING: error cleaning up symbol library\n");
    }
#endif
printht();
__wrap_free(testarr);

}
Пример #4
0
static void 
event_exit(void)
{
    char msg[512];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results: %llu instructions executed\n",
                      global_count);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
}
Пример #5
0
static void 
event_exit(void)
{
#ifdef SHOW_RESULTS
    char msg[256];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "<Largest malloc request: %d>\n<OOM simulations: %d>\n",
                      max_malloc, malloc_oom);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */

    dr_mutex_destroy(max_lock);
    drwrap_exit();
}
Пример #6
0
static void
display_results(per_thread_t *data, char *thread_note)
{
#ifdef SHOW_RESULTS
    char msg[512];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "%sInstrumentation results:\n"
                      "  saw %d direct calls\n"
                      "  saw %d indirect calls\n"
                      "  saw %d returns\n",
                      thread_note, data->num_direct_calls,
                      data->num_indirect_calls, data->num_returns);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */
}
Пример #7
0
static void 
event_thread_exit(void *drcontext)
{
    per_thread_t *data = (per_thread_t *) dr_get_tls_field(drcontext);
    char msg[512];
    int len;

    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Thread %d exited - ", dr_get_thread_id(drcontext));
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);

    /* display thread private counts data */
    display_results(data, msg);

    /* clean up memory */
    dr_thread_free(drcontext, data, sizeof(per_thread_t));
}
Пример #8
0
static void
exit_event(void)
{
#ifdef SHOW_RESULTS
    char msg[512];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results:\n"
                      "  saw %d div instructions\n"
                      "  of which %d were powers of 2\n",
                      div_count, div_p2_count);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */

    dr_mutex_destroy(count_mutex);
}
Пример #9
0
static void
event_exit(void)
{
#ifdef SHOW_RESULTS
    char msg[512];
    int len;
    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results:\n"
                      "%10d basic block executions\n"
                      "%10d basic blocks needed flag saving\n"
                      "%10d basic blocks did not\n",
                      global_count, bbs_eflags_saved, bbs_no_eflags_saved);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */
    drreg_exit();
    drmgr_exit();
}
Пример #10
0
void inscount_exit_event(void)
{
#ifdef SHOW_RESULTS
	char msg[512];
	int len;
	len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
					  "process name - %s\nInstrumentation results: %llu instructions executed - %d bbcount\n"
					  ,dr_get_application_name(),global_count,bbcount);
	DR_ASSERT(len > 0);
	NULL_TERMINATE(msg);
	DISPLAY_STRING(msg);
#endif /* SHOW_RESULTS */

	md_delete_list(head,false);
	dr_global_free(client_arg, sizeof(client_arg_t));

	if (log_mode){
		dr_close_file(logfile);
	}

	drmgr_exit();

}
Пример #11
0
void
writeCallgrind(int thread_id){
	char logname[MAXIMUM_PATH];
	char *dirsep;
    	int len;
	char * tmp = process_path;

	len = dr_snprintf(logname, sizeof(logname)/sizeof(logname[0]),
                      "%s", tmp);

	DR_ASSERT(len > 0);
	for (dirsep = logname + len; *dirsep != '/'; dirsep--)
        DR_ASSERT(dirsep > logname);
    	len = dr_snprintf(dirsep + 1,
                      (sizeof(logname) - (dirsep - logname))/sizeof(logname[0]),
                      "callgrind.%d.out", thread_id);
    	DR_ASSERT(len > 0);
    	NULL_TERMINATE(logname);
    	logOut = dr_open_file(logname, 
                             DR_FILE_WRITE_OVERWRITE | DR_FILE_ALLOW_LARGE);
    	DR_ASSERT(logOut != INVALID_FILE);
//    	dr_log(drcontext, LOG_ALL, 1, 
 //          "floating point: log for thread %d is fp.%03d\n",thread_id, thread_id);
	#ifdef SHOW_RESULTS
    	if (dr_is_notify_on()) {
//        	dr_fprintf(STDERR, "<floating point instruction operands for thread %d in %s>\n",
//                  dr_get_thread_id(drcontext), logname);
    	}
	#endif	

       	dr_fprintf(logOut, "version: 1\n");
       	dr_fprintf(logOut, "creator: callgrind-3.6.1-Debian\n");
       	dr_fprintf(logOut, "positions: instr line\n");
       	dr_fprintf(logOut, "events: Average Max\n\n\n");

}
Пример #12
0
static void 
event_exit(void)
{
    int i,j;
    unsigned long long flop_count = 0;
    double ilp;
    int total_bbexecs = 0;
    double total_ilp = 0;
    float max_ilp = FLT_MIN;
    float min_ilp = FLT_MAX;
    unsigned long long tot_instr_count[tracked_instrs_len];
    for( i = 0; i < tracked_instrs_len; i++ ) tot_instr_count[i] = 0;

    for(i = 0; i < MY_MAX_BB && i < my_bbcount; i++){
        flop_count += my_bbexecs[i] * bb_flop_count[i];
        for( j = 0; j < tracked_instrs_len; j++ )
            tot_instr_count[j] += my_bbexecs[i] * bb_instr_count[i*tracked_instrs_len+j];
        total_bbexecs += my_bbexecs[i];
        total_ilp += ((double)my_bbexecs[i])*((double)my_bbilp[i]);
        min_ilp = MIN(min_ilp, my_bbilp[i]);
        max_ilp = MAX(max_ilp, my_bbilp[i]);
    }
    ilp = total_ilp / ((double)(total_bbexecs != 0 ? total_bbexecs : 1));

#ifdef SHOW_RESULTS
    char msg[2048];
    int len;
#ifdef VERBOSE
    for(i = 0; i < MY_MAX_BB && i < my_bbcount; i++){
        len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                          "Basic block # %5d, size: %5d, execs: %8d, ILP: %3f",
                          i, my_bbsizes[i], my_bbexecs[i], my_bbilp[i]);
        DR_ASSERT(len > 0);
        NULL_TERMINATE(msg);
        dr_printf("%s\n", msg);
    }
#endif
    for( i = 0; i < tracked_instrs_len; i++ ) {
        len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                "%10d %s\n", tot_instr_count[i], tracked_instrs[i]);
        dr_printf("%s", msg);
    }

    len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                      "Instrumentation results:\n"
		      "%10d basic block execs\n"
                      "%10d basic blocks\n"
            "%10d flop(s)\n"
                      "%10.3f avg ILP\n"
                      "%10.3f max ILP\n"
                      "%10.3f min ILP\n",
                      total_bbexecs, my_bbcount, flop_count, ilp, max_ilp, min_ilp);
    DR_ASSERT(len > 0);
    NULL_TERMINATE(msg);
    dr_printf("%s\n", msg);
    if (my_bbcount > MY_MAX_BB){
        len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]),
                          "\n"
                          "Overflow warning! Only the latest %d basic blocks were used for ILP calcution.\n",
                          MY_MAX_BB);
        DR_ASSERT(len > 0);
        NULL_TERMINATE(msg);
        dr_printf("%s\n", msg);
    }

#endif /* SHOW_RESULTS */
    dr_mutex_destroy(stats_mutex);
}