DR_EXPORT void dr_init(client_id_t id) { dr_set_client_name("DynamoRIO Sample Client 'instrcalls'", "http://dynamorio.org/issues"); my_id = id; /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'instrcalls' initializing\n"); /* also give notification to stderr */ #ifdef SHOW_RESULTS if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called in dr_init(). */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client instrcalls is running\n"); } #endif dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_exit); #ifdef SHOW_SYMBOLS if (drsym_init(0) != DRSYM_SUCCESS) { dr_log(NULL, LOG_ALL, 1, "WARNING: unable to initialize symbol translation\n"); } #endif }
static dr_emit_flags_t event_analyze_bb(void *drcontext, void *tag, instrlist_t *bb, bool for_trace, bool translating, void **user_data) { instr_t *instr; trace_head_entry_t *e = NULL; if (translating) return DR_EMIT_DEFAULT; for (instr = instrlist_first_app(bb); instr != NULL; instr = instr_get_next_app(instr)) { /* Blocks containing calls are trace heads. */ if (instr_is_call(instr)) { dr_mark_trace_head(drcontext, tag); hashtable_lock(&head_table); e = hashtable_lookup(&head_table, tag); if (e == NULL) { e = create_trace_head_entry(tag); if (!hashtable_add(&head_table, tag, (void *)e)) DR_ASSERT(false); } else e->refcount++; e->is_trace_head = true; hashtable_unlock(&head_table); #ifdef VERBOSE dr_log(drcontext, DR_LOG_ALL, 3, "inline: marking bb "PFX" as call trace head\n", tag); #endif /* Doesn't matter what's in rest of the bb. */ return DR_EMIT_DEFAULT; } else if (instr_is_return(instr)) { hashtable_lock(&head_table); e = hashtable_lookup(&head_table, tag); if (e == NULL) { e = create_trace_head_entry(tag); if (!hashtable_add(&head_table, tag, (void *)e)) DR_ASSERT(false); } else e->refcount++; e->has_ret = true; hashtable_unlock(&head_table); #ifdef VERBOSE dr_log(drcontext, DR_LOG_ALL, 3, "inline: marking bb "PFX" as return trace head\n", tag); #endif } } return DR_EMIT_DEFAULT; }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { dr_set_client_name("DynamoRIO Sample Client 'inline'", "http://dynamorio.org/issues"); if (!drmgr_init()) DR_ASSERT(false); hashtable_init_ex(&head_table, HASH_BITS, HASH_INTPTR, false/*!strdup*/, false/*synchronization is external*/, free_trace_head_entry, NULL, NULL); dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(event_analyze_bb, NULL, NULL)) DR_ASSERT(false); dr_register_delete_event(event_fragment_deleted); dr_register_end_trace_event(query_end_trace); /* Make it easy to tell from the log file which client executed. */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'inline' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* Ask for best-effort printing to cmd window. Must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client inline is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { module_data_t *appmod; dr_set_client_name("DynamoRIO Sample Client 'modxfer_app2lib'", "http://dynamorio.org/issues"); appmod = dr_get_main_module(); DR_ASSERT(appmod != NULL); app_base = appmod->start; app_end = appmod->end; dr_free_module_data(appmod); if (!drmgr_init()) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(event_analyze_bb, event_insert_instrumentation, NULL)) DR_ASSERT(false); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'modxfer_app2lib' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client modxfer_app2lib is running\n"); } #endif }
DR_EXPORT void dr_init(client_id_t id) { dr_register_exit_event(event_exit); dr_register_trace_event(event_trace); /* this optimization is only worthwhile on the Pentium 4, where * an add of 1 is faster than an inc */ enable = (proc_get_family() == FAMILY_PENTIUM_4); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'inc2add' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called in dr_init(). */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client inc2add is running\n"); } #endif /* initialize our global variables */ num_examined = 0; num_converted = 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); }
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); }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = {sizeof(ops), 1 /*max slots needed: aflags*/, false}; dr_set_client_name("DynamoRIO Sample Client 'bbcount'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL)) DR_ASSERT(false); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'bbcount' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client bbcount is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { uint i; dr_set_client_name("DynamoRIO Sample Client 'stats'", "http://dynamorio.org/issues"); my_id = id; /* Make it easy to tell by looking at the log which client executed. */ dr_log(NULL, LOG_ALL, 1, "Client 'stats' initializing\n"); if (!drmgr_init()) DR_ASSERT(false); drx_init(); stats = shared_memory_init(); memset(stats, 0, sizeof(stats)); stats->num_stats = NUM_STATS; stats->pid = dr_get_process_id(); for (i=0; i<NUM_STATS; i++) { strncpy(stats->names[i], stat_names[i], CLIENTSTAT_NAME_MAX_LEN); stats->names[i][CLIENTSTAT_NAME_MAX_LEN-1] = '\0'; } dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(event_analyze_bb, event_insert_instrumentation, NULL)) DR_ASSERT(false); }
static dr_emit_flags_t event_basic_block(void *drcontext, void *tag, instrlist_t *bb, bool for_trace, bool translating) { instr_t *instr; trace_head_entry_t *e = NULL; if (translating) return DR_EMIT_DEFAULT; for (instr = instrlist_first(bb); instr != NULL; instr = instr_get_next(instr)) { /* blocks containing calls are trace heads */ if (instr_is_call(instr)) { dr_mark_trace_head(drcontext, tag); dr_mutex_lock(htable_mutex); e = add_trace_head_entry(NULL, tag); e->is_trace_head = true; dr_mutex_unlock(htable_mutex); #ifdef VERBOSE dr_log(drcontext, LOG_ALL, 3, "inline: marking bb "PFX" as trace head\n", tag); #endif /* doesn't matter what's in rest of bb */ return DR_EMIT_DEFAULT; } else if (instr_is_return(instr)) { dr_mutex_lock(htable_mutex); e = add_trace_head_entry(NULL, tag); e->has_ret = true; dr_mutex_unlock(htable_mutex); } } return DR_EMIT_DEFAULT; }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need 2 reg slots beyond drreg's eflags slots => 3 slots */ drreg_options_t ops = { sizeof(ops), 3, false }; dr_set_client_name("DynamoRIO Sample Client 'memtrace'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS || !drutil_init()) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, NULL) || !drmgr_register_bb_instrumentation_event(NULL /*analysis_func*/, event_app_instruction, NULL)) DR_ASSERT(false); client_id = id; mutex = dr_mutex_create(); tls_idx = drmgr_register_tls_field(); DR_ASSERT(tls_idx != -1); /* The TLS field provided by DR cannot be directly accessed from the code cache. * For better performance, we allocate raw TLS so that we can directly * access and update it with a single instruction. */ if (!dr_raw_tls_calloc(&tls_seg, &tls_offs, MEMTRACE_TLS_COUNT, 0)) DR_ASSERT(false); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memtrace' initializing\n"); }
DR_EXPORT void dr_init(client_id_t id) { module_data_t *appmod = dr_get_main_module(); DR_ASSERT(appmod != NULL); app_base = appmod->start; app_end = appmod->end; dr_free_module_data(appmod); /* register events */ dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'modxfer_app2lib' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called in dr_init(). */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client modxfer_app2lib is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = { sizeof(ops), 4 /*max slots needed*/, false }; dr_set_client_name("DynamoRIO Sample Client 'memval'", "http://dynamorio.org/issues"); if (!drmgr_init() || !drutil_init() || !drx_init()) DR_ASSERT(false); if (drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, NULL) || !drmgr_register_bb_instrumentation_event(event_app_analysis, event_app_instruction, NULL)) DR_ASSERT(false); client_id = id; tls_idx = drmgr_register_tls_field(); trace_buffer = drx_buf_create_trace_buffer(MEM_BUF_SIZE, trace_fault); /* We could make this a trace buffer and specially handle faults, but it is not yet * worth the effort. */ write_buffer = drx_buf_create_circular_buffer(WRT_BUF_SIZE); DR_ASSERT(tls_idx != -1 && trace_buffer != NULL && write_buffer != NULL); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memval' initializing\n"); }
static void event_exit(void) { dr_log(NULL, LOG_ALL, 1, "Client 'cbrtrace' exiting"); #ifdef SHOW_RESULTS if (dr_is_notify_on()) dr_fprintf(STDERR, "Client 'cbrtrace' exiting\n"); #endif }
static void event_exit(void) { #ifdef SHOW_SYMBOLS if (drsym_exit() != DRSYM_SUCCESS) { dr_log(NULL, LOG_ALL, 1, "WARNING: error cleaning up symbol library\n"); } #endif }
static client_stats_t * shared_memory_init(void) { bool is_NT = is_windows_NT(); int num; int pos; /* We do not want to rely on the registry. * Instead, a piece of shared memory with the key base name holds the * total number of stats instances. */ shared_map_count = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(client_stats_t), is_NT ? CLIENT_SHMEM_KEY_NT_L : CLIENT_SHMEM_KEY_L); DR_ASSERT(shared_map_count != NULL); shared_view_count = MapViewOfFile(shared_map_count, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 0); DR_ASSERT(shared_view_count != NULL); shared_count = (int *) shared_view_count; /* ASSUMPTION: memory is initialized to 0! * otherwise our protocol won't work * it's hard to build a protocol to initialize it to 0 -- if you want * to add one, feel free, but make sure it's correct */ do { pos = (int) atomic_swap(shared_count, (uint) -1); /* if get -1 back, someone else is looking at it */ } while (pos == -1); /* now increment it */ atomic_swap(shared_count, pos+1); num = 0; while (1) { _snwprintf(shared_keyname, KEYNAME_MAXLEN, L"%s.%03d", is_NT ? CLIENT_SHMEM_KEY_NT_L : CLIENT_SHMEM_KEY_L, num); shared_map = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(client_stats_t), shared_keyname); if (shared_map != NULL && GetLastError() == ERROR_ALREADY_EXISTS) { dr_close_file(shared_map); shared_map = NULL; } if (shared_map != NULL) break; num++; } dr_log(NULL, LOG_ALL, 1, "Shared memory key is: \"%S\"\n", shared_keyname); #ifdef SHOW_RESULTS dr_fprintf(STDERR, "Shared memory key is: \"%S\"\n", shared_keyname); #endif shared_view = MapViewOfFile(shared_map, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 0); DR_ASSERT(shared_view != NULL); return (client_stats_t *) shared_view; }
static void event_thread_init(void *drcontext) { /* create an instance of our data structure for this thread */ per_thread_t *data = (per_thread_t *)dr_thread_alloc(drcontext, sizeof(per_thread_t)); /* store it in the slot provided in the drcontext */ drmgr_set_tls_field(drcontext, tls_idx, data); data->num_direct_calls = 0; data->num_indirect_calls = 0; data->num_returns = 0; dr_log(drcontext, DR_LOG_ALL, 1, "countcalls: set up for thread " TIDFMT "\n", dr_get_thread_id(drcontext)); }
DR_EXPORT void dr_init(client_id_t id) { /* register events */ dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'memtrace' initializing\n"); if (dr_is_notify_on()) { dr_fprintf(STDERR, "Client is running\n"); } }
DR_EXPORT void dr_init(client_id_t id) { dr_set_client_name("DynamoRIO client 'ssljack'", "http://dynamorio.org/issues"); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client ssljack initializing\n"); #ifdef SHOW_RESULTS if (dr_is_notify_on()) { dr_fprintf(STDERR, "Client ssljack running! See trace-* files for SSL logs!\n"); } #endif drmgr_init(); drwrap_init(); dr_register_exit_event(event_exit); drmgr_register_module_load_event(module_load_event); }
DR_EXPORT void dr_init(client_id_t id) { htable_mutex = dr_mutex_create(); /* global HASH_BITS-bit addressed hash table */ htable = htable_create(NULL/*global*/); dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); dr_register_delete_event(event_fragment_deleted); dr_register_end_trace_event(query_end_trace); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'inline' initializing\n"); num_complete_inlines = 0; }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need 2 reg slots beyond drreg's eflags slots => 3 slots */ drreg_options_t ops = {sizeof(ops), 3, false}; /* Specify priority relative to other instrumentation operations: */ drmgr_priority_t priority = { sizeof(priority), /* size of struct */ "memtrace", /* name of our operation */ NULL, /* optional name of operation we should precede */ NULL, /* optional name of operation we should follow */ 0}; /* numeric priority */ dr_set_client_name("DynamoRIO Sample Client 'memtrace'", "http://dynamorio.org/issues"); page_size = dr_page_size(); drmgr_init(); drutil_init(); client_id = id; mutex = dr_mutex_create(); dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, &priority) || !drmgr_register_bb_instrumentation_event(NULL, event_bb_insert, &priority) || drreg_init(&ops) != DRREG_SUCCESS) { /* something is wrong: can't continue */ DR_ASSERT(false); return; } tls_index = drmgr_register_tls_field(); DR_ASSERT(tls_index != -1); code_cache_init(); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memtrace' initializing\n"); #ifdef SHOW_RESULTS if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client memtrace is running\n"); } #endif }
/**************************************************************************** * Utility Functions */ static file_t log_file_create_helper(void *drcontext, const char *suffix, char *buf, size_t buf_els) { file_t log = drx_open_unique_appid_file(options.logdir, drcontext == NULL ? dr_get_process_id() : dr_get_thread_id(drcontext), "drcov", suffix, #ifndef WINDOWS DR_FILE_CLOSE_ON_FORK | #endif DR_FILE_ALLOW_LARGE, buf, buf_els); if (log != INVALID_FILE) { dr_log(drcontext, DR_LOG_ALL, 1, "drcov: log file is %s\n", buf); NOTIFY(1, "<created log file %s>\n", buf); } return log; }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need no drreg slots ourselves, but we initialize drreg as we call * drreg_restore_app_values(), required since drx_insert_counter_update() * uses drreg when drmgr is used. */ drreg_options_t ops = {sizeof(ops)}; dr_set_client_name("DynamoRIO Sample Client 'modxfer'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); drx_init(); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(event_analyze_bb, event_insert_instrumentation, NULL)) DR_ASSERT(false); drmgr_register_module_load_event(event_module_load); drmgr_register_module_unload_event(event_module_unload); mod_lock = dr_mutex_create(); logfile = log_file_open(id, NULL /* drcontext */, NULL/* path */, "modxfer", #ifndef WINDOWS DR_FILE_CLOSE_ON_FORK | #endif DR_FILE_ALLOW_LARGE); DR_ASSERT(logfile != INVALID_FILE); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'modxfer' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client modxfer is running\n"); } #endif }
static void event_exit(void) { dr_log(NULL, DR_LOG_ALL, 1, "Client 'memtrace' num refs seen: " SZFMT "\n", num_refs); if (!dr_raw_tls_cfree(tls_offs, MEMTRACE_TLS_COUNT)) DR_ASSERT(false); if (!drmgr_unregister_tls_field(tls_idx) || !drmgr_unregister_thread_init_event(event_thread_init) || !drmgr_unregister_thread_exit_event(event_thread_exit) || !drmgr_unregister_bb_app2app_event(event_bb_app2app) || !drmgr_unregister_bb_insertion_event(event_app_instruction) || drreg_exit() != DRREG_SUCCESS) DR_ASSERT(false); dr_mutex_destroy(mutex); drutil_exit(); drmgr_exit(); }
DR_EXPORT void dr_init(client_id_t id) { dr_printf("dr_init()\n"); my_bbcount = 0; stats_mutex = dr_mutex_create(); dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); #ifdef SHOW_RESULTS dr_log(NULL, LOG_ALL, 1, "Client 'inspar' initializing\n"); if (dr_is_notify_on()) { # ifdef WINDOWS dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client inspar is running\n"); } #endif }
DR_EXPORT void dr_init(client_id_t id) { printf("Started dr_init\n"); dr_register_exit_event(exit_event); dr_register_bb_event(bb_event); dr_register_thread_init_event(writeLog); count_mutex = dr_mutex_create(); client_id = id; #ifdef SHOW_SYMBOLS if (drsym_init(0) != DRSYM_SUCCESS) { dr_log(NULL, LOG_ALL, 1, "WARNING: unable to initialize symbol translation\n"); } #endif htinit(); }
DR_EXPORT void dr_init(client_id_t id) { /* register events */ dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'inscount' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called in dr_init(). */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client inscount is running\n"); } #endif }
DR_EXPORT void dr_init(client_id_t id) { /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'wrap' initializing\n"); /* also give notification to stderr */ #ifdef SHOW_RESULTS if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called in dr_init(). */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client wrap is running\n"); } #endif drwrap_init(); dr_register_exit_event(event_exit); dr_register_module_load_event(module_load_event); max_lock = dr_mutex_create(); }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { dr_set_client_name("DynamoRIO Sample Client 'cbrtrace'", "http://dynamorio.org/issues"); dr_log(NULL, LOG_ALL, 1, "Client 'cbrtrace' initializing"); client_id = id; dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_exit); dr_register_bb_event(event_basic_block); dr_register_exit_event(event_exit); #ifdef SHOW_RESULTS if (dr_is_notify_on()) { # ifdef WINDOWS dr_enable_console_printing(); # endif /* WINDOWS */ dr_fprintf(STDERR, "Client 'cbrtrace' is running\n"); } #endif /* SHOW_RESULTS */ }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { dr_set_client_name("DynamoRIO Sample Client 'inscount'", "http://dynamorio.org/issues"); /* Options */ if (!droption_parser_t::parse_argv(DROPTION_SCOPE_CLIENT, argc, argv, NULL, NULL)) DR_ASSERT(false); drmgr_init(); /* Get main module address */ if (only_from_app.get_value()) { module_data_t *exe = dr_get_main_module(); if (exe != NULL) exe_start = exe->start; dr_free_module_data(exe); } /* register events */ dr_register_exit_event(event_exit); drmgr_register_bb_instrumentation_event(event_bb_analysis, event_app_instruction, NULL); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'inscount' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client inscount is running\n"); } #endif }