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