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