From 64deb08509bf9682e7d3b8141399c5603edb2df2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 2 Sep 2009 16:43:58 -0700 Subject: Provide backward-compatible unordered_map/set We were defining our own stap_map with a ::type to let us use typedefs to use the new unordered_map if available, or hash_map otherwise. Since unordered_map is the future direction, I'm changing our code to use that directly. The backward-compatible version is a #define to hash_map, which has a compatible interface. While I'm at it, let's also define unordered_multimap, unordered_set, and unordered_multiset. * unordered.h: New. * dwflpp.h (stap_map): Removed. (cache typedefs): Use the unordered name now. --- dwflpp.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index 047ad602..9ed18558 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -15,6 +15,7 @@ #include "dwarf_wrappers.h" #include "elaborate.h" #include "session.h" +#include "unordered.h" #include #include @@ -43,33 +44,17 @@ struct dwarf_query; enum line_t { ABSOLUTE, RELATIVE, RANGE, WILDCARD }; enum info_status { info_unknown, info_present, info_absent }; -#ifdef HAVE_TR1_UNORDERED_MAP -#include -template struct stap_map { - typedef std::tr1::unordered_map type; -}; -#else -#include -template struct stap_map { - typedef __gnu_cxx::hash_map type; - size_t operator() (std::string const& s) const - { __gnu_cxx::hash h; return h(s.c_str()); } - size_t operator() (void* const& p) const - { __gnu_cxx::hash h; return h(reinterpret_cast(p)); } -}; -#endif - // module -> cu die[] -typedef stap_map*>::type module_cu_cache_t; +typedef unordered_map*> module_cu_cache_t; // function -> die -typedef stap_map::type cu_function_cache_t; +typedef unordered_map cu_function_cache_t; // cu die -> (function -> die) -typedef stap_map::type mod_cu_function_cache_t; +typedef unordered_map mod_cu_function_cache_t; // inline function die -> instance die[] -typedef stap_map*>::type cu_inl_function_cache_t; +typedef unordered_map*> cu_inl_function_cache_t; typedef std::vector func_info_map_t; typedef std::vector inline_instance_map_t; -- cgit From b74789646bfe59131327716357c8b7c1521fa14a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 2 Sep 2009 19:09:50 -0700 Subject: PR10572: Allow duplicate function names in a CU We can't assume that a given function name will only appear once in a CU. In C++, two functions may have the same name in different classes or namespaces, or even in the same scope with overloaded parameters. Even in C, the compiler may generate multiple copies of a single function with different optimizations. We now use a multimap for function names, so we shouldn't miss any. * dwflpp.h (cu_type_cache_t, mod_cu_type_cache_t): New typedef to keep a normal map for the global_alias_cache. (cu_function_cache_t): Use a multimap for function names. * dwflpp.cxx (dwflpp::iterate_over_functions): Walk over the range of exactly-matching functions. * tapsets.cxx (query_dwarf_func): Don't abort after seeing an exact match -- there could be more to come. --- dwflpp.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index 9ed18558..431f3c4b 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -47,8 +47,17 @@ enum info_status { info_unknown, info_present, info_absent }; // module -> cu die[] typedef unordered_map*> module_cu_cache_t; +// typename -> die +typedef unordered_map cu_type_cache_t; + +// cu die -> (typename -> die) +typedef unordered_map mod_cu_type_cache_t; + // function -> die -typedef unordered_map cu_function_cache_t; +typedef unordered_multimap cu_function_cache_t; +typedef std::pair + cu_function_cache_range_t; // cu die -> (function -> die) typedef unordered_map mod_cu_function_cache_t; @@ -293,7 +302,7 @@ private: * cache is indexed by name. If other declaration lookups were * added to it, it would have to be indexed by name and tag */ - mod_cu_function_cache_t global_alias_cache; + mod_cu_type_cache_t global_alias_cache; static int global_alias_caching_callback(Dwarf_Die *die, void *arg); int iterate_over_globals (int (* callback)(Dwarf_Die *, void *), void * data); -- cgit From 7fdd3e2c61874abd631de5038d846dffb6f5bc5f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 3 Sep 2009 11:32:59 -0700 Subject: PR10573: Squash duplicate inline instances In C++, identical functions included in multiple CUs will get merged at link time into a single instance. We need to make sure that inlines within those merged functions are not probed multiple times. * tapsets.cxx (inline_instance_info::operator<): Used for set support. (dwarf_query::handle_query_module): Clear inline_dupes on each module. (query_dwarf_inline_instance): Squash this inline instance if it's already in the inline_dupes set. --- dwflpp.h | 1 + 1 file changed, 1 insertion(+) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index 431f3c4b..34531071 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -139,6 +139,7 @@ struct inline_instance_info { std::memset(&die, 0, sizeof(die)); } + bool operator<(const inline_instance_info& other) const; std::string name; char const * decl_file; int decl_line; -- cgit From 789448a36f57e53cc6a1878f7637998b0f15652c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 3 Sep 2009 12:00:10 -0700 Subject: Fetch the blacklist section only when needed We only check blacklisting on kernel probes, so it's a waste to dig up the section name otherwise. * dwflpp.cxx (dwflpp::blacklisted_p): Lookup the section directly. (relocate_address::relocate_address): Don't do blacklisting here. * tapsets.cxx (dwarf_query::add_probe_point): Don't carry the blacklist section directly anymore. --- dwflpp.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index 34531071..ea14bb87 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -268,13 +268,10 @@ struct dwflpp const std::string& filename, int line, const std::string& module, - const std::string& section, Dwarf_Addr addr, bool has_return); - Dwarf_Addr relocate_address(Dwarf_Addr addr, - std::string& reloc_section, - std::string& blacklist_section); + Dwarf_Addr relocate_address(Dwarf_Addr addr, std::string& reloc_section); Dwarf_Addr literal_addr_to_sym_addr(Dwarf_Addr lit_addr); -- cgit From 178ac3f6fdef839ef1ca646421e2c436a91ac1fb Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 3 Sep 2009 12:26:37 -0700 Subject: Use a regexp for matching blacklist sections We already use regexp for function/file blacklisting, so this just makes the section blacklisting consistent with the rest. * dwflpp.cxx (dwflpp::blacklisted_p): Use regexec instead of section==. (dwflpp::build_blacklist): Build blacklist_section too. --- dwflpp.h | 1 + 1 file changed, 1 insertion(+) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index ea14bb87..74a3ae00 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -369,6 +369,7 @@ private: regex_t blacklist_func; // function/statement probes regex_t blacklist_func_ret; // only for .return probes regex_t blacklist_file; // file name + regex_t blacklist_section; // init/exit sections bool blacklist_enabled; void build_blacklist(); std::string get_blacklist_section(Dwarf_Addr addr); -- cgit