From 3213d0891c826f16ba727a3e863075e2922666a0 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 11 Aug 2008 13:18:12 -0400 Subject: [PATCH] PR5049: prefix with "*" any filenames given in "fn@filename:line" probes --- ChangeLog | 6 ++++++ tapsets.cxx | 15 ++++++++++++--- testsuite/ChangeLog | 5 +++++ testsuite/semok/thirtyone.stp | 5 +++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100755 testsuite/semok/thirtyone.stp diff --git a/ChangeLog b/ChangeLog index b312bc345..f0a2307d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-11 Frank Ch. Eigler + + PR5049 + * tapsets.cxx (cu_name_matches, collect_srcfiles_matching): + Implicitly prefix probe source filenames with "*". + 2008-08-09 Frank Ch. Eigler * main.cxx (main): Don't override $PATH etc. diff --git a/tapsets.cxx b/tapsets.cxx index d9e0ebda8..48947a601 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -850,9 +850,14 @@ struct dwflpp bool cu_name_matches(string pattern) { assert(cu); - bool t = (fnmatch(pattern.c_str(), cu_name.c_str(), 0) == 0); + + // PR 5049: implicit * in front of given path pattern. + // NB: fnmatch() is used without FNM_PATHNAME. + string prefixed_pattern = string("*") + pattern; + + bool t = (fnmatch(prefixed_pattern.c_str(), cu_name.c_str(), 0) == 0); if (t && sess.verbose>3) - clog << "pattern '" << pattern << "' " + clog << "pattern '" << prefixed_pattern << "' " << "matches " << "CU '" << cu_name << "'" << "\n"; return t; @@ -1292,13 +1297,17 @@ struct dwflpp size_t nfiles; Dwarf_Files *srcfiles; + // PR 5049: implicit * in front of given path pattern. + // NB: fnmatch() is used without FNM_PATHNAME. + string prefixed_pattern = string("*") + pattern; + dwarf_assert ("dwarf_getsrcfiles", dwarf_getsrcfiles (cu, &srcfiles, &nfiles)); { for (size_t i = 0; i < nfiles; ++i) { char const * fname = dwarf_filesrc (srcfiles, i, NULL, NULL); - if (fnmatch (pattern.c_str(), fname, 0) == 0) + if (fnmatch (prefixed_pattern.c_str(), fname, 0) == 0) { filtered_srcfiles.insert (fname); if (sess.verbose>2) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 9dd388ad5..9ee9037ed 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-11 Frank Ch. Eigler + + PR5049 + * semok/thirtyone.stp: New test. + 2008-08-05 Stan Cox * systemtap.base/warnings.stp: Use relative instead of absolute line. diff --git a/testsuite/semok/thirtyone.stp b/testsuite/semok/thirtyone.stp new file mode 100755 index 000000000..5036e45ca --- /dev/null +++ b/testsuite/semok/thirtyone.stp @@ -0,0 +1,5 @@ +#! stap -p2 + +# PR5049 + +probe kernel.function("*@module.c") {} -- 2.43.5