]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/maint.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / maint.exp
1 # Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2007
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
22
23 # this file tests maintenance commands and help on those.
24
25 # source file used is break.c
26
27
28 #maintenance check-symtabs -- Check consistency of psymtabs and symtabs
29 #maintenance space -- Set the display of space usage
30 #maintenance set -- Set GDB internal variables used by the GDB maintainer
31 #maintenance show -- Show GDB internal variables used by the GDB maintainer
32 #maintenance time -- Set the display of time usage
33 #maintenance demangle -- Demangle a C++ mangled name
34 #maintenance dump-me -- Get fatal error; make debugger dump its core
35 #maintenance print -- Maintenance command for printing GDB internal state
36 #maintenance info -- Commands for showing internal info about the program being debugged
37 #maintenance internal-error -- Give GDB an internal error.
38 #
39 #maintenance print dummy-frames -- Print the dummy frame stack
40 #maintenance print statistics -- Print statistics about internal gdb state
41 #maintenance print objfiles -- Print dump of current object file definitions
42 #maintenance print psymbols -- Print dump of current partial symbol definitions
43 #maintenance print msymbols -- Print dump of current minimal symbol definitions
44 #maintenance print symbols -- Print dump of current symbol definitions
45 #maintenance print type -- Print a type chain for a given symbol
46 #maintenance print unwind -- Print unwind table entry at given address
47 #
48 #
49 #maintenance info sections -- List the BFD sections of the exec and core files
50 #maintenance info breakpoints -- Status of all breakpoints
51 #
52
53
54
55 if $tracelevel then {
56 strace $tracelevel
57 }
58
59 global usestubs
60
61 #
62 # test running programs
63 #
64 set prms_id 0
65 set bug_id 0
66
67 set testfile "break"
68 set srcfile ${testfile}.c
69 set srcfile1 ${testfile}1.c
70 set binfile ${objdir}/${subdir}/${testfile}
71
72 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
73 untested maint.exp
74 return -1
75 }
76
77 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
78 untested maint.exp
79 return -1
80 }
81
82 if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
83 untested maint.exp
84 return -1
85 }
86
87
88 gdb_exit
89 gdb_start
90 gdb_reinitialize_dir $srcdir/$subdir
91 gdb_load ${binfile}
92
93 if ![runto_main] then {
94 perror "tests suppressed"
95 }
96
97
98 # The commands we test here produce many lines of output; disable "press
99 # <return> to continue" prompts.
100 send_gdb "set height 0\n"
101 gdb_expect -re "$gdb_prompt $"
102
103 # use a larger expect input buffer for long help outputs.
104 match_max 6000
105
106 #
107 # this command does not produce any output
108 # unless there is some problem with the symtabs and psymtabs
109 # so that branch will really never be covered in this tests here!!
110 #
111
112 # guo: on linux this command output is huge. for some reason splitting up
113 # the regexp checks works.
114 #
115 send_gdb "maint check-symtabs\n"
116 gdb_expect {
117 -re "^maint check-symtabs" {
118 gdb_expect {
119 -re "$gdb_prompt $" \
120 { pass "maint check-symtabs" }
121 timeout { fail "(timeout) maint check-symtabs" }
122 }
123 }
124 -re ".*$gdb_prompt $" { fail "maint check-symtabs" }
125 timeout { fail "(timeout) maint check-symtabs" }
126 }
127
128 send_gdb "maint space\n"
129 gdb_expect {
130 -re "\"maintenance space\" takes a numeric argument\\..*$gdb_prompt $"\
131 { pass "maint space" }
132 -re ".*$gdb_prompt $" { fail "maint space" }
133 timeout { fail "(timeout) maint space" }
134 }
135
136 send_gdb "maint space 1\n"
137 gdb_expect {
138 -re "Space used: $decimal \\(\\+$decimal for this command\\).*$gdb_prompt $"\
139 { pass "maint space 1" }
140 -re ".*$gdb_prompt $" { fail "maint space 1" }
141 timeout { fail "(timeout) maint space 1" }
142 }
143
144
145 send_gdb "maint time\n"
146 gdb_expect {
147 -re "\"maintenance time\" takes a numeric argument\\..*Space used: $decimal \\(\\+$decimal for this command\\).*$gdb_prompt $"\
148 { pass "maint time" }
149 -re ".*$gdb_prompt $" { fail "maint time" }
150 timeout { fail "(timeout) maint time" }
151 }
152
153 send_gdb "maint time 1\n"
154 gdb_expect {
155 -re "Command execution time: $decimal.*Space used: $decimal \\(\\+$decimal for this command\\).*$gdb_prompt $"\
156 { pass "maint time 1" }
157 -re ".*$gdb_prompt $" { fail "maint time 1" }
158 timeout { fail "(timeout) maint time 1" }
159 }
160
161 send_gdb "maint time 0\n"
162 gdb_expect {
163 -re "Space used: $decimal \\(\\+$decimal for this command\\).*$gdb_prompt $"\
164 { pass "maint time 0" }
165 -re ".*$gdb_prompt $" { fail "maint time 0" }
166 timeout { fail "(timeout) maint time 0" }
167 }
168
169
170 send_gdb "maint space 0\n"
171 gdb_expect {
172 -re "maint space 0\r\n$gdb_prompt $"\
173 { pass "maint space 0" }
174 -re ".*$gdb_prompt $" { fail "maint space 0" }
175 timeout { fail "(timeout) maint space 0" }
176 }
177
178 send_gdb "maint demangle\n"
179 gdb_expect {
180 -re "\"maintenance demangle\" takes an argument to demangle\\..*$gdb_prompt $"\
181 { pass "maint demangle" }
182 -re ".*$gdb_prompt $" { fail "maint demangle" }
183 timeout { fail "(timeout) maint demangle" }
184 }
185
186 send_gdb "maint demangle main\n"
187 gdb_expect {
188 -re "Can't demangle \"main\".*$gdb_prompt $"\
189 { pass "maint demangle" }
190 -re ".*$gdb_prompt $" { fail "maint demangle" }
191 timeout { fail "(timeout) maint demangle" }
192 }
193
194 # The timeout value is raised, because printing all the symbols and
195 # statistical information about Cygwin and Windows libraries takes a lot
196 # of time.
197 if [istarget "*-*-cygwin*"] {
198 set oldtimeout $timeout
199 set timeout [expr $timeout + 500]
200 }
201
202 send_gdb "maint print statistics\n"
203 gdb_expect {
204 -re "Statistics for.*break.*Number of \"minimal\" symbols read.*Number of \"partial\" symbols read.*Number of \"types\" defined.*Number of psym tables \\(not yet expanded\\).*Number of symbol tables.*Number of symbol tables with line tables.*Number of symbol tables with blockvectors.*Total memory used for psymbol obstack.*Total memory used for psymbol cache.*Total memory used for symbol obstack.*Total memory used for type obstack.*$gdb_prompt $"\
205 {
206 # Old output for gdb 6.0 and earlier
207 pass "maint print statistics"
208 }
209 -re "Statistics for.*break.*Number of \"minimal\" symbols read.*Number of \"partial\" symbols read.*Number of \"types\" defined.*Number of psym tables \\(not yet expanded\\).*Number of symbol tables.*Number of symbol tables with line tables.*Number of symbol tables with blockvectors.*Total memory used for objfile obstack.*Total memory used for psymbol cache.*Total memory used for macro cache.*$gdb_prompt $"\
210 { pass "maint print statistics" }
211 -re ".*$gdb_prompt $" { fail "maint print statistics" }
212 timeout { fail "(timeout) maint print statistics" }
213 }
214
215 # There aren't any ...
216 gdb_test "maint print dummy-frames" ""
217
218 send_gdb "maint print objfiles\n"
219
220 # To avoid timeouts, we avoid expects with many .* patterns that match
221 # many lines. Instead, we keep track of which milestones we've seen
222 # in the output, and stop when we've seen all of them.
223
224 set header 0
225 set psymtabs 0
226 set symtabs 0
227 set keep_looking 1
228
229 while {$keep_looking} {
230 gdb_expect {
231
232 -re ".*Object file.*break($EXEEXT)?: Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" { set header 1 }
233 -re ".*Psymtabs:\[\r\t \]+\n" { set psymtabs 1 }
234 -re ".*Symtabs:\[\r\t \]+\n" { set symtabs 1 }
235
236 -re ".*$gdb_prompt $" {
237 set keep_looking 0
238 }
239 timeout {
240 fail "(timeout) maint print objfiles"
241 set keep_looking 0
242 }
243 }
244 }
245
246 proc maint_pass_if {val name} {
247 if $val { pass $name } else { fail $name }
248 }
249
250 maint_pass_if $header "maint print objfiles: header"
251 maint_pass_if $psymtabs "maint print objfiles: psymtabs"
252 maint_pass_if $symtabs "maint print objfiles: symtabs"
253
254 send_gdb "maint print psymbols\n"
255 gdb_expect {
256 -re "print-psymbols takes an output file name and optional symbol file name.*$gdb_prompt $"\
257 { pass "maint print psymbols w/o args" }
258 -re ".*$gdb_prompt $" { fail "maint print psymbols w/o args" }
259 timeout { fail "(timeout) maint print psymbols w/o args" }
260 }
261
262 send_gdb "maint print psymbols psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
263 gdb_expect {
264 -re "^maint print psymbols psymbols_output \[^\n\]*\r\n$gdb_prompt $"\
265 {
266 send_gdb "shell ls psymbols_output\n"
267 gdb_expect {
268 -re "psymbols_output\r\n$gdb_prompt $"\
269 {
270 # We want this grep to be as specific as possible,
271 # so it's less likely to match symbol file names in
272 # psymbols_output. Yes, this actually happened;
273 # poor expect got tons of output, and timed out
274 # trying to match it. --- Jim Blandy <jimb@cygnus.com>
275 send_gdb "shell grep 'main.*function' psymbols_output\n"
276 gdb_expect {
277 -re ".main., function, $hex.*$gdb_prompt $"\
278 { pass "maint print psymbols 1" }
279 -re ".*main. .., function, $hex.*$gdb_prompt $"\
280 { pass "maint print psymbols 2" }
281 -re ".*$gdb_prompt $" { fail "maint print psymbols" }
282 timeout { fail "(timeout) maint print psymbols" }
283 }
284 gdb_test "shell rm -f psymbols_output" ""
285
286 }
287 -re ".*$gdb_prompt $" { fail "maint print psymbols" }
288 timeout { fail "(timeout) maint print psymbols" }
289 }
290 }
291 -re ".*$gdb_prompt $" { fail "maint print psymbols" }
292 timeout { fail "(timeout) maint print psymbols" }
293 }
294
295
296 send_gdb "maint print msymbols\n"
297 gdb_expect {
298 -re "print-msymbols takes an output file name and optional symbol file name.*$gdb_prompt $"\
299 { pass "maint print msymbols w/o args" }
300 -re ".*$gdb_prompt $" { fail "maint print msymbols w/o args" }
301 timeout { fail "(timeout) maint print msymbols w/o args" }
302 }
303
304 send_gdb "maint print msymbols msymbols_output ${binfile}\n"
305 gdb_expect {
306 -re "^maint print msymbols msymbols_output \[^\n\]*\r\n$gdb_prompt $"\
307 {
308 send_gdb "shell ls msymbols_output\n"
309 gdb_expect {
310 -re "msymbols_output\r\n$gdb_prompt $"\
311 {
312 send_gdb "shell grep factorial msymbols_output\n"
313 gdb_expect {
314 -re "\\\[ *$decimal\\\] T\[ \t\]+$hex factorial.*$gdb_prompt $"\
315 { pass "maint print msymbols" }
316 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
317 timeout { fail "(timeout) maint print msymbols" }
318 }
319 gdb_test "shell rm -f msymbols_output" ""
320
321 }
322 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
323 timeout { fail "(timeout) maint print msymbols" }
324 }
325 }
326 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
327 timeout { fail "(timeout) maint print msymbols" }
328 }
329
330 # Check that maint print msymbols allows relative pathnames
331 set mydir [pwd]
332 gdb_test "cd ${objdir}" "Working directory [string_to_regexp ${objdir}]\..*"
333 gdb_test_multiple "maint print msymbols msymbols_output2 ${subdir}/${testfile}" "maint print msymbols" {
334 -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
335 gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
336 -re "msymbols_output2\r\n$gdb_prompt $" {
337 gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
338 -re "\\\[ *$decimal\\\] T\[ \t\]+$hex factorial.*$gdb_prompt $" {
339 pass "maint print msymbols"
340 }
341 -re ".*$gdb_prompt $" {
342 fail "maint print msymbols"
343 }
344 timeout {
345 fail "(timeout) maint print msymbols"
346 }
347 }
348 gdb_test "shell rm -f msymbols_output2" ""
349 }
350 -re ".*$gdb_prompt $" {
351 fail "maint print msymbols"
352 }
353 timeout {
354 fail "(timeout) maint print msymbols"
355 }
356 }
357 }
358 -re ".*$gdb_prompt $" {
359 fail "maint print msymbols"
360 }
361 timeout {
362 fail "(timeout) maint print msymbols"
363 }
364 }
365 gdb_test "cd ${mydir}" "Working directory [string_to_regexp ${mydir}]\..*"
366
367 send_gdb "maint print symbols\n"
368 gdb_expect {
369 -re "Arguments missing: an output file name and an optional symbol file name.*$gdb_prompt $"\
370 { pass "maint print symbols w/o args" }
371 -re ".*$gdb_prompt $" { fail "maint print symbols w/o args" }
372 timeout { fail "(timeout) maint print symbols w/o args" }
373 }
374
375 # Request symbols for one particular source file so that we don't try to
376 # dump the symbol information for the entire C library - over 500MB nowadays
377 # for GNU libc.
378
379 send_gdb "maint print symbols symbols_output ${srcdir}/${subdir}/${srcfile}\n"
380 gdb_expect {
381 -re "^maint print symbols symbols_output \[^\n\]*\r\n$gdb_prompt $"\
382 {
383 send_gdb "shell ls symbols_output\n"
384 gdb_expect {
385 -re "symbols_output\r\n$gdb_prompt $"\
386 {
387 # See comments for `maint print psymbols'.
388 send_gdb "shell grep 'main(.*block' symbols_output\n"
389 gdb_expect {
390 -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $"\
391 { pass "maint print symbols" }
392 -re ".*$gdb_prompt $" { fail "maint print symbols" }
393 timeout { fail "(timeout) maint print symbols" }
394 }
395 gdb_test "shell rm -f symbols_output" ""
396
397 }
398 -re ".*$gdb_prompt $" { fail "maint print symbols" }
399 timeout { fail "(timeout) maint print symbols" }
400 }
401 }
402 -re ".*$gdb_prompt $" { fail "maint print symbols" }
403 timeout { fail "(timeout) maint print symbols" }
404 }
405
406 send_gdb "maint print type argc\n"
407 gdb_expect {
408 -re "type node $hex\r\nname .int. \\($hex\\)\r\ntagname .<NULL>. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nupper_bound_type $hex \\(BOUND_SIMPLE\\)\r\nlower_bound_type $hex \\(BOUND_SIMPLE\\)\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 $hex\r\nnfields 0 $hex\r\nvptr_basetype $hex\r\nvptr_fieldno -1\r\ntype_specific $hex\r\n$gdb_prompt $"\
409 { pass "maint print type" }
410 -re ".*$gdb_prompt $" { fail "maint print type" }
411 timeout { fail "(timeout) maint print type" }
412 }
413
414 if [istarget "hppa*-*-11*"] {
415 setup_xfail hppa*-*-*11* CLLbs14860
416 send "maint print unwind &main\n"
417 expect {
418 -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 $"\
419 { pass "maint print unwind" }
420 -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 $"\
421 { xfail "maint print unwind" }
422 -re ".*$gdb_prompt $" { xfail "maint info unwind" }
423 timeout { fail "(timeout) maint print unwind" }
424 }
425 }
426
427 set oldtimeout $timeout
428 set timeout [expr $timeout + 300]
429
430 # It'd be nice to check for every possible section. However, that's
431 # problematic, since the relative ordering wanders from release to
432 # release of the compilers. Instead, we'll just check for two
433 # sections which appear to always come out in the same relative
434 # order. (If that changes, then we should just check for one
435 # section.)
436 #
437 # And by the way: This testpoint will break for PA64, where a.out's
438 # are ELF files.
439 #
440 send_gdb "maint info sections\n"
441 gdb_expect {
442 -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $"\
443 { pass "maint info sections" }
444 -re ".*$gdb_prompt $" { fail "maint info sections" }
445 timeout { fail "(timeout) maint info sections" }
446 }
447
448 # Test for new option: maint info sections <section name>
449 # If you don't have a .text section, this will require tweaking.
450 send_gdb "maint info sections .text\n"
451 gdb_expect {
452 -re ".*bss.*$gdb_prompt $" { fail "maint info sections .text" }
453 -re ".*data.*$gdb_prompt $" { fail "maint info sections .text" }
454 -re ".* .text .*$gdb_prompt $" { pass "maint info sections .text" }
455 -re ".*$gdb_prompt $" { fail "maint info sections .text" }
456 timeout { fail "(timeout) maint info sections .text" }
457 }
458
459 # Test for new option: CODE section flag
460 # If your data section is tagged CODE, xfail this test.
461 send_gdb "maint info sections CODE\n"
462 gdb_expect {
463 -re ".* .data .*$gdb_prompt $" { fail "maint info sections CODE" }
464 -re ".* .text .*$gdb_prompt $" { pass "maint info sections CODE" }
465 -re ".*$gdb_prompt $" { fail "maint info sections CODE" }
466 timeout { fail "(timeout) maint info sections CODE" }
467 }
468
469 # Test for new option: DATA section flag
470 # If your text section is tagged DATA, xfail this test.
471 #
472 # The "maint info sections DATA" test is marked for XFAIL on Cygwin,
473 # because Windows has text sections marked DATA.
474 setup_xfail "*-*-*cygwin*"
475 send_gdb "maint info sections DATA\n"
476 gdb_expect {
477 -re ".* .text .*$gdb_prompt $" { fail "maint info sections DATA" }
478 -re ".* .data .*$gdb_prompt $" { pass "maint info sections DATA" }
479 -re ".*$gdb_prompt $" { fail "maint info sections DATA" }
480 timeout { fail "(timeout) maint info sections DATA" }
481 }
482
483 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
484
485 send_gdb "maint info breakpoints\n"
486 gdb_expect {
487 -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\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $"\
488 { pass "maint info breakpoints" }
489 -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\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 $"\
490 { pass "maint info breakpoints (with shlib events)" }
491 -re ".*$gdb_prompt $" { fail "maint info breakpoints" }
492 timeout { fail "(timeout) maint info breakpoints" }
493 }
494
495 send_gdb "maint print\n"
496 gdb_expect {
497 -re "\"maintenance print\" must be followed by the name of a print command\\.\r\nList.*unambiguous\\..*$gdb_prompt $"\
498 { pass "maint print w/o args" }
499 -re ".*$gdb_prompt $" { fail "maint print w/o args" }
500 timeout { fail "(timeout) maint print w/o args" }
501 }
502
503 send_gdb "maint info\n"
504 gdb_expect {
505 -re "\"maintenance info\" must be followed by the name of an info command\\.\r\nList.*unambiguous\\..*$gdb_prompt $"\
506 { pass "maint info w/o args" }
507 -re ".*$gdb_prompt $" { fail "maint info w/o args" }
508 timeout { fail "(timeout) maint info w/o args" }
509 }
510
511 send_gdb "maint\n"
512 gdb_expect {
513 -re "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*$gdb_prompt $"\
514 { pass "maint w/o args" }
515 -re ".*$gdb_prompt $" { fail "maint w/o args" }
516 timeout { fail "(timeout) maint w/o args" }
517 }
518
519
520 set timeout $oldtimeout
521
522 #============test help on maint commands
523
524 send_gdb "help maint\n"
525 gdb_expect {
526 -re "Commands for use by GDB maintainers\\..*Includes commands to dump specific internal GDB structures in.*a human readable form, to cause GDB to deliberately dump core,.*to test internal functions such as the C../ObjC demangler, etc\\..*List of maintenance subcommands:.*maintenance check-symtabs.*maintenance demangle.*(maintenance dump-me.*)?maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*maintenance space.*maintenance time.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
527 { pass "help maint" }
528 -re ".*$gdb_prompt $" { fail "help maint" }
529 timeout { fail "(timeout) help maint" }
530 }
531
532
533 send_gdb "help maint check-symtabs\n"
534 gdb_expect {
535 -re "Check consistency of psymtabs and symtabs\\..*$gdb_prompt $"\
536 { pass "help maint check-symtabs" }
537 -re ".*$gdb_prompt $" { fail "help maint check-symtabs" }
538 timeout { fail "(timeout) help maint check-symtabs" }
539 }
540
541 send_gdb "help maint space\n"
542 gdb_expect {
543 -re "Set the display of space usage\\.\r\nIf nonzero, will cause the execution space for each command to be\r\ndisplayed, following the command's output\\..*$gdb_prompt $"\
544 { pass "help maint space" }
545 -re ".*$gdb_prompt $" { fail "help maint space" }
546 timeout { fail "(timeout) help maint space" }
547 }
548
549 send_gdb "help maint time\n"
550 gdb_expect {
551 -re "Set the display of time usage\\.\r\nIf nonzero, will cause the execution time for each command to be\r\ndisplayed, following the command's output\\..*$gdb_prompt $"\
552 { pass "help maint time" }
553 -re ".*$gdb_prompt $" { fail "help maint time" }
554 timeout { fail "(timeout) help maint time" }
555 }
556
557 send_gdb "help maint demangle\n"
558 gdb_expect {
559 -re "Demangle a C\\+\\+/ObjC mangled name\\.\r\nCall internal GDB demangler routine to demangle a C\\+\\+ link name\r\nand prints the result\\..*$gdb_prompt $"\
560 { pass "help maint demangle" }
561 -re ".*$gdb_prompt $" { fail "help maint demangle" }
562 timeout { fail "(timeout) help maint demangle" }
563 }
564
565 send_gdb "help maint dump-me\n"
566 gdb_expect {
567 -re "Get fatal error; make debugger dump its core\\.\r\nGDB sets its handling of SIGQUIT back to SIG_DFL and then sends\r\nitself a SIGQUIT signal\\..*$gdb_prompt $"\
568 { pass "help maint dump-me" }
569 -re ".*$gdb_prompt $" { fail "help maint dump-me" }
570 timeout { fail "(timeout) help maint dump-me" }
571 }
572
573 send_gdb "help maint internal-error\n"
574 gdb_expect {
575 -re "Give GDB an internal error\\.\r\nCause GDB to behave as if an internal error was detected\\..*$gdb_prompt $"\
576 { pass "help maint internal-error" }
577 -re ".*$gdb_prompt $" { fail "help maint internal-error" }
578 timeout { fail "(timeout) help maint internal-error" }
579 }
580
581 send_gdb "help maint internal-warning\n"
582 gdb_expect {
583 -re "Give GDB an internal warning\\.\r\nCause GDB to behave as if an internal warning was reported\\..*$gdb_prompt $"\
584 { pass "help maint internal-warning" }
585 -re ".*$gdb_prompt $" { fail "help maint internal-warning" }
586 timeout { fail "(timeout) help maint internal-warning" }
587 }
588
589 send_gdb "help maint print statistics\n"
590 gdb_expect {
591 -re "Print statistics about internal gdb state\\..*$gdb_prompt $"\
592 { pass "help maint print statistics" }
593 -re ".*$gdb_prompt $" { fail "help maint print statistics" }
594 timeout { fail "(timeout) help maint print statistics" }
595 }
596
597 gdb_test "help maint print dummy-frames" \
598 "Print the contents of the internal dummy-frame stack."
599
600 send_gdb "help maint print objfiles\n"
601 gdb_expect {
602 -re "Print dump of current object file definitions\\..*$gdb_prompt $"\
603 { pass "help maint print objfiles" }
604 -re ".*$gdb_prompt $" { fail "help maint print objfiles" }
605 timeout { fail "(timeout) help maint print objfiles" }
606 }
607
608 send_gdb "help maint print psymbols\n"
609 gdb_expect {
610 -re "Print dump of current partial symbol definitions\\.\r\nEntries in the partial symbol table are dumped to file OUTFILE\\.\r\nIf a SOURCE file is specified, dump only that file's partial symbols\\..*$gdb_prompt $"\
611 { pass "help maint print psymbols" }
612 -re ".*$gdb_prompt $" { fail "help maint print psymbols" }
613 timeout { fail "(timeout) help maint print psymbols" }
614 }
615
616 send_gdb "help maint print msymbols\n"
617 gdb_expect {
618 -re "Print dump of current minimal symbol definitions\\.\r\nEntries in the minimal symbol table are dumped to file OUTFILE\\.\r\nIf a SOURCE file is specified, dump only that file's minimal symbols\\..*$gdb_prompt $"\
619 { pass "help maint print msymbols" }
620 -re ".*$gdb_prompt $" { fail "help maint print msymbols" }
621 timeout { fail "(timeout) help maint print msymbols" }
622 }
623
624 send_gdb "help maint print symbols\n"
625 gdb_expect {
626 -re "Print dump of current symbol definitions\\.\r\nEntries in the full symbol table are dumped to file OUTFILE\\.\r\nIf a SOURCE file is specified, dump only that file's symbols\\..*$gdb_prompt $"\
627 { pass "help maint print symbols" }
628 -re ".*$gdb_prompt $" { fail "help maint print symbols" }
629 timeout { fail "(timeout) help maint print symbols" }
630 }
631
632
633 send_gdb "help maint print type\n"
634 gdb_expect {
635 -re "Print a type chain for a given symbol\\.\r\nFor each node in a type chain, print the raw data for each member of\r\nthe type structure, and the interpretation of the data\\..*$gdb_prompt $"\
636 { pass "help maint print type" }
637 -re ".*$gdb_prompt $" { fail "help maint print type" }
638 timeout { fail "(timeout) help maint print type" }
639 }
640
641 if [istarget "hppa*-*-*"] {
642 send_gdb "help maint print unwind\n"
643 gdb_expect {
644 -re "Print unwind table entry at given address\\..*$gdb_prompt $"\
645 { pass "help maint print unwind" }
646 -re ".*$gdb_prompt $" { fail "help maint print unwind" }
647 timeout { fail "(timeout) help maint print unwind" }
648 }
649 }
650
651 send_gdb "help maint info sections\n"
652 gdb_expect {
653 -re "List the BFD sections of the exec and core files\\..*$gdb_prompt $"\
654 { pass "help maint info sections" }
655 -re ".*$gdb_prompt $" { fail "help maint info sections" }
656 timeout { fail "(timeout) help maint info sections" }
657 }
658
659
660 send_gdb "help maint info breakpoints\n"
661 gdb_expect {
662 -re "Status of all breakpoints, or breakpoint number NUMBER.*$gdb_prompt $" { pass "help maint info breakpoints" }
663 -re ".*$gdb_prompt $" { fail "help maint info breakpoints" }
664 timeout { fail "(timeout) help maint info breakpoints" }
665 }
666
667 #send_gdb "help maint info breakpoints\n"
668 #expect {
669 # -re "Status of all breakpoints, or breakpoint number NUMBER\\.\[ \r\n\t\]+The \"Type\" column indicates one of:\[ \r\n\t\]+breakpoint\[ \t\]+- normal breakpoint\[ \r\n\t\]+watchpoint\[ \t\]+- watchpoint\[ \r\n\t\]+longjmp\[ \t\]+- internal breakpoint used to step through longjmp\\(\\)\[ \r\n\t\]+longjmp resume - internal breakpoint at the target of longjmp\\(\\)\[ \r\n\t\]+until\[ \t\]+- internal breakpoint used by the \"until\" command\[ \r\n\t\]+finish\[ \t\]+- internal breakpoint used by the \"finish\" command\[ \r\n\t\]+The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\[ \r\n\t\]+the disposition of the breakpoint after it gets hit\\. \"dis\" means that the\[ \r\n\t\]+breakpoint will be disabled\\. The \"Address\" and \"What\" columns indicate the\[ \r\n\t\]+address and file.line number respectively\\.\[ \r\n\t\]+Convenience variable \".*\" and default examine address for \"x\"\[ \r\n\t\]+are set to the address of the last breakpoint listed\\.\[ \r\n\t\]+Convenience variable \".bpnum\" contains the number of the last\[ \r\n\t\]+breakpoint set\\..*$gdb_prompt $"\
670 # { pass "help maint info breakpoints" }
671 # -re ".*$gdb_prompt $" { fail "help maint info breakpoints" }
672 # timeout { fail "(timeout) help maint info breakpoints" }
673 # }
674
675 send_gdb "help maint info\n"
676 gdb_expect {
677 -re "Commands for showing internal info about the program being debugged.*unambiguous\\..*$gdb_prompt $"\
678 { pass "help maint info" }
679 -re ".*$gdb_prompt $" { fail "help maint info" }
680 timeout { fail "(timeout) help maint info" }
681 }
682
683 test_prefix_command_help {"maint print" "maintenance print"} {
684 "Maintenance command for printing GDB internal state\\.\[\r\n\]+"
685 }
686
687 test_prefix_command_help {"maint" "maintenance"} {
688 "Commands for use by GDB maintainers\\.\[\r\n\]+"
689 "Includes commands to dump specific internal GDB structures in\[\r\n\]+"
690 "a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+"
691 "to test internal functions such as the C\\+\\+/ObjC demangler, etc\\.\[\r\n\]+"
692 }
693
694 #set oldtimeout $timeout
695 #set timeout [expr $timeout + 300]
696
697 send_gdb "maint dump-me\n"
698 gdb_expect {
699 -re "Should GDB dump core.*\\(y or n\\) $"\
700 { send_gdb "n\n"
701 gdb_expect {
702 -re ".*$gdb_prompt $" { pass "maint dump-me" }
703 timeout { fail "(timeout) maint dump-me" }
704 }
705 }
706 -re ".*$gdb_prompt $" { fail "maint dump-me" }
707 timeout { fail "(timeout) maint dump-me" }
708 }
709
710 send_gdb "maint internal-error\n"
711 gdb_expect {
712 -re "A problem internal to GDB has been detected" {
713 pass "maint internal-error"
714 if [gdb_internal_error_resync] {
715 pass "internal-error resync"
716 } else {
717 fail "internal-error resync"
718 }
719 }
720 -re ".*$gdb_prompt $" {
721 fail "maint internal-error"
722 untested "internal-error resync"
723 }
724 timeout {
725 fail "maint internal-error (timeout)"
726 untested "internal-error resync"
727 }
728 }
729
730 #set timeout $oldtimeout
731
732
733 gdb_exit
734 return 0