]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-framefilter.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-framefilter.exp
1 # Copyright (C) 2013-2014 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 gdb_continue_to_breakpoint "Backtrace end breakpoint"
78
79 # Test set/show
80 gdb_test "info frame-filter" \
81 ".*900.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
82 "info frame filter before setting priority"
83 gdb_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"
86 gdb_test_no_output "set frame-filter priority global Elider 1000" \
87 "set frame-filter priotiy global Elider 1000"
88 gdb_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"
91 gdb_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
96 gdb_test "info frame-filter" \
97 ".*1000.*Yes.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
98 "info frame filter before disable frame filter"
99 gdb_test_no_output "disable frame-filter global Elider" \
100 "disable frame-filter global Elider"
101 gdb_test "info frame-filter" \
102 ".*1000.*No.*Elider.*100.*Yes.*Reverse.*10.*.*No.*Object.*1.*" \
103 "info frame filter after disable frame filter"
104 gdb_test_no_output "enable frame-filter global Elider" \
105 "enable frame-filter global Elider"
106 gdb_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
111 gdb_test "bt no-filters" \
112 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
113 "bt no-filters"
114
115 # Test reverse
116 gdb_test "bt" \
117 ".*#0.*cnuf_dne.*#22.*in 1cnuf.*#27.*in niam \\(\\).*" \
118 "bt with frame filters"
119
120 # Disable Reverse
121 gdb_test_no_output "disable frame-filter global Reverse" \
122 "disable frame-filter global Reverse"
123 gdb_test "bt" \
124 ".*#0.*end_func.*#22.*in func1.*#27.*in main \\(\\).*" \
125 "bt with frame-filter Reverse disabled"
126 gdb_test "bt -2" \
127 ".*#26.*func5.*#27.*in main \\(\\).*" \
128 "bt -2 with frame-filter Reverse disabled"
129 gdb_test "bt 3" \
130 ".*#0.*end_func.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*" \
131 "bt 3 with frame-filter Reverse disabled"
132 gdb_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"
135 gdb_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
141 gdb_test_no_output "set print frame-arguments none" \
142 "turn off frame arguments"
143 gdb_test "bt no-filter 1" \
144 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
145 "bt no-filter 1 no args"
146 gdb_test "bt 1" \
147 "#0.*end_func \\(foo=\.\.\., bar=\.\.\., fb=\.\.\., bf=\.\.\.\\) at .*py-framefilter.c.*" \
148 "bt 1 no args"
149
150 # scalars
151 gdb_test_no_output "set print frame-arguments scalars" \
152 "turn frame arguments to scalars only"
153 gdb_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"
156 gdb_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
161 gdb_test_no_output "set print frame-arguments all" \
162 "turn on frame arguments"
163 gdb_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"
166 gdb_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
171 gdb_test_no_output "set print address off" \
172 "Turn off address printing"
173 gdb_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"
176 gdb_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
180 remote_file host delete ${remote_python_file}
181
182 # Test with no debuginfo
183
184 # We cannot use prepare_for_testing as we have to set the safe-patch
185 # to check objfile and progspace printers.
186 if {[build_executable $testfile.exp $testfile $srcfile {nodebug}] == -1} {
187 return -1
188 }
189
190 # Start with a fresh gdb.
191 gdb_exit
192 gdb_start
193
194 # Skip all tests if Python scripting is not enabled.
195 if { [skip_python_tests] } { continue }
196
197 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
198 # Care is taken to put it in the same directory as the binary so that
199 # gdb will find it.
200 set remote_obj_python_file \
201 [remote_download \
202 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
203 [standard_output_file ${testfile}-gdb.py]]
204
205 gdb_reinitialize_dir $srcdir/$subdir
206 gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
207 "set auto-load safe-path for no debug info"
208 gdb_load ${binfile}
209
210 # Verify gdb loaded the script.
211 gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
212 "Set autoload path for no debug info tests"
213 if ![runto_main] then {
214 perror "couldn't run to breakpoint"
215 return
216 }
217
218 gdb_test_no_output "set python print-stack full" \
219 "set python print-stack full for no debuginfo tests"
220
221 # Load global frame-filters
222 set remote_python_file [gdb_remote_download host \
223 ${srcdir}/${subdir}/${testfile}.py]
224 gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
225 "Load python file for no debuginfo tests"
226
227 # Disable Reverse
228 gdb_test_no_output "disable frame-filter global Reverse" \
229 "disable frame-filter gloval Reverse for no debuginfo"
230 gdb_test "bt" \
231 ".*#0..*in main \\(\\).*" \
232 "bt for no debuginfo"
233 gdb_test "bt full" \
234 ".*#0..*in main \\(\\).*" \
235 "bt full for no debuginfo"
236 gdb_test "bt no-filters" \
237 ".*#0..*in main \\(\\).*" \
238 "bt no filters for no debuginfo"
239 gdb_test "bt no-filters full" \
240 ".*#0..*in main \\(\\).*" \
241 "bt no-filters full no debuginfo"