]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/maint.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / maint.exp
CommitLineData
61baf725 1# Copyright 1998-2017 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 49standard_testfile break.c break1.c
a1dea79a 50
5b362f04 51if {[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.
58gdb_test_no_output "set height 0"
59
60# Tests that require that no program is running
61
62gdb_file_cmd ${binfile}
63
64# Test for a regression where this command would internal-error if the
65# program wasn't running.
66gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
67
7d0c9981
DE
68# Test "mt expand-symtabs" here as it's easier to verify before we
69# run the program.
70gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
71gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
72 "mt expand-symtabs" {
43f3e411 73 -re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
bf6d8a91
TT
74 # This should expand at most two primary symtabs.
75 # "Normally" it will not expand any, because the symtab
76 # holding "main" will already have been expanded, but if the
e19d3afb
DE
77 # file is compiled with -fdebug-types-section then a second primary
78 # symtab for break.c will be created for any types.
7d0c9981
DE
79 pass "mt expand-symtabs"
80 }
81 }
82gdb_test "mt set per off" ".*" "mt set per off for expand-symtabs"
83
b78974c3
PA
84# Tests that can or should be done with a running program
85
c906108c
SS
86gdb_load ${binfile}
87
88if ![runto_main] then {
89 perror "tests suppressed"
90}
91
27210e12
DE
92# If we're using .gdb_index there will be no psymtabs.
93set have_gdb_index 0
94gdb_test_multiple "maint info sections .gdb_index" "check for .gdb_index" {
95 -re ": .gdb_index.*$gdb_prompt $" {
96 set have_gdb_index 1
97 }
98 -re ".*$gdb_prompt $" {
99 ;# Nothing to do, present to avoid a FAIL.
100 }
101}
c906108c 102
c906108c
SS
103#
104# this command does not produce any output
105# unless there is some problem with the symtabs and psymtabs
106# so that branch will really never be covered in this tests here!!
107#
108
a0b3c4fd
JM
109# guo: on linux this command output is huge. for some reason splitting up
110# the regexp checks works.
111#
7d0c9981 112send_gdb "maint check-psymtabs\n"
c906108c 113gdb_expect {
7d0c9981 114 -re "^maint check-psymtabs" {
65731a6b
MS
115 gdb_expect {
116 -re "$gdb_prompt $" {
7d0c9981 117 pass "maint check-psymtabs"
a0b3c4fd 118 }
7d0c9981 119 timeout { fail "(timeout) maint check-psymtabs" }
a0b3c4fd 120 }
65731a6b 121 }
7d0c9981
DE
122 -re ".*$gdb_prompt $" { fail "maint check-psymtabs" }
123 timeout { fail "(timeout) maint check-psymtabs" }
65731a6b 124}
c906108c 125
7d0c9981
DE
126# This command does not produce any output unless there is some problem
127# with the symtabs, so that branch will really never be covered in the
128# tests here!!
129gdb_test_no_output "maint check-symtabs"
130
b8b8facf 131# Test per-command stats.
bd712aed 132gdb_test_no_output "maint set per-command on"
b8b8facf 133gdb_test "pwd" \
43f3e411 134 "Command 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\\)"
b8b8facf 135gdb_test_no_output "maint set per-command off"
c906108c 136
dbdfa66c
CV
137# The timeout value is raised, because printing all the symbols and
138# statistical information about Cygwin and Windows libraries takes a lot
cb80163c
DE
139# of time.
140if [istarget "*-*-cygwin*"] {
141 set oldtimeout $timeout
142 set timeout [expr $timeout + 500]
143}
c906108c 144
55b7ce7f
UW
145send_gdb "maint print statistics\n"
146gdb_expect {
f8b41b00 147 -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
148 gdb_expect {
149 -re "$gdb_prompt $" {
150 pass "maint print statistics"
151 }
152 timeout { fail "(timeout) maint print statistics" }
153 }
65731a6b 154 }
55b7ce7f
UW
155 -re ".*$gdb_prompt $" { fail "maint print statistics" }
156 timeout { fail "(timeout) maint print statistics" }
65731a6b 157}
c906108c 158
00905d52 159# There aren't any ...
27d3a1a2 160gdb_test_no_output "maint print dummy-frames"
00905d52 161
c906108c 162send_gdb "maint print objfiles\n"
adf40b2e 163
c906108c 164# To avoid timeouts, we avoid expects with many .* patterns that match
adf40b2e
JM
165# many lines. Instead, we keep track of which milestones we've seen
166# in the output, and stop when we've seen all of them.
167
168set header 0
169set psymtabs 0
170set symtabs 0
171set keep_looking 1
172
173while {$keep_looking} {
174 gdb_expect {
175
e48744a0
PA
176 -re "\r\n" {
177 set output $expect_out(buffer)
178 if {[regexp ".*Object file.*maint($EXEEXT)?: Objfile at ${hex}" $output]} {
179 set header 1
180 }
181 if {[regexp ".*Psymtabs:\[\r\t \]+\n" $output]} {
182 set psymtabs 1
183 }
184 if {[regexp ".*Symtabs:\[\r\t \]+\n" $output]} {
185 set symtabs 1
186 }
187 }
adf40b2e
JM
188
189 -re ".*$gdb_prompt $" {
190 set keep_looking 0
191 }
192 timeout {
193 fail "(timeout) maint print objfiles"
194 set keep_looking 0
195 }
196 }
c906108c 197}
adf40b2e
JM
198
199proc maint_pass_if {val name} {
200 if $val { pass $name } else { fail $name }
c906108c
SS
201}
202
adf40b2e 203maint_pass_if $header "maint print objfiles: header"
27210e12
DE
204if { ! $have_gdb_index } {
205 maint_pass_if $psymtabs "maint print objfiles: psymtabs"
206}
adf40b2e
JM
207maint_pass_if $symtabs "maint print objfiles: symtabs"
208
27210e12 209if { ! $have_gdb_index } {
f8b41b00 210 set psymbols_output [standard_output_file psymbols_output]
37539ebe 211 set psymbols_output_re [string_to_regexp $psymbols_output]
34c41c68
DE
212 set test_list [list \
213 "maint print psymbols -source" \
214 "maint print psymbols -source ${srcdir}/${subdir}/${srcfile} $psymbols_output" \
215 "maint print psymbols -pc" \
216 "maint print psymbols -pc main $psymbols_output"]
217 foreach { test_name command } $test_list {
218 send_gdb "$command\n"
219 gdb_expect {
220 -re "^maint print psymbols \[^\n\]*\r\n$gdb_prompt $" {
221 send_gdb "shell ls $psymbols_output\n"
27210e12 222 gdb_expect {
34c41c68
DE
223 -re "$psymbols_output_re\r\n$gdb_prompt $" {
224 # We want this grep to be as specific as possible,
225 # so it's less likely to match symbol file names in
226 # psymbols_output. Yes, this actually happened;
227 # poor expect got tons of output, and timed out
228 # trying to match it. --- Jim Blandy <jimb@cygnus.com>
229 send_gdb "shell grep 'main.*function' $psymbols_output\n"
230 gdb_expect {
231 -re ".main., function, $hex.*$gdb_prompt $" {
232 pass "$test_name 1"
233 }
234 -re ".*main. .., function, $hex.*$gdb_prompt $" {
235 pass "$test_name 2"
236 }
237 -re ".*$gdb_prompt $" { fail "$test_name" }
238 timeout { fail "$test_name (timeout)" }
239 }
240 gdb_test "shell rm -f $psymbols_output" ".*" \
241 "shell rm -f psymbols_output"
27210e12 242 }
34c41c68
DE
243 -re ".*$gdb_prompt $" { fail "$test_name" }
244 timeout { fail "$test_name (timeout)" }
65731a6b 245 }
65731a6b 246 }
34c41c68
DE
247 -re ".*$gdb_prompt $" { fail "$test_name" }
248 timeout { fail "$test_name (timeout)" }
65731a6b 249 }
65731a6b 250 }
65731a6b 251}
c906108c 252
c906108c 253
f8b41b00 254set msymbols_output [standard_output_file msymbols_output]
37539ebe 255set msymbols_output_re [string_to_regexp $msymbols_output]
34c41c68 256send_gdb "maint print msymbols -objfile ${binfile} $msymbols_output\n"
c906108c 257gdb_expect {
34c41c68 258 -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" {
f8b41b00 259 send_gdb "shell ls $msymbols_output\n"
65731a6b 260 gdb_expect {
37539ebe 261 -re "$msymbols_output_re\r\n$gdb_prompt $" {
f8b41b00 262 send_gdb "shell grep factorial $msymbols_output\n"
65731a6b 263 gdb_expect {
efd11a33 264 -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
65731a6b
MS
265 pass "maint print msymbols"
266 }
34c41c68
DE
267 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
268 timeout { fail "maint print msymbols (timeout)" }
65731a6b 269 }
f8b41b00
TT
270 gdb_test "shell rm -f $msymbols_output" ".*" \
271 "shell rm -f msymbols_output"
65731a6b 272 }
34c41c68
DE
273 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
274 timeout { fail "maint print msymbols (timeout)" }
65731a6b
MS
275 }
276 }
34c41c68
DE
277 -re ".*$gdb_prompt $" { fail "maint print msymbols" }
278 timeout { fail "maint print msymbols (timeout)" }
65731a6b 279}
c906108c 280
dbdfa66c
CV
281# Check that maint print msymbols allows relative pathnames
282set mydir [pwd]
08b3fe69
TT
283gdb_test "cd [standard_output_file {}]" \
284 "Working directory .*\..*" \
65731a6b
MS
285 "cd to objdir"
286
34c41c68
DE
287gdb_test_multiple "maint print msymbols -objfile ${testfile} msymbols_output2" "maint print msymbols" {
288 -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" {
dbdfa66c
CV
289 gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
290 -re "msymbols_output2\r\n$gdb_prompt $" {
107c2d62
LM
291 gdb_test "shell grep factorial msymbols_output2" \
292 "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \
293 "maint print msymbols"
294 gdb_test "shell rm -f msymbols_output2" ".*"
dbdfa66c 295 }
dbdfa66c
CV
296 }
297 }
dbdfa66c 298}
65731a6b
MS
299gdb_test "cd ${mydir}" \
300 "Working directory [string_to_regexp ${mydir}]\..*" \
301 "cd to mydir"
302
c906108c 303
3bcbaac5
DJ
304# Request symbols for one particular source file so that we don't try to
305# dump the symbol information for the entire C library - over 500MB nowadays
306# for GNU libc.
adf40b2e 307
f8b41b00 308set symbols_output [standard_output_file symbols_output]
37539ebe 309set symbols_output_re [string_to_regexp $symbols_output]
34c41c68
DE
310set test_list [list \
311 "maint print symbols -source" \
312 "maint print symbols -source ${srcdir}/${subdir}/${srcfile} $symbols_output" \
313 "maint print symbols -pc" \
314 "maint print symbols -pc main $symbols_output"]
315foreach { test_name command } $test_list {
316 send_gdb "$command\n"
317 gdb_expect {
318 -re "^maint print symbols \[^\n\]*\r\n$gdb_prompt $" {
319 send_gdb "shell ls $symbols_output\n"
320 gdb_expect {
321 -re "$symbols_output_re\r\n$gdb_prompt $" {
322 # See comments for `maint print psymbols'.
323 send_gdb "shell grep 'main(.*block' $symbols_output\n"
324 gdb_expect {
325 -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" {
326 pass "$test_name"
327 }
328 -re ".*$gdb_prompt $" { fail "$test_name" }
329 timeout { fail "$test_name (timeout)" }
65731a6b 330 }
34c41c68
DE
331 gdb_test "shell rm -f $symbols_output" ".*" \
332 "shell rm -f symbols_output"
65731a6b 333 }
34c41c68
DE
334 -re ".*$gdb_prompt $" { fail "$test_name" }
335 timeout { fail "$test_name (timeout)" }
65731a6b 336 }
65731a6b 337 }
34c41c68
DE
338 -re ".*$gdb_prompt $" { fail "$test_name" }
339 timeout { fail "$test_name (timeout)" }
65731a6b 340 }
65731a6b 341}
c906108c 342
b4ba55a1
JB
343set msg "maint print type"
344gdb_test_multiple "maint print type argc" $msg {
ae6ae975 345 -re "type node $hex\r\nname .int. \\($hex\\)\r\ntagname .<NULL>. \\($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
346 pass $msg
347 }
348}
c906108c 349
a0b3c4fd
JM
350if [istarget "hppa*-*-11*"] {
351 setup_xfail hppa*-*-*11* CLLbs14860
65731a6b
MS
352 gdb_test_multiple "maint print unwind &main" "maint print unwind" {
353 -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 $" {
354 pass "maint print unwind"
355 }
356 -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 $" {
357 xfail "maint print unwind"
358 }
a0b3c4fd
JM
359 }
360}
c906108c
SS
361
362set oldtimeout $timeout
363set timeout [expr $timeout + 300]
364
365# It'd be nice to check for every possible section. However, that's
366# problematic, since the relative ordering wanders from release to
367# release of the compilers. Instead, we'll just check for two
368# sections which appear to always come out in the same relative
369# order. (If that changes, then we should just check for one
370# section.)
371#
372# And by the way: This testpoint will break for PA64, where a.out's
373# are ELF files.
293e2f9e
DJ
374
375# Standard GNU names.
376set text_section ".text"
377set data_section ".data"
378
65731a6b 379gdb_test_multiple "maint info sections" "maint info sections" {
f8b41b00 380 -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*ER_RO.*$gdb_prompt $" {
65731a6b
MS
381 # Looks like RealView which uses different section names.
382 set text_section ER_RO
383 set data_section ER_RW
384 pass "maint info sections"
385 }
f8b41b00 386 -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
d93f7b5c
YQ
387 # c6x doesn't have .data section. It has .neardata and .fardata section.
388 set data_section ".neardata"
389 pass "maint info sections"
390 }
f8b41b00 391 -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*$gdb_prompt $" {
65731a6b
MS
392 pass "maint info sections"
393 }
394}
c906108c 395
8ddad156
MS
396# Test for new option: maint info sections <section name>
397# If you don't have a .text section, this will require tweaking.
65731a6b
MS
398
399gdb_test_multiple "maint info sections $text_section" \
400 "maint info sections .text" {
401 -re ".* \\.bss .*$gdb_prompt $" {
402 fail "maint info sections .text"
403 }
404 -re ".* $data_section .*$gdb_prompt $" {
405 fail "maint info sections .text"
406 }
407 -re ".* $text_section .*$gdb_prompt $" {
408 pass "maint info sections .text"
409 }
410 }
8ddad156
MS
411
412# Test for new option: CODE section flag
413# If your data section is tagged CODE, xfail this test.
65731a6b
MS
414
415gdb_test_multiple "maint info sections CODE" "maint info sections CODE" {
293e2f9e
DJ
416 -re ".* $data_section .*$gdb_prompt $" { fail "maint info sections CODE" }
417 -re ".* $text_section .*$gdb_prompt $" { pass "maint info sections CODE" }
8ddad156
MS
418}
419
420# Test for new option: DATA section flag
421# If your text section is tagged DATA, xfail this test.
dbdfa66c 422#
58e8570a 423# The "maint info sections DATA" test is marked for XFAIL on Windows,
dbdfa66c
CV
424# because Windows has text sections marked DATA.
425setup_xfail "*-*-*cygwin*"
58e8570a 426setup_xfail "*-*-*mingw*"
65731a6b
MS
427
428gdb_test_multiple "maint info sections DATA" "maint info sections DATA" {
293e2f9e
DJ
429 -re ".* $text_section .*$gdb_prompt $" { fail "maint info sections DATA" }
430 -re ".* $data_section .*$gdb_prompt $" { pass "maint info sections DATA" }
759f0f0b 431 -re ".* .rodata .*$gdb_prompt $" { pass "maint info sections DATA" }
8ddad156
MS
432}
433
a1dea79a
FF
434set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
435
65731a6b
MS
436gdb_test_multiple "maint info breakpoints" "maint info breakpoints" {
437 -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 $" {
438 pass "maint info breakpoints"
439 }
440 -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 $" {
441 pass "maint info breakpoints (with shlib events)"
442 }
c906108c
SS
443}
444
65731a6b
MS
445gdb_test "maint print" \
446 "\"maintenance print\" must be followed by the name of a print command\\.\r\nList.*unambiguous\\..*" \
447 "maint print w/o args"
c906108c 448
65731a6b
MS
449gdb_test "maint info" \
450 "\"maintenance info\" must be followed by the name of an info command\\.\r\nList.*unambiguous\\..*" \
451 "maint info w/o args"
c906108c 452
65731a6b
MS
453gdb_test "maint" \
454 "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*" \
455 "maint w/o args"
c906108c 456
f610ab6d
PA
457# Test that "main info line-table" w/o a file name shows the symtab for
458# $srcfile.
459set saw_srcfile 0
460set test "maint info line-table w/o a file name"
461gdb_test_multiple "maint info line-table" $test {
462 -re "symtab: \[^\n\r\]+${srcfile} \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" {
463 set saw_srcfile 1
464 exp_continue
465 }
466 -re "symtab: \[^\n\r\]+ \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" {
467 # Match each symtab to avoid overflowing expect's buffer.
468 exp_continue
469 }
470 -re "$decimal\[ \t\]+$decimal\[ \t\]+$hex\r\n" {
471 # Line table entries can be long too:
472 #
473 # INDEX LINE ADDRESS
474 # 0 29 0x00000000004006f6
475 # 1 30 0x00000000004006fa
476 # 2 31 0x0000000000400704
477 # 3 42 0x0000000000400706
478 # 4 43 0x0000000000400719
479 # 5 44 0x0000000000400722
480 # 6 45 0x0000000000400740
481 # (...)
482 # 454 129 0x00007ffff7df1d28
483 # 455 0 0x00007ffff7df1d3f
484 #
485 # Match each line to avoid overflowing expect's buffer.
486 exp_continue
487 }
488 -re "$gdb_prompt $" {
489 gdb_assert $saw_srcfile $test
490 }
491}
f2403c39
AB
492
493gdb_test "maint info line-table ${srcfile}" \
494 "symtab: \[^\n\r\]+${srcfile}.*INDEX.*LINE.*ADDRESS.*" \
495 "maint info line-table with filename of current symtab"
496
497gdb_test_no_output "maint info line-table ${srcfile2}" \
498 "maint info line-table with filename of symtab that is not currently expanded"
499
500gdb_test_no_output "maint expand-symtabs"
501
502gdb_test "maint info line-table ${srcfile2}" \
503 "symtab: \[^\n\r\]+${srcfile2}.*INDEX.*LINE.*ADDRESS.*" \
504 "maint info line-table with filename of symtab that is not current"
505
506gdb_test_no_output "maint info line-table xxx.c" \
507 "maint info line-table with invalid filename"
508
c906108c
SS
509set timeout $oldtimeout
510
511#============test help on maint commands
512
65731a6b 513gdb_test "help maint" \
439250fb 514 "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, etc\\..*List of maintenance subcommands:.*maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*"
c906108c 515
65731a6b
MS
516gdb_test "help maint info" \
517 "Commands for showing internal info about the program being debugged.*unambiguous\\..*"
c906108c 518
d8295fe9
VP
519test_prefix_command_help {"maint print" "maintenance print"} {
520 "Maintenance command for printing GDB internal state\\.\[\r\n\]+"
521}
c906108c 522
d8295fe9
VP
523test_prefix_command_help {"maint" "maintenance"} {
524 "Commands for use by GDB maintainers\\.\[\r\n\]+"
525 "Includes commands to dump specific internal GDB structures in\[\r\n\]+"
439250fb 526 "a human readable form, to cause GDB to deliberately dump core, etc\\.\[\r\n\]+"
d8295fe9 527}
c906108c
SS
528
529#set oldtimeout $timeout
530#set timeout [expr $timeout + 300]
531
65731a6b
MS
532gdb_test_multiple "maint dump-me" "maint dump-me" {
533 -re "Should GDB dump core.*\\(y or n\\) $" {
534 gdb_test "n" ".*" "maint dump-me"
535 }
9bdd0636
YQ
536 -re "Undefined maintenance command: .*$gdb_prompt $" {
537 # Command 'maint dump-me' is registered on non-win32 host.
538 unsupported "maint dump-me"
539 }
65731a6b 540}
c906108c 541
7be570e7 542send_gdb "maint internal-error\n"
039cf96d
AC
543gdb_expect {
544 -re "A problem internal to GDB has been detected" {
545 pass "maint internal-error"
546 if [gdb_internal_error_resync] {
547 pass "internal-error resync"
548 } else {
549 fail "internal-error resync"
7be570e7
JM
550 }
551 }
552 -re ".*$gdb_prompt $" {
553 fail "maint internal-error"
039cf96d 554 untested "internal-error resync"
7be570e7
JM
555 }
556 timeout {
039cf96d
AC
557 fail "maint internal-error (timeout)"
558 untested "internal-error resync"
7be570e7
JM
559 }
560}
561
c906108c
SS
562#set timeout $oldtimeout
563
564
565gdb_exit
566return 0