summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-03-04 11:55:56 +0100
committerMark Wielaard <mjw@redhat.com>2009-03-04 11:55:56 +0100
commitcd1db1dd034141535648a66d9896db6c5e74dd9e (patch)
tree74d83c6785aa4b1348ea89a0d7f7fa8f6e641a2f
parent46cfaf7b18b1d8dfa3e827f3b32d0e8f66e8399f (diff)
downloadsystemtap-steved-cd1db1dd034141535648a66d9896db6c5e74dd9e.tar.gz
systemtap-steved-cd1db1dd034141535648a66d9896db6c5e74dd9e.tar.xz
systemtap-steved-cd1db1dd034141535648a66d9896db6c5e74dd9e.zip
PR9919: Set last_stmt for array (scalar or statistical) assignments.
* translate.cxx (visit_arrayindex): Update last_stmt.
-rw-r--r--testsuite/systemtap.base/overflow_error.exp32
-rw-r--r--testsuite/systemtap.base/overflow_error.stp22
-rw-r--r--translate.cxx4
3 files changed, 56 insertions, 2 deletions
diff --git a/testsuite/systemtap.base/overflow_error.exp b/testsuite/systemtap.base/overflow_error.exp
new file mode 100644
index 00000000..33be90a7
--- /dev/null
+++ b/testsuite/systemtap.base/overflow_error.exp
@@ -0,0 +1,32 @@
+# Test overflow errors point to the correct thing.
+
+set test "overflow_error"
+if {![installtest_p]} { untested $test; return }
+
+set error_msg1 "ERROR: Array overflow, check size limit (3) near identifier 'overflow1' at $srcdir/$subdir/$test.stp"
+set error_msg2 "ERROR: Array overflow, check size limit (5) near identifier 'overflow2' at $srcdir/$subdir/$test.stp"
+set exit_warning "WARNING: Number of errors: 2, skipped probes: 0"
+
+set pass 0
+
+spawn stap -DMAXERRORS=1 $srcdir/$subdir/$test.stp
+expect {
+ $error_msg1 {incr pass; exp_continue}
+ $error_msg2 {incr pass; exp_continue}
+ $exit_warning {incr pass; exp_continue}
+ timeout {
+ exec kill -INT -[exp_pid]
+ fail "$test timed out"
+ }
+ eof {}
+}
+catch { close }
+wait
+
+if {$pass == 3} {
+ pass $test
+} else {
+ fail "$test ($pass)"
+}
+
+
diff --git a/testsuite/systemtap.base/overflow_error.stp b/testsuite/systemtap.base/overflow_error.stp
new file mode 100644
index 00000000..f5a3e917
--- /dev/null
+++ b/testsuite/systemtap.base/overflow_error.stp
@@ -0,0 +1,22 @@
+# overflow some stuff to see if error message point to the correct thing.
+global count;
+global overflow1[3];
+global overflow2[5];
+
+probe timer.ms(10)
+{
+ if (count <= 3)
+ {
+ overflow1[count++] = gettimeofday_ns();
+ }
+ else
+ {
+ overflow2[count++] <<< gettimeofday_ns();
+ }
+}
+
+probe timer.s(3)
+{
+ exit();
+}
+
diff --git a/translate.cxx b/translate.cxx
index 655937d7..23a24100 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -3882,7 +3882,7 @@ c_unparser_assignment::visit_arrayindex (arrayindex *e)
assert (rvalue->type == pe_long);
mapvar mvar = parent->getmap (array->referent, e->tok);
- // o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
+ o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
o->newline() << mvar.add (idx, rvar) << ";";
res = rvar;
// no need for these dummy assignments
@@ -3892,7 +3892,7 @@ c_unparser_assignment::visit_arrayindex (arrayindex *e)
else
{
mapvar mvar = parent->getmap (array->referent, e->tok);
- // o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
+ o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
if (op != "=") // don't bother fetch slot if we will just overwrite it
parent->c_assign (lvar, mvar.get(idx), e->tok);
c_assignop (res, lvar, rvar, e->tok);