diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2009-07-08 13:04:10 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-07-08 13:09:36 -0400 |
commit | 665e12562a4aa4f40aeeed0cfd207b49f89c9fd1 (patch) | |
tree | 617016b8b0f71394217792ae7e571b4e40022383 | |
parent | 619d9aaf011c975159a79d34259083a596162bf1 (diff) | |
download | systemtap-steved-665e12562a4aa4f40aeeed0cfd207b49f89c9fd1.tar.gz systemtap-steved-665e12562a4aa4f40aeeed0cfd207b49f89c9fd1.tar.xz systemtap-steved-665e12562a4aa4f40aeeed0cfd207b49f89c9fd1.zip |
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.
-rw-r--r-- | dwflpp.cxx | 44 | ||||
-rw-r--r-- | dwflpp.h | 2 | ||||
-rw-r--r-- | tapsets.cxx | 2 | ||||
-rwxr-xr-x | testsuite/buildok/fortysix.stp | 3 |
4 files changed, 27 insertions, 24 deletions
@@ -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 @@ -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 <string,dwflpp*> kern_dw; + map <string,dwflpp*> kern_dw; /* NB: key string could be a wildcard */ map <string,dwflpp*> 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 { } |