From 1c6b77e564d4d849f1994d56d662ceb018a112d4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 1 Jul 2009 18:59:41 -0700 Subject: PR10327: resolve symbol aliases to dwarf functions This will first read in the symbol table for modules, and update the dwarf cu_function_cache with aliased names too. Then when iterating in dwarf, all of the possible names are matched, instead of only the canonical dwarf name. * dwflpp.cxx (dwflpp::iterate_over_functions): call update_symtab, and track wildcard addresses in a set to avoid alias dupes * dwflpp.h (symbol_table::Compare): removed * tapsets.cxx (symbol_table::map_by_addr): replaces list_by_addr (symbol_table::sort): removed -- multimap doesn't need sorting (symbol_table::mark_dwarf_redundancies): removed, see update_symtab (symbol_table::purge_syscall_stubs): remove map elements inline (dwarf_query::handle_query_module): preload the symtable. (query_dwarf_func): don't compare the function a second time, especially since it may have been an alias that matched at first. (module_info::get_symtab): allow being called multiple times (module_info::update_symtab): copy dies from the cache to the symtab, and also add aliased names to the cache --- dwflpp.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'dwflpp.cxx') diff --git a/dwflpp.cxx b/dwflpp.cxx index ee5d2233..b2532246 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -563,29 +563,40 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * dwarf_getfuncs (cu, cu_function_caching_callback, v, 0); if (sess.verbose > 4) clog << "function cache " << key << " size " << v->size() << endl; + mod_info->update_symtab(v); } cu_function_cache_t::iterator it = v->find(function); if (it != v->end()) { - Dwarf_Die die = it->second; + Dwarf_Die& die = it->second; if (sess.verbose > 4) clog << "function cache " << key << " hit " << function << endl; return (*callback)(& die, q); } else if (name_has_wildcard (function)) { + // track addresses we've already seen + set alias_dupes; + for (it = v->begin(); it != v->end(); it++) { - if (pending_interrupts) return DWARF_CB_ABORT; - string func_name = it->first; - Dwarf_Die die = it->second; + if (pending_interrupts) return DWARF_CB_ABORT; + const string& func_name = it->first; + Dwarf_Die& die = it->second; if (function_name_matches_pattern (func_name, function)) { if (sess.verbose > 4) clog << "function cache " << key << " match " << func_name << " vs " << function << endl; + // make sure that this function address hasn't + // already been matched under an aliased name + Dwarf_Addr addr; + if (dwarf_entrypc(&die, &addr) == 0 && + !alias_dupes.insert(addr).second) + continue; + rc = (*callback)(& die, q); if (rc != DWARF_CB_OK) break; } -- cgit