summaryrefslogtreecommitdiffstats
path: root/elaborate.cxx
diff options
context:
space:
mode:
authorfche <fche>2007-11-20 03:59:19 +0000
committerfche <fche>2007-11-20 03:59:19 +0000
commitd898100ab001dd4b3465f738dad76d1d646c3261 (patch)
treeeb20e3219db643c07802dbec890b704e44b87458 /elaborate.cxx
parent3b0c565c2b75d777c3993f0284185b5aa4c3528d (diff)
downloadsystemtap-steved-d898100ab001dd4b3465f738dad76d1d646c3261.tar.gz
systemtap-steved-d898100ab001dd4b3465f738dad76d1d646c3261.tar.xz
systemtap-steved-d898100ab001dd4b3465f738dad76d1d646c3261.zip
PR 3887: sufficient+optional probe points
2007-11-19 Frank Ch. Eigler <fche@elastic.org> PR 3887. * staptree.h (probe_point): Add "sufficient" field. * staptree.cxx: Initialize it, print it. * parse.cxx (parse_probe_point): Parse it. * elaborate.cxx (derive_probes): Implement it. * stapprobes.5.in: Document it. * NEWS: Gloat about it. * parseok/five.stp, semok/twentyseven.stp: Test "!" probe point flag. * iostat-scsi.stp: Adopt "!" probe point flag.
Diffstat (limited to 'elaborate.cxx')
-rw-r--r--elaborate.cxx42
1 files changed, 29 insertions, 13 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index d86cc37d..aa6529fa 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -553,23 +553,40 @@ derive_probes (systemtap_session& s,
{
probe_point *loc = p->locations[i];
- // Pass down optional flag from e.g. alias reference to each
- // probe_point instance. We do this by temporarily overriding
- // the probe_point optional flag. We could instead deep-copy
- // and set a flag on the copy permanently.
-
- bool old_loc_opt = loc->optional;
- loc->optional = loc->optional || optional;
-
try
{
unsigned num_atbegin = dps.size();
- s.pattern_root->find_and_build (s, p, loc, 0, dps);
+
+ // Pass down optional flag from e.g. alias reference to each
+ // probe_point instance. We do this by temporarily overriding
+ // the probe_point optional flag. We could instead deep-copy
+ // 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!
+ loc->optional = old_loc_opt;
unsigned num_atend = dps.size();
-
- if (! loc->optional && // something required, but
+
+ if (! (loc->optional||optional) && // something required, but
num_atbegin == num_atend) // nothing new derived!
- throw semantic_error ("no match for probe point");
+ throw semantic_error ("no match");
+
+ if (loc->sufficient && (num_atend > num_atbegin))
+ {
+ if (s.verbose > 1)
+ {
+ clog << "Probe point ";
+ p->locations[i]->print(clog);
+ clog << " sufficient, skipped";
+ for (unsigned j = i+1; j < p->locations.size(); ++j)
+ {
+ clog << " ";
+ p->locations[j]->print(clog);
+ }
+ clog << endl;
+ }
+ break; // we need not try to derive for any other locations
+ }
}
catch (const semantic_error& e)
{
@@ -584,7 +601,6 @@ derive_probes (systemtap_session& s,
delete er;
}
- loc->optional = old_loc_opt;
}
}