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 | ||
724c7dd8 | 40 | proc rec_fun_all {} { |
5de9129b MM |
41 | gdb_test "record function-call-history 1" [join [list \ |
42 | "1\tmain" \ | |
43 | "2\tinc" \ | |
44 | "3\tmain" \ | |
45 | "4\tinc" \ | |
46 | "5\tmain" \ | |
47 | "6\tinc" \ | |
48 | "7\tmain" \ | |
49 | "8\tinc" \ | |
50 | "9\tmain" \ | |
51 | "10\tinc" \ | |
52 | "11\tmain" \ | |
53 | "12\tinc" \ | |
54 | "13\tmain" \ | |
55 | "14\tinc" \ | |
56 | "15\tmain" \ | |
57 | "16\tinc" \ | |
58 | "17\tmain" \ | |
59 | "18\tinc" \ | |
60 | "19\tmain" \ | |
61 | "20\tinc" \ | |
62 | "21\tmain"] "\r\n"] | |
724c7dd8 MM |
63 | } |
64 | ||
2f1d9bdd MM |
65 | # show function call history with unlimited size, we expect to see all 21 entries |
66 | gdb_test_no_output "set record function-call-history-size 0" | |
724c7dd8 | 67 | with_test_prefix "size unlimited" rec_fun_all |
2f1d9bdd MM |
68 | |
69 | # show function call history with size of 21, we expect to see all 21 entries | |
70 | gdb_test_no_output "set record function-call-history-size 21" | |
724c7dd8 | 71 | with_test_prefix "size 21" rec_fun_all |
2f1d9bdd MM |
72 | |
73 | # show first 15 entries | |
74 | gdb_test_no_output "set record function-call-history-size 15" | |
5de9129b MM |
75 | gdb_test "record function-call-history 1" [join [list \ |
76 | "1\tmain" \ | |
77 | "2\tinc" \ | |
78 | "3\tmain" \ | |
79 | "4\tinc" \ | |
80 | "5\tmain" \ | |
81 | "6\tinc" \ | |
82 | "7\tmain" \ | |
83 | "8\tinc" \ | |
84 | "9\tmain" \ | |
85 | "10\tinc" \ | |
86 | "11\tmain" \ | |
87 | "12\tinc" \ | |
88 | "13\tmain" \ | |
89 | "14\tinc" \ | |
90 | "15\tmain"] "\r\n"] "forward - 1" | |
2f1d9bdd MM |
91 | |
92 | # show last 6 entries | |
724c7dd8 | 93 | gdb_test "record function-call-history +" [join [list \ |
5de9129b MM |
94 | "16\tinc" \ |
95 | "17\tmain" \ | |
96 | "18\tinc" \ | |
97 | "19\tmain" \ | |
98 | "20\tinc" \ | |
99 | "21\tmain"] "\r\n"] "forward - 2" | |
2f1d9bdd MM |
100 | |
101 | # moving further should not work | |
724c7dd8 | 102 | gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 3" |
2f1d9bdd MM |
103 | |
104 | # make sure we cannot move any further a second time | |
724c7dd8 | 105 | gdb_test "record function-call-history +" "At the end of the branch trace record\\." "forward - 4" |
2f1d9bdd MM |
106 | |
107 | # moving back showing the latest 15 function calls | |
724c7dd8 | 108 | gdb_test "record function-call-history -" [join [list \ |
5de9129b MM |
109 | "7\tmain" \ |
110 | "8\tinc" \ | |
111 | "9\tmain" \ | |
112 | "10\tinc" \ | |
113 | "11\tmain" \ | |
114 | "12\tinc" \ | |
115 | "13\tmain" \ | |
116 | "14\tinc" \ | |
117 | "15\tmain" \ | |
118 | "16\tinc" \ | |
119 | "17\tmain" \ | |
120 | "18\tinc" \ | |
121 | "19\tmain" \ | |
122 | "20\tinc" \ | |
123 | "21\tmain"] "\r\n"] "backward - 1" | |
2f1d9bdd MM |
124 | |
125 | # moving further back shows the 6 first function calls | |
724c7dd8 | 126 | gdb_test "record function-call-history -" [join [list \ |
5de9129b MM |
127 | "1\tmain" \ |
128 | "2\tinc" \ | |
129 | "3\tmain" \ | |
130 | "4\tinc" \ | |
131 | "5\tmain" \ | |
132 | "6\tinc"] "\r\n"] "backward - 2" | |
2f1d9bdd MM |
133 | |
134 | # moving further back shouldn't work | |
724c7dd8 | 135 | gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 3" |
2f1d9bdd MM |
136 | |
137 | # make sure we cannot move any further back | |
724c7dd8 | 138 | gdb_test "record function-call-history -" "At the start of the branch trace record\\." "backward - 4" |
2f1d9bdd MM |
139 | |
140 | # moving forward again, but this time with file and line number, expected to see the first 15 entries | |
724c7dd8 MM |
141 | gdb_test "record function-call-history /l +" [join [list \ |
142 | ".*$srcfile:40-41\tmain" \ | |
143 | ".*$srcfile:22-24\tinc" \ | |
144 | ".*$srcfile:40-41\tmain" \ | |
145 | ".*$srcfile:22-24\tinc" \ | |
146 | ".*$srcfile:40-41\tmain" \ | |
147 | ".*$srcfile:22-24\tinc" \ | |
148 | ".*$srcfile:40-41\tmain" \ | |
149 | ".*$srcfile:22-24\tinc" \ | |
150 | ".*$srcfile:40-41\tmain" \ | |
151 | ".*$srcfile:22-24\tinc" \ | |
152 | ".*$srcfile:40-41\tmain" \ | |
153 | ".*$srcfile:22-24\tinc" \ | |
154 | ".*$srcfile:40-41\tmain" \ | |
155 | ".*$srcfile:22-24\tinc" \ | |
156 | ".*$srcfile:40-41\tmain"] "\r\n"] "forward /l - 1" | |
2f1d9bdd MM |
157 | |
158 | # moving forward and expect to see the latest 6 entries | |
724c7dd8 MM |
159 | gdb_test "record function-call-history /l +" [join [list \ |
160 | ".*$srcfile:22-24\tinc" \ | |
161 | ".*$srcfile:40-41\tmain" \ | |
162 | ".*$srcfile:22-24\tinc" \ | |
163 | ".*$srcfile:40-41\tmain" \ | |
164 | ".*$srcfile:22-24\tinc" \ | |
165 | ".*$srcfile:40-43\tmain"] "\r\n"] "forward /l - 2" | |
2f1d9bdd MM |
166 | |
167 | # moving further forward shouldn't work | |
724c7dd8 MM |
168 | gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "forward /l - 3" |
169 | gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "forward /l - 4" | |
170 | ||
171 | set expected_range [join [list \ | |
5de9129b MM |
172 | "4\tinc" \ |
173 | "5\tmain" \ | |
174 | "6\tinc" \ | |
175 | "7\tmain" \ | |
176 | "8\tinc" \ | |
177 | "9\tmain" \ | |
178 | "10\tinc"] "\r\n"] | |
2f1d9bdd MM |
179 | |
180 | # show functions in instruction range | |
5de9129b MM |
181 | gdb_test "record function-call-history 4,11" $expected_range |
182 | gdb_test "record function-call-history 4,+7" $expected_range | |
183 | gdb_test "record function-call-history 11,-7" $expected_range | |
2f1d9bdd MM |
184 | |
185 | # set bp after fib recursion and continue | |
186 | set bp_location [gdb_get_line_number "bp.2" $testfile.c] | |
187 | gdb_breakpoint $bp_location | |
188 | gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" | |
189 | ||
23a7fe75 MM |
190 | # at this point we expect to have main, fib, ..., fib, main, where fib occurs 9 times, |
191 | # so we limit the output to only show the latest 11 function calls | |
192 | gdb_test_no_output "set record function-call-history-size 11" | |
193 | gdb_test "record function-call-history" [join [list \ | |
5de9129b | 194 | "21\tmain" \ |
23a7fe75 MM |
195 | "22\tfib" \ |
196 | "23\tfib" \ | |
197 | "24\tfib" \ | |
198 | "25\tfib" \ | |
199 | "26\tfib" \ | |
200 | "27\tfib" \ | |
201 | "28\tfib" \ | |
202 | "29\tfib" \ | |
5de9129b MM |
203 | "30\tfib" \ |
204 | "31\tmain"] "\r\n"] "recursive" |