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