summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/alternatives.exp17
-rw-r--r--testsuite/systemtap.base/badkprobe.exp32
-rw-r--r--testsuite/systemtap.base/bitfield.exp3
-rw-r--r--testsuite/systemtap.base/bitfield.stp46
-rw-r--r--testsuite/systemtap.base/bz10078.c22
-rw-r--r--testsuite/systemtap.base/bz10078.exp35
-rwxr-xr-xtestsuite/systemtap.base/bz10078.stp4
-rwxr-xr-xtestsuite/systemtap.base/bz5274.exp9
-rw-r--r--testsuite/systemtap.base/bz6850.exp9
-rw-r--r--testsuite/systemtap.base/cast.exp6
-rw-r--r--testsuite/systemtap.base/cast.stp25
-rw-r--r--testsuite/systemtap.base/flightrec1.exp43
-rw-r--r--testsuite/systemtap.base/flightrec2.exp68
-rw-r--r--testsuite/systemtap.base/flightrec2.stp5
-rw-r--r--testsuite/systemtap.base/flightrec3.exp79
-rw-r--r--testsuite/systemtap.base/flightrec3.stp5
-rw-r--r--testsuite/systemtap.base/itrace.exp49
-rw-r--r--testsuite/systemtap.base/kprobes.exp2
-rw-r--r--testsuite/systemtap.base/kprobes.stp25
-rw-r--r--testsuite/systemtap.base/labels.exp82
-rw-r--r--testsuite/systemtap.base/maxactive.exp16
-rw-r--r--testsuite/systemtap.base/onoffprobe.stp4
-rw-r--r--testsuite/systemtap.base/optionalprobe.exp9
-rw-r--r--testsuite/systemtap.base/optionalprobe.stp14
-rw-r--r--testsuite/systemtap.base/overload.exp2
-rw-r--r--testsuite/systemtap.base/sdt.exp28
-rw-r--r--testsuite/systemtap.base/sdt.stp20
-rw-r--r--testsuite/systemtap.base/sdt_types.c168
-rw-r--r--testsuite/systemtap.base/sdt_types.stp371
-rw-r--r--testsuite/systemtap.base/skipped.exp6
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp100
-rw-r--r--testsuite/systemtap.base/stmt_rel.exp46
-rw-r--r--testsuite/systemtap.base/stmt_rel.stp71
-rw-r--r--testsuite/systemtap.base/stmtvars.exp6
-rw-r--r--testsuite/systemtap.base/strftime.exp49
-rw-r--r--testsuite/systemtap.base/system_func.stp4
-rw-r--r--testsuite/systemtap.base/tracepoints.exp23
-rw-r--r--testsuite/systemtap.base/uprobes.exp9
-rw-r--r--testsuite/systemtap.base/uprobes_exe.c29
-rw-r--r--testsuite/systemtap.base/uprobes_lib.c21
-rw-r--r--testsuite/systemtap.base/uprobes_lib.exp46
-rw-r--r--testsuite/systemtap.base/uprobes_lib.stp15
-rw-r--r--testsuite/systemtap.base/uprobes_uname.exp46
-rw-r--r--testsuite/systemtap.base/uprobes_uname.stp7
-rw-r--r--testsuite/systemtap.base/uprobes_ustack.exp97
-rw-r--r--testsuite/systemtap.base/uprobes_ustack.stp35
-rw-r--r--testsuite/systemtap.base/utrace_p4.exp34
-rw-r--r--testsuite/systemtap.base/utrace_p5.exp21
-rw-r--r--testsuite/systemtap.base/utrace_syscall_args.c67
-rw-r--r--testsuite/systemtap.base/utrace_syscall_args.exp82
-rw-r--r--testsuite/systemtap.base/utrace_syscall_args.stp406
-rw-r--r--testsuite/systemtap.base/x86_gs.exp12
-rw-r--r--testsuite/systemtap.base/x86_gs.stp10
53 files changed, 2170 insertions, 270 deletions
diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp
index deaf3bf8..f5dc4513 100644
--- a/testsuite/systemtap.base/alternatives.exp
+++ b/testsuite/systemtap.base/alternatives.exp
@@ -14,11 +14,11 @@
# listed, but that some alternatives are listed.
set local1_script {
- probe kernel.function("sys_getrlimit") { x = $z; }
+ probe kernel.function("vfs_write") { ret = $z; }
}
set struct1_script {
- probe kernel.function("sys_getrlimit") { rlim_cur = $rlim->rlim_cud; }
+ probe kernel.function("vfs_write") { f_pos = $file->f_po; }
}
proc stap_run_alternatives {args} {
@@ -26,10 +26,11 @@ proc stap_run_alternatives {args} {
verbose -log "starting $args"
eval spawn $args
expect {
+ -timeout 60
-re {semantic error: .+ \(alternatives: [a-zA-Z_]} {incr alternatives_found; exp_continue}
-re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue }
- eof { }
- timeout { }
+ eof { verbose -log "EOF" }
+ timeout { verbose -log "TIMEOUT" }
}
set results [wait]
verbose -log "wait results: $results"
@@ -37,9 +38,9 @@ proc stap_run_alternatives {args} {
}
set test "LOCAL1"
-set rc [stap_run_alternatives stap -vu -p2 -e $local1_script]
-if {$rc == 1} { pass $test } else { fail "$test ($rc)" }
+set rc [stap_run_alternatives stap -u -p2 -e $local1_script]
+if {$rc >= 1} { pass $test } else { fail "$test ($rc)" }
set test "STRUCT1"
-set rc [stap_run_alternatives stap -vu -p2 -e $struct1_script]
-if {$rc == 1} { pass $test } else { fail "$test ($rc)" }
+set rc [stap_run_alternatives stap -u -p2 -e $struct1_script]
+if {$rc >= 1} { pass $test } else { fail "$test ($rc)" }
diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp
index efc06695..c0815fbe 100644
--- a/testsuite/systemtap.base/badkprobe.exp
+++ b/testsuite/systemtap.base/badkprobe.exp
@@ -1,14 +1,28 @@
-set script "probe kernel.statement(-1).absolute {} probe timer.s(1) { exit() }"
set test "bad kprobe registration"
+set script {
+ probe $1 {}
+ probe timer.s(1) { exit() }
+ probe end { println("cleanup ok") }
+}
if {! [installtest_p]} { untested $test; return }
-spawn stap -g -w -e "$script"
-expect {
- -timeout 60
- -re "^WARNING: probe .*registration error.*" { pass $test }
- eof { fail "$test (eof)" }
- timeout { fail "$test (timeout)" }
+set bad_kprobes {
+ kernel.statement(-1).absolute
+ kprobe.statement(-1).absolute
+ kprobe.function("no_such_function")
+ kprobe.function("no_such_function").return
+}
+
+foreach bk $bad_kprobes {
+ set test "bad kprobe registration: $bk"
+ spawn stap -g -w -e "$script" "$bk"
+ expect {
+ -timeout 60
+ -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test }
+ eof { fail "$test (eof)" }
+ timeout { fail "$test (timeout)" }
+ }
+ catch {close}
+ catch {wait}
}
-catch {close}
-catch {wait}
diff --git a/testsuite/systemtap.base/bitfield.exp b/testsuite/systemtap.base/bitfield.exp
new file mode 100644
index 00000000..16451369
--- /dev/null
+++ b/testsuite/systemtap.base/bitfield.exp
@@ -0,0 +1,3 @@
+# test that bitfield r/w works correctly
+set test "bitfield"
+stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g
diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp
new file mode 100644
index 00000000..c2ff4929
--- /dev/null
+++ b/testsuite/systemtap.base/bitfield.stp
@@ -0,0 +1,46 @@
+%{
+#include <linux/tcp.h>
+static struct tcphdr foo = {0};
+%}
+
+function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %}
+function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %}
+function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %}
+
+function check:long(ack:long, urg:long) {
+ ptr = get_ptr()
+
+ /* set the bits with cast */
+ @cast(ptr, "tcphdr")->ack = ack
+ @cast(ptr, "tcphdr")->urg = urg
+
+ /* check that reading with embedded-C is ok */
+ real_ack = get_ack()
+ real_urg = get_urg()
+ errors = (ack != real_ack) + (urg != real_urg)
+
+ /* check that reading with a cast is ok */
+ cast_ack = @cast(ptr, "tcphdr")->ack
+ cast_urg = @cast(ptr, "tcphdr")->urg
+ errors += (ack != cast_ack) + (urg != cast_urg)
+
+ if (errors)
+ printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n",
+ errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg)
+
+ return errors
+}
+
+probe begin {
+ println("systemtap starting probe")
+
+ errors = check(0, 0)
+ errors += check(0, 1)
+ errors += check(1, 0)
+ errors += check(1, 1)
+
+ println("systemtap ending probe")
+ if (errors == 0)
+ println("systemtap test success")
+ exit()
+}
diff --git a/testsuite/systemtap.base/bz10078.c b/testsuite/systemtap.base/bz10078.c
new file mode 100644
index 00000000..9075fbc7
--- /dev/null
+++ b/testsuite/systemtap.base/bz10078.c
@@ -0,0 +1,22 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+struct point { int x, y; };
+
+struct point mkpoint2(void)
+{
+ struct point p = { 1, 2 };
+ return p;
+}
+
+struct point mkpoint1(void)
+{
+ return mkpoint2();
+}
+
+main()
+{
+ struct point p = mkpoint1();
+ printf("%d,%d\n", p.x, p.y);
+ exit(0);
+}
diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp
new file mode 100644
index 00000000..cad3a3a8
--- /dev/null
+++ b/testsuite/systemtap.base/bz10078.exp
@@ -0,0 +1,35 @@
+set test bz10078
+
+catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err
+if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" }
+
+if {![utrace_p]} {
+ catch {exec rm -f $test}
+ untested "$test -p4"
+ untested "$test -p5"
+ return
+}
+
+set rc [stap_run_batch $srcdir/$subdir/$test.stp]
+if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" }
+
+if {! [installtest_p]} {
+ catch {exec rm -f $test}
+ untested "$test -p5"
+ return
+}
+
+# Pick up the stap being tested.
+set stapexe [exec /usr/bin/which stap]
+spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test
+set ok 0
+expect {
+ -timeout 60
+ -re {mkpoint[^\r\n]* returns\r\n} { incr ok; exp_continue }
+ -re {1,2\r\n} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+if {$ok == 3} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" }
+exec rm -f $test
diff --git a/testsuite/systemtap.base/bz10078.stp b/testsuite/systemtap.base/bz10078.stp
new file mode 100755
index 00000000..0318e4e9
--- /dev/null
+++ b/testsuite/systemtap.base/bz10078.stp
@@ -0,0 +1,4 @@
+#! stap -p4
+probe process("./bz10078").function("mkpoint*").return {
+ printf("%s returns\n", probefunc())
+}
diff --git a/testsuite/systemtap.base/bz5274.exp b/testsuite/systemtap.base/bz5274.exp
index 92441e9e..2f76a43f 100755
--- a/testsuite/systemtap.base/bz5274.exp
+++ b/testsuite/systemtap.base/bz5274.exp
@@ -17,14 +17,7 @@ if {! [installtest_p]} {
return
}
-# Try to find utrace_attach symbol in /proc/kallsyms
-# copy from utrace_p5.exp
-set utrace_support_found 0
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
catch {exec rm -f $test}
untested "$test -p5"
return
diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp
index b96ed95c..32ecdaf5 100644
--- a/testsuite/systemtap.base/bz6850.exp
+++ b/testsuite/systemtap.base/bz6850.exp
@@ -3,14 +3,7 @@ set test bz6850
catch {exec gcc -g -o bz6850 $srcdir/$subdir/bz6850.c} err
if {$err == "" && [file exists bz6850]} then { pass "$test compile" } else { fail "$test compile" }
-# Try to find utrace_attach symbol in /proc/kallsyms
-# copy from utrace_p5.exp
-set utrace_support_found 0
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
catch {exec rm -f $test}
untested "$test -p4"
untested "$test -p5"
diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp
index df3246e8..374132f0 100644
--- a/testsuite/systemtap.base/cast.exp
+++ b/testsuite/systemtap.base/cast.exp
@@ -1,4 +1,6 @@
set test "cast"
set ::result_string {PID OK
-execname OK}
-stap_run2 $srcdir/$subdir/$test.stp
+PID2 OK
+execname OK
+sa_data OK}
+stap_run2 $srcdir/$subdir/$test.stp -g
diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp
index bec0cc9b..e2505000 100644
--- a/testsuite/systemtap.base/cast.stp
+++ b/testsuite/systemtap.base/cast.stp
@@ -10,6 +10,13 @@ probe begin
else
printf("PID %d != %d\n", pid, cast_pid)
+ // Compare PIDs using a generated kernel module
+ cast_pid = @cast(curr, "task_struct", "kernel<linux/sched.h>")->tgid
+ if (pid == cast_pid)
+ println("PID2 OK")
+ else
+ printf("PID2 %d != %d\n", pid, cast_pid)
+
// Compare execnames
name = execname()
cast_name = kernel_string(@cast(curr, "task_struct")->comm)
@@ -18,5 +25,23 @@ probe begin
else
printf("execname \"%s\" != \"%s\"\n", name, cast_name)
+ // Compare sa_data using a generated user module
+ data = 42
+ cast_data = @cast(get_sockaddr(data), "sockaddr", "<sys/socket.h>")->sa_data[0]
+ if (data == cast_data)
+ println("sa_data OK")
+ else
+ printf("sa_data %d != %d\n", data, cast_data)
+
exit()
}
+
+%{
+#include <linux/socket.h>
+%}
+
+function get_sockaddr:long(data:long) %{
+ static struct sockaddr sa = {0};
+ sa.sa_data[0] = THIS->data;
+ THIS->__retvalue = (long)&sa;
+%}
diff --git a/testsuite/systemtap.base/flightrec1.exp b/testsuite/systemtap.base/flightrec1.exp
new file mode 100644
index 00000000..c32a77f2
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec1.exp
@@ -0,0 +1,43 @@
+set test "flightrec1"
+if {![installtest_p]} { untested $test; return }
+
+# run stapio in background mode
+spawn stap -F -o $test.out -we {probe begin {}}
+# check whether stap outputs stapio pid
+set pid 0
+expect {
+ -timeout 240
+ -re {([0-9]+)\r\n} {
+ pass "$test (flight recorder option)"
+ set pid $expect_out(1,string)
+ exp_continue}
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+if {$pid == 0} {
+ fail "$test (no pid)"
+ return -1
+}
+
+# check whether stapio is running in background
+spawn ps -o cmd hc $pid
+expect {
+ -timeout 10
+ "stapio" {pass "$test (stapio in background)"} # don't contine
+ timeout { fail "$test (timeout)"}
+ eof { fail "$test (stapio was not found)" }
+}
+wait
+
+exec kill -TERM $pid
+
+# check output file
+if {[catch {exec rm $test.out}]} {
+ fail "$test (no output file)"
+ return -1
+} else {
+ pass "$test (output file)"
+}
+
+
diff --git a/testsuite/systemtap.base/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp
new file mode 100644
index 00000000..d4481db4
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec2.exp
@@ -0,0 +1,68 @@
+set test "flightrec2"
+if {![installtest_p]} { untested $test; return }
+
+# cleanup
+system "rm -f flightlog.out*"
+
+set pid 0
+# check -S option
+spawn stap -F -o flightlog.out -S 1,3 $srcdir/$subdir/$test.stp
+expect {
+ -timeout 240
+ -re {([0-9]+)\r\n} {
+ pass "$test (-S option)"
+ set pid $expect_out(1,string)
+ exp_continue}
+ timeout { fail "$test (timeout)"}
+ eof { }
+}
+wait
+if {$pid == 0} {
+ fail "$test (no pid)"
+ return -1
+}
+
+exec sleep 4
+set scnt 0
+set cnt1 0
+# wait for log files
+eval spawn stat -c %s [glob flightlog.out.*]
+expect {
+ -timeout 100
+ -re {[0-9]+} {
+ incr cnt1;
+ if {$expect_out(buffer) <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+exec sleep 3
+set cnt2 0
+# wait for log files
+eval spawn stat -c %s [glob flightlog.out.*]
+expect {
+ -timeout 100
+ -re {[0-9]+} {
+ incr cnt2;
+ if {$expect_out(buffer) <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+# check logfile number
+if {$cnt1 == 3 && $cnt2 == 3} {
+ pass "$test (log file numbers limitation)"
+} else {
+ fail "$test (log file numbers ($cnt1, $cnt2))"
+}
+# check logfile size
+if {$scnt == $cnt1 + $cnt2 } {
+ pass "$test (log file size limitation)"
+} else {
+ fail "$test (log file size ($scnt != $cnt1 + $cnt2))"
+}
+exec kill -TERM $pid
+# wait for exiting...
+exec sleep 1
+system "rm -f flightlog.out*"
+
diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp
new file mode 100644
index 00000000..f42c9b8e
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec2.stp
@@ -0,0 +1,5 @@
+probe timer.ms(10)
+{
+ for (j = 0; j < 1000; j++)
+ printf("1234567890\n")
+}
diff --git a/testsuite/systemtap.base/flightrec3.exp b/testsuite/systemtap.base/flightrec3.exp
new file mode 100644
index 00000000..5b9d8253
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec3.exp
@@ -0,0 +1,79 @@
+set test "flightrec3"
+if {![installtest_p]} { untested $test; return }
+
+# cleanup
+system "rm -f flightlog.out*"
+
+set pid 0
+# check -S option with bulk(percpu file) mode
+spawn stap -F -o flightlog.out -S 1,3 -b $srcdir/$subdir/$test.stp
+expect {
+ -timeout 240
+ -re {([0-9]+)\r\n} {
+ pass "$test (-S option with bulk mode)"
+ set pid $expect_out(1,string)
+ exp_continue}
+ timeout { fail "$test (timeout)"}
+ eof { }
+}
+wait
+if {$pid == 0} {
+ fail "$test (no pid)"
+ return -1
+}
+
+exec sleep 4
+array set cpus {}
+set scnt 0
+# wait for log files
+exec kill -STOP $pid
+exec sleep 1
+eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*]
+expect {
+ -timeout 100
+ -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
+ set cpuid $expect_out(1,string)
+ set size $expect_out(2,string)
+ if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
+ incr cpus($cpuid);
+ if {$size <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+exec kill -CONT $pid
+exec sleep 3
+exec kill -STOP $pid
+eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*]
+expect {
+ -timeout 100
+ -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
+ set cpuid $expect_out(1,string)
+ set size $expect_out(2,string)
+ if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
+ incr cpus($cpuid);
+ if {$size <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+exec kill -CONT $pid
+# check logfile number
+set cnt 0
+foreach e [array names cpus] {
+ if {$cpus($e) != 6} {
+ fail "$test (log file numbers cpu:$e, cnt:$cpus($e)))"
+ }
+ set cnt [expr $cnt + $cpus($e)]
+}
+# check logfile size
+if {$scnt == $cnt} {
+ pass "$test (log file size limitation with bulk mode)"
+} else {
+ fail "$test (log file size ($scnt != $cnt))"
+}
+exec kill -TERM $pid
+# wait for exiting...
+exec sleep 1
+system "rm -f flightlog.out*"
+
diff --git a/testsuite/systemtap.base/flightrec3.stp b/testsuite/systemtap.base/flightrec3.stp
new file mode 100644
index 00000000..d660793f
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec3.stp
@@ -0,0 +1,5 @@
+probe kernel.function("update_process_times")
+{
+ for (j = 0; j < 100; j++)
+ printf("1234567890\n")
+}
diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp
index f19af977..5da0dfaf 100644
--- a/testsuite/systemtap.base/itrace.exp
+++ b/testsuite/systemtap.base/itrace.exp
@@ -1,17 +1,13 @@
# itrace test
-# temporarily disabled
-return
-
# Initialize variables
-set utrace_support_found 0
set exepath "[pwd]/ls_[pid]"
set itrace1_script {
global instrs = 0
probe begin { printf("systemtap starting probe\n") }
- probe process("%s").itrace
+ probe process("%s").insn
{
instrs += 1
if (instrs == 5)
@@ -28,7 +24,7 @@ set itrace1_script_output "itraced = 5\r\n"
set itrace2_script {
global instrs = 0, itrace_on = 0, start_timer = 0
probe begin { start_timer = 1; printf("systemtap starting probe\n") }
- probe process("%s").itrace if (itrace_on)
+ probe process("%s").insn if (itrace_on)
{
instrs += 1
if (instrs == 5)
@@ -51,6 +47,26 @@ set itrace2_script {
}
set itrace2_script_output "itraced = 5\r\n"
+set itrace3_script {
+ global branches = 0
+ probe begin
+ {
+ printf("systemtap starting probe\n")
+ }
+ probe process("%s").insn.block
+ {
+ branches += 1
+ if (branches == 5)
+ exit()
+ }
+
+
+ probe end { printf("systemtap ending probe\n")
+ printf("itraced block mode = %%d\n", branches)
+ }
+}
+set itrace3_script_output "itraced block mode = 5\r\n"
+
# Set up our own copy of /bin/ls, to make testing for a particular
# executable easy. We can't use 'ln' here, since we might be creating
@@ -75,14 +91,8 @@ proc run_ls_5_sec {} {
}
-# Try to find utrace_attach symbol in /proc/kallsyms
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-
set TEST_NAME "itrace1"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested $TEST_NAME
@@ -93,7 +103,7 @@ if {$utrace_support_found == 0} {
set TEST_NAME "itrace2"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested $TEST_NAME
@@ -102,5 +112,16 @@ if {$utrace_support_found == 0} {
stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script
}
+set TEST_NAME "itrace3"
+if {![utrace_p]} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} else {
+ send_log "ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n"
+ set script [format $itrace3_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script
+}
+
# Cleanup
exec rm -f $exepath
diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp
new file mode 100644
index 00000000..635930f8
--- /dev/null
+++ b/testsuite/systemtap.base/kprobes.exp
@@ -0,0 +1,2 @@
+set test "kprobes"
+stap_run $srcdir/$subdir/$test.stp no_load "probe point hit"
diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp
new file mode 100644
index 00000000..884b321c
--- /dev/null
+++ b/testsuite/systemtap.base/kprobes.stp
@@ -0,0 +1,25 @@
+/*
+ * kprobes.stp
+ * Probe to test the functionality of kprobe-based probes
+ * (Dwarfless Probing)
+ */
+global hit_str
+
+probe begin
+{
+ println("systemtap starting probe");
+ hit_str = ""
+}
+
+probe kprobe.function("vfs_read")
+{
+ hit_str = "probe point hit"
+ exit();
+}
+
+probe end
+{
+ println("systemtap ending probe");
+ println(hit_str);
+ delete hit_str;
+}
diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp
index 6db81c54..79e3f483 100644
--- a/testsuite/systemtap.base/labels.exp
+++ b/testsuite/systemtap.base/labels.exp
@@ -1,14 +1,6 @@
set test "labels"
if {![installtest_p]} {untested $test; return}
-
-# Try to find utrace_attach symbol in /proc/kallsyms
-# copy from utrace_p5.exp
-set utrace_support_found 0
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-if {$utrace_support_found == 0} { untested "$test"; return }
+if {![utrace_p]} { untested $test; return }
# Compile a C program to use as the user-space probing target
set label_srcpath "[pwd]/labels.c"
@@ -18,15 +10,22 @@ set label_flags "additional_flags=-g"
set fp [open $label_srcpath "w"]
puts $fp "
int
+foo ()
+{
+init_an_int:
+ return 1;
+}
+int
main ()
{
sleep(5);
+ foo();
int a = 0;
int b = 0;
char *c;
init_an_int:
a = 2;
-init_another_int:
+init_an_int_again:
b = 3;
c = \"abc\";
ptr_inited:
@@ -38,8 +37,9 @@ close $fp
set label_stppath "[pwd]/labels.stp"
set fp [open $label_stppath "w"]
puts $fp "
-probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)}
-probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")}
"
close $fp
@@ -55,20 +55,66 @@ if { $res != "" } {
pass "compiling labels.c -g"
}
+# line number error
+
+set ok 0
+spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:10\").label(\"*\")"
+
+wait
+expect {
+ -timeout 180
+ -re {no match while resolving probe point} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" }
+
+# line number
+
+set ok 0
+spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:4\").label(\"*\")"
+
+wait
+expect {
+ -timeout 180
+ -re {process.*function.*labels.c:5...label..init_an_int} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" }
+
+# list of labels
+
+spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")"
+
+wait
+set ok 0
+expect {
+ -timeout 180
+ -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+if {$ok == 1} { pass "$test -l .label" } { fail "$test -l .label $ok" }
+
# label in an executable
+set ok 0
verbose -log "spawn stap -c $label_exepath $label_stppath"
spawn stap -c $label_exepath $label_stppath
wait
expect {
-timeout 180
- -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue }
+ -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}
-if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" }
+if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" }
# address of label in an executable
@@ -76,7 +122,7 @@ set label_shpath "[pwd]/label.sh"
set fp [open $label_shpath "w"]
puts $fp "
readelf --debug-dump $label_exepath | awk \"
-/init_another_int/ {have_label=1}
+/init_an_int_again/ {have_label=1}
/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}}
\"
"
@@ -111,7 +157,7 @@ if { $res != "" } {
# label in a shared object
-spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)"
+spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)"
expect {
-timeout 180
-re {process.*function} { incr ok; exp_continue }
@@ -119,7 +165,7 @@ expect {
eof { }
}
-if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" }
+if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" }
# address of label in a shared object
@@ -127,7 +173,7 @@ set label_shpath "[pwd]/label.sh"
set fp [open $label_shpath "w"]
puts $fp "
readelf --debug-dump $label_sopath | awk \"
-/init_another_int/ {have_label=1}
+/init_an_int_again/ {have_label=1}
/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}}
\"
"
diff --git a/testsuite/systemtap.base/maxactive.exp b/testsuite/systemtap.base/maxactive.exp
index 7c03a1bf..79ede897 100644
--- a/testsuite/systemtap.base/maxactive.exp
+++ b/testsuite/systemtap.base/maxactive.exp
@@ -10,12 +10,12 @@ proc sleep_five_sec {} {
return 0;
}
-# Script1. For 5 seconds, probe the return of "sys_select" and
-# "sys_read". See if we skip any probes.
+# Script1. For 5 seconds, probe the return of "vfs_read" and
+# "do_select". See if we skip any probes.
set script1 {
global foo
- probe kernel.function("sys_select").return,
- kernel.function("sys_read").return { foo++ }
+ probe kernel.function("vfs_read").return,
+ kernel.function("do_select").return { foo++ }
probe timer.ms(5000) { exit(); }
probe begin { log("systemtap starting probe"); log("systemtap ending probe");}
@@ -26,13 +26,13 @@ set script1 {
stap_run "MAXACTIVE01" sleep_five_sec "" -e $script1
set skipped1 $skipped_probes
-# Script2. For 5 seconds, probe the return of "sys_select" and
-# "sys_read", with a limit of 1 probe active at a time. See if we
+# Script2. For 5 seconds, probe the return of "vfs_read" and
+# "do_select", with a limit of 1 probe active at a time. See if we
# skip any probes.
set script2 {
global foo
- probe kernel.function("sys_select").return.maxactive(1),
- kernel.function("sys_read").return.maxactive(1) { foo++ }
+ probe kernel.function("vfs_read").return.maxactive(1),
+ kernel.function("do_select").return.maxactive(1) { foo++ }
probe timer.ms(5000) { exit(); }
probe begin { log("systemtap starting probe"); log("systemtap ending probe");}
diff --git a/testsuite/systemtap.base/onoffprobe.stp b/testsuite/systemtap.base/onoffprobe.stp
index f7169039..79c41a3c 100644
--- a/testsuite/systemtap.base/onoffprobe.stp
+++ b/testsuite/systemtap.base/onoffprobe.stp
@@ -10,13 +10,13 @@ probe begin if (switch==0) {
}
#dwarf probe (return)
-probe kernel.function("sys_write").return if (switch == 1) {
+probe kernel.function("vfs_write").return if (switch == 1) {
log("function return probed")
switch = 0
}
#dwarf probe (entry)
-probe kernel.function("sys_write") if (switch == 2) {
+probe kernel.function("vfs_write").return if (switch == 2) {
log("function entry probed")
switch = 0
}
diff --git a/testsuite/systemtap.base/optionalprobe.exp b/testsuite/systemtap.base/optionalprobe.exp
new file mode 100644
index 00000000..5484003c
--- /dev/null
+++ b/testsuite/systemtap.base/optionalprobe.exp
@@ -0,0 +1,9 @@
+set test "optionalprobe"
+spawn stap -p2 -w $srcdir/$subdir/$test.stp
+expect {
+ -timeout 60
+ -re "# probes\r\n" { exp_continue }
+ -re "^begin" { pass $test }
+ eof { fail $test }
+ timeout { fail "$test unexpected timeout" }
+}
diff --git a/testsuite/systemtap.base/optionalprobe.stp b/testsuite/systemtap.base/optionalprobe.stp
new file mode 100644
index 00000000..13918cee
--- /dev/null
+++ b/testsuite/systemtap.base/optionalprobe.stp
@@ -0,0 +1,14 @@
+#! stap
+
+# test optional probe
+
+probe foo ?,
+ process("/do/not/exist").function("main") !,
+ kernel.mark("no such mark") ?,
+ kernel.trace("no trace") !,
+ process.foo ?,
+ kernel.statement("no statement") !,
+ module("no mod").function("*") ?,
+ kernel.function("no such func*") !,
+ begin {
+}
diff --git a/testsuite/systemtap.base/overload.exp b/testsuite/systemtap.base/overload.exp
index cbcbe817..ac9ceb24 100644
--- a/testsuite/systemtap.base/overload.exp
+++ b/testsuite/systemtap.base/overload.exp
@@ -8,7 +8,7 @@ set script {
k["foo"] = 0
}
- probe kernel.function("sys_read"), kernel.function("sys_write") {
+ probe kernel.function("vfs_read"), kernel.function("vfs_write") {
k["foo"]++
}
probe end {
diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp
index 74818beb..c3aed91e 100644
--- a/testsuite/systemtap.base/sdt.exp
+++ b/testsuite/systemtap.base/sdt.exp
@@ -10,11 +10,12 @@ set ::result_string {1
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10}
-set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic}}
+set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-ansi additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}}
# Iterate extra_flags, trying each with C and C++
for {set i 0} {$i < [llength $extra_flags]} {incr i} {
set extra_flag [lindex $extra_flags $i]
+set testprog "sdt.c.exe.$i"
# C
set test_flags "additional_flags=-g"
@@ -23,44 +24,47 @@ set test_flags "$test_flags additional_flags=-Wall"
set test_flags "$test_flags additional_flags=-Wextra"
set test_flags "$test_flags additional_flags=-Werror"
-set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"]
+set saveidx 0
+
+set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"]
if { $res != "" } {
verbose "target_compile failed: $res" 2
fail "compiling $test.c $extra_flag"
- return
+ untested "$test $extra_flag"
+ continue
} else {
pass "compiling $test.c $extra_flag"
}
-if {[installtest_p]} {
-# XXX: we need distinct test names for these
- stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog
+if {[installtest_p] && [utrace_p]} {
+ stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog
} else {
untested "$test $extra_flag"
}
# C++
+set testprog "sdt.cxx.exe.$i"
+
set test_flags "additional_flags=-g"
set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys"
set test_flags "$test_flags additional_flags=-Wall"
set test_flags "$test_flags additional_flags=-Werror"
set test_flags "$test_flags additional_flags=-x additional_flags=c++"
-set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"]
+set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"]
if { $res != "" } {
verbose "target_compile failed: $res" 2
fail "compiling $test.c c++ $extra_flag"
- return
+ untested "$test $extra_flag"
+ continue
} else {
pass "compiling $test.c c++ $extra_flag"
}
-if {[installtest_p]} {
-# XXX: we need distinct test names for these
- stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog
+if {[installtest_p] && [utrace_p]} {
+ stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog
} else {
untested "$test c++ $extra_flag"
}
}
-catch {exec rm -f $test.prog}
diff --git a/testsuite/systemtap.base/sdt.stp b/testsuite/systemtap.base/sdt.stp
index 1f075bca..5df1fdc9 100644
--- a/testsuite/systemtap.base/sdt.stp
+++ b/testsuite/systemtap.base/sdt.stp
@@ -1,49 +1,49 @@
-probe process("sdt.prog").mark("mark_a")
+probe process(@1).mark("mark_a")
{
printf("%d\n", $arg1);
}
-probe process("sdt.prog").mark("mark_b")
+probe process(@1).mark("mark_b")
{
printf("%d %d\n", $arg1, $arg2);
}
-probe process("sdt.prog").mark("mark_c")
+probe process(@1).mark("mark_c")
{
printf("%d %d %d\n", $arg1, $arg2, $arg3);
}
-probe process("sdt.prog").mark("mark_d")
+probe process(@1).mark("mark_d")
{
printf("%d %d %d %d\n", $arg1, $arg2, $arg3, $arg4);
}
-probe process("sdt.prog").mark("mark_e")
+probe process(@1).mark("mark_e")
{
printf("%d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5);
}
-probe process("sdt.prog").mark("mark_f")
+probe process(@1).mark("mark_f")
{
printf("%d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
}
-probe process("sdt.prog").mark("mark_g")
+probe process(@1).mark("mark_g")
{
printf("%d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
}
-probe process("sdt.prog").mark("mark_h")
+probe process(@1).mark("mark_h")
{
printf("%d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
}
-probe process("sdt.prog").mark("mark_i")
+probe process(@1).mark("mark_i")
{
printf("%d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
}
-probe process("sdt.prog").mark("mark_j")
+probe process(@1).mark("mark_j")
{
printf("%d %d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9, $arg10);
}
diff --git a/testsuite/systemtap.base/sdt_types.c b/testsuite/systemtap.base/sdt_types.c
new file mode 100644
index 00000000..2e04ec7e
--- /dev/null
+++ b/testsuite/systemtap.base/sdt_types.c
@@ -0,0 +1,168 @@
+#include "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */
+#include <stdint.h>
+#include <values.h>
+
+int
+main (int argc, char **argv)
+{
+ char char_var = '~';
+ STAP_PROBE1(provider,char_var,char_var);
+ const char const_char_var = '!';
+ STAP_PROBE1(provider,const_char_var,const_char_var);
+ volatile char volatile_char_var = '!';
+ STAP_PROBE1(provider,volatile_char_var,volatile_char_var);
+ char *ptr_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_char_var,ptr_char_var,&char_var);
+ const char *ptr_const_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_const_char_var,ptr_const_char_var,&char_var);
+ char * const char_ptr_const_var = &char_var;
+ STAP_PROBE2(provider,char_ptr_const_var,char_ptr_const_var,&char_var);
+ volatile char *ptr_volatile_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_volatile_char_var,ptr_volatile_char_var,&char_var);
+ char * volatile char_ptr_volatile_var = &char_var;
+ STAP_PROBE2(provider,char_ptr_volatile_var,char_ptr_volatile_var,&char_var);
+ short int short_int_var = 32767;
+ STAP_PROBE1(provider,short_int_var,short_int_var);
+ const short int const_short_int_var = -32767;
+ STAP_PROBE1(provider,const_short_int_var,const_short_int_var);
+ volatile short int volatile_short_int_var = -32767;
+ STAP_PROBE1(provider,volatile_short_int_var,volatile_short_int_var);
+ short int *ptr_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_short_int_var,ptr_short_int_var,&short_int_var);
+ const short int *ptr_const_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_const_short_int_var,ptr_const_short_int_var,&short_int_var);
+ short int * const short_int_ptr_const_var = &short_int_var;
+ STAP_PROBE2(provider,short_int_ptr_const_var,short_int_ptr_const_var,&short_int_var);
+ volatile short int *ptr_volatile_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_volatile_short_int_var,ptr_volatile_short_int_var,&short_int_var);
+ short int * volatile short_int_ptr_volatile_var = &short_int_var;
+ STAP_PROBE2(provider,short_int_ptr_volatile_var,short_int_ptr_volatile_var,&short_int_var);
+ int int_var = 65536;
+ STAP_PROBE1(provider,int_var,int_var);
+ const int const_int_var = -65536;
+ STAP_PROBE1(provider,const_int_var,const_int_var);
+ volatile int volatile_int_var = -65536;
+ STAP_PROBE1(provider,volatile_int_var,volatile_int_var);
+ int *ptr_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_int_var,ptr_int_var,&int_var);
+ const int *ptr_const_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_const_int_var,ptr_const_int_var,&int_var);
+ int * const int_ptr_const_var = &int_var;
+ STAP_PROBE2(provider,int_ptr_const_var,int_ptr_const_var,&int_var);
+ volatile int *ptr_volatile_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_volatile_int_var,ptr_volatile_int_var,&int_var);
+ int * volatile int_ptr_volatile_var = &int_var;
+ STAP_PROBE2(provider,int_ptr_volatile_var,int_ptr_volatile_var,&int_var);
+ long int long_int_var = 65536;
+ STAP_PROBE1(provider,long_int_var,long_int_var);
+ const long int const_long_int_var = -65536;
+ STAP_PROBE1(provider,const_long_int_var,const_long_int_var);
+ volatile long int volatile_long_int_var = -65536;
+ STAP_PROBE1(provider,volatile_long_int_var,volatile_long_int_var);
+ long int *ptr_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_long_int_var,ptr_long_int_var,&long_int_var);
+ const long int *ptr_const_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_const_long_int_var,ptr_const_long_int_var,&long_int_var);
+ long int * const long_int_ptr_const_var = &long_int_var;
+ STAP_PROBE2(provider,long_int_ptr_const_var,long_int_ptr_const_var,&long_int_var);
+ volatile long int *ptr_volatile_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_volatile_long_int_var,ptr_volatile_long_int_var,&long_int_var);
+ long int * volatile long_int_ptr_volatile_var = &long_int_var;
+ STAP_PROBE2(provider,long_int_ptr_volatile_var,long_int_ptr_volatile_var,&long_int_var);
+ long long int long_long_int_var = 65536;
+ STAP_PROBE1(provider,long_long_int_var,long_long_int_var);
+ const long long int const_long_long_int_var = -65536;
+ STAP_PROBE1(provider,const_long_long_int_var,const_long_long_int_var);
+ volatile long long int volatile_long_long_int_var = -65536;
+ STAP_PROBE1(provider,volatile_long_long_int_var,volatile_long_long_int_var);
+ long long int *ptr_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_long_long_int_var,ptr_long_long_int_var,&long_long_int_var);
+ const long long int *ptr_const_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_const_long_long_int_var,ptr_const_long_long_int_var,&long_long_int_var);
+ long long int * const long_long_int_ptr_const_var = &long_long_int_var;
+ STAP_PROBE2(provider,long_long_int_ptr_const_var,long_long_int_ptr_const_var,&long_long_int_var);
+ volatile long long int *ptr_volatile_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_volatile_long_long_int_var,ptr_volatile_long_long_int_var,&long_long_int_var);
+ long long int * volatile long_long_int_ptr_volatile_var = &long_long_int_var;
+ STAP_PROBE2(provider,long_long_int_ptr_volatile_var,long_long_int_ptr_volatile_var,&long_long_int_var);
+
+ char arr_char [2] = "!~";
+ STAP_PROBE1(provider,arr_char,&arr_char);
+ struct {
+ int int_var;
+ } arr_struct [2] = {{
+ .int_var=1,
+ },{
+ .int_var=2,
+ }};
+ STAP_PROBE1(provider,arr_struct,&arr_struct);
+ struct {
+ unsigned int bit1_0:1;
+ unsigned int bit1_1:1;
+ char char_2;
+ unsigned int bit1_6:1;
+ unsigned int bit1_7:1;
+ char char_8;
+ unsigned int bit1_9:1;
+ unsigned int bit1_10:1;
+ } bitfields_small_var = {
+ .bit1_0=1,
+ .bit1_1=0,
+ .char_2='a',
+ .bit1_6=1,
+ .bit1_7=0,
+ .char_8='z',
+ .bit1_9=1,
+ .bit1_10=0,
+ };
+ STAP_PROBE8(provider,bitfields_small_var,
+ (int)bitfields_small_var.bit1_0,
+ (int)bitfields_small_var.bit1_1,
+ bitfields_small_var.char_2,
+ (int)bitfields_small_var.bit1_6,
+ (int)bitfields_small_var.bit1_7,
+ bitfields_small_var.char_8,
+ (int)bitfields_small_var.bit1_9,
+ (int)bitfields_small_var.bit1_10);
+ struct {
+ unsigned char char_0;
+ int bit1_4:1;
+ unsigned int bit1_5:1;
+ int bit2_6:2;
+ unsigned int bit2_8:2;
+ int bit3_10:3;
+ unsigned int bit3_13:3;
+ int bit9_16:9;
+ unsigned int bit9_25:9;
+ char char_34;
+ } bitfields_bit_var = {
+ .char_0='A',
+ .bit1_4=-1,
+ .bit1_5=1,
+ .bit2_6=1,
+ .bit2_8=3,
+ .bit3_10=3,
+ .bit3_13=7,
+ .bit9_16=255,
+ .bit9_25=511,
+ .char_34='Z',
+ };
+ STAP_PROBE10(provider,bitfields_bit_var,bitfields_bit_var.char_0,
+ (int)bitfields_bit_var.bit1_4,
+ (int)bitfields_bit_var.bit1_5,
+ (int)bitfields_bit_var.bit2_6,
+ (int)bitfields_bit_var.bit2_8,
+ (int)bitfields_bit_var.bit3_10,
+ (int)bitfields_bit_var.bit3_13,
+ (int)bitfields_bit_var.bit9_16,
+ (int)bitfields_bit_var.bit9_25,
+ bitfields_bit_var.char_34);
+ enum {
+ red = 0,
+ green = 1,
+ blue = 2
+ } primary_colors_var = green;
+ STAP_PROBE1(provider,primary_colors_var,primary_colors_var);
+ return 0;
+}
+
diff --git a/testsuite/systemtap.base/sdt_types.stp b/testsuite/systemtap.base/sdt_types.stp
new file mode 100644
index 00000000..654b0d18
--- /dev/null
+++ b/testsuite/systemtap.base/sdt_types.stp
@@ -0,0 +1,371 @@
+probe process(@1).mark("char_var") {
+ if ($arg1 != 126)
+ printf("FAIL: char_var\n")
+ else
+ printf("PASS: char_var\n")
+}
+
+probe process(@1).mark("const_char_var") {
+ if ($arg1 != 33)
+ printf("FAIL: const_char_var\n")
+ else
+ printf("PASS: const_char_var\n")
+}
+
+probe process(@1).mark("volatile_char_var") {
+ if ($arg1 != 33)
+ printf("FAIL: volatile_char_var\n")
+ else
+ printf("PASS: volatile_char_var\n")
+}
+
+probe process(@1).mark("ptr_char_var") {
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_char_var\n")
+ else
+ printf("PASS: ptr_char_var\n")
+}
+
+probe process(@1).mark("ptr_const_char_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_char_var\n")
+ else
+ printf("PASS: ptr_const_char_var\n")
+}
+
+probe process(@1).mark("char_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: char_ptr_const_var\n")
+ else
+ printf("PASS: char_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_char_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_char_var\n")
+ else
+ printf("PASS: ptr_volatile_char_var\n")
+}
+
+probe process(@1).mark("char_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: char_ptr_volatile_var\n")
+ else
+ printf("PASS: char_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("short_int_var")
+{
+ if ($arg1 != 32767)
+ printf("FAIL: short_int_var\n")
+ else
+ printf("PASS: short_int_var\n")
+}
+
+probe process(@1).mark("const_short_int_var")
+{
+ if ($arg1 != -32767)
+ printf("FAIL: const_short_int_var\n")
+ else
+ printf("PASS: const_short_int_var\n")
+}
+
+probe process(@1).mark("volatile_short_int_var")
+{
+ if ($arg1 != -32767)
+ printf("FAIL: volatile_short_int_var\n")
+ else
+ printf("PASS: volatile_short_int_var\n")
+}
+
+probe process(@1).mark("ptr_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_short_int_var\n")
+ else
+ printf("PASS: ptr_short_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_short_int_var\n")
+ else
+ printf("PASS: ptr_const_short_int_var\n")
+}
+
+probe process(@1).mark("short_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: short_int_ptr_const_var\n")
+ else
+ printf("PASS: short_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_short_int_var\n")
+ else
+ printf("PASS: ptr_volatile_short_int_var\n")
+}
+
+probe process(@1).mark("short_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: short_int_ptr_volatile_var\n")
+ else
+ printf("PASS: short_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: int_var")
+ else
+ printf("PASS: int_var")
+}
+
+probe process(@1).mark("const_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_int_var\n")
+ else
+ printf("PASS: const_int_var\n")
+}
+
+probe process(@1).mark("volatile_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_int_var\n")
+ else
+ printf("PASS: volatile_int_var\n")
+}
+
+probe process(@1).mark("ptr_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_int_var\n")
+ else
+ printf("PASS: ptr_const_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_int_var\n")
+ else
+ printf("PASS: ptr_const_int_var\n")
+}
+
+probe process(@1).mark("int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: int_ptr_const_var\n")
+ else
+ printf("PASS: int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_int_var\n")
+ else
+ printf("PASS: ptr_volatile_int_var\n")
+}
+
+probe process(@1).mark("int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: int_ptr_volatile_var\n")
+ else
+ printf("PASS: int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("long_int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: long_int_var\n")
+ else
+ printf("PASS: long_int_var\n")
+}
+
+probe process(@1).mark("const_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_long_int_var\n")
+ else
+ printf("PASS: const_long_int_var\n")
+}
+
+probe process(@1).mark("volatile_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_long_int_var\n")
+ else
+ printf("PASS: volatile_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_long_int_var\n")
+ else
+ printf("PASS: ptr_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_long_int_var\n")
+ else
+ printf("PASS: ptr_const_long_int_var\n")
+}
+
+probe process(@1).mark("long_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_int_ptr_const_var\n")
+ else
+ printf("PASS: long_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_long_int_var\n")
+ else
+ printf("PASS: ptr_volatile_long_int_var\n")
+}
+
+probe process(@1).mark("long_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_int_ptr_volatile_var\n")
+ else
+ printf("PASS: long_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("long_long_int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: long_long_int_var\n")
+ else
+ printf("PASS: long_long_int_var\n")
+}
+
+probe process(@1).mark("const_long_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_long_long_int_var\n")
+ else
+ printf("PASS: const_long_long_int_var\n")
+}
+
+probe process(@1).mark("volatile_long_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_long_long_int_var\n")
+ else
+ printf("PASS: volatile_long_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_long_long_int_var\n")
+ else
+ printf("PASS: ptr_long_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_long_long_int_var\n")
+ else
+ printf("PASS: ptr_const_long_long_int_var\n")
+}
+
+probe process(@1).mark("long_long_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_long_int_ptr_const_var\n")
+ else
+ printf("PASS: long_long_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_long_long_int_var\n")
+ else
+ printf("PASS: ptr_volatile_long_long_int_var\n")
+}
+
+probe process(@1).mark("long_long_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_long_int_ptr_volatile_var\n")
+ else
+ printf("PASS: long_long_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("arr_char")
+{
+ arr_char = user_string ($arg1);
+ if (arr_char != "!~")
+ printf("FAIL: arr_char_var\n")
+ else
+ printf("PASS: arr_char_var\n")
+}
+
+probe process(@1).mark("arr_struct")
+{
+ arr_struct_int_var = user_int ($arg1)
+ if (arr_struct_int_var != 1)
+ printf("FAIL: arr_struct_var\n")
+ else
+ printf("PASS: arr_struct_var\n")
+}
+
+probe process(@1).mark("bitfields_small_var")
+{
+ if ($arg1 != 1 || $arg2 != 0 || $arg3 != 97 || $arg4 != 1
+ || $arg5 != 0 || $arg6 != 122 || $arg7 != 1 || $arg8 != 0)
+ printf("FAIL: bitfields_small_var\n")
+
+}
+
+probe process(@1).mark("bitfields_bit_var")
+{
+ if ($arg1 != 65 || $arg2 != -1 || $arg3 != 1 || $arg4 != 1
+ || $arg5 != 3 || $arg6 != 3 || $arg7 != 7 || $arg8 != 255
+ || $arg9 != 511 || $arg10 != 90)
+ printf("FAIL: bitfields_bit_var\n")
+ else
+ printf("PASS: bitfields_bit_var\n")
+}
+
+
+probe process(@1).mark("primary_colors_var")
+{
+ if ($arg1 != 1)
+ printf("FAIL: primary_colors_var\n")
+ else
+ printf("PASS: primary_colors_var\n")
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testsuite/systemtap.base/skipped.exp b/testsuite/systemtap.base/skipped.exp
index 8c491037..f3048c8a 100644
--- a/testsuite/systemtap.base/skipped.exp
+++ b/testsuite/systemtap.base/skipped.exp
@@ -2,8 +2,8 @@ set test "skip tracking"
if {! [installtest_p]} { untested $test; return }
-set cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"]
-if {$cpus < 2} { unsupported $test; return }
+set nr_cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"]
+if {$nr_cpus < 2} { unsupported $test; return }
set ok 0
spawn stap -e "probe timer.s(5) {exit()} probe timer.profile,syscall.* {f++} global f" -DMAXTRYLOCK=0 -tu
@@ -18,4 +18,4 @@ expect {
catch {close}
catch {wait}
-if {$ok >= 3} { pass "$test ($cpus $ok)" } else { fail "$test ($cpus $ok)" }
+if {$ok >= 3} { pass "$test ($nr_cpus $ok)" } else { fail "$test ($nr_cpus $ok)" }
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index a4bd5e2c..1e53d5d3 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -1,5 +1,6 @@
+set test "static_uprobes"
-set test "sduprobes"
+# Test miscellaneous features of .mark probes
# Compile a C program to use as the user-space probing target
set sup_srcpath "[pwd]/static_uprobes.c"
@@ -81,6 +82,9 @@ provider static_uprobes {
};
"
close $fp
+
+# Test dtrace
+
if {[installtest_p]} {
set dtrace $env(SYSTEMTAP_PATH)/dtrace
} else {
@@ -89,11 +93,10 @@ if {[installtest_p]} {
if {[catch {exec $dtrace -h -s $sup_dpath} res]} {
verbose -log "unable to run $dtrace: $res"
}
-catch {exec rm -f $sup_dpath}
if {[file exists $sup_hpath]} then {
- pass "$test generating header"
+ pass "$test dtrace"
} else {
- fail "$test generating header"
+ fail "$test dtrace"
catch {exec rm -f $sup_srcpath $sup_hpath $sup_stppath}
return
}
@@ -104,7 +107,11 @@ if {[installtest_p]} {
set sdtdir $srcdir/../includes
}
-set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I."
+set sup_flags "additional_flags=-I$srcdir/../includes/sys"
+set sup_flags "$sup_flags additional_flags=-I$sdtdir"
+set sup_flags "$sup_flags additional_flags=-g"
+set sup_flags "$sup_flags additional_flags=-O"
+set sup_flags "$sup_flags additional_flags=-I."
set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
@@ -115,34 +122,15 @@ if { $res != "" } {
pass "$test compiling C -g"
}
-spawn mv $sup_srcpath "[pwd]/static_uprobes.cc"
-set sup_srcpath "[pwd]/static_uprobes.cc"
-set sup_flags "$sup_flags c++"
-set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags]
-if { $res != "" } {
- verbose "target_compile failed: $res" 2
- fail "$test compiling C++ -g"
- catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath}
- return
-} else {
- pass "$test compiling C++ -g"
-}
-
if {![installtest_p]} {untested $test; return}
-
-# Try to find utrace_attach symbol in /proc/kallsyms
-# copy from utrace_p5.exp
-set utrace_support_found 0
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$test"
catch {exec rm -f $sup_srcpath}
return
}
+# Run stap on executable built with dtrace generated header file
+
set ok 0
verbose -log "spawn stap -c $sup_exepath $sup_stppath"
@@ -161,28 +149,56 @@ wait
if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" }
-set ok 0
+# Test passing various C types to .mark probes
-# spawn objcopy -R .probes $supcplus_exepath $sup_exepath
-verbose -log "cp $supcplus_exepath $sup_exepath"
-spawn cp $supcplus_exepath $sup_exepath
-verbose -log "spawn stap -c $sup_exepath $sup_stppath"
-spawn stap -c $sup_exepath $sup_stppath
+set sup_flags "$sup_flags additional_flags=-O0"
+set res [target_compile $srcdir/$subdir/sdt_types.c sdt_types.x executable $sup_flags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compiling types -g"
+ return
+} else {
+ pass "$test compiling types -g"
+}
+
+set ok 0
+set fail "types"
+verbose -log "spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x"
+spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x
expect {
-timeout 180
- -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
- -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
- -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
- -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue }
- timeout { fail "$test C++ (timeout)" }
+ -re {FAIL: [a-z_]+var} { regexp " .*$" $expect_out(0,string) s;
+ incr ok; set fail "$fail $s"; exp_continue }
+ timeout { fail "$test C (timeout)" }
eof { }
}
wait
-if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" }
+if { $ok != 0 } {
+ fail "$test $fail"
+} else {
+ pass "$test types"
+}
+
+# Test .mark probe wildcard matching
+
+set ok 0
+spawn stap -l "process(\"./sdt_types.x\").mark(\"*\")"
+expect {
+ -timeout 180
+ -re {mark\(\"[a-z_]+\"\)} { incr ok; exp_continue }
+ timeout { fail "$test C (timeout)" }
+ eof { }
+}
-# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath}
+if { $ok == 45 } {
+ pass "$test wildcard"
+} else {
+ fail "$test wildcard ($ok)"
+}
+
+if { $verbose == 0 } {
+catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath sdt_types.x}
+}
-# It's not so important to clean up, and it's unhelpful if
-# one needs to diagnose a test failure.
diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp
index be51fef9..619c91a5 100644
--- a/testsuite/systemtap.base/stmt_rel.exp
+++ b/testsuite/systemtap.base/stmt_rel.exp
@@ -1,8 +1,42 @@
-# test integer limits. Set and print variables and print constants.
-
set test "stmt_rel"
-set ::result_string {PASS bio_init
-PASS line number
-PASS wildcard}
-stap_run2 $srcdir/$subdir/$test.stp
+set line1 ""
+spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+2\")"
+expect {
+ -timeout 180
+ -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line1; }
+ timeout { fail "$test C (timeout)" }
+ eof { }
+}
+
+set line2 ""
+spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+3\")"
+expect {
+ -timeout 180
+ -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line2; }
+ timeout { fail "$test C (timeout)" }
+ eof { }
+}
+
+if { $line1 < $line2 } {
+ pass "$test line numbers"
+} else {
+ fail "$test line numbers"
+}
+
+set ok 0
+spawn stap -l "kernel.statement(\"bio_init@fs/bio.c:*\")"
+expect {
+ -timeout 180
+ -re {[0-9][0-9][0-9]} { incr ok; exp_continue }
+ timeout { fail "$test C (timeout)" }
+ eof { }
+}
+
+# bio_init drifts a bit in different kernels.
+# maybe 3, 4 or 15 lines in it.
+if { $ok >= 3 } {
+ pass "$test wildcard"
+} else {
+ fail "$test wildcard ($ok)"
+}
diff --git a/testsuite/systemtap.base/stmt_rel.stp b/testsuite/systemtap.base/stmt_rel.stp
deleted file mode 100644
index cfe77317..00000000
--- a/testsuite/systemtap.base/stmt_rel.stp
+++ /dev/null
@@ -1,71 +0,0 @@
-global stack2pp, stack2func, stack3pp, stack3func
-global wildcardpp, wild_count
-
-probe kernel.statement("bio_init@fs/bio.c+2") {
- # stack2 = tokenize(backtrace(), " ")
- stack2func = probefunc()
- stack2pp = pp()
-}
-probe kernel.statement("bio_init@fs/bio.c+3") {
- # stack3 = tokenize(backtrace(), " " )
- stack3func = probefunc()
- stack3pp = pp()
-}
-
-probe kernel.statement("bio_put@fs/bio.c:*") {
- line = tokenize(pp(),":")
- line = tokenize("",":")
- line = substr(line,0,strlen(line)-2)
- wildcardpp[strtol(line,10)]++
-
- if (wild_count++ <= 10) {
- next
- }
-
- stack2pp = tokenize(stack2pp,":")
- stack2pp = tokenize("",":")
- stack3pp = tokenize(stack3pp,":")
- stack3pp = tokenize("",":")
-
- stack2line = strtol (substr(stack2pp,0,strlen(stack2pp)-2), 10)
- stack3line = strtol (substr(stack3pp,0,strlen(stack3pp)-2), 10)
-
- # Did functions for both bio_init probes match?
- if (stack2func == stack3func) {
- printf ("PASS %s\n", stack2func)
- }
- else {
- printf ("FAIL %s %s\n", stack2func, stack3func)
- }
-
- # Was line # for bio_init probe +2 < line # for bio_init probe +3?
- if ((stack2line + 1) == stack3line) {
- printf ("PASS line number\n")
- }
- else {
- printf ("FAIL line number %d %d\n", stack2line, stack3line)
- }
-
- # This test does not take optimized code into account
- # Was address for bio_init probe +2 < address for bio_init probe +3?
- # if (stack2 < stack3) {
- # printf ("PASS address\n")
- # }
- # else {
- # printf ("FAIL address %s %s\n", stack2, stack3)
- # }
-
- # Did wildcard probe hit at least 4 different statements?
- foreach ([i] in wildcardpp) {
- statement_count += 1
- }
- if (statement_count >= 4) {
- printf ("PASS wildcard\n")
- }
- else
- {
- printf ("FAIL wildcard %d\n", statement_count)
- }
-
- exit()
-}
diff --git a/testsuite/systemtap.base/stmtvars.exp b/testsuite/systemtap.base/stmtvars.exp
index 822e0d7e..c0099f2d 100644
--- a/testsuite/systemtap.base/stmtvars.exp
+++ b/testsuite/systemtap.base/stmtvars.exp
@@ -3,9 +3,9 @@ set test "stmtvars"
set pc 0
set vars ""
-spawn stap -e "probe kernel.function(\"sys_open\") {\$foo}" -p4 -vv -u
+spawn stap -e "probe kernel.function(\"do_sys_open\") {\$foo}" -p4 -vv -u
expect {
- -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue }
+ -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue }
-re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars $expect_out(1,string); exp_continue }
timeout { fail "$test (timeout)" }
eof
@@ -18,7 +18,7 @@ set pc2 0
set vars2 ""
spawn stap -e "probe kernel.statement($pc) {\$foo}" -p4 -vv -u
expect {
- -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue }
+ -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue }
-re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars2 $expect_out(1,string); exp_continue }
timeout { fail "$test (timeout)" }
eof
diff --git a/testsuite/systemtap.base/strftime.exp b/testsuite/systemtap.base/strftime.exp
new file mode 100644
index 00000000..ad9e471d
--- /dev/null
+++ b/testsuite/systemtap.base/strftime.exp
@@ -0,0 +1,49 @@
+set test "strftime"
+if {![installtest_p]} { untested $test; return }
+# cleanup
+system "rm -f %*"
+
+# check %S and %T
+set format %%%S_%T
+exec stap -o $format -we {probe begin {println("hello");exit()}}
+
+spawn ls -1
+set ok 0
+expect {
+ -re {%([0-9][0-9])_[0-9][0-9]:[0-9][0-9]:\1} {incr ok}
+ eof { }
+}
+wait
+
+if {$ok == 1} {
+ pass "$test (%S and %T)"
+} else {
+ fail "$test (%S and %T)"
+}
+
+# check except for %S and %T
+set format %%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k,%l,%M,%R,%u,%w
+
+set date1 [exec date +$format]
+# run stapio with strftime
+exec stap -o $format -we {probe begin {println("hello");exit()}}
+# check whether stap outputs stapio pid
+set date2 [exec date +$format]
+
+spawn ls -1
+set ok 0
+expect {
+ $date1 {incr ok}
+ $date2 {incr ok}
+ eof { }
+}
+wait
+
+if {$ok == 1} {
+ pass "$test (except %S and %T)"
+} else {
+ fail "$test (except %S and %T)"
+}
+
+# cleanup
+system "rm -f %*"
diff --git a/testsuite/systemtap.base/system_func.stp b/testsuite/systemtap.base/system_func.stp
index d14fb25b..6a6bb04a 100644
--- a/testsuite/systemtap.base/system_func.stp
+++ b/testsuite/systemtap.base/system_func.stp
@@ -4,10 +4,10 @@
global saw_echo, did_cat
-probe kernel.function("sys_open") {
+probe kernel.function("do_sys_open") {
if (!saw_echo) {
# very inefficient. Testing only. DO NOT DO THIS
- msg="echo sys_open"
+ msg="echo do_sys_open"
system(msg)
saw_echo = 1
}
diff --git a/testsuite/systemtap.base/tracepoints.exp b/testsuite/systemtap.base/tracepoints.exp
index bea461c4..cd033908 100644
--- a/testsuite/systemtap.base/tracepoints.exp
+++ b/testsuite/systemtap.base/tracepoints.exp
@@ -1,3 +1,26 @@
+
+set tracepoints {}
+spawn stap -l {kernel.trace("*")}
+expect {
+ -re {^kernel.trace[^\r\n]*\r\n} {
+ append tracepoints $expect_out(0,string)
+ exp_continue
+ }
+ timeout {}
+ eof {}
+}
+catch {close}; catch { wait }
+
+foreach tp $tracepoints {
+ set test "tracepoint $tp -p4"
+ if {[catch {exec stap -w -p4 -e "probe $tp {}"} res]} {
+ fail "$test $res"
+ } else {
+ pass "$test"
+ }
+}
+
set test "tracepoints"
+if {![installtest_p]} { untested $test; return }
set ::result_string {tracepoints OK}
stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp
index 89250e7b..6344cbf0 100644
--- a/testsuite/systemtap.base/uprobes.exp
+++ b/testsuite/systemtap.base/uprobes.exp
@@ -18,14 +18,7 @@ if [file exists $path] then { pass "$test prep" } else { fail "$test prep" }
catch {exec gcc -g -o jennie jennie.c} err
if {$err == "" && [file exists jennie]} then { pass "$test compile" } else { fail "$test compile" }
-# Try to find utrace_attach symbol in /proc/kallsyms
-# copy from utrace_p5.exp
-set utrace_support_found 0
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$test -p4"; untested "$test -p5"
catch {exec rm -f jennie.c jennie}
return
diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c
new file mode 100644
index 00000000..b4811335
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_exe.c
@@ -0,0 +1,29 @@
+/* uprobes_lib test case
+ * Copyright (C) 2009, Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#include <unistd.h>
+
+// function from our library
+int lib_main (void);
+
+void
+main_func (int foo)
+{
+ if (foo > 1)
+ main_func (foo - 1);
+ else
+ lib_main();
+}
+
+int
+main (int argc, char *argv[], char *envp[])
+{
+ main_func (3);
+ return 0;
+}
diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c
new file mode 100644
index 00000000..25297b6b
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_lib.c
@@ -0,0 +1,21 @@
+/* uprobes_lib test case - library helper
+ * Copyright (C) 2009, Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+void
+lib_func (int bar)
+{
+ if (bar > 1)
+ lib_func (bar - 1);
+}
+
+void
+lib_main ()
+{
+ lib_func (3);
+}
diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp
new file mode 100644
index 00000000..313c01b6
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_lib.exp
@@ -0,0 +1,46 @@
+set test "uprobes_lib"
+set testpath "$srcdir/$subdir"
+set testsrc "$testpath/uprobes_exe.c"
+set testsrclib "$testpath/uprobes_lib.c"
+set testexe "./uprobes_exe"
+set testlibname "uprobes_lib"
+set testlibdir "."
+set testso "$testlibdir/lib${testlibname}.so"
+set testflags "additional_flags=-g additional_flags=-O"
+set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared"
+set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir"
+
+# Compile our test program and library.
+set res [target_compile $testsrclib $testso executable $testlibflags]
+if { $res != "" } {
+ verbose "target_compile for $testso failed: $res" 2
+ fail "$test compile $testsrclib"
+ return
+} else {
+ pass "$test compile $testsrclib"
+}
+
+set res [target_compile $testsrc $testexe executable $maintestflags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compile $testsrc"
+ return
+} else {
+ pass "$test compile $testsrc"
+}
+
+set ::result_string {main
+main_func
+main_func
+main_func
+lib_main
+lib_func
+lib_func
+lib_func}
+
+# Only run on make installcheck
+if {! [installtest_p]} { untested "$test"; return }
+if {! [utrace_p]} { untested $test; return }
+stap_run2 $srcdir/$subdir/$test.stp -c $testexe
+
+#exec rm -f $testexe $testso
diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp
new file mode 100644
index 00000000..459351a4
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_lib.stp
@@ -0,0 +1,15 @@
+probe process("uprobes_exe").function("main") {
+ printf("main\n");
+}
+
+probe process("uprobes_exe").function("main_func") {
+ printf("main_func\n");
+}
+
+probe process("libuprobes_lib.so").function("lib_main") {
+ printf("lib_main\n");
+}
+
+probe process("libuprobes_lib.so").function("lib_func") {
+ printf("lib_func\n");
+}
diff --git a/testsuite/systemtap.base/uprobes_uname.exp b/testsuite/systemtap.base/uprobes_uname.exp
new file mode 100644
index 00000000..65e1ff70
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_uname.exp
@@ -0,0 +1,46 @@
+set test "uprobes_uname"
+set testpath "$srcdir/$subdir"
+set testsrc "$testpath/uprobes_exe.c"
+set testsrclib "$testpath/uprobes_lib.c"
+set testexe "./uprobes_exe"
+set testlibname "uprobes_lib"
+set testlibdir "."
+set testso "$testlibdir/lib${testlibname}.so"
+set testflags "additional_flags=-g additional_flags=-O"
+set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared"
+set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir"
+
+# Compile our test program and library.
+set res [target_compile $testsrclib $testso executable $testlibflags]
+if { $res != "" } {
+ verbose "target_compile for $testso failed: $res" 2
+ fail "$test compile $testsrclib"
+ return
+} else {
+ pass "$test compile $testsrclib"
+}
+
+set res [target_compile $testsrc $testexe executable $maintestflags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compile $testsrc"
+ return
+} else {
+ pass "$test compile $testsrc"
+}
+
+set ::result_string {exe: main=main
+exe: main_func=main_func
+exe: main_func=main_func
+exe: main_func=main_func
+lib: lib_main=lib_main
+lib: lib_func=lib_func
+lib: lib_func=lib_func
+lib: lib_func=lib_func}
+
+# Only run on make installcheck
+if {! [installtest_p]} { untested "$test"; return }
+if {! [utrace_p]} { untested $test; return }
+stap_run2 $srcdir/$subdir/$test.stp -c $testexe
+
+#exec rm -f $testexe $testso
diff --git a/testsuite/systemtap.base/uprobes_uname.stp b/testsuite/systemtap.base/uprobes_uname.stp
new file mode 100644
index 00000000..a44d78d3
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_uname.stp
@@ -0,0 +1,7 @@
+probe process("uprobes_exe").function("*") {
+ printf("exe: %s=%s\n",probefunc(), usymname(uaddr()));
+}
+
+probe process("libuprobes_lib.so").function("*") {
+ printf("lib: %s=%s\n",probefunc(), usymname(uaddr()));
+}
diff --git a/testsuite/systemtap.base/uprobes_ustack.exp b/testsuite/systemtap.base/uprobes_ustack.exp
new file mode 100644
index 00000000..bfc435e9
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_ustack.exp
@@ -0,0 +1,97 @@
+set test "uprobes_ustack"
+set testpath "$srcdir/$subdir"
+set testsrc "$testpath/uprobes_exe.c"
+set testsrclib "$testpath/uprobes_lib.c"
+set testexe "./uprobes_exe"
+set testlibname "uprobes_lib"
+set testlibdir "."
+set testso "$testlibdir/lib${testlibname}.so"
+set testflags "additional_flags=-g additional_flags=-O"
+set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared"
+set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir"
+
+# Compile our test program and library.
+set res [target_compile $testsrclib $testso executable $testlibflags]
+if { $res != "" } {
+ verbose "target_compile for $testso failed: $res" 2
+ fail "$test compile $testsrclib"
+ return
+} else {
+ pass "$test compile $testsrclib"
+}
+
+set res [target_compile $testsrc $testexe executable $maintestflags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compile $testsrc"
+ return
+} else {
+ pass "$test compile $testsrc"
+}
+
+set ::result_string {exe: main=main
+exe: main_func=main_func
+exe: main_func=main_func
+exe: main_func=main_func
+lib: lib_main=lib_main
+lib: lib_func=lib_func
+lib: lib_func=lib_func
+lib: lib_func=lib_func}
+
+# Only run on make installcheck
+if {! [installtest_p]} { untested "$test"; return }
+if {! [utrace_p]} { untested $test; return }
+
+# Output is:
+#print_ubacktrace exe 0
+# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe]
+# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe]
+#print_ustack exe 1
+# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe]
+# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe]
+# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe]
+#print_ubacktrace lib 2
+# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so]
+# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so]
+# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe]
+# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe]
+# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe]
+# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe]
+#print_ustack lib 3
+# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so]
+# 0x00db2431 : lib_func+0x25/0x2b [.../libuprobes_lib.so]
+# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so]
+# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe]
+# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe]
+# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe]
+# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe]
+
+set print 0
+set main 0
+set main_func 0
+set lib_main 0
+set lib_func 0
+# Needs extra space since on 64bit the last ubacktrace string is
+# 7 entries * (16 hex + 2 for 0x + 1 space) = 133 chars.
+# Default MAXSTRINGLEN is 128 chars.
+spawn stap -DMAXSTRINGLEN=133 $srcdir/$subdir/$test.stp -c $testexe
+
+wait
+expect {
+ -timeout 60
+ -re {^print_[^\r\n]+\r\n} {incr print; exp_continue}
+ -re {^ 0x[a-f0-9]+ : main\+0x[^\r\n]+\r\n} {incr main; exp_continue}
+ -re {^ 0x[a-f0-9]+ : main_func\+0x[^\r\n]+\r\n} {incr main_func; exp_continue}
+ -re {^ 0x[a-f0-9]+ : lib_main\+0x[^\r\n]+\r\n} {incr lib_main; exp_continue}
+ -re {^ 0x[a-f0-9]+ : lib_func\+0x[^\r\n]+\r\n} {incr lib_func; exp_continue}
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+if {$print == 4} {pass "$test print"} {fail "$test print ($print)"}
+if {$main == 4} {pass "$test main"} {fail "$test main ($main)"}
+if {$main_func == 9} {pass "$test main_func"} {fail "$test main_func ($main_func)"}
+if {$lib_main == 2} {pass "$test lib_main"} {fail "$test lib_main ($lib_main)"}
+if {$lib_func == 3} {pass "$test lib_func"} {fail "$test lib_func ($lib_func)"}
+
+#exec rm -f $testexe $testso
diff --git a/testsuite/systemtap.base/uprobes_ustack.stp b/testsuite/systemtap.base/uprobes_ustack.stp
new file mode 100644
index 00000000..6de03b42
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_ustack.stp
@@ -0,0 +1,35 @@
+// Prints backtrace from lib through exe twice using diffent ustack functions.
+
+global hits = 0;
+
+probe process("uprobes_exe").function("main_func")
+{
+ if (hits == 0)
+ {
+ log("print_ubacktrace exe 0");
+ print_ubacktrace();
+ hits++;
+ }
+ else if (hits == 1)
+ {
+ log("print_ustack exe 1");
+ print_ustack(ubacktrace());
+ hits++;
+ }
+}
+
+probe process("libuprobes_lib.so").function("lib_func")
+{
+ if (hits == 2)
+ {
+ log("print_ubacktrace lib 2");
+ print_ubacktrace();
+ hits++;
+ }
+ else if (hits == 3)
+ {
+ log("print_ustack lib 3");
+ print_ustack(ubacktrace());
+ hits++;
+ }
+}
diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp
index 1467d9c8..8d323a8a 100644
--- a/testsuite/systemtap.base/utrace_p4.exp
+++ b/testsuite/systemtap.base/utrace_p4.exp
@@ -7,8 +7,6 @@
# utrace doesn't exist in the kernel, marks the tests as 'untested'.
# Initialize variables
-set utrace_support_found 0
-
set begin_script {"probe process(\"/bin/ls\").begin { print(\"ls begin\") }"}
set end_script {"probe process(\"/bin/ls\").end { print(\"ls end\") }"}
set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"}
@@ -24,18 +22,12 @@ set pid_syscall_return_script {"probe process(123).syscall.return { printf(\"|%d
set pid_thread_begin_script {"probe process(123).thread.begin { print(\"123 thread.begin\") }"}
set pid_thread_end_script {"probe process(123).thread.end { print(\"123 thread.end\") }"}
-# Try to find utrace_attach symbol in /proc/kallsyms
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-
#
# Do some utrace compile tests.
#
set TEST_NAME "UTRACE_P4_01"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a begin script using a path
@@ -43,7 +35,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_01_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a begin script using a pid
@@ -51,7 +43,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_02"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a end script using a path
@@ -59,7 +51,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_02_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a end script using a pid
@@ -67,7 +59,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_03"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a syscall script using a path
@@ -75,7 +67,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_03_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a syscall script using a pid
@@ -83,7 +75,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_04"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a syscall return script using a path
@@ -91,7 +83,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_04_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling a syscall return script using a pid
@@ -99,7 +91,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_05"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling an thread.begin script using a path
@@ -107,7 +99,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_05_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling an thread.begin script using a pid
@@ -115,7 +107,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_06"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling an thread.end script using a path
@@ -123,7 +115,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_06_pid"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling an thread.end script using a pid
@@ -131,7 +123,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P4_07"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} else {
# Try compiling an system-wide begin script
diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp
index 33281350..3d432dc3 100644
--- a/testsuite/systemtap.base/utrace_p5.exp
+++ b/testsuite/systemtap.base/utrace_p5.exp
@@ -1,7 +1,6 @@
# Utrace run (pass 5) tests.
# Initialize variables
-set utrace_support_found 0
set exepath "[pwd]/cat_[pid]"
set multi_srcpath "$srcdir/systemtap.base/utrace_p5_multi.c"
set multi_exepath "[pwd]/utrace_p5_multi_[pid]"
@@ -90,12 +89,6 @@ set bz6841_script {
}
set bz6841_script_output ".+ issues syscall \\d+ times\r\n"
-# Try to find utrace_attach symbol in /proc/kallsyms
-set path "/proc/kallsyms"
-if {! [catch {exec grep -q utrace_attach $path} dummy]} {
- set utrace_support_found 1
-}
-
# Set up our own copy of /bin/cat, to make testing for a particular
# executable easy. We can't use 'ln' here, since we might be creating
# a cross-device link. We can't use 'ln -s' here, since the kernel
@@ -138,7 +131,7 @@ proc run_utrace_p5_multi {} {
}
set TEST_NAME "UTRACE_P5_01"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -148,7 +141,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_02"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -158,7 +151,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_03"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -168,7 +161,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_04"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -178,7 +171,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_05"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -189,7 +182,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_06"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
@@ -200,7 +193,7 @@ if {$utrace_support_found == 0} {
}
set TEST_NAME "UTRACE_P5_07"
-if {$utrace_support_found == 0} {
+if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested "$TEST_NAME"
diff --git a/testsuite/systemtap.base/utrace_syscall_args.c b/testsuite/systemtap.base/utrace_syscall_args.c
new file mode 100644
index 00000000..2d3da838
--- /dev/null
+++ b/testsuite/systemtap.base/utrace_syscall_args.c
@@ -0,0 +1,67 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h> /* For SYS_xxx definitions */
+
+int main()
+{
+ int fd, ret;
+ struct stat fs;
+ void *r;
+ int rc;
+
+ /* create a file with something in it */
+ fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600);
+ lseek(fd, 1024, SEEK_SET);
+ write(fd, "abcdef", 6);
+ close(fd);
+
+ fd = open("foobar", O_RDONLY);
+
+ /* stat for file size */
+ ret = fstat(fd, &fs);
+
+ /* mmap file file, then unmap it. */
+ r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (r != MAP_FAILED)
+ munmap(r, fs.st_size);
+ close(fd);
+
+ /* OK, try some system calls to see if we get the arguments
+ * correctly. */
+#if (__LONG_MAX__ > __INT_MAX__)
+ rc = syscall (__NR_dup, (unsigned long)-12345,
+ (unsigned long)0xffffffffffffffff,
+ (unsigned long)0xa5a5a5a5a5a5a5a5,
+ (unsigned long)0xf0f0f0f0f0f0f0f0,
+ (unsigned long)0x5a5a5a5a5a5a5a5a,
+ (unsigned long)0xe38e38e38e38e38e);
+#else
+ rc = syscall (__NR_dup, (unsigned long)-12345,
+ (unsigned long)0xffffffff,
+ (unsigned long)0xa5a5a5a5,
+ (unsigned long)0xf0f0f0f0,
+ (unsigned long)0x5a5a5a5a,
+ (unsigned long)0xe38e38e3);
+#endif
+#if (__LONG_MAX__ > __INT_MAX__)
+ rc = syscall ((unsigned long)-1,
+ (unsigned long)0x1c71c71c71c71c71,
+ (unsigned long)0x0f0f0f0f0f0f0f0f,
+ (unsigned long)0xdb6db6db6db6db6d,
+ (unsigned long)0x2492492492492492,
+ (unsigned long)0xad6b5ad6b5ad6b5a,
+ (unsigned long)0xdef7ddef7ddef7dd);
+#else
+ rc = syscall ((unsigned long)-1,
+ (unsigned long)0x1c71c71c,
+ (unsigned long)0x0f0f0f0f,
+ (unsigned long)0xdb6db6db,
+ (unsigned long)0x24924924,
+ (unsigned long)0xad6b5ad6,
+ (unsigned long)0xdef7ddef);
+#endif
+ return 0;
+}
diff --git a/testsuite/systemtap.base/utrace_syscall_args.exp b/testsuite/systemtap.base/utrace_syscall_args.exp
new file mode 100644
index 00000000..98bc457e
--- /dev/null
+++ b/testsuite/systemtap.base/utrace_syscall_args.exp
@@ -0,0 +1,82 @@
+# Utrace system call argument tests.
+
+set flags ""
+set srcpath "$srcdir/$subdir/utrace_syscall_args.c"
+set exepath "[pwd]/utrace_syscall_args"
+set stppath "$srcdir/$subdir/utrace_syscall_args.stp"
+
+set output_string "mmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nmunmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nclose\\(\[0-9\]+\\)\\(0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\ndup\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nbad_syscall\\(-?\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nsystemtap test success\r\n"
+
+# For first pass, force 64-bit compilation for 64-bit systems. Add
+# any other 64-bit architecture you want tested below.
+#
+# To find tcl's platform name for your machine, run the following:
+# echo "puts $::tcl_platform(machine)" | tclsh
+
+switch -regexp $::tcl_platform(machine) {
+ ^ia64$ {
+ set do_64_bit_pass 1
+ set flags ""
+ }
+ ^(x86_64|ppc64|s390x)$ {
+ set do_64_bit_pass 1
+ set flags "additional_flags=-m64"
+ }
+ default {
+ set do_64_bit_pass 0
+ }
+}
+
+if {$do_64_bit_pass} {
+ set testname "64_BIT_UTRACE_SYSCALL_ARGS"
+ if {![installtest_p]} { untested $testname; continue }
+ if {![utrace_p]} { untested $testname; continue }
+ send_log "Testing ${testname}\n"
+
+ # Compile our test program.
+ set res [target_compile $srcpath $exepath executable $flags]
+ if { $res != "" } {
+ verbose "target_compile for $exepath failed: $res" 2
+ fail "$testname: unable to compile $srcpath"
+ return
+ }
+
+ # Run the test.
+ stap_run $testname no_load $output_string -g $stppath -c $exepath
+
+ catch {exec rm -f $exepath foobar}
+}
+
+# The second pass is for systems that support 32-bit executables
+# (either exclusively or in addition to 64-bit executables).
+set do_32_bit_pass 1
+switch -regexp $::tcl_platform(machine) {
+ ^(x86_64|ppc64)$ {
+ set flags "additional_flags=-m32"
+ }
+ ^s390x$ {
+ set flags "additional_flags=-m31"
+ }
+ ^ia64$ {
+ set do_32_bit_pass 0
+ }
+}
+
+if {$do_32_bit_pass} {
+ set testname "32_BIT_UTRACE_SYSCALL_ARGS"
+ if {![installtest_p]} { untested $testname; continue }
+ if {![utrace_p]} { untested $testname; continue }
+ send_log "Testing ${testname}\n"
+
+ # Compile our test program
+ set res [target_compile $srcpath $exepath executable $flags]
+ if { $res != "" } {
+ verbose "target_compile for $exepath failed: $res" 2
+ fail "$testname: unable to compile $srcpath"
+ return
+ }
+
+ stap_run $testname no_load $output_string -g $stppath -c $exepath
+
+ catch {exec rm -f $exepath foobar}
+}
diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp
new file mode 100644
index 00000000..6c9e14fc
--- /dev/null
+++ b/testsuite/systemtap.base/utrace_syscall_args.stp
@@ -0,0 +1,406 @@
+%{
+#include "syscall.h"
+%}
+
+function mmap_syscall_no:long () %{
+ THIS->__retvalue = MMAP_SYSCALL_NO(current); /* pure */
+%}
+function mmap2_syscall_no:long () %{
+ THIS->__retvalue = MMAP2_SYSCALL_NO(current); /* pure */
+%}
+function munmap_syscall_no:long () %{
+ THIS->__retvalue = MUNMAP_SYSCALL_NO(current); /* pure */
+%}
+
+global syscalls_seen = 0
+global failures = 0
+
+global mmap_found = 0
+global mmap_args[10]
+
+global munmap_found = 0
+global munmap_args[10]
+
+global close_found = 0
+global close_args[10]
+
+global dup_found = 0
+global dup_args[10]
+
+global bad_syscall_found = 0
+global bad_syscall_args[10]
+
+probe begin
+{
+ printf("systemtap starting probe\n")
+}
+
+probe syscall.open {
+ if (filename == "foobar") {
+ syscalls_seen += 1
+ }
+}
+
+probe process("utrace_syscall_args").syscall {
+ if (syscalls_seen >= 2) {
+ syscalls_seen += 1
+
+ # We skip the fstat() syscall, which is the 1st syscall after
+ # the open() by not looking at 'syscalls_seen == 3'.
+
+ if (syscalls_seen == 4 && ($syscall == mmap_syscall_no()
+ || $syscall == mmap2_syscall_no())) {
+ mmap_found = 1
+ mmap_args[0] = $syscall
+ mmap_args[1] = $arg1
+ mmap_args[2] = $arg2
+ mmap_args[3] = $arg3
+ mmap_args[4] = $arg4
+ mmap_args[5] = $arg5
+ mmap_args[6] = $arg6
+
+%(arch == "s390x" %?
+ # s390 requires this for mmap. Verified by running:
+ # # strace strace utrace_syscall_args
+ addr = mmap_args[1]
+ mmap_args[1] = user_long(addr)
+ addr += 8
+ mmap_args[2] = user_long(addr)
+ addr += 8
+ mmap_args[3] = user_long(addr)
+ addr += 8
+ mmap_args[4] = user_long(addr)
+ addr += 8
+ mmap_args[5] = user_long(addr)
+ addr += 8
+ mmap_args[6] = user_long(addr)
+%)
+ }
+ else if (syscalls_seen == 5 && $syscall == munmap_syscall_no()) {
+ munmap_found = 1
+ munmap_args[0] = $syscall
+ munmap_args[1] = $arg1
+ munmap_args[2] = $arg2
+ }
+ else if (syscalls_seen == 6) {
+ close_found = 1
+ close_args[0] = $syscall
+ close_args[1] = $arg1
+ }
+ else if (syscalls_seen == 7) {
+ dup_found = 1
+ dup_args[0] = $syscall
+ dup_args[1] = $arg1
+ dup_args[2] = $arg2
+ dup_args[3] = $arg3
+ dup_args[4] = $arg4
+ dup_args[5] = $arg5
+ dup_args[6] = $arg6
+ }
+ else if (syscalls_seen == 8) {
+ bad_syscall_found = 1
+ bad_syscall_args[0] = $syscall
+ bad_syscall_args[1] = $arg1
+ bad_syscall_args[2] = $arg2
+ bad_syscall_args[3] = $arg3
+ bad_syscall_args[4] = $arg4
+ bad_syscall_args[5] = $arg5
+ bad_syscall_args[6] = $arg6
+ }
+ }
+}
+probe process("utrace_syscall_args").syscall.return {
+ if (syscalls_seen >= 4) {
+ if (syscalls_seen == 4) {
+ mmap_args[7] = $return
+ mmap_args[8] = $syscall
+ }
+ else if (syscalls_seen == 5) {
+ munmap_args[3] = $return
+ munmap_args[4] = $syscall
+ }
+ else if (syscalls_seen == 6) {
+ close_args[2] = $return
+ close_args[3] = $syscall
+ }
+ else if (syscalls_seen == 7) {
+ dup_args[7] = $return
+ dup_args[8] = $syscall
+ }
+ else if (syscalls_seen == 8) {
+ bad_syscall_args[7] = $return
+ bad_syscall_args[8] = $syscall
+ syscalls_seen = 0
+ }
+ }
+}
+
+probe end
+{
+ printf("systemtap ending probe\n")
+
+ # print mmap info
+ if (mmap_found == 0) {
+ printf("error: no mmap system call found\n")
+ failures += 1
+ }
+ else {
+ printf("mmap(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n",
+ mmap_args[0], mmap_args[1], mmap_args[2], mmap_args[3],
+ mmap_args[4], mmap_args[5], mmap_args[6], mmap_args[7])
+
+ # Validate arguments. We can only check certain arguments.
+ # It is possible that mmap's 'prot' and 'flags' arguments
+ # could vary per platform, so we'll ignore them.
+ if (mmap_args[1] != 0) {
+ failures += 1
+ printf("mmap bad arg 1: 0x%x vs 0x0\n", mmap_args[1])
+ }
+ if (mmap_args[2] != 0x406) {
+ failures += 1
+ printf("mmap bad arg 2: 0x%x vs 0x406\n", mmap_args[2])
+ }
+ if (mmap_args[6] != 0) {
+ failures += 1
+ printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6])
+ }
+
+ # Validate syscall number
+ if (mmap_args[0] != mmap_args[8]) {
+ failures += 1
+ printf("mmap $syscall mismatch: %d vs. %d\n",
+ mmap_args[0], mmap_args[8])
+ }
+ }
+
+ # print munmap info
+ if (munmap_found == 0) {
+ printf("error: no munmap system call found\n")
+ failures += 1
+ }
+ else if (munmap_found == 0 || mmap_found == 0) {
+ printf("error: no munmap/mmap system call found\n")
+ failures += 1
+ }
+ else {
+ printf("munmap(%d)(0x%x, 0x%x) = 0x%x\n",
+ munmap_args[0], munmap_args[1], munmap_args[2], munmap_args[3])
+
+ # Validate arguments. munmap()'s first argument should be the
+ # same as the mmap() return value.
+ if (munmap_args[1] != mmap_args[7]) {
+ failures += 1
+ printf("munmap bad arg 1: 0x%x vs 0x%x\n", munmap_args[1],
+ mmap_args[7])
+ }
+ if (munmap_args[2] != mmap_args[2]) {
+ failures += 1
+ printf("munmap bad arg 2: 0x%x vs 0x%x\n", munmap_args[2],
+ mmap_args[2])
+ }
+ # Validate return value
+ if (munmap_args[7] != 0) {
+ failures += 1
+ printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7])
+ }
+
+ # Validate syscall number
+ if (munmap_args[0] != munmap_args[4]) {
+ failures += 1
+ printf("munmap $syscall mismatch: %d vs. %d\n",
+ munmap_args[0], munmap_args[4])
+ }
+ }
+
+ # print close info
+ if (close_found == 0) {
+ printf("error: no close system call found\n")
+ failures += 1
+ }
+ else if (close_found == 1) {
+ printf("close(%d)(0x%x) = 0x%x\n",
+ close_args[0], close_args[1], close_args[2])
+
+ if (mmap_args[5] != close_args[1]) {
+ failures += 1
+ printf("close bad arg 1: 0x%x vs 0x%x\n",
+ close_args[0], mmap_args[5])
+ }
+
+ # Validate syscall number
+ if (close_args[0] != close_args[3]) {
+ failures += 1
+ printf("close $syscall mismatch: %d vs. %d\n",
+ close_args[0], close_args[3])
+ }
+ }
+
+ # print dup info
+ if (dup_found == 0) {
+ printf("error: no dup system call found\n")
+ failures += 1
+ }
+ else {
+ printf("dup(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n",
+ dup_args[0], dup_args[1], dup_args[2], dup_args[3],
+ dup_args[4], dup_args[5], dup_args[6], dup_args[7])
+
+ # Validate arguments - handle 32-bit vs. 64-bit.
+ if ((dup_args[1] & 0xffffffff00000000) != 0) {
+ if (dup_args[1] != 0xffffffffffffcfc7) {
+ failures += 1
+ printf("dup bad arg 1: 0x%x vs 0xffffffffffffcfc7\n",
+ dup_args[1])
+ }
+ if (dup_args[2] != 0xffffffffffffffff) {
+ failures += 1
+ printf("dup bad arg 2: 0x%x vs 0xffffffffffffffff\n",
+ dup_args[2])
+ }
+ if (dup_args[3] != 0xa5a5a5a5a5a5a5a5) {
+ failures += 1
+ printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5a5a5a5a5\n",
+ dup_args[3])
+ }
+ if (dup_args[4] != 0xf0f0f0f0f0f0f0f0) {
+ failures += 1
+ printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0f0f0f0f0\n",
+ dup_args[4])
+ }
+ if (dup_args[5] != 0x5a5a5a5a5a5a5a5a) {
+ failures += 1
+ printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a5a5a5a5a\n",
+ dup_args[5])
+ }
+ if (dup_args[6] != 0xe38e38e38e38e38e) {
+ failures += 1
+ printf("dup bad arg 6: 0x%x vs 0xe38e38e38e38d38e\n",
+ dup_args[6])
+ }
+ }
+ else {
+ if (dup_args[1] != 0xffffcfc7) {
+ failures += 1
+ printf("dup bad arg 1: 0x%x vs 0xffffcfc7\n", dup_args[1])
+ }
+ if (dup_args[2] != 0xffffffff) {
+ failures += 1
+ printf("dup bad arg 2: 0x%x vs 0xffffffff\n", dup_args[2])
+ }
+ if (dup_args[3] != 0xa5a5a5a5) {
+ failures += 1
+ printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5\n", dup_args[3])
+ }
+ if (dup_args[4] != 0xf0f0f0f0) {
+ failures += 4
+ printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0\n", dup_args[4])
+ }
+ if (dup_args[5] != 0x5a5a5a5a) {
+ failures += 1
+ printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a\n", dup_args[5])
+ }
+ if (dup_args[6] != 0xe38e38e3) {
+ failures += 1
+ printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6])
+ }
+ }
+
+ # Validate syscall number
+ if (dup_args[0] != dup_args[8]) {
+ failures += 1
+ printf("dup $syscall mismatch: %d vs. %d\n",
+ dup_args[0], dup_args[8])
+ }
+ }
+
+ # print bad_syscall info
+ if (bad_syscall_found == 0) {
+ printf("error: no bad_syscall system call found\n")
+ failures += 1
+ }
+ else {
+ printf("bad_syscall(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n",
+ bad_syscall_args[0], bad_syscall_args[1], bad_syscall_args[2], bad_syscall_args[3],
+ bad_syscall_args[4], bad_syscall_args[5], bad_syscall_args[6], bad_syscall_args[7])
+
+ # Validate arguments - handle 32-bit vs. 64-bit.
+ if (bad_syscall_args[1] > 0xffffffff) {
+ if (bad_syscall_args[1] != 0x1c71c71c71c71c71) {
+ failures += 1
+ printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c71c71c71\n",
+ bad_syscall_args[1])
+ }
+ if (bad_syscall_args[2] != 0x0f0f0f0f0f0f0f0f) {
+ failures += 1
+ printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f0f0f0f0f\n",
+ bad_syscall_args[2])
+ }
+ if (bad_syscall_args[3] != 0xdb6db6db6db6db6d) {
+ failures += 1
+ printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db6db6db6d\n",
+ bad_syscall_args[3])
+ }
+ if (bad_syscall_args[4] != 0x2492492492492492) {
+ failures += 1
+ printf("bad_syscall bad arg 4: 0x%x vs 0x2492492492492492\n",
+ bad_syscall_args[4])
+ }
+ if (bad_syscall_args[5] != 0xad6b5ad6b5ad6b5a) {
+ failures += 1
+ printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6b5ad6b5a\n",
+ bad_syscall_args[5])
+ }
+ if (bad_syscall_args[6] != 0xdef7ddef7ddef7dd) {
+ failures += 1
+ printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef7ddef7dd\n",
+ bad_syscall_args[6])
+ }
+ }
+ else {
+ if (bad_syscall_args[1] != 0x1c71c71c) {
+ failures += 1
+ printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c\n",
+ bad_syscall_args[1])
+ }
+ if (bad_syscall_args[2] != 0x0f0f0f0f) {
+ failures += 1
+ printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f\n",
+ bad_syscall_args[2])
+ }
+ if (bad_syscall_args[3] != 0xdb6db6db) {
+ failures += 1
+ printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db\n",
+ bad_syscall_args[3])
+ }
+ if (bad_syscall_args[4] != 0x24924924) {
+ failures += 4
+ printf("bad_syscall bad arg 4: 0x%x vs 0x24924924\n",
+ bad_syscall_args[4])
+ }
+ if (bad_syscall_args[5] != 0xad6b5ad6) {
+ failures += 1
+ printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6\n",
+ bad_syscall_args[5])
+ }
+ if (bad_syscall_args[6] != 0xdef7ddef) {
+ failures += 1
+ printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef\n",
+ bad_syscall_args[6])
+ }
+ }
+
+ # Validate syscall number
+ if (bad_syscall_args[0] != bad_syscall_args[8]) {
+ failures += 1
+ printf("bad_syscall $syscall mismatch: %d vs. %d\n",
+ bad_syscall_args[0], bad_syscall_args[8])
+ }
+ }
+
+ if (failures == 0) {
+ printf("systemtap test success\n")
+ }
+ else {
+ printf("systemtap test failure\n")
+ }
+}
diff --git a/testsuite/systemtap.base/x86_gs.exp b/testsuite/systemtap.base/x86_gs.exp
new file mode 100644
index 00000000..98ab3051
--- /dev/null
+++ b/testsuite/systemtap.base/x86_gs.exp
@@ -0,0 +1,12 @@
+set test "x86_gs"
+if {![installtest_p]} { untested $test; return }
+set arch [exec uname -m]
+if {$arch!="i686"} { untested $test; return }
+spawn stap $srcdir/$subdir/x86_gs.stp
+expect {
+ -timeout 60
+ -re "0\r\n" { pass $test }
+ -re "140\r\n" { pass $test }
+ eof { fail $test }
+ timeout { fail "$test unexpected timeout" }
+}
diff --git a/testsuite/systemtap.base/x86_gs.stp b/testsuite/systemtap.base/x86_gs.stp
new file mode 100644
index 00000000..68b58512
--- /dev/null
+++ b/testsuite/systemtap.base/x86_gs.stp
@@ -0,0 +1,10 @@
+#! stap
+
+# test x86 gs register
+
+probe begin {
+ if (!_stp_regs_registered)
+ _stp_register_regs()
+ printf("%d\n",test_x86_gs() * 100 + _reg_offsets["gs"]) /* 0 or 140 */
+ exit()
+}