]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/tracecmd.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tracecmd.exp
1 # Copyright 1998-2024 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
17
18 load_lib "trace-support.exp"
19
20 standard_testfile actions.c
21 require gdb_trace_common_supports_arch
22 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
23 executable {debug nowarnings}] != "" } {
24 untested "failed to compile"
25 return -1
26 }
27
28 clean_restart
29 gdb_file_cmd $binfile
30
31 # define relative source line numbers:
32 # all subsequent line numbers are relative to this first one (baseline)
33 set baseline [gdb_find_recursion_test_baseline $srcfile]
34 if {$baseline == -1} {
35 fail "could not find gdb_recursion_test function"
36 return
37 }
38
39 set testline1 [expr $baseline + 1]
40 set testline2 [expr $baseline + 3]
41
42 #
43 # test "help tracepoints"
44 #
45
46 set helpcnt 0
47 test_class_help "tracepoints" {
48 "Tracing of program execution without stopping the program\.[\r\n\]+"
49 } {} "1.0: help tracepoints"
50
51 #
52 # test trace command:
53 #
54
55 # 1.1 trace source line
56 gdb_delete_tracepoints
57 gdb_test "trace $srcfile:$testline2" \
58 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
59 "1.1a: set tracepoint at sourceline"
60 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
61 \[\t \]+not installed on target" \
62 "1.1b: trace sourcefile:line"
63
64 # 1.2 trace invalid source line
65 gdb_delete_tracepoints
66 gdb_test_no_output "set breakpoint pending off"
67 gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
68 "1.2a: trace invalid line in sourcefile"
69 gdb_test "info trace" "No tracepoints.*" \
70 "1.2b: reject invalid line in srcfile"
71
72 # 1.3 trace line in invalid source file
73 gdb_delete_tracepoints
74 gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \
75 "1.3a: trace invalid source file"
76 gdb_test "info trace" "No tracepoints.*" \
77 "1.3b: reject invalid srcfile"
78
79 # 1.4 trace function by name
80 gdb_delete_tracepoints
81 gdb_test "trace gdb_recursion_test" \
82 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
83 "1.4a: trace function by name"
84 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
85 \[\t \]+not installed on target" \
86 "1.4b: trace function by name"
87
88 # 1.5 trace non-existant function
89 gdb_delete_tracepoints
90 gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \
91 "1.5a: trace invalid function"
92 gdb_test "info trace" "No tracepoints.*" \
93 "1.5b: reject invalid srcfile"
94
95 # 1.6 trace at a specific address
96 # Collect the address of "gdb_asm_test", and use that.
97 gdb_test_multiple "print gdb_asm_test" "" {
98 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
99 set asm_test_addr $expect_out(1,string)
100 }
101 }
102
103 gdb_delete_tracepoints
104 gdb_test "trace \*0x$asm_test_addr" \
105 "Tracepoint $decimal at .*$asm_test_addr.*" \
106 "1.6a: trace at specific address"
107 gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \
108 "1.6b: verify trace at specific address"
109
110 # 1.7 trace at function's exact address
111 # Collect the address of the function for comparison
112 gdb_test_multiple "print gdb_recursion_test" "" {
113 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
114 set c_test_addr $expect_out(1,string)
115 }
116 }
117
118 gdb_delete_tracepoints
119 gdb_test "trace \*gdb_recursion_test" \
120 "Tracepoint $decimal at .*$c_test_addr.*" \
121 "1.7a: trace at function label (before prologue)"
122 gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline.
123 \[\t \]+not installed on target" \
124 "1.7b: verify trace at specific address"
125
126 # 1.8 trace at invalid address
127 # no address is invalid
128
129 # 1.9 trace no arguments
130 gdb_test "trace" "No default breakpoint address now." \
131 "1.9: trace <no arguments>"
132
133 # 1.10 there's no 1.10.
134
135 # 1.11 tracepoint conditions
136 gdb_delete_tracepoints
137 gdb_test "trace gdb_recursion_test if q1 > 0" \
138 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
139 "1.11a: conditional tracepoint"
140 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
141 \[\t \]+trace only if q1 > 0.
142 \[\t \]+not installed on target" \
143 "1.11b: verify conditional tracepoint"
144
145 # 1.12 set tracepoint in prologue
146 # [see tfind.exp]
147
148 # 1.13 trace on recursion
149 # interesting only in "live" session: see backtrace.exp for live test.
150
151 # 1.14 help trace
152 gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace"
153
154 # 1.15 ftrace
155
156 gdb_delete_tracepoints
157
158 # Acceptance vs rejection of a location are target-specific, so allow both.
159 gdb_test_multiple "ftrace gdb_recursion_test" "set a fast tracepoint" {
160 -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $" {
161 pass "set a fast tracepoint"
162 }
163 -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $" {
164 pass "declined to set a fast tracepoint"
165 }
166 }