Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 1998-2020 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This file was written by Michael Snyder (msnyder@cygnus.com) |
17 | ||
4ec70201 | 18 | load_lib "trace-support.exp" |
c906108c | 19 | |
c906108c SS |
20 | |
21 | gdb_exit | |
22 | gdb_start | |
497a5eb0 | 23 | standard_testfile actions.c |
8bca2978 SL |
24 | if ![gdb_trace_common_supports_arch] { |
25 | unsupported "no trace-common.h support for arch" | |
26 | return -1 | |
27 | } | |
f8b7eaf3 DJ |
28 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ |
29 | executable {debug nowarnings}] != "" } { | |
84c93cd5 | 30 | untested "failed to compile" |
f8b7eaf3 | 31 | return -1 |
c906108c SS |
32 | } |
33 | gdb_reinitialize_dir $srcdir/$subdir | |
34 | ||
35 | # If testing on a remote host, download the source file. | |
36 | # remote_download host $srcdir/$subdir/$srcfile | |
37 | ||
38 | gdb_file_cmd $binfile | |
39 | ||
40 | # define relative source line numbers: | |
41 | # all subsequent line numbers are relative to this first one (baseline) | |
4ec70201 | 42 | set baseline [gdb_find_recursion_test_baseline $srcfile] |
c906108c | 43 | if { $baseline == -1 } then { |
bc6c7af4 | 44 | fail "could not find gdb_recursion_test function" |
4ec70201 | 45 | return |
c906108c SS |
46 | } |
47 | ||
48 | set testline1 [expr $baseline + 1] | |
49 | set testline2 [expr $baseline + 3] | |
50 | ||
51 | # | |
52 | # test "help tracepoints" | |
53 | # | |
54 | ||
4ec70201 | 55 | set helpcnt 0 |
d8295fe9 VP |
56 | test_class_help "tracepoints" { |
57 | "Tracing of program execution without stopping the program\.[\r\n\]+" | |
206584bd | 58 | } {} "1.0: help tracepoints" |
c906108c SS |
59 | |
60 | # | |
61 | # test trace command: | |
62 | # | |
63 | ||
64 | # 1.1 trace source line | |
65 | gdb_delete_tracepoints | |
66 | gdb_test "trace $srcfile:$testline2" \ | |
67 | "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \ | |
68 | "1.1a: set tracepoint at sourceline" | |
f2a8bc8a YQ |
69 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2. |
70 | \[\t \]+not installed on target." \ | |
c906108c SS |
71 | "1.1b: trace sourcefile:line" |
72 | ||
73 | # 1.2 trace invalid source line | |
74 | gdb_delete_tracepoints | |
f8eba3c6 | 75 | gdb_test_no_output "set breakpoint pending off" |
c906108c SS |
76 | gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \ |
77 | "1.2a: trace invalid line in sourcefile" | |
78 | gdb_test "info trace" "No tracepoints.*" \ | |
79 | "1.2b: reject invalid line in srcfile" | |
80 | ||
81 | # 1.3 trace line in invalid source file | |
82 | gdb_delete_tracepoints | |
83 | gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \ | |
84 | "1.3a: trace invalid source file" | |
85 | gdb_test "info trace" "No tracepoints.*" \ | |
86 | "1.3b: reject invalid srcfile" | |
87 | ||
88 | # 1.4 trace function by name | |
89 | gdb_delete_tracepoints | |
90 | gdb_test "trace gdb_recursion_test" \ | |
91 | "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \ | |
92 | "1.4a: trace function by name" | |
f2a8bc8a YQ |
93 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1. |
94 | \[\t \]+not installed on target." \ | |
c906108c SS |
95 | "1.4b: trace function by name" |
96 | ||
97 | # 1.5 trace non-existant function | |
98 | gdb_delete_tracepoints | |
99 | gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \ | |
100 | "1.5a: trace invalid function" | |
101 | gdb_test "info trace" "No tracepoints.*" \ | |
102 | "1.5b: reject invalid srcfile" | |
103 | ||
104 | # 1.6 trace at a specific address | |
105 | # Collect the address of "gdb_asm_test", and use that. | |
0ab48859 | 106 | gdb_test_multiple "print gdb_asm_test" "" { |
c906108c SS |
107 | -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" { |
108 | set asm_test_addr $expect_out(1,string) | |
109 | } | |
c906108c SS |
110 | } |
111 | ||
112 | gdb_delete_tracepoints | |
113 | gdb_test "trace \*0x$asm_test_addr" \ | |
114 | "Tracepoint $decimal at .*$asm_test_addr.*" \ | |
115 | "1.6a: trace at specific address" | |
116 | gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \ | |
117 | "1.6b: verify trace at specific address" | |
118 | ||
119 | # 1.7 trace at function's exact address | |
120 | # Collect the address of the function for comparison | |
0ab48859 | 121 | gdb_test_multiple "print gdb_recursion_test" "" { |
c906108c SS |
122 | -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" { |
123 | set c_test_addr $expect_out(1,string) | |
124 | } | |
c906108c SS |
125 | } |
126 | ||
127 | gdb_delete_tracepoints | |
128 | gdb_test "trace \*gdb_recursion_test" \ | |
129 | "Tracepoint $decimal at .*$c_test_addr.*" \ | |
130 | "1.7a: trace at function label (before prologue)" | |
f2a8bc8a YQ |
131 | gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline. |
132 | \[\t \]+not installed on target." \ | |
c906108c SS |
133 | "1.7b: verify trace at specific address" |
134 | ||
135 | # 1.8 trace at invalid address | |
136 | # no address is invalid | |
137 | ||
138 | # 1.9 trace no arguments | |
1042e4c0 | 139 | gdb_test "trace" "No default breakpoint address now." \ |
c906108c SS |
140 | "1.9: trace <no arguments>" |
141 | ||
94f31136 | 142 | # 1.10 there's no 1.10. |
c906108c SS |
143 | |
144 | # 1.11 tracepoint conditions | |
782b2b07 SS |
145 | gdb_delete_tracepoints |
146 | gdb_test "trace gdb_recursion_test if q1 > 0" \ | |
147 | "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \ | |
148 | "1.11a: conditional tracepoint" | |
f2a8bc8a YQ |
149 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1. |
150 | \[\t \]+trace only if q1 > 0. | |
151 | \[\t \]+not installed on target." \ | |
782b2b07 | 152 | "1.11b: verify conditional tracepoint" |
c906108c SS |
153 | |
154 | # 1.12 set tracepoint in prologue | |
155 | # [see tfind.exp] | |
156 | ||
157 | # 1.13 trace on recursion | |
158 | # interesting only in "live" session: see backtrace.exp for live test. | |
159 | ||
160 | # 1.14 help trace | |
161 | gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace" | |
162 | ||
7a697b8d | 163 | # 1.15 ftrace |
c906108c | 164 | |
7a697b8d SS |
165 | gdb_delete_tracepoints |
166 | ||
7a697b8d | 167 | # Acceptance vs rejection of a location are target-specific, so allow both. |
de97fdd4 | 168 | gdb_test_multiple "ftrace gdb_recursion_test" "set a fast tracepoint" { |
0ab48859 | 169 | -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $" { |
bc6c7af4 | 170 | pass "set a fast tracepoint" |
0ab48859 MS |
171 | } |
172 | -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $" { | |
bc6c7af4 | 173 | pass "declined to set a fast tracepoint" |
0ab48859 | 174 | } |
7a697b8d | 175 | } |