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 }
DR_EXPORT void dr_init(client_id_t id) { dr_fprintf(STDERR, "info: starting dtrace, &dr_init=%p..\n", &dr_init); trace_file = dr_open_file(TRACE_FILE_NAME, DR_FILE_ALLOW_LARGE | DR_FILE_WRITE_OVERWRITE); if(trace_file == INVALID_FILE) { dr_fprintf(STDERR, "fatal: dr_open_file() failed\n"); dr_exit_process(1); } trace_file_lock = dr_mutex_create(); trace_buffer = tb_create(-1); trace_buffer_lock = dr_mutex_create(); hashtable_init_ex(&tags, 16, HASH_INTPTR, false, false, &tag_info_free_raw, NULL, NULL); tags_lock = dr_mutex_create(); dr_register_exit_event(&dr_exit); dr_register_thread_init_event(&handle_thread_init); dr_register_thread_exit_event(&handle_thread_exit); dr_register_bb_event(&handle_bb); dr_register_trace_event(&handle_trace); dr_register_delete_event(&handle_delete); dr_register_signal_event(&handle_signal); dr_register_restore_state_event(&handle_restore_state); }
DR_EXPORT void dr_init(client_id_t id) { insn_count = 0; read_count = 0; writ_count = 0; read_size = 0; writ_size = 0; dr_register_post_syscall_event(event_post_syscall); dr_register_bb_event(event_bb); dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_exit); dr_register_exit_event(event_exit); }
DR_EXPORT void dr_init(client_id_t id) { /* register events */ dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_exit); dr_register_exit_event(event_exit); dr_register_bb_event(event_basic_block); /* The TLS field provided by DR cannot be directly accessed from 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, 1, 0)) DR_ASSERT(false); }
DR_EXPORT void dr_init(client_id_t id) { /* register events */ dr_register_exit_event(event_exit); dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_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 'countcalls' 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 countcalls is running\n"); } #endif }
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 bool drmgr_init(void) { static bool initialized; if (initialized) return true; initialized = true; exit_lock = dr_mutex_create(); note_lock = dr_mutex_create(); bb_cb_lock = dr_rwlock_create(); thread_event_lock = dr_rwlock_create(); tls_lock = dr_mutex_create(); cls_event_lock = dr_rwlock_create(); presys_event_lock = dr_rwlock_create(); dr_register_thread_init_event(drmgr_thread_init_event); dr_register_thread_exit_event(drmgr_thread_exit_event); dr_register_pre_syscall_event(drmgr_presyscall_event); return true; }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { dr_set_client_name("DynamoRIO Sample Client 'countcalls'", "http://dynamorio.org/issues"); /* register events */ dr_register_exit_event(event_exit); dr_register_thread_init_event(event_thread_init); dr_register_thread_exit_event(event_thread_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 'countcalls' 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 countcalls is running\n"); } #endif }