Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 1998-2019 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) |
17 | ||
18 | # this file tests maintenance commands and help on those. | |
19 | ||
20 | # source file used is break.c | |
21 | ||
22 | ||
7d0c9981 DE |
23 | #maintenance check-psymtabs -- Check consistency of psymtabs vs symtabs |
24 | #maintenance check-symtabs -- Check consistency of symtabs | |
25 | #maintenance expand-symtabs -- Expand symtabs matching a file regexp | |
4f337972 AC |
26 | #maintenance set -- Set GDB internal variables used by the GDB maintainer |
27 | #maintenance show -- Show GDB internal variables used by the GDB maintainer | |
c906108c SS |
28 | #maintenance dump-me -- Get fatal error; make debugger dump its core |
29 | #maintenance print -- Maintenance command for printing GDB internal state | |
30 | #maintenance info -- Commands for showing internal info about the program being debugged | |
7be570e7 | 31 | #maintenance internal-error -- Give GDB an internal error. |
c906108c | 32 | # |
00905d52 | 33 | #maintenance print dummy-frames -- Print the dummy frame stack |
c906108c SS |
34 | #maintenance print statistics -- Print statistics about internal gdb state |
35 | #maintenance print objfiles -- Print dump of current object file definitions | |
36 | #maintenance print psymbols -- Print dump of current partial symbol definitions | |
37 | #maintenance print msymbols -- Print dump of current minimal symbol definitions | |
38 | #maintenance print symbols -- Print dump of current symbol definitions | |
39 | #maintenance print type -- Print a type chain for a given symbol | |
40 | #maintenance print unwind -- Print unwind table entry at given address | |
41 | # | |
42 | # | |
43 | #maintenance info sections -- List the BFD sections of the exec and core files | |
44 | #maintenance info breakpoints -- Status of all breakpoints | |
45 | # | |
46 | ||
47 | ||
48 | ||
f8b41b00 | 49 | standard_testfile break.c break1.c |
a1dea79a | 50 | |
5b362f04 | 51 | if {[prepare_for_testing "failed to prepare" $testfile \ |
f8b41b00 | 52 | [list $srcfile $srcfile2] {debug nowarnings}]} { |
f8b41b00 | 53 | return -1 |
c906108c SS |
54 | } |
55 | ||
b78974c3 PA |
56 | # The commands we test here produce many lines of output; disable "press |
57 | # <return> to continue" prompts. | |
58 | gdb_test_no_output "set height 0" | |
59 | ||
60 | # Tests that require that no program is running | |
61 | ||
62 | gdb_file_cmd ${binfile} | |
63 | ||
64 | # Test for a regression where this command would internal-error if the | |
11859c31 AB |
65 | # program wasn't running. If there's a lot of registers then this |
66 | # might overflow expect's buffers, so process the output line at a | |
67 | # time. | |
68 | set saw_registers 0 | |
69 | set saw_headers 0 | |
70 | set test "maint print registers" | |
71 | gdb_test_multiple $test $test { | |
72 | -re "\[^\r\n\]+Name\[^\r\n\]+Nr\[^\r\n\]+Rel\[^\r\n\]+Offset\[^\r\n\]+Size\[^\r\n\]+Type\[^\r\n\]+\[\r\n\]+" { | |
73 | set saw_headers 1 | |
74 | exp_continue | |
75 | } | |
76 | -re "^\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[\r\n\]+" { | |
77 | set saw_registers 1 | |
78 | exp_continue | |
79 | } | |
80 | -re "^\\*\[0-9\]+\[^\r\n\]+\[\r\n\]+" { | |
81 | exp_continue | |
82 | } | |
83 | -re "$gdb_prompt $" { | |
84 | gdb_assert { $saw_registers && $saw_headers } $test | |
85 | } | |
86 | } | |
b78974c3 | 87 | |
7d0c9981 DE |
88 | # Test "mt expand-symtabs" here as it's easier to verify before we |
89 | # run the program. | |
90 | gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs" | |
91 | gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \ | |
92 | "mt expand-symtabs" { | |
43f3e411 | 93 | -re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" { |
bf6d8a91 TT |
94 | # This should expand at most two primary symtabs. |
95 | # "Normally" it will not expand any, because the symtab | |
96 | # holding "main" will already have been expanded, but if the | |
e19d3afb DE |
97 | # file is compiled with -fdebug-types-section then a second primary |
98 | # symtab for break.c will be created for any types. | |
7d0c9981 DE |
99 | pass "mt expand-symtabs" |
100 | } | |
101 | } | |
102 | gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs" | |
103 | ||
b78974c3 PA |
104 | # Tests that can or should be done with a running program |
105 | ||
c906108c SS |
106 | gdb_load ${binfile} |
107 | ||
108 | if ![runto_main] then { | |
109 | perror "tests suppressed" | |
110 | } | |
111 | ||
927aa2e7 | 112 | # If we're using .gdb_index or .debug_names there will be no psymtabs. |
27210e12 | 113 | set have_gdb_index 0 |
927aa2e7 JK |
114 | gdb_test_multiple "maint info sections .gdb_index .debug_names" "check for .gdb_index" { |
115 | -re ": \\.gdb_index .*\r\n$gdb_prompt $" { | |
116 | set have_gdb_index 1 | |
117 | } | |
118 | -re ": \\.debug_names .*\r\n$gdb_prompt $" { | |
27210e12 DE |
119 | set have_gdb_index 1 |
120 | } | |
121 | -re ".*$gdb_prompt $" { | |
122 | ;# Nothing to do, present to avoid a FAIL. | |
123 | } | |
124 | } | |
c906108c | 125 | |
87d6a7aa SM |
126 | # There also won't be any psymtabs if we read the index from the index cache. |
127 | # We can detect this by looking if the index-cache is enabled and if the number | |
128 | # of cache misses is 0. | |
129 | set index_cache_misses -1 | |
130 | gdb_test_multiple "show index-cache stats" "check index cache stats" { | |
131 | -re ".*Cache misses \\(this session\\): (\\d+)\r\n.*$gdb_prompt $" { | |
132 | set index_cache_misses $expect_out(1,string) | |
133 | } | |
134 | } | |
135 | ||
136 | set using_index_cache 0 | |
137 | gdb_test_multiple "show index-cache" "check index cache status" { | |
138 | -re ".*is currently disabled.\r\n$gdb_prompt $" { | |
139 | set using_index_cache 0 | |
140 | } | |
141 | -re ".*is currently enabled.\r\n$gdb_prompt $" { | |
142 | set using_index_cache 1 | |
143 | } | |
144 | } | |
145 | ||
146 | if { $index_cache_misses == 0 && $using_index_cache } { | |
147 | set have_gdb_index 1 | |
148 | } | |
149 | ||
c906108c SS |
150 | # |
151 | # this command does not produce any output | |
152 | # unless there is some problem with the symtabs and psymtabs | |
153 | # so that branch will really never be covered in this tests here!! | |
154 | # | |
155 | ||
a0b3c4fd JM |
156 | # guo: on linux this command output is huge. for some reason splitting up |
157 | # the regexp checks works. | |
158 | # | |
7d0c9981 | 159 | send_gdb "maint check-psymtabs\n" |
c906108c | 160 | gdb_expect { |
7d0c9981 | 161 | -re "^maint check-psymtabs" { |
65731a6b MS |
162 | gdb_expect { |
163 | -re "$gdb_prompt $" { | |
7d0c9981 | 164 | pass "maint check-psymtabs" |
a0b3c4fd | 165 | } |
7d0c9981 | 166 | timeout { fail "(timeout) maint check-psymtabs" } |
a0b3c4fd | 167 | } |
65731a6b | 168 | } |
7d0c9981 DE |
169 | -re ".*$gdb_prompt $" { fail "maint check-psymtabs" } |
170 | timeout { fail "(timeout) maint check-psymtabs" } | |
65731a6b | 171 | } |
c906108c | 172 | |
7d0c9981 DE |
173 | # This command does not produce any output unless there is some problem |
174 | # with the symtabs, so that branch will really never be covered in the | |
175 | # tests here!! | |
176 | gdb_test_no_output "maint check-symtabs" | |
177 | ||
b8b8facf | 178 | # Test per-command stats. |
bd712aed | 179 | gdb_test_no_output "maint set per-command on" |
3847a7bf TT |
180 | set decimal "\[0-9\]+" |
181 | set time_fmt "${decimal}-${decimal}-${decimal} ${decimal}:${decimal}:${decimal}\\.${decimal}" | |
b8b8facf | 182 | gdb_test "pwd" \ |
3847a7bf TT |
183 | "${time_fmt} - command started\r\n.*\r\n${time_fmt} - command finished\r\nCommand execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #compunits: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)" |
184 | gdb_test "maint set per-command off" \ | |
185 | "${time_fmt} - command started" | |
c906108c | 186 | |
dbdfa66c CV |
187 | # The timeout value is raised, because printing all the symbols and |
188 | # statistical information about Cygwin and Windows libraries takes a lot | |
cb80163c DE |
189 | # of time. |
190 | if [istarget "*-*-cygwin*"] { | |
191 | set oldtimeout $timeout | |
192 | set timeout [expr $timeout + 500] | |
193 | } | |
c906108c | 194 | |
55b7ce7f UW |
195 | send_gdb "maint print statistics\n" |
196 | gdb_expect { | |
f8b41b00 | 197 | -re "Statistics for\[^\n\r\]*maint\[^\n\r\]*:\r\n Number of \"minimal\" symbols read: $decimal\r\n( Number of \"partial\" symbols read: $decimal\r\n)? Number of \"full\" symbols read: $decimal\r\n Number of \"types\" defined: $decimal\r\n( Number of psym tables \\(not yet expanded\\): $decimal\r\n)?( Number of read CUs: $decimal\r\n Number of unread CUs: $decimal\r\n)? Number of symbol tables: $decimal\r\n Number of symbol tables with line tables: $decimal\r\n Number of symbol tables with blockvectors: $decimal\r\n Total memory used for objfile obstack: $decimal\r\n Total memory used for BFD obstack: $decimal\r\n Total memory used for psymbol cache: $decimal\r\n Total memory used for macro cache: $decimal\r\n Total memory used for file name cache: $decimal\r\n" { |
55b7ce7f UW |
198 | gdb_expect { |
199 | -re "$gdb_prompt $" { | |
200 | pass "maint print statistics" | |
201 | } | |
202 | timeout { fail "(timeout) maint print statistics" } | |
203 | } | |
65731a6b | 204 | } |
55b7ce7f UW |
205 | -re ".*$gdb_prompt $" { fail "maint print statistics" } |
206 | timeout { fail "(timeout) maint print statistics" } | |
65731a6b | 207 | } |
c906108c | 208 | |
00905d52 | 209 | # There aren't any ... |
27d3a1a2 | 210 | gdb_test_no_output "maint print dummy-frames" |
00905d52 | 211 | |
c906108c | 212 | send_gdb "maint print objfiles\n" |
adf40b2e | 213 | |
c906108c | 214 | # To avoid timeouts, we avoid expects with many .* patterns that match |
adf40b2e JM |
215 | # many lines. Instead, we keep track of which milestones we've seen |
216 | # in the output, and stop when we've seen all of them. | |
217 | ||
218 | set header 0 | |
219 | set psymtabs 0 | |
220 | set symtabs 0 | |
221 | set keep_looking 1 | |
222 | ||
223 | while {$keep_looking} { | |
224 | gdb_expect { | |
225 | ||
e48744a0 PA |
226 | -re "\r\n" { |
227 | set output $expect_out(buffer) | |
228 | if {[regexp ".*Object file.*maint($EXEEXT)?: Objfile at ${hex}" $output]} { | |
229 | set header 1 | |
230 | } | |
231 | if {[regexp ".*Psymtabs:\[\r\t \]+\n" $output]} { | |
232 | set psymtabs 1 | |
233 | } | |
234 | if {[regexp ".*Symtabs:\[\r\t \]+\n" $output]} { | |
235 | set symtabs 1 | |
236 | } | |
237 | } | |
adf40b2e JM |
238 | |
239 | -re ".*$gdb_prompt $" { | |
240 | set keep_looking 0 | |
241 | } | |
242 | timeout { | |
243 | fail "(timeout) maint print objfiles" | |
244 | set keep_looking 0 | |
245 | } | |
246 | } | |
c906108c | 247 | } |
adf40b2e JM |
248 | |
249 | proc maint_pass_if {val name} { | |
250 | if $val { pass $name } else { fail $name } | |
c906108c SS |
251 | } |
252 | ||
adf40b2e | 253 | maint_pass_if $header "maint print objfiles: header" |
27210e12 DE |
254 | if { ! $have_gdb_index } { |
255 | maint_pass_if $psymtabs "maint print objfiles: psymtabs" | |
256 | } | |
adf40b2e JM |
257 | maint_pass_if $symtabs "maint print objfiles: symtabs" |
258 | ||
27210e12 | 259 | if { ! $have_gdb_index } { |
f8b41b00 | 260 | set psymbols_output [standard_output_file psymbols_output] |
37539ebe | 261 | set psymbols_output_re [string_to_regexp $psymbols_output] |
34c41c68 DE |
262 | set test_list [list \ |
263 | "maint print psymbols -source" \ | |
264 | "maint print psymbols -source ${srcdir}/${subdir}/${srcfile} $psymbols_output" \ | |
265 | "maint print psymbols -pc" \ | |
266 | "maint print psymbols -pc main $psymbols_output"] | |
267 | foreach { test_name command } $test_list { | |
268 | send_gdb "$command\n" | |
269 | gdb_expect { | |
270 | -re "^maint print psymbols \[^\n\]*\r\n$gdb_prompt $" { | |
271 | send_gdb "shell ls $psymbols_output\n" | |
27210e12 | 272 | gdb_expect { |
34c41c68 DE |
273 | -re "$psymbols_output_re\r\n$gdb_prompt $" { |
274 | # We want this grep to be as specific as possible, | |
275 | # so it's less likely to match symbol file names in | |
276 | # psymbols_output. Yes, this actually happened; | |
277 | # poor expect got tons of output, and timed out | |
278 | # trying to match it. --- Jim Blandy <jimb@cygnus.com> | |
279 | send_gdb "shell grep 'main.*function' $psymbols_output\n" | |
280 | gdb_expect { | |
281 | -re ".main., function, $hex.*$gdb_prompt $" { | |
282 | pass "$test_name 1" | |
283 | } | |
284 | -re ".*main. .., function, $hex.*$gdb_prompt $" { | |
285 | pass "$test_name 2" | |
286 | } | |
287 | -re ".*$gdb_prompt $" { fail "$test_name" } | |
288 | timeout { fail "$test_name (timeout)" } | |
289 | } | |
290 | gdb_test "shell rm -f $psymbols_output" ".*" \ | |
45fe4a03 | 291 | "${test_name}: shell rm -f psymbols_output" |
27210e12 | 292 | } |
34c41c68 DE |
293 | -re ".*$gdb_prompt $" { fail "$test_name" } |
294 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 295 | } |
65731a6b | 296 | } |
34c41c68 DE |
297 | -re ".*$gdb_prompt $" { fail "$test_name" } |
298 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 299 | } |
65731a6b | 300 | } |
65731a6b | 301 | } |
c906108c | 302 | |
c906108c | 303 | |
f8b41b00 | 304 | set msymbols_output [standard_output_file msymbols_output] |
37539ebe | 305 | set msymbols_output_re [string_to_regexp $msymbols_output] |
34c41c68 | 306 | send_gdb "maint print msymbols -objfile ${binfile} $msymbols_output\n" |
c906108c | 307 | gdb_expect { |
34c41c68 | 308 | -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { |
f8b41b00 | 309 | send_gdb "shell ls $msymbols_output\n" |
65731a6b | 310 | gdb_expect { |
37539ebe | 311 | -re "$msymbols_output_re\r\n$gdb_prompt $" { |
45fe4a03 AB |
312 | gdb_test "shell grep factorial $msymbols_output" \ |
313 | "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ | |
314 | "maint print msymbols, absolute pathname" | |
f8b41b00 TT |
315 | gdb_test "shell rm -f $msymbols_output" ".*" \ |
316 | "shell rm -f msymbols_output" | |
65731a6b | 317 | } |
34c41c68 DE |
318 | -re ".*$gdb_prompt $" { fail "maint print msymbols" } |
319 | timeout { fail "maint print msymbols (timeout)" } | |
65731a6b MS |
320 | } |
321 | } | |
34c41c68 DE |
322 | -re ".*$gdb_prompt $" { fail "maint print msymbols" } |
323 | timeout { fail "maint print msymbols (timeout)" } | |
65731a6b | 324 | } |
c906108c | 325 | |
dbdfa66c CV |
326 | # Check that maint print msymbols allows relative pathnames |
327 | set mydir [pwd] | |
08b3fe69 TT |
328 | gdb_test "cd [standard_output_file {}]" \ |
329 | "Working directory .*\..*" \ | |
65731a6b MS |
330 | "cd to objdir" |
331 | ||
34c41c68 DE |
332 | gdb_test_multiple "maint print msymbols -objfile ${testfile} msymbols_output2" "maint print msymbols" { |
333 | -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { | |
dbdfa66c CV |
334 | gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" { |
335 | -re "msymbols_output2\r\n$gdb_prompt $" { | |
107c2d62 LM |
336 | gdb_test "shell grep factorial msymbols_output2" \ |
337 | "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ | |
45fe4a03 | 338 | "maint print msymbols, relative pathname" |
107c2d62 | 339 | gdb_test "shell rm -f msymbols_output2" ".*" |
dbdfa66c | 340 | } |
dbdfa66c CV |
341 | } |
342 | } | |
dbdfa66c | 343 | } |
65731a6b MS |
344 | gdb_test "cd ${mydir}" \ |
345 | "Working directory [string_to_regexp ${mydir}]\..*" \ | |
346 | "cd to mydir" | |
347 | ||
c906108c | 348 | |
3bcbaac5 DJ |
349 | # Request symbols for one particular source file so that we don't try to |
350 | # dump the symbol information for the entire C library - over 500MB nowadays | |
351 | # for GNU libc. | |
adf40b2e | 352 | |
f8b41b00 | 353 | set symbols_output [standard_output_file symbols_output] |
37539ebe | 354 | set symbols_output_re [string_to_regexp $symbols_output] |
34c41c68 DE |
355 | set test_list [list \ |
356 | "maint print symbols -source" \ | |
357 | "maint print symbols -source ${srcdir}/${subdir}/${srcfile} $symbols_output" \ | |
358 | "maint print symbols -pc" \ | |
359 | "maint print symbols -pc main $symbols_output"] | |
360 | foreach { test_name command } $test_list { | |
361 | send_gdb "$command\n" | |
362 | gdb_expect { | |
363 | -re "^maint print symbols \[^\n\]*\r\n$gdb_prompt $" { | |
364 | send_gdb "shell ls $symbols_output\n" | |
365 | gdb_expect { | |
366 | -re "$symbols_output_re\r\n$gdb_prompt $" { | |
367 | # See comments for `maint print psymbols'. | |
368 | send_gdb "shell grep 'main(.*block' $symbols_output\n" | |
369 | gdb_expect { | |
370 | -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" { | |
371 | pass "$test_name" | |
372 | } | |
373 | -re ".*$gdb_prompt $" { fail "$test_name" } | |
374 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 375 | } |
34c41c68 | 376 | gdb_test "shell rm -f $symbols_output" ".*" \ |
45fe4a03 | 377 | "$test_name: shell rm -f symbols_output" |
65731a6b | 378 | } |
34c41c68 DE |
379 | -re ".*$gdb_prompt $" { fail "$test_name" } |
380 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 381 | } |
65731a6b | 382 | } |
34c41c68 DE |
383 | -re ".*$gdb_prompt $" { fail "$test_name" } |
384 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 385 | } |
65731a6b | 386 | } |
c906108c | 387 | |
b4ba55a1 JB |
388 | set msg "maint print type" |
389 | gdb_test_multiple "maint print type argc" $msg { | |
e86ca25f | 390 | -re "type node $hex\r\nname .int. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" { |
b4ba55a1 JB |
391 | pass $msg |
392 | } | |
393 | } | |
c906108c | 394 | |
a0b3c4fd JM |
395 | if [istarget "hppa*-*-11*"] { |
396 | setup_xfail hppa*-*-*11* CLLbs14860 | |
65731a6b MS |
397 | gdb_test_multiple "maint print unwind &main" "maint print unwind" { |
398 | -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tRegion_description = $hex\r\n\tEntry_FR = $hex\r\n\tEntry_GR = $hex\r\n\tTotal_frame_size = $hex\r\n$gdb_prompt $" { | |
399 | pass "maint print unwind" | |
400 | } | |
401 | -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n$gdb_prompt $" { | |
402 | xfail "maint print unwind" | |
403 | } | |
a0b3c4fd JM |
404 | } |
405 | } | |
c906108c SS |
406 | |
407 | set oldtimeout $timeout | |
408 | set timeout [expr $timeout + 300] | |
409 | ||
410 | # It'd be nice to check for every possible section. However, that's | |
411 | # problematic, since the relative ordering wanders from release to | |
412 | # release of the compilers. Instead, we'll just check for two | |
413 | # sections which appear to always come out in the same relative | |
414 | # order. (If that changes, then we should just check for one | |
415 | # section.) | |
416 | # | |
417 | # And by the way: This testpoint will break for PA64, where a.out's | |
418 | # are ELF files. | |
293e2f9e DJ |
419 | |
420 | # Standard GNU names. | |
421 | set text_section ".text" | |
422 | set data_section ".data" | |
423 | ||
65731a6b | 424 | gdb_test_multiple "maint info sections" "maint info sections" { |
f8b41b00 | 425 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*ER_RO.*$gdb_prompt $" { |
65731a6b MS |
426 | # Looks like RealView which uses different section names. |
427 | set text_section ER_RO | |
428 | set data_section ER_RW | |
429 | pass "maint info sections" | |
430 | } | |
f8b41b00 | 431 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*neardata.*$gdb_prompt $" { |
d93f7b5c YQ |
432 | # c6x doesn't have .data section. It has .neardata and .fardata section. |
433 | set data_section ".neardata" | |
434 | pass "maint info sections" | |
435 | } | |
f8b41b00 | 436 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*$gdb_prompt $" { |
65731a6b MS |
437 | pass "maint info sections" |
438 | } | |
439 | } | |
c906108c | 440 | |
8ddad156 MS |
441 | # Test for new option: maint info sections <section name> |
442 | # If you don't have a .text section, this will require tweaking. | |
65731a6b MS |
443 | |
444 | gdb_test_multiple "maint info sections $text_section" \ | |
445 | "maint info sections .text" { | |
446 | -re ".* \\.bss .*$gdb_prompt $" { | |
447 | fail "maint info sections .text" | |
448 | } | |
449 | -re ".* $data_section .*$gdb_prompt $" { | |
450 | fail "maint info sections .text" | |
451 | } | |
452 | -re ".* $text_section .*$gdb_prompt $" { | |
453 | pass "maint info sections .text" | |
454 | } | |
455 | } | |
8ddad156 MS |
456 | |
457 | # Test for new option: CODE section flag | |
458 | # If your data section is tagged CODE, xfail this test. | |
65731a6b MS |
459 | |
460 | gdb_test_multiple "maint info sections CODE" "maint info sections CODE" { | |
293e2f9e DJ |
461 | -re ".* $data_section .*$gdb_prompt $" { fail "maint info sections CODE" } |
462 | -re ".* $text_section .*$gdb_prompt $" { pass "maint info sections CODE" } | |
8ddad156 MS |
463 | } |
464 | ||
465 | # Test for new option: DATA section flag | |
466 | # If your text section is tagged DATA, xfail this test. | |
dbdfa66c | 467 | # |
58e8570a | 468 | # The "maint info sections DATA" test is marked for XFAIL on Windows, |
dbdfa66c CV |
469 | # because Windows has text sections marked DATA. |
470 | setup_xfail "*-*-*cygwin*" | |
58e8570a | 471 | setup_xfail "*-*-*mingw*" |
65731a6b MS |
472 | |
473 | gdb_test_multiple "maint info sections DATA" "maint info sections DATA" { | |
293e2f9e DJ |
474 | -re ".* $text_section .*$gdb_prompt $" { fail "maint info sections DATA" } |
475 | -re ".* $data_section .*$gdb_prompt $" { pass "maint info sections DATA" } | |
759f0f0b | 476 | -re ".* .rodata .*$gdb_prompt $" { pass "maint info sections DATA" } |
8ddad156 MS |
477 | } |
478 | ||
a1dea79a FF |
479 | set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] |
480 | ||
65731a6b MS |
481 | gdb_test_multiple "maint info breakpoints" "maint info breakpoints" { |
482 | -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex\[ \t\]+in main at.*break.c:$bp_location6 inf 1\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $" { | |
483 | pass "maint info breakpoints" | |
484 | } | |
485 | -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex in main at.*break.c:$bp_location6 sspace 1\r\n\[ \t\]+breakpoint already hit 1 time\r\n-1\[ \t\]+shlib events\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex.*breakpoint already hit.*$gdb_prompt $" { | |
486 | pass "maint info breakpoints (with shlib events)" | |
487 | } | |
c906108c SS |
488 | } |
489 | ||
65731a6b MS |
490 | gdb_test "maint print" \ |
491 | "\"maintenance print\" must be followed by the name of a print command\\.\r\nList.*unambiguous\\..*" \ | |
492 | "maint print w/o args" | |
c906108c | 493 | |
65731a6b MS |
494 | gdb_test "maint info" \ |
495 | "\"maintenance info\" must be followed by the name of an info command\\.\r\nList.*unambiguous\\..*" \ | |
496 | "maint info w/o args" | |
c906108c | 497 | |
65731a6b MS |
498 | gdb_test "maint" \ |
499 | "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*" \ | |
500 | "maint w/o args" | |
c906108c | 501 | |
f610ab6d PA |
502 | # Test that "main info line-table" w/o a file name shows the symtab for |
503 | # $srcfile. | |
504 | set saw_srcfile 0 | |
505 | set test "maint info line-table w/o a file name" | |
506 | gdb_test_multiple "maint info line-table" $test { | |
507 | -re "symtab: \[^\n\r\]+${srcfile} \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" { | |
508 | set saw_srcfile 1 | |
509 | exp_continue | |
510 | } | |
511 | -re "symtab: \[^\n\r\]+ \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" { | |
512 | # Match each symtab to avoid overflowing expect's buffer. | |
513 | exp_continue | |
514 | } | |
515 | -re "$decimal\[ \t\]+$decimal\[ \t\]+$hex\r\n" { | |
516 | # Line table entries can be long too: | |
517 | # | |
518 | # INDEX LINE ADDRESS | |
519 | # 0 29 0x00000000004006f6 | |
520 | # 1 30 0x00000000004006fa | |
521 | # 2 31 0x0000000000400704 | |
522 | # 3 42 0x0000000000400706 | |
523 | # 4 43 0x0000000000400719 | |
524 | # 5 44 0x0000000000400722 | |
525 | # 6 45 0x0000000000400740 | |
526 | # (...) | |
527 | # 454 129 0x00007ffff7df1d28 | |
528 | # 455 0 0x00007ffff7df1d3f | |
529 | # | |
530 | # Match each line to avoid overflowing expect's buffer. | |
531 | exp_continue | |
532 | } | |
533 | -re "$gdb_prompt $" { | |
534 | gdb_assert $saw_srcfile $test | |
535 | } | |
536 | } | |
f2403c39 AB |
537 | |
538 | gdb_test "maint info line-table ${srcfile}" \ | |
539 | "symtab: \[^\n\r\]+${srcfile}.*INDEX.*LINE.*ADDRESS.*" \ | |
540 | "maint info line-table with filename of current symtab" | |
541 | ||
542 | gdb_test_no_output "maint info line-table ${srcfile2}" \ | |
543 | "maint info line-table with filename of symtab that is not currently expanded" | |
544 | ||
545 | gdb_test_no_output "maint expand-symtabs" | |
546 | ||
547 | gdb_test "maint info line-table ${srcfile2}" \ | |
548 | "symtab: \[^\n\r\]+${srcfile2}.*INDEX.*LINE.*ADDRESS.*" \ | |
549 | "maint info line-table with filename of symtab that is not current" | |
550 | ||
551 | gdb_test_no_output "maint info line-table xxx.c" \ | |
552 | "maint info line-table with invalid filename" | |
553 | ||
c906108c SS |
554 | set timeout $oldtimeout |
555 | ||
3c3bb058 AB |
556 | # Just check that the DWARF unwinders control flag is visible. |
557 | gdb_test "maint show dwarf unwinders" \ | |
558 | "The DWARF stack unwinders are currently (on|off)\\." | |
559 | ||
c906108c SS |
560 | #============test help on maint commands |
561 | ||
45fe4a03 AB |
562 | test_prefix_command_help {"maint info" "maintenance info"} { |
563 | "Commands for showing internal info about the program being debugged\\.\[\r\n\]+" | |
564 | } | |
c906108c | 565 | |
d8295fe9 VP |
566 | test_prefix_command_help {"maint print" "maintenance print"} { |
567 | "Maintenance command for printing GDB internal state\\.\[\r\n\]+" | |
568 | } | |
c906108c | 569 | |
d8295fe9 VP |
570 | test_prefix_command_help {"maint" "maintenance"} { |
571 | "Commands for use by GDB maintainers\\.\[\r\n\]+" | |
572 | "Includes commands to dump specific internal GDB structures in\[\r\n\]+" | |
439250fb | 573 | "a human readable form, to cause GDB to deliberately dump core, etc\\.\[\r\n\]+" |
d8295fe9 | 574 | } |
c906108c SS |
575 | |
576 | #set oldtimeout $timeout | |
577 | #set timeout [expr $timeout + 300] | |
578 | ||
65731a6b MS |
579 | gdb_test_multiple "maint dump-me" "maint dump-me" { |
580 | -re "Should GDB dump core.*\\(y or n\\) $" { | |
581 | gdb_test "n" ".*" "maint dump-me" | |
582 | } | |
9bdd0636 YQ |
583 | -re "Undefined maintenance command: .*$gdb_prompt $" { |
584 | # Command 'maint dump-me' is registered on non-win32 host. | |
585 | unsupported "maint dump-me" | |
586 | } | |
65731a6b | 587 | } |
c906108c | 588 | |
7be570e7 | 589 | send_gdb "maint internal-error\n" |
039cf96d AC |
590 | gdb_expect { |
591 | -re "A problem internal to GDB has been detected" { | |
592 | pass "maint internal-error" | |
593 | if [gdb_internal_error_resync] { | |
594 | pass "internal-error resync" | |
595 | } else { | |
596 | fail "internal-error resync" | |
7be570e7 JM |
597 | } |
598 | } | |
599 | -re ".*$gdb_prompt $" { | |
600 | fail "maint internal-error" | |
039cf96d | 601 | untested "internal-error resync" |
7be570e7 JM |
602 | } |
603 | timeout { | |
039cf96d AC |
604 | fail "maint internal-error (timeout)" |
605 | untested "internal-error resync" | |
7be570e7 JM |
606 | } |
607 | } | |
608 | ||
c906108c SS |
609 | #set timeout $oldtimeout |
610 | ||
99e8a4f9 SDJ |
611 | # Test that the commands work without an argument. For this test, we |
612 | # don't need an inferior loaded/running. See PR gdb/21164. | |
613 | gdb_exit | |
614 | gdb_start | |
615 | gdb_test_no_output "maint print symbols" | |
616 | gdb_test_no_output "maint print msymbols" | |
617 | gdb_test_no_output "maint print psymbols" | |
c906108c SS |
618 | |
619 | gdb_exit | |
620 | return 0 |