summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjistone <jistone>2006-12-08 02:17:09 +0000
committerjistone <jistone>2006-12-08 02:17:09 +0000
commit16e8f21f336bcfc16a1174be8a8143668dbd0118 (patch)
treec967ecdec501b69910a16ee0f50317434ed49675
parente0d86324628566cedd055ed038fd487c12db676a (diff)
downloadsystemtap-steved-16e8f21f336bcfc16a1174be8a8143668dbd0118.tar.gz
systemtap-steved-16e8f21f336bcfc16a1174be8a8143668dbd0118.tar.xz
systemtap-steved-16e8f21f336bcfc16a1174be8a8143668dbd0118.zip
2006-12-07 Josh Stone <joshua.i.stone@intel.com>
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.
-rw-r--r--ChangeLog12
-rw-r--r--parse.cxx46
-rw-r--r--tapsets.cxx25
-rw-r--r--testsuite/ChangeLog13
-rw-r--r--testsuite/lib/stap_run.exp2
-rwxr-xr-xtestsuite/semok/beginend.stp11
-rw-r--r--testsuite/systemtap.base/be_order.exp7
-rw-r--r--testsuite/systemtap.base/be_order.stp37
-rw-r--r--testsuite/systemtap.base/maxactive.exp9
-rw-r--r--testsuite/systemtap.base/probefunc.exp4
-rw-r--r--testsuite/systemtap.samples/ioblocktest.exp2
-rw-r--r--testsuite/systemtap.samples/ioblocktest.stp2
-rw-r--r--testsuite/systemtap.samples/tcptest.exp4
13 files changed, 144 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index a250315f..703b3be8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-12-07 Josh Stone <joshua.i.stone@intel.com>
+
+ 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.
+
2006-12-06 Josh Stone <joshua.i.stone@intel.com>
PR 3623.
diff --git a/parse.cxx b/parse.cxx
index dd41a259..be9fd1d4 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -1277,25 +1277,37 @@ parser::parse_literal ()
literal* l;
if (t->type == tok_string)
l = new literal_string (t->content);
- else if (t->type == tok_number)
+ else
{
- const char* startp = t->content.c_str ();
- char* endp = (char*) startp;
-
- // NB: we allow controlled overflow from LLONG_MIN .. ULLONG_MAX
- // Actually, this allows all the way from -ULLONG_MAX to ULLONG_MAX,
- // since the lexer only gives us positive digit strings.
- errno = 0;
- long long value = (long long) strtoull (startp, & endp, 0);
- if (errno == ERANGE || errno == EINVAL || *endp != '\0'
- || (unsigned long long) value > 18446744073709551615ULL
- || value < -9223372036854775807LL-1)
- throw parse_error ("number invalid or out of range");
-
- l = new literal_number (value);
+ bool neg = false;
+ if (t->type == tok_operator && t->content == "-")
+ {
+ neg = true;
+ t = next ();
+ }
+
+ if (t->type == tok_number)
+ {
+ const char* startp = t->content.c_str ();
+ char* endp = (char*) startp;
+
+ // NB: we allow controlled overflow from LLONG_MIN .. ULLONG_MAX
+ // Actually, this allows all the way from -ULLONG_MAX to ULLONG_MAX,
+ // since the lexer only gives us positive digit strings.
+ errno = 0;
+ long long value = (long long) strtoull (startp, & endp, 0);
+ if (neg)
+ value = -value;
+ if (errno == ERANGE || errno == EINVAL || *endp != '\0'
+ || (unsigned long long) value > 18446744073709551615ULL
+ || value < -9223372036854775807LL-1)
+ throw parse_error ("number invalid or out of range");
+
+ l = new literal_number (value);
+ }
+ else
+ throw parse_error ("expected literal string or number");
}
- else
- throw parse_error ("expected literal string or number");
l->tok = t;
return l;
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<std::string, literal *> const & parameters,
vector<derived_probe *> & 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);
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 131bd06c..83a48057 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2006-12-07 Josh Stone <joshua.i.stone@intel.com>
+
+ PR 3624.
+ * 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.
+
2006-11-30 Martin Hunt <hunt@redhat.com>
* systemtap.samples/pfaults.exp: Fix regular expression
diff --git a/testsuite/lib/stap_run.exp b/testsuite/lib/stap_run.exp
index 63ad597c..68fceb32 100644
--- a/testsuite/lib/stap_run.exp
+++ b/testsuite/lib/stap_run.exp
@@ -52,7 +52,7 @@ proc stap_run { TEST_NAME {LOAD_GEN_FUNCTION ""} {OUTPUT_CHECK_STRING ""} args }
send "\003"
# check the output to see if it is sane
- set output "^systemtap ending probe\r\n$OUTPUT_CHECK_STRING"
+ set output "^systemtap ending probe\r\n$OUTPUT_CHECK_STRING$"
expect {
-re $output {
diff --git a/testsuite/semok/beginend.stp b/testsuite/semok/beginend.stp
new file mode 100755
index 00000000..a5fe7fda
--- /dev/null
+++ b/testsuite/semok/beginend.stp
@@ -0,0 +1,11 @@
+#! stap -p2
+
+probe begin {}
+probe begin(0) {}
+probe begin(9223372036854775807) {}
+probe begin(-9223372036854775808) {}
+
+probe end {}
+probe end(0) {}
+probe end(9223372036854775807) {}
+probe end(-9223372036854775808) {}
diff --git a/testsuite/systemtap.base/be_order.exp b/testsuite/systemtap.base/be_order.exp
new file mode 100644
index 00000000..a40c7684
--- /dev/null
+++ b/testsuite/systemtap.base/be_order.exp
@@ -0,0 +1,7 @@
+# Simple function to test that ordering of begin/end probes works
+
+load_lib "stap_run.exp"
+
+set test "be_order"
+
+stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string
diff --git a/testsuite/systemtap.base/be_order.stp b/testsuite/systemtap.base/be_order.stp
new file mode 100644
index 00000000..eb8ef0c8
--- /dev/null
+++ b/testsuite/systemtap.base/be_order.stp
@@ -0,0 +1,37 @@
+/*
+ * add.stp
+ *
+ * Check that ordering of begin/end probes works
+ */
+
+probe begin { log("systemtap starting probe") }
+probe end { log("systemtap ending probe") }
+
+global beginstr, endstr
+
+probe begin { beginstr .= "c" }
+probe begin(1) { beginstr .= "d" }
+probe begin(-1) { beginstr .= "b" }
+probe begin(0) { beginstr .= "c" }
+probe begin(9223372036854775807) { beginstr .= "e" }
+probe begin(-9223372036854775808) { beginstr .= "a" }
+
+probe end { endstr .= "x" }
+probe end(1) { endstr .= "y" }
+probe end(-1) { endstr .= "w" }
+probe end(0) { endstr .= "x" }
+probe end(9223372036854775807) {
+ endstr .= "z"
+
+ if (beginstr == "abccde")
+ log("systemtap test success")
+ else
+ printf("systemtap test failure - beginstr:%s != abccde\n", beginstr)
+
+ if (endstr == "vwxxyz")
+ log("systemtap test success")
+ else
+ printf("systemtap test failure - endstr:%s != vwxxyz\n", endstr)
+}
+probe end(-9223372036854775808) { endstr .= "v" }
+
diff --git a/testsuite/systemtap.base/maxactive.exp b/testsuite/systemtap.base/maxactive.exp
index b5cb7dd7..8754ff6e 100644
--- a/testsuite/systemtap.base/maxactive.exp
+++ b/testsuite/systemtap.base/maxactive.exp
@@ -3,6 +3,8 @@
# Check to see if using the 'maxactive(N)' limit on return probes
# works, by seeing if skipped probes increases when using it.
+load_lib "stap_run.exp"
+
if {[info procs installtest_p] != "" && ![installtest_p]} {
untested "MAXACTIVE"
return
@@ -42,7 +44,8 @@ set script2 {
}
# Run script2 and save the number of skipped probes.
-stap_run "MAXACTIVE02" sleep_five_sec "" -e $script2
+set output_string "(WARNING: Number of errors: 0, skipped probes: \\d+\r\n)?"
+stap_run "MAXACTIVE02" sleep_five_sec $output_string -e $script2
set skipped2 $skipped_probes
# If the number of skipped probes for script 1 is less than the number
@@ -52,8 +55,8 @@ set skipped2 $skipped_probes
# Note that this isn't 100% accurate based on the system load at the
# time of the scripts.
set test "MAXACTIVE03"
-if {$skipped1 < $skipped2} {
- pass "$test ($skipped1 skipped probes < $skipped2 skipped probes)"
+if {$skipped1 <= $skipped2} {
+ pass "$test ($skipped1 skipped probes <= $skipped2 skipped probes)"
} else {
fail "$test ($skipped1 skipped probes > $skipped2 skipped probes)"
}
diff --git a/testsuite/systemtap.base/probefunc.exp b/testsuite/systemtap.base/probefunc.exp
index 10190fc9..b9c02552 100644
--- a/testsuite/systemtap.base/probefunc.exp
+++ b/testsuite/systemtap.base/probefunc.exp
@@ -41,7 +41,7 @@ close $symfd
set prefix "probefunc:"
# test probefunc() with kernel.statement()
-set output_string "\\mscheduler_tick\\M"
+set output_string "\\mscheduler_tick\\M\r\n"
set probepoint "kernel.statement(0x$addr)"
set script [format $systemtap_script $probepoint]
stap_run $prefix$probepoint sleep_one_sec $output_string -e $script
@@ -52,7 +52,7 @@ set script [format $systemtap_script $probepoint]
stap_run $prefix$probepoint sleep_one_sec $output_string -e $script
# test probefunc() with kernel.inline()
-set output_string "\\mcontext_switch\\M"
+set output_string "\\mcontext_switch\\M\r\n"
set probepoint "kernel.inline(\"context_switch\")"
set script [format $systemtap_script $probepoint]
stap_run $prefix$probepoint sleep_one_sec $output_string -e $script
diff --git a/testsuite/systemtap.samples/ioblocktest.exp b/testsuite/systemtap.samples/ioblocktest.exp
index 43c44f5e..e80ec757 100644
--- a/testsuite/systemtap.samples/ioblocktest.exp
+++ b/testsuite/systemtap.samples/ioblocktest.exp
@@ -8,5 +8,5 @@ proc sleep_ten_secs {} {
return 0;
}
-set output_string "\\mioblock*"
+set output_string "ioblock: \\S+\t\\d+\t\[RW]\t\[01]\r\n"
stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string
diff --git a/testsuite/systemtap.samples/ioblocktest.stp b/testsuite/systemtap.samples/ioblocktest.stp
index 1386903c..43b3e7d0 100644
--- a/testsuite/systemtap.samples/ioblocktest.stp
+++ b/testsuite/systemtap.samples/ioblocktest.stp
@@ -10,5 +10,5 @@ probe ioblock.end {
}
probe end {
log("systemtap ending probe")
- printf("%s\n", teststr)
+ printf("%s", teststr)
}
diff --git a/testsuite/systemtap.samples/tcptest.exp b/testsuite/systemtap.samples/tcptest.exp
index 0c40f93d..0ae088ef 100644
--- a/testsuite/systemtap.samples/tcptest.exp
+++ b/testsuite/systemtap.samples/tcptest.exp
@@ -7,5 +7,7 @@ proc tcp_gen { } {
exec $::tcp_tcl 1
return 0
}
-set output_string "\\mTCP totalbytes: \\d+\\M"
+set output_header "UID\tPID\tSIZE\tNAME\t\t\tPORT\tSOURCE\t\tRTO\tRCVMSS\tSSTHRES\tCWND\tSTATE\r\n"
+set output_rows "((\\d+\t\\d+\t\\d+\t\\S+\t\t\t\\d+\t\\S*\t\\d+\t\\d+\t\\d+\t\\d+\t\\d+)?\r\n){5}"
+set output_string "TCP totalbytes: \\d+\r\n$output_header$output_rows"
stap_run $srcdir/$subdir/$test.stp tcp_gen $output_string