Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.trace / stap-trace.exp
blob5b556f50a07172c44db1bfcedf72ea243b2ea2eb
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"
18 standard_testfile
19 set executable ""
21 set ws "\[\r\n\t \]+"
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 ""}} {
28 global srcfile
29 global srcdir
30 global subdir
31 global executable
33 if { $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"
43 return 0
46 return 1
49 proc prepare_for_trace_test {} {
50 global executable
52 clean_restart $executable
54 if { ![runto_main] } {
55 perror "Could not run to `main'."
56 return
59 gdb_breakpoint [gdb_get_line_number "end-here"]
62 proc run_trace_experiment { test_probe msg } {
63 global gdb_prompt
65 set test "collect $msg: start trace experiment"
66 gdb_test_multiple "tstart" "$test" {
67 -re "^tstart\r\n$gdb_prompt $" {
68 pass "$test"
72 gdb_test "continue" \
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" \
78 "#0 .*" \
79 "collect $msg: tfind test frame"
82 proc gdb_collect_probe_arg { msg probe val_arg0 } {
83 global gdb_prompt
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" \
91 "" \
92 "collect \$_probe_arg0" "^$"
94 # Begin the test.
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
104 return -1
107 clean_restart $executable
108 if { ![runto_main] } {
109 perror "Could not run to `main'."
110 return
113 if { ![gdb_target_supports_trace] } {
114 # Test cannot run on this target.
115 unsupported "test requires trace"
116 return 1
119 gdb_collect_probe_arg "probe args without semaphore" "-probe-stap user" "23"
120 gdb_exit
122 if {![compile_stap_bin "stap-probe-sem" "-DUSE_PROBES"]} {
123 # An appropriate failure message has already been output
124 return -1
127 gdb_collect_probe_arg "probe args with semaphore" "-probe-stap two" "46"
129 # Finished!
130 gdb_test "tfind none" ".*" ""