]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-framefilter.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-framefilter.exp
1 # Copyright (C) 2013-2016 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 is part of the GDB testsuite. It tests Python-based
17 # frame-filters.
18
19 load_lib gdb-python.exp
20
21 standard_testfile
22
23 # We cannot use prepare_for_testing as we have to set the safe-patch
24 # to check objfile and progspace printers.
25 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
26 return -1
27 }
28
29 # Start with a fresh gdb.
30 gdb_exit
31 gdb_start
32
33 # Skip all tests if Python scripting is not enabled.
34 if { [skip_python_tests] } { continue }
35
36 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
37 # Care is taken to put it in the same directory as the binary so that
38 # gdb will find it.
39 set remote_obj_python_file \
40 [remote_download \
41 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
42 [standard_output_file ${testfile}-gdb.py]]
43
44 gdb_reinitialize_dir $srcdir/$subdir
45 gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
46 "set auto-load safe-path"
47 gdb_load ${binfile}
48 # Verify gdb loaded the script.
49 gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
50 "Test auto-load had loaded python scripts"
51
52 if ![runto_main] then {
53 perror "couldn't run to breakpoint"
54 return
55 }
56 gdb_test_no_output "set python print-stack full" \
57 "Set python print-stack to full"
58
59 # Load global frame-filters
60 set remote_python_file [gdb_remote_download host \
61 ${srcdir}/${subdir}/${testfile}.py]
62 gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
63 "Load python file"
64
65 gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"]
66 gdb_breakpoint [gdb_get_line_number "Inner test breakpoint"]
67 gdb_continue_to_breakpoint "Inner test breakpoint"
68
69 # Test multiple local blocks.
70 gdb_test "bt full no-filters" \
71 ".*#0.*end_func.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*" \
72 "bt full no-filters"
73 gdb_test "bt full" \
74 ".*#0.*cnuf_dne.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*" \
75 "bt full with filters"
76
77 # Test pagination can be aborted even for frame filters.
78 gdb_test_no_output "set height 5" "pagination quit - set height limited"
79 foreach bttype [list "bt" "bt full"] {
80 set test "pagination quit - $bttype"
81 gdb_test_multiple "$bttype" $test {
82 -re "$pagination_prompt$" {
83 pass $test
84 }
85 }
86 gdb_test "q" "^q\r\nQuit" "pagination quit - $bttype - q"
87 }
88 gdb_test_no_output "set height unlimited" "pagination quit - set height unlimited"
89
90 gdb_continue_to_breakpoint "Backtrace end breakpoint"
91
92 # Test set/show
93 gdb_test "info frame-filter" \
94 ".*900.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
95 "info frame filter before setting priority"
96 gdb_test "show frame-filter priority global Elider" \
97 "Priority of filter 'Elider' in list 'global' is: 900" \
98 "show frame-filter priority global Elider before setting"
99 gdb_test_no_output "set frame-filter priority global Elider 1000" \
100 "set frame-filter priotiy global Elider 1000"
101 gdb_test "show frame-filter priority global Elider" \
102 "Priority of filter 'Elider' in list 'global' is: 1000" \
103 "show frame-filter priority global Elider after setting"
104 gdb_test "info frame-filter" \
105 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
106 "info frame filter after setting priority"
107
108 # Test enable/disable
109 gdb_test "info frame-filter" \
110 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
111 "info frame filter before disable frame filter"
112 gdb_test_no_output "disable frame-filter global Elider" \
113 "disable frame-filter global Elider"
114 gdb_test "info frame-filter" \
115 ".*1000.*No.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
116 "info frame filter after disable frame filter"
117 gdb_test_no_output "enable frame-filter global Elider" \
118 "enable frame-filter global Elider"
119 gdb_test "info frame-filter" \
120 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
121 "info frame filter after reenabling frame filter"
122
123 # Test no-filters
124 gdb_test "bt no-filters" \
125 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
126 "bt no-filters"
127
128 # Test reverse
129 gdb_test "bt" \
130 ".*#0.*cnuf_dne.*#22.*in 1cnuf.*#27.*in niam \\(\\).*" \
131 "bt with frame filters"
132
133 # Disable Reverse
134 gdb_test_no_output "disable frame-filter global Reverse" \
135 "disable frame-filter global Reverse"
136 gdb_test "bt" \
137 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
138 "bt with frame-filter Reverse disabled"
139 gdb_test "bt -2" \
140 ".*#26.*func5.*#27.*in main \\(\\).*" \
141 "bt -2 with frame-filter Reverse disabled"
142 gdb_test "bt 3" \
143 ".*#0.*end_func.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*" \
144 "bt 3 with frame-filter Reverse disabled"
145 gdb_test "bt no-filter full" \
146 ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*" \
147 "bt no-filters full with Reverse disabled"
148 gdb_test "bt full" \
149 ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\).*#23.*in func2 \\(f=3\\).*elided = $hex \"Elided frame\".*fb = \{nothing = $hex \"Elided Foo Bar\", f = 84, s = 38\}.*bf = $hex.*" \
150 "bt full with Reverse disabled"
151
152 # Test set print frame-arguments
153 # none
154 gdb_test_no_output "set print frame-arguments none" \
155 "turn off frame arguments"
156 gdb_test "bt no-filter 1" \
157 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
158 "bt no-filter 1 no args"
159 gdb_test "bt 1" \
160 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
161 "bt 1 no args"
162
163 # scalars
164 gdb_test_no_output "set print frame-arguments scalars" \
165 "turn frame arguments to scalars only"
166 gdb_test "bt no-filter 1" \
167 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
168 "bt no-filter 1 scalars"
169 gdb_test "bt 1" \
170 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
171 "bt 1 scalars"
172
173 # all
174 gdb_test_no_output "set print frame-arguments all" \
175 "turn on frame arguments"
176 gdb_test "bt no-filter 1" \
177 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
178 "bt no-filter 1 all args"
179 gdb_test "bt 1" \
180 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
181 "bt 1 all args"
182
183 # set print address off
184 gdb_test_no_output "set print address off" \
185 "Turn off address printing"
186 gdb_test "bt no-filter 1" \
187 "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
188 "bt no-filter 1 no address"
189 gdb_test "bt 1" \
190 "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
191 "bt 1 no addresss"
192
193 gdb_test_no_output "set python print-stack message" \
194 "Set python print-stack to message for Error filter"
195 gdb_test_no_output "enable frame-filter global Error" \
196 "enable frame-filter global Error"
197 set test "bt 1 with Error filter"
198 gdb_test_multiple "bt 1" $test {
199 -re "Python Exception .*whoops:.*$gdb_prompt $" {
200 pass $test
201 }
202 }
203
204 # Test with no debuginfo
205
206 # We cannot use prepare_for_testing as we have to set the safe-patch
207 # to check objfile and progspace printers.
208 if {[build_executable $testfile.exp $testfile $srcfile {nodebug}] == -1} {
209 return -1
210 }
211
212 # Start with a fresh gdb.
213 gdb_exit
214 gdb_start
215
216 # Skip all tests if Python scripting is not enabled.
217 if { [skip_python_tests] } { continue }
218
219 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
220 # Care is taken to put it in the same directory as the binary so that
221 # gdb will find it.
222 set remote_obj_python_file \
223 [remote_download \
224 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
225 [standard_output_file ${testfile}-gdb.py]]
226
227 gdb_reinitialize_dir $srcdir/$subdir
228 gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
229 "set auto-load safe-path for no debug info"
230 gdb_load ${binfile}
231
232 # Verify gdb loaded the script.
233 gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
234 "Set autoload path for no debug info tests"
235 if ![runto_main] then {
236 perror "couldn't run to breakpoint"
237 return
238 }
239
240 gdb_test_no_output "set python print-stack full" \
241 "set python print-stack full for no debuginfo tests"
242
243 # Load global frame-filters
244 set remote_python_file [gdb_remote_download host \
245 ${srcdir}/${subdir}/${testfile}.py]
246 gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
247 "Load python file for no debuginfo tests"
248
249 # Disable Reverse
250 gdb_test_no_output "disable frame-filter global Reverse" \
251 "disable frame-filter global Reverse for no debuginfo"
252 gdb_test "bt" \
253 ".*#0..*in main \\(\\).*" \
254 "bt for no debuginfo"
255 gdb_test "bt full" \
256 ".*#0..*in main \\(\\).*" \
257 "bt full for no debuginfo"
258 gdb_test "bt no-filters" \
259 ".*#0..*in main \\(\\).*" \
260 "bt no filters for no debuginfo"
261 gdb_test "bt no-filters full" \
262 ".*#0..*in main \\(\\).*" \
263 "bt no-filters full no debuginfo"