]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/trace-mt.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-mt.exp
CommitLineData
1d506c26 1# Copyright 2012-2024 Free Software Foundation, Inc.
c03e6ccc
YQ
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.
6#
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.
11#
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/>.
14
4ec70201 15load_lib "trace-support.exp"
c03e6ccc 16
497a5eb0 17standard_testfile
c03e6ccc 18set executable $testfile
c03e6ccc
YQ
19set expfile $testfile.exp
20
21# Some targets have leading underscores on assembly symbols.
22set additional_flags [gdb_target_symbol_prefix_flags]
23
fbee47e0 24require gdb_trace_common_supports_arch
8bca2978 25
c03e6ccc
YQ
26if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
27 executable [list debug $additional_flags] ] != "" } {
8bca2978 28 # gdb_compile_pthreads provides an appropriate unsupported message.
c03e6ccc
YQ
29 return -1
30}
31
32clean_restart ${testfile}
33
34if ![runto_main] {
c03e6ccc
YQ
35 return -1
36}
37
38if ![gdb_target_supports_trace] {
39 unsupported "target does not support trace"
40 return -1
41}
42
43proc step_over_tracepoint { trace_type } \
44{with_test_prefix "step over $trace_type" \
45{
46 global executable
47 global hex
48
49 # Start with a fresh gdb.
50 clean_restart ${executable}
51 # Make sure inferior is running in all-stop mode.
52 gdb_test_no_output "set non-stop 0"
53 if ![runto_main] {
c03e6ccc
YQ
54 return -1
55 }
56
57 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
58 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1"
59
60 gdb_test "${trace_type} *\$pc" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
61 gdb_test_no_output "tstart"
62
63 gdb_test "stepi" ".*"
64 gdb_test_no_output "tstop"
65}}
66
67# Set breakpoint and tracepoint at the same address.
68
69proc break_trace_same_addr { trace_type option } \
70{with_test_prefix "$trace_type $option" \
71{
72 global executable
73 global hex
74
75 # Start with a fresh gdb.
76 clean_restart ${executable}
77 if ![runto_main] {
c03e6ccc
YQ
78 return -1
79 }
80
81 gdb_test_no_output "set breakpoint always-inserted ${option}"
82
194ed413 83 gdb_breakpoint "end" qualified
c03e6ccc
YQ
84
85 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
86 gdb_test "${trace_type} set_point1" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
87
88 gdb_test_no_output "tstart"
89
90 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 1"
91 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 2"
92
93 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to end"
94 gdb_test_no_output "tstop"
95
96 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
97 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
98
99 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
100}}
101
102foreach break_always_inserted { "on" "off" } {
103 break_trace_same_addr "trace" ${break_always_inserted}
104}
105
106step_over_tracepoint "trace"
107
d6195dc9 108require allow_shlib_tests
8bca2978 109
c0d4d1c0 110set libipa [get_in_proc_agent]
952ebca5 111set remote_libipa [gdb_load_shlib $libipa]
c03e6ccc
YQ
112
113# Compile test case again with IPA.
114if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
115 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
84c93cd5 116 untested "failed to compile with in-process agent library"
c03e6ccc
YQ
117 return -1
118}
119clean_restart ${executable}
120
121if ![runto_main] {
c03e6ccc
YQ
122 return 0
123}
124
125gdb_reinitialize_dir $srcdir/$subdir
952ebca5 126if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
bc6c7af4 127 untested "could not find IPA lib loaded"
c03e6ccc
YQ
128} else {
129 foreach break_always_inserted { "on" "off" } {
130 break_trace_same_addr "ftrace" ${break_always_inserted}
131 }
132
133 step_over_tracepoint "ftrace"
134}