void symcache_module_unload(void *drcontext, const module_data_t *mod) { mod_cache_t *modcache; const char *modname = dr_module_preferred_name(mod); if (modname == NULL) return; /* don't support caching */ ASSERT(initialized, "symcache was not initialized"); dr_mutex_lock(symcache_lock); modcache = (mod_cache_t *) hashtable_lookup(&symcache_table, (void *)mod->full_path); if (modcache != NULL) { symcache_write_symfile(modname, modcache); hashtable_remove(&symcache_table, (void *)mod->full_path); } dr_mutex_unlock(symcache_lock); }
void symcache_exit(void) { uint i; ASSERT(initialized, "symcache was not initialized"); dr_mutex_lock(symcache_lock); for (i = 0; i < HASHTABLE_SIZE(symcache_table.table_bits); i++) { hash_entry_t *he; for (he = symcache_table.table[i]; he != NULL; he = he->next) { mod_cache_t *modcache = (mod_cache_t *) he->payload; symcache_write_symfile(modcache->modname, modcache); } } hashtable_delete(&symcache_table); dr_mutex_unlock(symcache_lock); dr_mutex_destroy(symcache_lock); }
static bool symcache_module_save_common(const module_data_t *mod, bool remove) { mod_cache_t *modcache; const char *modname = dr_module_preferred_name(mod); if (modname == NULL) return false; /* don't support caching */ ASSERT(initialized, "symcache was not initialized"); dr_mutex_lock(symcache_lock); modcache = (mod_cache_t *) hashtable_lookup(&symcache_table, (void *)mod->full_path); if (modcache != NULL) { symcache_write_symfile(modname, modcache); if (remove) hashtable_remove(&symcache_table, (void *)mod->full_path); } dr_mutex_unlock(symcache_lock); return true; }