Avoid "text file busy" in dw2-using-debug-str.exp
[binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-mt.exp
blob7246ddc8a8eab5c15654f2d363c34f6c11b99f71
1 # Copyright 2012-2024 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 load_lib "trace-support.exp"
17 standard_testfile
19 # Some targets have leading underscores on assembly symbols.
20 set additional_flags [gdb_target_symbol_prefix_flags]
22 require gdb_trace_common_supports_arch
24 with_test_prefix "runtime trace support check" {
25     if { [prepare_for_testing "prepare for testing" ${binfile} $srcfile \
26               [list debug pthreads $additional_flags]] } {
27         return
28     }
30     if ![runto_main] {
31         return -1
32     }
34     if ![gdb_target_supports_trace] {
35         unsupported "target does not support trace"
36         return -1
37     }
40 proc step_over_tracepoint { binfile trace_type } \
41 {with_test_prefix "step over $trace_type" \
43     global hex
45     # Start with a fresh gdb.
46     clean_restart $binfile
48     # Make sure inferior is running in all-stop mode.
49     gdb_test_no_output "set non-stop 0"
50     if ![runto_main] {
51         return -1
52     }
54     gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
55     gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1"
57     gdb_test "${trace_type} *\$pc" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
58     gdb_test_no_output "tstart"
60     gdb_test "stepi" ".*"
61     gdb_test_no_output "tstop"
64 # Set breakpoint and tracepoint at the same address.
66 proc break_trace_same_addr { binfile trace_type option } \
67 {with_test_prefix "$trace_type $option" \
69     global hex
71     # Start with a fresh gdb.
72     clean_restart $binfile
73     if ![runto_main] {
74         return -1
75     }
77     gdb_test_no_output "set breakpoint always-inserted ${option}"
79     gdb_breakpoint "end" qualified
81     gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
82     gdb_test "${trace_type} set_point1" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
84     gdb_test_no_output "tstart"
86     gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 1"
87     gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 2"
89     gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to end"
90     gdb_test_no_output "tstop"
92     gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
93     gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
95     gdb_test "tfind" "Target failed to find requested trace frame\\..*"
98 foreach break_always_inserted { "on" "off" } {
99     break_trace_same_addr $binfile "trace" ${break_always_inserted}
102 step_over_tracepoint $binfile "trace"
104 require allow_shlib_tests
106 require allow_in_proc_agent
107 set libipa [get_in_proc_agent]
108 set remote_libipa [gdb_load_shlib $libipa]
110 # Compile test case again with IPA.
111 set binfile_ipa ${binfile}-ipa
112 if { [prepare_for_testing "prepare for testing" $binfile_ipa $srcfile \
113           [list debug pthreads $additional_flags shlib=$libipa]] } {
114     return
117 if ![runto_main] {
118     return 0
121 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
122     untested "could not find IPA lib loaded"
123 } else {
124     foreach break_always_inserted { "on" "off" } {
125         break_trace_same_addr $binfile_ipa "ftrace" ${break_always_inserted}
126     }
128     step_over_tracepoint $binfile_ipa "ftrace"