static void event_exit(void) { dr_mutex_destroy(syslock); dr_mutex_destroy(threadlock); CHECK(checked_tls_from_cache, "failed to hit clean call"); CHECK(checked_cls_from_cache, "failed to hit clean call"); CHECK(checked_tls_write_from_cache, "failed to hit clean call"); CHECK(checked_cls_write_from_cache, "failed to hit clean call"); CHECK(one_time_exec == 1, "failed to execute one-time event"); if (!drmgr_unregister_bb_instrumentation_event(event_bb_analysis)) CHECK(false, "drmgr unregistration failed"); if (!drmgr_unregister_bb_instrumentation_ex_event(event_bb4_app2app, event_bb4_analysis, event_bb4_insert, event_bb4_instru2instru)) CHECK(false, "drmgr unregistration failed"); if (!drmgr_unregister_cls_field(event_thread_context_init, event_thread_context_exit, cls_idx)) CHECK(false, "drmgr unregistration failed"); drmgr_exit(); dr_fprintf(STDERR, "all done\n"); }
static void event_exit(void) { file_t f; /* Display the results! */ char msg[512]; int len; len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]), "Instrumentation results:\n" " saw %" STAT_FORMAT_CODE " flops\n", stats->num_flops); DR_ASSERT(len > 0); msg[sizeof(msg)/sizeof(msg[0])-1] = '\0'; #ifdef SHOW_RESULTS DISPLAY_STRING(msg); #endif /* SHOW_RESULTS */ /* On Windows we need an absolute path so we place it in * the same directory as our library. */ f = log_file_open(my_id, NULL, NULL /* client lib path */, "stats", 0); DR_ASSERT(f != INVALID_FILE); dr_fprintf(f, "%s\n", msg); dr_close_file(f); shared_memory_exit(); drx_exit(); if (!drmgr_unregister_bb_instrumentation_event(event_analyze_bb)) DR_ASSERT(false); drmgr_exit(); }
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 */ if (!drmgr_unregister_bb_instrumentation_event(event_analyze_bb)) DR_ASSERT(false); drmgr_exit(); }
static void event_exit(void) { #ifdef SHOW_RESULTS /* Display the results! */ char msg[512]; int len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]), "Inlining results:\n" " Number of traces: %d\n" " Number of complete inlines: %d\n", num_traces, num_complete_inlines); DR_ASSERT(len > 0); msg[sizeof(msg)/sizeof(msg[0])-1] = '\0'; DISPLAY_STRING(msg); #endif hashtable_delete(&head_table); if (!drmgr_unregister_bb_instrumentation_event(event_analyze_bb)) DR_ASSERT(false); drmgr_exit(); }
static void event_exit(void) { int i; char msg[512]; int len; int j; uint64 xmod_xfer = 0; uint64 self_xfer = 0; for (i = 0; i < num_mods; i++) { dr_fprintf(logfile, "module %3d: %s\n", i, dr_module_preferred_name(mod_array[i].info) == NULL ? "<unknown>" : dr_module_preferred_name(mod_array[i].info)); dr_fprintf(logfile, "%20llu instruction executed\n", mod_cnt[i]); } if (mod_cnt[UNKNOW_MODULE_IDX] != 0) { dr_fprintf(logfile, "unknown modules:\n%20llu instruction executed\n", mod_cnt[UNKNOW_MODULE_IDX]); } for (i = 0; i < MAX_NUM_MODULES; i++) { for (j = 0; j < num_mods; j++) { if (xfer_cnt[i][j] != 0) { dr_fprintf(logfile, "mod %3d => mod %3d: %8u\n", i, j, xfer_cnt[i][j]); if (i == j) self_xfer += xfer_cnt[i][j]; else xmod_xfer += xfer_cnt[i][j]; } } } len = dr_snprintf(msg, sizeof(msg)/sizeof(msg[0]), "Instrumentation results:\n" "\t%10llu instructions executed\n" "\t%10llu (%2.3f%%) cross module indirect branches\n" "\t%10llu (%2.3f%%) intra-module indirect branches\n", ins_count, xmod_xfer, 100*(float)xmod_xfer/ins_count, self_xfer, 100*(float)self_xfer/ins_count); DR_ASSERT(len > 0); NULL_TERMINATE_BUFFER(msg); #ifdef SHOW_RESULTS DISPLAY_STRING(msg); #endif /* SHOW_RESULTS */ dr_fprintf(logfile, "%s\n", msg); dr_mutex_lock(mod_lock); for (i = 0; i < num_mods; i++) { DR_ASSERT(mod_array[i].info != NULL); dr_free_module_data(mod_array[i].info); } dr_mutex_unlock(mod_lock); dr_mutex_destroy(mod_lock); log_file_close(logfile); drx_exit(); if (!drmgr_unregister_bb_instrumentation_event(event_analyze_bb) || !drmgr_unregister_module_load_event(event_module_load) || !drmgr_unregister_module_unload_event(event_module_unload) || drreg_exit() != DRREG_SUCCESS) DR_ASSERT(false); drmgr_exit(); }