Ejemplo n.º 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);
}
Ejemplo n.º 2
0
/* This routine builds the full map file path from the name of the client.
 * Assumes that map files for the test_{dll,exe}, probe and client dlls are all
 * in the same directory as the client, which is true for tests.
 */
unsigned int get_symbol_offset(const char *map_file, const char *symbol)
{
    unsigned long offset = 0xdeadc0de, client_path_len;
    char *client_path = NULL, *map_path, *ptr;

    client_path = (char *) dr_get_client_path();
    if (client_path != NULL) {
        client_path_len = strlen(client_path);
        map_path = dr_global_alloc(client_path_len * 2);        /* be safe */
        strcpy(map_path, client_path);
        ptr = map_path + client_path_len;
        while (*--ptr != '\\');             /* get the dirname */
        strcpy(++ptr, map_file);
    }

    offset = get_symbol_offset_from_map(map_path, symbol);

    if (map_path != NULL)
        dr_global_free(map_path, client_path_len * 2);

    return offset;
}