diff options
-rw-r--r-- | dwflpp.cxx | 23 | ||||
-rw-r--r-- | dwflpp.h | 20 |
2 files changed, 25 insertions, 18 deletions
@@ -558,15 +558,15 @@ dwflpp::declaration_resolve(const char *name) if (!name) return NULL; - string key = module_name + ":" + cu_name; - cu_function_cache_t *v = global_alias_cache[key]; + cu_function_cache_t *v = global_alias_cache[cu->addr]; if (v == 0) // need to build the cache, just once per encountered module/cu { v = new cu_function_cache_t; - global_alias_cache[key] = v; + global_alias_cache[cu->addr] = v; iterate_over_globals(global_alias_caching_callback, v); if (sess.verbose > 4) - clog << "global alias cache " << key << " size " << v->size() << endl; + clog << "global alias cache " << module_name << ":" << cu_name + << " size " << v->size() << endl; } // XXX: it may be desirable to search other modules' declarations @@ -607,15 +607,15 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * assert (module); assert (cu); - string key = module_name + ":" + cu_name; - cu_function_cache_t *v = cu_function_cache[key]; + cu_function_cache_t *v = cu_function_cache[cu->addr]; if (v == 0) { v = new cu_function_cache_t; - cu_function_cache[key] = v; + cu_function_cache[cu->addr] = v; dwarf_getfuncs (cu, cu_function_caching_callback, v, 0); if (sess.verbose > 4) - clog << "function cache " << key << " size " << v->size() << endl; + clog << "function cache " << module_name << ":" << cu_name + << " size " << v->size() << endl; mod_info->update_symtab(v); } @@ -624,7 +624,8 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * { Dwarf_Die& die = it->second; if (sess.verbose > 4) - clog << "function cache " << key << " hit " << function << endl; + clog << "function cache " << module_name << ":" << cu_name + << " hit " << function << endl; return (*callback)(& die, q); } else if (name_has_wildcard (function)) @@ -637,8 +638,8 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * if (function_name_matches_pattern (func_name, function)) { if (sess.verbose > 4) - clog << "function cache " << key << " match " << func_name << " vs " - << function << endl; + clog << "function cache " << module_name << ":" << cu_name + << " match " << func_name << " vs " << function << endl; rc = (*callback)(& die, q); if (rc != DWARF_CB_OK) break; @@ -45,19 +45,25 @@ enum info_status { info_unknown, info_present, info_absent }; #ifdef HAVE_TR1_UNORDERED_MAP #include <tr1/unordered_map> -template<class T> struct stap_map { - typedef std::tr1::unordered_map<std::string, T> type; +template<class K, class V> struct stap_map { + typedef std::tr1::unordered_map<K, V> type; }; #else #include <ext/hash_map> -template<class T> struct stap_map { - typedef __gnu_cxx::hash_map<std::string, T, stap_map> type; - size_t operator() (const std::string& s) const +template<class K, class V> struct stap_map { + typedef __gnu_cxx::hash_map<K, V, stap_map> type; + size_t operator() (std::string const& s) const { __gnu_cxx::hash<const char*> h; return h(s.c_str()); } + size_t operator() (void* const& p) const + { __gnu_cxx::hash<long> h; return h(reinterpret_cast<long>(p)); } }; #endif -typedef stap_map<Dwarf_Die>::type cu_function_cache_t; // function -> die -typedef stap_map<cu_function_cache_t*>::type mod_cu_function_cache_t; // module:cu -> function -> die + +// function -> die +typedef stap_map<std::string, Dwarf_Die>::type cu_function_cache_t; + +// cu die -> (function -> die) +typedef stap_map<void*, cu_function_cache_t*>::type mod_cu_function_cache_t; typedef std::vector<func_info> func_info_map_t; typedef std::vector<inline_instance_info> inline_instance_map_t; |