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