From 665e12562a4aa4f40aeeed0cfd207b49f89c9fd1 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 8 Jul 2009 13:04:10 -0400 Subject: PR3498 cont'd, fix wildcard module("*") probes * dwflpp.cxx (name_has_wildcard): Make static. (dwfl_report_offline_predicate): Check & adjust behavior. * dwflpp.h: Corresponding changes. * tapsets.cxx: Note that kern_dw[] keys may be wildcard strings. * testsuite/buildok/fortysix.stp: New test. --- dwflpp.cxx | 44 +++++++++++++++++++++--------------------- dwflpp.h | 2 +- tapsets.cxx | 2 +- testsuite/buildok/fortysix.stp | 3 +++ 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100755 testsuite/buildok/fortysix.stp diff --git a/dwflpp.cxx b/dwflpp.cxx index 17bce608..531d413e 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -205,7 +205,7 @@ dwflpp::module_name_matches(const string& pattern) bool -dwflpp::name_has_wildcard(const string& pattern) +dwflpp::name_has_wildcard (const string& pattern) { return (pattern.find('*') != string::npos || pattern.find('?') != string::npos || @@ -258,19 +258,30 @@ static int dwfl_report_offline_predicate (const char* modname, const char* filen if (pending_interrupts) return -1; - if (offline_search_match_p) - return -1; - assert (offline_search_modname); - /* Reject mismatching module names */ - if (strcmp(modname, offline_search_modname)) - return 0; - else - { + if (dwflpp::name_has_wildcard (offline_search_modname)) { + int match_p = !fnmatch(offline_search_modname, modname, 0); + // In the wildcard case, we don't short-circuit (return -1) upon + // offline_search_match_p, analogously to dwflpp::module_name_final_match(). + + if (match_p) offline_search_match_p ++; - return 1; - } + + return match_p; + } else { /* non-wildcard mode */ + if (offline_search_match_p) + return -1; + + /* Reject mismatching module names */ + if (strcmp(modname, offline_search_modname)) + return 0; + else + { + offline_search_match_p ++; + return 1; + } + } } @@ -339,17 +350,6 @@ dwflpp::setup_kernel(const string& name, bool debuginfo_needed) sess.kernel_build_tree + string("'")); } - // XXX: it would be nice if we could do a single - // ..._report_offline call for an entire systemtap script, so - // that a selection predicate would filter out modules outside - // the union of all the requested wildcards. But we build - // derived_probes one-by-one and we don't have lookahead. - // PR 3498. - - // XXX: a special case: if we have only kernel.* probe points, - // we shouldn't waste time looking for module debug-info (and - // vice versa). - // NB: the result of an _offline call is the assignment of // virtualized addresses to relocatable objects such as // modules. These have to be converted to real addresses at diff --git a/dwflpp.h b/dwflpp.h index d6d97cd0..e0098b9b 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -178,7 +178,7 @@ struct dwflpp Dwarf_Die *query_cu_containing_address(Dwarf_Addr a); bool module_name_matches(const std::string& pattern); - bool name_has_wildcard(const std::string& pattern); + static bool name_has_wildcard(const std::string& pattern); bool module_name_final_match(const std::string& pattern); bool function_name_matches_pattern(const std::string& name, const std::string& pattern); diff --git a/tapsets.cxx b/tapsets.cxx index 4988b7e7..aecdca61 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -589,7 +589,7 @@ struct dwarf_query : public base_query struct dwarf_builder: public derived_probe_builder { - map kern_dw; + map kern_dw; /* NB: key string could be a wildcard */ map user_dw; dwarf_builder() {} diff --git a/testsuite/buildok/fortysix.stp b/testsuite/buildok/fortysix.stp new file mode 100755 index 00000000..013ca5bc --- /dev/null +++ b/testsuite/buildok/fortysix.stp @@ -0,0 +1,3 @@ +#! stap -p4 +// PR 3498 + wildcarded modules +probe module("*scsi*").function("*").call { } -- cgit