1 # Copyright
2012-2023 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"
23 # Only x86 and x86_64 targets are supported
for now.
25 require
{is_any_target
"x86_64-*" "i?86-*"}
27 proc compile_stap_bin
{exec_name
{arg ""}} {
34 set arg "additional_flags=$arg"
37 set executable $
{exec_name
}
39 if { [gdb_compile
"$srcdir/$subdir/$srcfile" \
40 [standard_output_file $exec_name
] \
41 executable
[concat $
arg debug nowarnings
]] != "" } {
42 untested
"failed to compile"
49 proc prepare_for_trace_test
{} {
52 clean_restart $executable
54 if { ![runto_main
] } {
55 perror
"Could not run to `main'."
59 gdb_breakpoint
[gdb_get_line_number
"end-here"]
62 proc run_trace_experiment
{ test_probe msg
} {
65 set test
"collect $msg: start trace experiment"
66 gdb_test_multiple
"tstart" "$test" {
67 -re
"^tstart\r\n$gdb_prompt $" {
73 "Continuing.*Breakpoint \[0-9\]+.*" \
74 "collect $msg: run trace experiment"
75 gdb_test_no_output
"tstop" \
76 "collect $msg: stop trace experiment"
77 gdb_test
"tfind start" \
79 "collect $msg: tfind test frame"
82 proc gdb_collect_probe_arg
{ msg probe val_arg0
} {
85 prepare_for_trace_test
87 gdb_test
"trace $probe" \
88 "Tracepoint \[0-9\]+ at .*" \
89 "collect $msg: set tracepoint"
90 gdb_trace_setactions
"collect $msg: define actions" \
92 "collect \$_probe_arg0" "^$"
95 run_trace_experiment $msg $probe
97 gdb_test
"print \$_probe_arg0" \
98 "\\$\[0-9\]+ = $val_arg0" \
99 "collect $msg: collected probe arg0"
102 if {![compile_stap_bin
"stap-probe-nosem"]} {
103 # An appropriate failure message has already been output
107 clean_restart $executable
108 if { ![runto_main
] } {
109 perror
"Could not run to `main'."
113 if { ![gdb_target_supports_trace
] } {
114 # Test cannot run
on this target.
115 unsupported
"test requires trace"
119 gdb_collect_probe_arg
"probe args without semaphore" "-probe-stap user" "23"
122 if {![compile_stap_bin
"stap-probe-sem" "-DUSE_PROBES"]} {
123 # An appropriate failure message has already been output
127 gdb_collect_probe_arg
"probe args with semaphore" "-probe-stap two" "46"
130 gdb_test
"tfind none" ".*" ""