Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 1998, 2007, 2008, 2009, 2010, 2011 |
2 | # Free Software Foundation, Inc. | |
c906108c SS |
3 | # |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Michael Snyder (msnyder@cygnus.com) |
18 | ||
19 | load_lib "trace-support.exp"; | |
20 | ||
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
c906108c SS |
25 | |
26 | gdb_exit | |
27 | gdb_start | |
f8b7eaf3 DJ |
28 | set testfile "actions" |
29 | set srcfile ${testfile}.c | |
30 | set binfile $objdir/$subdir/tracecmd | |
31 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
32 | executable {debug nowarnings}] != "" } { | |
33 | untested tracecmd.exp | |
34 | return -1 | |
c906108c SS |
35 | } |
36 | gdb_reinitialize_dir $srcdir/$subdir | |
37 | ||
38 | # If testing on a remote host, download the source file. | |
39 | # remote_download host $srcdir/$subdir/$srcfile | |
40 | ||
41 | gdb_file_cmd $binfile | |
42 | ||
43 | # define relative source line numbers: | |
44 | # all subsequent line numbers are relative to this first one (baseline) | |
45 | set baseline [gdb_find_recursion_test_baseline $srcfile]; | |
46 | if { $baseline == -1 } then { | |
47 | fail "Could not find gdb_recursion_test function" | |
48 | return; | |
49 | } | |
50 | ||
51 | set testline1 [expr $baseline + 1] | |
52 | set testline2 [expr $baseline + 3] | |
53 | ||
54 | # | |
55 | # test "help tracepoints" | |
56 | # | |
57 | ||
58 | set helpcnt 0; | |
d8295fe9 VP |
59 | test_class_help "tracepoints" { |
60 | "Tracing of program execution without stopping the program\.[\r\n\]+" | |
61 | } "1.0: help tracepoints" | |
c906108c SS |
62 | |
63 | # | |
64 | # test trace command: | |
65 | # | |
66 | ||
67 | # 1.1 trace source line | |
68 | gdb_delete_tracepoints | |
69 | gdb_test "trace $srcfile:$testline2" \ | |
70 | "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \ | |
71 | "1.1a: set tracepoint at sourceline" | |
72 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2" \ | |
73 | "1.1b: trace sourcefile:line" | |
74 | ||
75 | # 1.2 trace invalid source line | |
76 | gdb_delete_tracepoints | |
77 | gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \ | |
78 | "1.2a: trace invalid line in sourcefile" | |
79 | gdb_test "info trace" "No tracepoints.*" \ | |
80 | "1.2b: reject invalid line in srcfile" | |
81 | ||
82 | # 1.3 trace line in invalid source file | |
83 | gdb_delete_tracepoints | |
e68d8fd4 | 84 | gdb_test_no_output "set breakpoint pending off" |
c906108c SS |
85 | gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \ |
86 | "1.3a: trace invalid source file" | |
87 | gdb_test "info trace" "No tracepoints.*" \ | |
88 | "1.3b: reject invalid srcfile" | |
89 | ||
90 | # 1.4 trace function by name | |
91 | gdb_delete_tracepoints | |
92 | gdb_test "trace gdb_recursion_test" \ | |
93 | "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \ | |
94 | "1.4a: trace function by name" | |
95 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1" \ | |
96 | "1.4b: trace function by name" | |
97 | ||
98 | # 1.5 trace non-existant function | |
99 | gdb_delete_tracepoints | |
100 | gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \ | |
101 | "1.5a: trace invalid function" | |
102 | gdb_test "info trace" "No tracepoints.*" \ | |
103 | "1.5b: reject invalid srcfile" | |
104 | ||
105 | # 1.6 trace at a specific address | |
106 | # Collect the address of "gdb_asm_test", and use that. | |
0ab48859 | 107 | gdb_test_multiple "print gdb_asm_test" "" { |
c906108c SS |
108 | -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" { |
109 | set asm_test_addr $expect_out(1,string) | |
110 | } | |
c906108c SS |
111 | } |
112 | ||
113 | gdb_delete_tracepoints | |
114 | gdb_test "trace \*0x$asm_test_addr" \ | |
115 | "Tracepoint $decimal at .*$asm_test_addr.*" \ | |
116 | "1.6a: trace at specific address" | |
117 | gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \ | |
118 | "1.6b: verify trace at specific address" | |
119 | ||
120 | # 1.7 trace at function's exact address | |
121 | # Collect the address of the function for comparison | |
0ab48859 | 122 | gdb_test_multiple "print gdb_recursion_test" "" { |
c906108c SS |
123 | -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" { |
124 | set c_test_addr $expect_out(1,string) | |
125 | } | |
c906108c SS |
126 | } |
127 | ||
128 | gdb_delete_tracepoints | |
129 | gdb_test "trace \*gdb_recursion_test" \ | |
130 | "Tracepoint $decimal at .*$c_test_addr.*" \ | |
131 | "1.7a: trace at function label (before prologue)" | |
132 | gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline" \ | |
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" | |
149 | gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.*trace only if q1 > 0" \ | |
150 | "1.11b: verify conditional tracepoint" | |
c906108c SS |
151 | |
152 | # 1.12 set tracepoint in prologue | |
153 | # [see tfind.exp] | |
154 | ||
155 | # 1.13 trace on recursion | |
156 | # interesting only in "live" session: see backtrace.exp for live test. | |
157 | ||
158 | # 1.14 help trace | |
159 | gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace" | |
160 | ||
7a697b8d | 161 | # 1.15 ftrace |
c906108c | 162 | |
7a697b8d SS |
163 | gdb_delete_tracepoints |
164 | ||
7a697b8d | 165 | # Acceptance vs rejection of a location are target-specific, so allow both. |
0ab48859 MS |
166 | gdb_test_multiple "ftrace gdb_recursion_test" "Set a fast tracepoint" { |
167 | -re "Fast tracepoint $decimal at $hex: file.*$srcfile, line $testline1.*$gdb_prompt $" { | |
168 | pass "Set a fast tracepoint" | |
169 | } | |
170 | -re ".*May not have a fast tracepoint at $hex.*$gdb_prompt $" { | |
171 | pass "Declined to set a fast tracepoint" | |
172 | } | |
7a697b8d | 173 | } |