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