fix erroneous error-handling in frame filter code
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-framefilter.exp
CommitLineData
ecd75fc8 1# Copyright (C) 2013-2014 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
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.
39set remote_obj_python_file \
40 [remote_download \
41 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
8448e842 42 [standard_output_file ${testfile}-gdb.py]]
1e611234
PM
43
44gdb_reinitialize_dir $srcdir/$subdir
45gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
46 "set auto-load safe-path"
47gdb_load ${binfile}
48# Verify gdb loaded the script.
49gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
50 "Test auto-load had loaded python scripts"
51
52if ![runto_main] then {
53 perror "couldn't run to breakpoint"
54 return
55}
56gdb_test_no_output "set python print-stack full" \
57 "Set python print-stack to full"
58
59# Load global frame-filters
8448e842
TT
60set remote_python_file [gdb_remote_download host \
61 ${srcdir}/${subdir}/${testfile}.py]
8f28f522 62gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
1e611234
PM
63 "Load python file"
64
65gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"]
66gdb_breakpoint [gdb_get_line_number "Inner test breakpoint"]
67gdb_continue_to_breakpoint "Inner test breakpoint"
68
69# Test multiple local blocks.
70gdb_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"
73gdb_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
77gdb_continue_to_breakpoint "Backtrace end breakpoint"
78
79# Test set/show
80gdb_test "info frame-filter" \
81 ".*900.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
82 "info frame filter before setting priority"
83gdb_test "show frame-filter priority global Elider" \
84 "Priority of filter 'Elider' in list 'global' is: 900" \
85 "show frame-filter priority global Elider before setting"
86gdb_test_no_output "set frame-filter priority global Elider 1000" \
87 "set frame-filter priotiy global Elider 1000"
88gdb_test "show frame-filter priority global Elider" \
89 "Priority of filter 'Elider' in list 'global' is: 1000" \
90 "show frame-filter priority global Elider after setting"
91gdb_test "info frame-filter" \
92 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
93 "info frame filter after setting priority"
94
95# Test enable/disable
96gdb_test "info frame-filter" \
97 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
98 "info frame filter before disable frame filter"
99gdb_test_no_output "disable frame-filter global Elider" \
100 "disable frame-filter global Elider"
101gdb_test "info frame-filter" \
102 ".*1000.*No.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
103 "info frame filter after disable frame filter"
104gdb_test_no_output "enable frame-filter global Elider" \
105 "enable frame-filter global Elider"
106gdb_test "info frame-filter" \
107 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
108 "info frame filter after reenabling frame filter"
109
110# Test no-filters
111gdb_test "bt no-filters" \
112 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
113 "bt no-filters"
114
115# Test reverse
116gdb_test "bt" \
117 ".*#0.*cnuf_dne.*#22.*in 1cnuf.*#27.*in niam \\(\\).*" \
118 "bt with frame filters"
119
120# Disable Reverse
121gdb_test_no_output "disable frame-filter global Reverse" \
122 "disable frame-filter global Reverse"
123gdb_test "bt" \
124 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
125 "bt with frame-filter Reverse disabled"
126gdb_test "bt -2" \
127 ".*#26.*func5.*#27.*in main \\(\\).*" \
128 "bt -2 with frame-filter Reverse disabled"
129gdb_test "bt 3" \
130 ".*#0.*end_func.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*" \
131 "bt 3 with frame-filter Reverse disabled"
132gdb_test "bt no-filter full" \
133 ".*#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\}.*" \
134 "bt no-filters full with Reverse disabled"
135gdb_test "bt full" \
136 ".*#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.*" \
137 "bt full with Reverse disabled"
138
139# Test set print frame-arguments
140# none
141gdb_test_no_output "set print frame-arguments none" \
142 "turn off frame arguments"
143gdb_test "bt no-filter 1" \
144 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
145 "bt no-filter 1 no args"
146gdb_test "bt 1" \
147 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
148 "bt 1 no args"
149
150# scalars
151gdb_test_no_output "set print frame-arguments scalars" \
152 "turn frame arguments to scalars only"
153gdb_test "bt no-filter 1" \
154 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
155 "bt no-filter 1 scalars"
156gdb_test "bt 1" \
157 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\.\.\.\\) at .*py-framefilter.c.*" \
158 "bt 1 scalars"
159
160# all
161gdb_test_no_output "set print frame-arguments all" \
162 "turn on frame arguments"
163gdb_test "bt no-filter 1" \
164 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
165 "bt no-filter 1 all args"
166gdb_test "bt 1" \
167 "#0.*end_func \\(foo=21, bar=$hex \"Param\", fb=$hex, bf=\{nothing = $hex \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
168 "bt 1 all args"
169
170# set print address off
171gdb_test_no_output "set print address off" \
172 "Turn off address printing"
173gdb_test "bt no-filter 1" \
174 "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
175 "bt no-filter 1 no address"
176gdb_test "bt 1" \
177 "#0 end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
178 "bt 1 no addresss"
179
0740f8d8
TT
180gdb_test_no_output "set python print-stack message" \
181 "Set python print-stack to message for Error filter"
182gdb_test_no_output "enable frame-filter global Error" \
183 "enable frame-filter global Error"
184set test "bt 1 with Error filter"
185gdb_test_multiple "bt 1" $test {
186 -re "Python Exception .*whoops:.*$gdb_prompt $" {
187 pass $test
188 }
189}
190
1e611234
PM
191remote_file host delete ${remote_python_file}
192
193# Test with no debuginfo
194
195# We cannot use prepare_for_testing as we have to set the safe-patch
196# to check objfile and progspace printers.
197if {[build_executable $testfile.exp $testfile $srcfile {nodebug}] == -1} {
198 return -1
199}
200
201# Start with a fresh gdb.
202gdb_exit
203gdb_start
204
205# Skip all tests if Python scripting is not enabled.
206if { [skip_python_tests] } { continue }
207
208# Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
209# Care is taken to put it in the same directory as the binary so that
210# gdb will find it.
211set remote_obj_python_file \
212 [remote_download \
213 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
8448e842 214 [standard_output_file ${testfile}-gdb.py]]
1e611234
PM
215
216gdb_reinitialize_dir $srcdir/$subdir
217gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
218 "set auto-load safe-path for no debug info"
219gdb_load ${binfile}
220
221# Verify gdb loaded the script.
222gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
223 "Set autoload path for no debug info tests"
224if ![runto_main] then {
225 perror "couldn't run to breakpoint"
226 return
227}
228
229gdb_test_no_output "set python print-stack full" \
230 "set python print-stack full for no debuginfo tests"
231
232# Load global frame-filters
8448e842
TT
233set remote_python_file [gdb_remote_download host \
234 ${srcdir}/${subdir}/${testfile}.py]
8f28f522 235gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
1e611234
PM
236 "Load python file for no debuginfo tests"
237
238# Disable Reverse
239gdb_test_no_output "disable frame-filter global Reverse" \
240 "disable frame-filter gloval Reverse for no debuginfo"
241gdb_test "bt" \
242 ".*#0..*in main \\(\\).*" \
243 "bt for no debuginfo"
244gdb_test "bt full" \
245 ".*#0..*in main \\(\\).*" \
246 "bt full for no debuginfo"
247gdb_test "bt no-filters" \
248 ".*#0..*in main \\(\\).*" \
249 "bt no filters for no debuginfo"
250gdb_test "bt no-filters full" \
251 ".*#0..*in main \\(\\).*" \
252 "bt no-filters full no debuginfo"
This page took 0.119335 seconds and 4 git commands to generate.