Commit | Line | Data |
---|---|---|
2f1d9bdd MM |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
ecd75fc8 | 3 | # Copyright 2013-2014 Free Software Foundation, Inc. |
2f1d9bdd MM |
4 | # |
5 | # Contributed by Intel Corp. <christian.himpel@intel.com> | |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 3 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | # check for btrace support | |
21 | if { [skip_btrace_tests] } { return -1 } | |
22 | ||
23 | # start inferior | |
24 | standard_testfile | |
25 | if [prepare_for_testing function_call_history.exp $testfile {} {debug}] { | |
26 | return -1 | |
27 | } | |
28 | if ![runto_main] { | |
29 | return -1 | |
30 | } | |
31 | ||
32 | # start btrace | |
33 | gdb_test_no_output "record btrace" | |
34 | ||
35 | # set bp after increment loop and continue | |
36 | set bp_location [gdb_get_line_number "bp.1" $testfile.c] | |
37 | gdb_breakpoint $bp_location | |
38 | gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" | |
39 | ||
40 | # show function call history with unlimited size, we expect to see all 21 entries | |
41 | gdb_test_no_output "set record function-call-history-size 0" | |
42 | gdb_test "record function-call-history" " | |
43 | 0\tmain\r | |
44 | 1\tinc\r | |
45 | 2\tmain\r | |
46 | 3\tinc\r | |
47 | 4\tmain\r | |
48 | 5\tinc\r | |
49 | 6\tmain\r | |
50 | 7\tinc\r | |
51 | 8\tmain\r | |
52 | 9\tinc\r | |
53 | 10\tmain\r | |
54 | 11\tinc\r | |
55 | 12\tmain\r | |
56 | 13\tinc\r | |
57 | 14\tmain\r | |
58 | 15\tinc\r | |
59 | 16\tmain\r | |
60 | 17\tinc\r | |
61 | 18\tmain\r | |
62 | 19\tinc\r | |
63 | 20\tmain\r" "record function-call-history - with size unlimited" | |
64 | ||
65 | # show function call history with size of 21, we expect to see all 21 entries | |
66 | gdb_test_no_output "set record function-call-history-size 21" | |
67 | # show function call history | |
68 | gdb_test "record function-call-history 0" " | |
69 | 0\tmain\r | |
70 | 1\tinc\r | |
71 | 2\tmain\r | |
72 | 3\tinc\r | |
73 | 4\tmain\r | |
74 | 5\tinc\r | |
75 | 6\tmain\r | |
76 | 7\tinc\r | |
77 | 8\tmain\r | |
78 | 9\tinc\r | |
79 | 10\tmain\r | |
80 | 11\tinc\r | |
81 | 12\tmain\r | |
82 | 13\tinc\r | |
83 | 14\tmain\r | |
84 | 15\tinc\r | |
85 | 16\tmain\r | |
86 | 17\tinc\r | |
87 | 18\tmain\r | |
88 | 19\tinc\r | |
89 | 20\tmain\r" "record function-call-history - show all 21 entries" | |
90 | ||
91 | # show first 15 entries | |
92 | gdb_test_no_output "set record function-call-history-size 15" | |
93 | gdb_test "record function-call-history 0" " | |
94 | 0\tmain\r | |
95 | 1\tinc\r | |
96 | 2\tmain\r | |
97 | 3\tinc\r | |
98 | 4\tmain\r | |
99 | 5\tinc\r | |
100 | 6\tmain\r | |
101 | 7\tinc\r | |
102 | 8\tmain\r | |
103 | 9\tinc\r | |
104 | 10\tmain\r | |
105 | 11\tinc\r | |
106 | 12\tmain\r | |
107 | 13\tinc\r | |
108 | 14\tmain\r" "record function-call-history - show first 15 entries" | |
109 | ||
110 | # show last 6 entries | |
111 | gdb_test "record function-call-history +" " | |
112 | 15\tinc\r | |
113 | 16\tmain\r | |
114 | 17\tinc\r | |
115 | 18\tmain\r | |
116 | 19\tinc\r | |
117 | 20\tmain\r" "record function-call-history - show last 6 entries" | |
118 | ||
119 | # moving further should not work | |
120 | gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (1)" | |
121 | ||
122 | # make sure we cannot move any further a second time | |
123 | gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (2)" | |
124 | ||
125 | # moving back showing the latest 15 function calls | |
126 | gdb_test "record function-call-history -" " | |
127 | 6\tmain\r | |
128 | 7\tinc\r | |
129 | 8\tmain\r | |
130 | 9\tinc\r | |
131 | 10\tmain\r | |
132 | 11\tinc\r | |
133 | 12\tmain\r | |
134 | 13\tinc\r | |
135 | 14\tmain\r | |
136 | 15\tinc\r | |
137 | 16\tmain\r | |
138 | 17\tinc\r | |
139 | 18\tmain\r | |
140 | 19\tinc\r | |
141 | 20\tmain\r" "record function-call-history - show last 15 entries" | |
142 | ||
143 | # moving further back shows the 6 first function calls | |
144 | gdb_test "record function-call-history -" " | |
145 | 0\tmain\r | |
146 | 1\tinc\r | |
147 | 2\tmain\r | |
148 | 3\tinc\r | |
149 | 4\tmain\r | |
150 | 5\tinc\r" "record function-call-history - show first 6 entries" | |
151 | ||
152 | # moving further back shouldn't work | |
153 | gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (1)" | |
154 | ||
155 | # make sure we cannot move any further back | |
156 | gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (2)" | |
157 | ||
158 | # moving forward again, but this time with file and line number, expected to see the first 15 entries | |
159 | gdb_test "record function-call-history /l +" " | |
160 | .*$srcfile:40-41\tmain\r | |
161 | .*$srcfile:22-24\tinc\r | |
162 | .*$srcfile:40-41\tmain\r | |
163 | .*$srcfile:22-24\tinc\r | |
164 | .*$srcfile:40-41\tmain\r | |
165 | .*$srcfile:22-24\tinc\r | |
166 | .*$srcfile:40-41\tmain\r | |
167 | .*$srcfile:22-24\tinc\r | |
168 | .*$srcfile:40-41\tmain\r | |
169 | .*$srcfile:22-24\tinc\r | |
170 | .*$srcfile:40-41\tmain\r | |
171 | .*$srcfile:22-24\tinc\r | |
172 | .*$srcfile:40-41\tmain\r | |
173 | .*$srcfile:22-24\tinc\r | |
174 | .*$srcfile:40-41\tmain\r" "record function-call-history /l - show first 15 entries" | |
175 | ||
176 | # moving forward and expect to see the latest 6 entries | |
177 | gdb_test "record function-call-history /l +" " | |
178 | .*$srcfile:22-24\tinc\r | |
179 | .*$srcfile:40-41\tmain\r | |
180 | .*$srcfile:22-24\tinc\r | |
181 | .*$srcfile:40-41\tmain\r | |
182 | .*$srcfile:22-24\tinc\r | |
183 | .*$srcfile:40-43\tmain\r" "record function-call-history /l - show last 6 entries" | |
184 | ||
185 | # moving further forward shouldn't work | |
186 | gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "record function-call-history /l - at the end (1)" | |
187 | gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "record function-call-history /l - at the end (2)" | |
188 | ||
189 | set expected_range "3\tinc\r | |
190 | 4\tmain\r | |
191 | 5\tinc\r | |
192 | 6\tmain\r | |
193 | 7\tinc\r | |
194 | 8\tmain\r | |
195 | 9\tinc\r" | |
196 | ||
197 | # show functions in instruction range | |
198 | gdb_test "record function-call-history 3,10" $expected_range "absolute instruction range" | |
199 | gdb_test "record function-call-history 3,+7" $expected_range "relative positive instruction range" | |
200 | gdb_test "record function-call-history 10,-7" $expected_range "relative negative instruction range" | |
201 | ||
202 | # set bp after fib recursion and continue | |
203 | set bp_location [gdb_get_line_number "bp.2" $testfile.c] | |
204 | gdb_breakpoint $bp_location | |
205 | gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" | |
206 | ||
207 | # at this point we expect to have main, fib, ..., fib, main, where fib occurs 8 times, | |
208 | # so we limit the output to only show the latest 10 function calls | |
209 | gdb_test_no_output "set record function-call-history-size 10" | |
210 | set message "show recursive function call history" | |
211 | gdb_test_multiple "record function-call-history" $message { | |
212 | -re "13\tmain\r\n14\tfib\r\n15\tfib\r\n16\tfib\r\n17\tfib\r\n18\tfib\r\n19\tfib\r\n20\tfib\r\n21\tfib\r\n22 main\r\n$gdb_prompt $" { | |
213 | pass $message | |
214 | } | |
215 | -re "13\tinc\r\n14\tmain\r\n15\tinc\r\n16\tmain\r\n17\tinc\r\n18\tmain\r\n19\tinc\r\n20\tmain\r\n21\tfib\r\n22\tmain\r\n$gdb_prompt $" { | |
216 | # recursive function calls appear only as 1 call | |
217 | kfail "gdb/15240" $message | |
218 | } | |
219 | } |