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