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