diff options
-rw-r--r-- | elaborate.cxx | 16 | ||||
-rw-r--r-- | testsuite/systemtap.base/optionalprobe.stp | 10 |
2 files changed, 21 insertions, 5 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index 53f2a8f6..6fb3f197 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -406,9 +406,6 @@ match_node::find_and_build (systemtap_session& s, sub_map_iterator_t i = sub.find (match); if (i == sub.end()) // no match { - if (loc->optional) /* PR10102: to tolerate mismatched optional probe */ - return; - string alternatives; for (sub_map_iterator_t i = sub.begin(); i != sub.end(); i++) alternatives += string(" ") + i->first.str(); @@ -633,7 +630,18 @@ derive_probes (systemtap_session& s, // and set a flag on the copy permanently. bool old_loc_opt = loc->optional; loc->optional = loc->optional || optional; - s.pattern_root->find_and_build (s, p, loc, 0, dps); // <-- actual derivation! + try + { + s.pattern_root->find_and_build (s, p, loc, 0, dps); // <-- actual derivation! + } + catch (const semantic_error& e) + { + if (!loc->optional) + throw semantic_error(e); + else /* tolerate failure for optional probe */ + continue; + } + loc->optional = old_loc_opt; unsigned num_atend = dps.size(); diff --git a/testsuite/systemtap.base/optionalprobe.stp b/testsuite/systemtap.base/optionalprobe.stp index 239cf6e3..13918cee 100644 --- a/testsuite/systemtap.base/optionalprobe.stp +++ b/testsuite/systemtap.base/optionalprobe.stp @@ -2,5 +2,13 @@ # test optional probe -probe foo ?, bar !, foo* ?, bar* !, begin { +probe foo ?, + process("/do/not/exist").function("main") !, + kernel.mark("no such mark") ?, + kernel.trace("no trace") !, + process.foo ?, + kernel.statement("no statement") !, + module("no mod").function("*") ?, + kernel.function("no such func*") !, + begin { } |