1 # Copyright 2012-2013 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 load_lib "trace-support.exp"
24 # Only x86 and x86_64 targets are supported for now.
26 if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } {
30 proc compile_stap_bin {exec_name {arg ""}} {
37 set arg "additional_flags=$arg"
40 set executable ${exec_name}
42 if { [gdb_compile "$srcdir/$subdir/$srcfile" \
43 [standard_output_file $exec_name] \
44 executable [concat $arg debug nowarnings]] != "" } {
45 untested "Could not compile ${srcfile}"
52 proc prepare_for_trace_test {} {
55 clean_restart $executable
57 if { ![runto_main] } {
58 perror "Could not run to `main'."
62 gdb_breakpoint [gdb_get_line_number "end-here"]
65 proc run_trace_experiment { test_probe msg } {
68 set test "collect $msg: start trace experiment"
69 gdb_test_multiple "tstart" "$test" {
70 -re "^tstart\r\n$gdb_prompt $" {
76 "Continuing.*Breakpoint \[0-9\]+.*" \
77 "collect $msg: run trace experiment"
80 "collect $msg: stop trace experiment"
81 gdb_test "tfind start" \
83 "collect $msg: tfind test frame"
86 proc gdb_collect_probe_arg { msg probe val_arg0 } {
90 prepare_for_trace_test
92 gdb_test "trace $probe" \
93 "Tracepoint \[0-9\]+ at .*" \
94 "collect $msg: set tracepoint"
95 gdb_trace_setactions "collect $msg: define actions" \
97 "collect \$_probe_arg0" "^$"
100 run_trace_experiment $msg $probe
102 gdb_test "print \$_probe_arg0" \
103 "\\$\[0-9\]+ = $val_arg0$cr" \
104 "collect $msg: collected probe arg0"
107 if {![compile_stap_bin "stap-probe-nosem"]} {
108 # An appropriate failure message has already been output
112 clean_restart $executable
113 if { ![runto_main] } {
114 perror "Could not run to `main'."
118 if { ![gdb_target_supports_trace] } {
119 # Test cannot run on this target.
123 gdb_collect_probe_arg "probe args without semaphore" "-probe-stap user" "23"
126 if {![compile_stap_bin "stap-probe-sem" "-DUSE_PROBES"]} {
127 # An appropriate failure message has already been output
131 gdb_collect_probe_arg "probe args with semaphore" "-probe-stap two" "46"
134 gdb_test "tfind none" ".*" ""