From 16e8f21f336bcfc16a1174be8a8143668dbd0118 Mon Sep 17 00:00:00 2001 From: jistone Date: Fri, 8 Dec 2006 02:17:09 +0000 Subject: 2006-12-07 Josh Stone PR 3624. * tapsets.cxx (struct be_derived_probe): Add a new priority parameter for begin/end probes, and a comparison function for sorting. (be_builder::build): Parse the priority & pass it to be_derived_probe. (be_derived_probe_group::emit_module_init, emit_module_exit): Sort the probe list by priority before emitting any code. (register_standard_tapsets): Add new begin/end variants. * parse.cxx (parser::parse_literal): Allow negative numeric literals, by checking for a '-' unary operator right before a number. testsuite/ * systemtap.base/be_order.exp, systemtap.base/be_order.stp, semok/beginend.stp: New tests for begin/end priorities. * lib/stap_run.exp: Anchor OUTPUT_CHECK_STRING to the end of output. * systemtap.base/maxactive.exp: Fix to compare output to the end. * systemtap.base/probefunc.exp: Ditto. * systemtap.samples/ioblocktest.exp: Ditto. * systemtap.samples/ioblocktest.stp: Ditto. * systemtap.samples/tcptest.exp: Ditto. --- tapsets.cxx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index a71b352e..73e3ed11 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -110,11 +110,18 @@ public: struct be_derived_probe: public derived_probe { bool begin; - be_derived_probe (probe* p, bool b): derived_probe (p), begin (b) {} - be_derived_probe (probe* p, probe_point* l, bool b): - derived_probe (p, l), begin (b) {} + int64_t priority; + + be_derived_probe (probe* p, bool b, int64_t pr): + derived_probe (p), begin (b), priority (pr) {} + be_derived_probe (probe* p, probe_point* l, bool b, int64_t pr): + derived_probe (p, l), begin (b), priority (pr) {} void join_group (systemtap_session& s); + + static inline bool comp(be_derived_probe const *a, + be_derived_probe const *b) + { return a->priority < b->priority; } }; @@ -137,7 +144,12 @@ struct be_builder: public derived_probe_builder std::map const & parameters, vector & finished_results) { - finished_results.push_back(new be_derived_probe(base, location, begin)); + int64_t priority; + if ((begin && !get_param(parameters, "begin", priority)) + || (!begin && !get_param(parameters, "end", priority))) + priority = 0; + finished_results.push_back( + new be_derived_probe(base, location, begin, priority)); } }; @@ -286,6 +298,7 @@ be_derived_probe_group::emit_module_init (systemtap_session& s) { // if (probes.empty()) return; bool have_begin_probes = false; + sort(probes.begin(), probes.end(), be_derived_probe::comp); for (unsigned i=0; i < probes.size (); i++) if (probes[i]->begin) { @@ -303,6 +316,7 @@ void be_derived_probe_group::emit_module_exit (systemtap_session& s) { // if (probes.empty()) return; + sort(probes.begin(), probes.end(), be_derived_probe::comp); for (unsigned i=0; i < probes.size (); i++) if (! probes[i]->begin) // note polarity s.op->newline() << "enter_end_probe (& " << probes[i]->name << ");"; @@ -5168,7 +5182,10 @@ void register_standard_tapsets(systemtap_session & s) { s.pattern_root->bind("begin")->bind(new be_builder(true)); + s.pattern_root->bind_num("begin")->bind(new be_builder(true)); s.pattern_root->bind("end")->bind(new be_builder(false)); + s.pattern_root->bind_num("end")->bind(new be_builder(false)); + s.pattern_root->bind("never")->bind(new never_builder()); timer_builder::register_patterns(s.pattern_root); -- cgit