From: Josh Stone Date: Wed, 15 May 2013 19:51:33 +0000 (-0700) Subject: PR14297: Skip the user's input when scanning for resolved probes X-Git-Tag: release-2.2.1~9 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=a126c5b16ef6fdf1560f37628a1d4be38f2732be;p=systemtap.git PR14297: Skip the user's input when scanning for resolved probes * elaborate.cxx (derived_probe::script_location): Sweep the derivation chain from its second-to-last, so we get at least one level of resolution from the user's input. * testsuite/systemtap.base/list.exp: Add a case for kernel init_once, which demonstrates listing the @file:line is useful to disambiguate. Add a case for 'begin' too, the simplest expansion we have. --- diff --git a/elaborate.cxx b/elaborate.cxx index efae1666e..28282cd47 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -163,7 +163,11 @@ derived_probe::script_location () const vector chain; collect_derivation_pp_chain (chain); - for (int i=chain.size()-1; i>=0; i--) + // NB: we actually start looking from the second-to-last item, so the user's + // direct input is not considered. Input like 'kernel.function("init_once")' + // will thus be listed with the resolved @file:line too, disambiguating the + // distinct functions by this name, and matching our historical behavior. + for (int i=chain.size()-2; i>=0; i--) { probe_point pp_copy (* chain [i]); // drop any ?/! denotations that would confuse a glob-char search diff --git a/testsuite/systemtap.base/list.exp b/testsuite/systemtap.base/list.exp index 9cc4d9ecc..3e3fe94f7 100644 --- a/testsuite/systemtap.base/list.exp +++ b/testsuite/systemtap.base/list.exp @@ -85,3 +85,43 @@ expect { eof { fail $test } } catch { close }; catch { wait } + +set test init_once-glob +spawn stap -l {kernel.function("init_once*")} +expect { + -re {kernel.function."init_once@fs/inode.c:\d+".\r\n} { pass $test } + -re {^[^\r\n]*\r\n} { exp_continue } + timeout { fail $test } + eof { fail $test } +} +catch { close }; catch { wait } + +set test init_once-noglob +spawn stap -l {kernel.function("init_once")} +expect { + -re {kernel.function."init_once@fs/inode.c:\d+".\r\n} { pass $test } + -re {^[^\r\n]*\r\n} { exp_continue } + timeout { fail $test } + eof { fail $test } +} +catch { close }; catch { wait } + +set test begin-glob +spawn stap -l {begin*} +expect { + -re {begin\r\n} { pass $test } + -re {^[^\r\n]*\r\n} { exp_continue } + timeout { fail $test } + eof { fail $test } +} +catch { close }; catch { wait } + +set test begin-noglob +spawn stap -l {begin} +expect { + -re {begin\r\n} { pass $test } + -re {^[^\r\n]*\r\n} { exp_continue } + timeout { fail $test } + eof { fail $test } +} +catch { close }; catch { wait }