catch {close}; catch {wait}
if {$ok == 6} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
+ # test PR17749
+ set test "global_end_var_used"
+ if {$runtime != ""} {
+ set test "${test}_${runtime}"
+ spawn stap $srcdir/$subdir/global_end_var_used.stp --runtime=$runtime
+ } else {
+ spawn stap $srcdir/$subdir/global_end_var_used.stp
+ }
+ set ok 0
+ # strictly look for "hello". if anything else is printed it's a fail.
+ expect {
+ -timeout 180
+ -re {^hello!$} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+ }
+ catch {close}; catch {wait}
+
+ if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
}
--- /dev/null
+// None of these global vars should be
+// autoprinted because they are all used
+
+global a // if condition
+global b // function arg
+
+global arr // used in foreach
+global c // foreach array slice
+global d // foreach limit
+
+global e // return value
+global f // ternary cond
+global g // while condition
+global h // arrayindex index
+
+function foo(b) {
+ if (b)
+ printf("e")
+}
+
+function bar() {
+ return ++e;
+}
+
+probe oneshot {
+
+ if (++a)
+ printf("h")
+
+ foo(++b)
+
+ arr[1,1] = 1
+ foreach ([i,j] in arr[*,++c] limit ++d) {
+ printf("l")
+ }
+
+ if (bar()) {
+ printf("l")
+ }
+
+ ++f ? printf("o") : printf("");
+
+ while (!g++)
+ printf("!")
+
+ arr[++h, 1]++
+}