Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-mt.exp
CommitLineData
88b9d363 1# Copyright 2012-2022 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
8bca2978
SL
24if ![gdb_trace_common_supports_arch] {
25 unsupported "no trace-common.h support for arch"
26 return -1
27}
28
c03e6ccc
YQ
29if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
30 executable [list debug $additional_flags] ] != "" } {
8bca2978 31 # gdb_compile_pthreads provides an appropriate unsupported message.
c03e6ccc
YQ
32 return -1
33}
34
35clean_restart ${testfile}
36
37if ![runto_main] {
bc6c7af4 38 fail "can't run to main to check for trace support"
c03e6ccc
YQ
39 return -1
40}
41
42if ![gdb_target_supports_trace] {
43 unsupported "target does not support trace"
44 return -1
45}
46
47proc step_over_tracepoint { trace_type } \
48{with_test_prefix "step over $trace_type" \
49{
50 global executable
51 global hex
52
53 # Start with a fresh gdb.
54 clean_restart ${executable}
55 # Make sure inferior is running in all-stop mode.
56 gdb_test_no_output "set non-stop 0"
57 if ![runto_main] {
bc6c7af4 58 fail "can't run to main"
c03e6ccc
YQ
59 return -1
60 }
61
62 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
63 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1"
64
65 gdb_test "${trace_type} *\$pc" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
66 gdb_test_no_output "tstart"
67
68 gdb_test "stepi" ".*"
69 gdb_test_no_output "tstop"
70}}
71
72# Set breakpoint and tracepoint at the same address.
73
74proc break_trace_same_addr { trace_type option } \
75{with_test_prefix "$trace_type $option" \
76{
77 global executable
78 global hex
79
80 # Start with a fresh gdb.
81 clean_restart ${executable}
82 if ![runto_main] {
bc6c7af4 83 fail "can't run to main"
c03e6ccc
YQ
84 return -1
85 }
86
87 gdb_test_no_output "set breakpoint always-inserted ${option}"
88
194ed413 89 gdb_breakpoint "end" qualified
c03e6ccc
YQ
90
91 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
92 gdb_test "${trace_type} set_point1" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
93
94 gdb_test_no_output "tstart"
95
96 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 1"
97 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 2"
98
99 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to end"
100 gdb_test_no_output "tstop"
101
102 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
103 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
104
105 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
106}}
107
108foreach break_always_inserted { "on" "off" } {
109 break_trace_same_addr "trace" ${break_always_inserted}
110}
111
112step_over_tracepoint "trace"
113
8bca2978
SL
114if {[skip_shlib_tests]} {
115 return 0
116}
117
c0d4d1c0 118set libipa [get_in_proc_agent]
952ebca5 119set remote_libipa [gdb_load_shlib $libipa]
c03e6ccc
YQ
120
121# Compile test case again with IPA.
122if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
123 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
84c93cd5 124 untested "failed to compile with in-process agent library"
c03e6ccc
YQ
125 return -1
126}
127clean_restart ${executable}
128
129if ![runto_main] {
bc6c7af4 130 fail "can't run to main for ftrace tests"
c03e6ccc
YQ
131 return 0
132}
133
134gdb_reinitialize_dir $srcdir/$subdir
952ebca5 135if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
bc6c7af4 136 untested "could not find IPA lib loaded"
c03e6ccc
YQ
137} else {
138 foreach break_always_inserted { "on" "off" } {
139 break_trace_same_addr "ftrace" ${break_always_inserted}
140 }
141
142 step_over_tracepoint "ftrace"
143}
This page took 1.356878 seconds and 4 git commands to generate.