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 | ||
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 { | |
50a3cc5d | 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 string 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 | |
eaeaf44c | 218 | |
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 | |
eaeaf44c TV |
227 | gdb_test_multiple "maint print objfiles" "" -lbl { |
228 | -re "\r\nObject file.*maint($EXEEXT)?: Objfile at ${hex}" { | |
229 | set header 1 | |
230 | exp_continue | |
231 | } | |
232 | -re "\r\nPsymtabs:\[\r\t \]+" { | |
233 | set psymtabs 1 | |
234 | exp_continue | |
235 | } | |
236 | -re "\r\nSymtabs:\[\r\t \]+\n" { | |
237 | set symtabs 1 | |
238 | exp_continue | |
239 | } | |
240 | -re " at $hex," { | |
241 | exp_continue | |
242 | } | |
243 | -re -wrap "" { | |
244 | pass $gdb_test_name | |
adf40b2e | 245 | } |
c906108c | 246 | } |
adf40b2e JM |
247 | |
248 | proc maint_pass_if {val name} { | |
249 | if $val { pass $name } else { fail $name } | |
c906108c SS |
250 | } |
251 | ||
adf40b2e | 252 | maint_pass_if $header "maint print objfiles: header" |
27210e12 DE |
253 | if { ! $have_gdb_index } { |
254 | maint_pass_if $psymtabs "maint print objfiles: psymtabs" | |
255 | } | |
adf40b2e JM |
256 | maint_pass_if $symtabs "maint print objfiles: symtabs" |
257 | ||
27210e12 | 258 | if { ! $have_gdb_index } { |
f8b41b00 | 259 | set psymbols_output [standard_output_file psymbols_output] |
37539ebe | 260 | set psymbols_output_re [string_to_regexp $psymbols_output] |
34c41c68 DE |
261 | set test_list [list \ |
262 | "maint print psymbols -source" \ | |
263 | "maint print psymbols -source ${srcdir}/${subdir}/${srcfile} $psymbols_output" \ | |
264 | "maint print psymbols -pc" \ | |
265 | "maint print psymbols -pc main $psymbols_output"] | |
266 | foreach { test_name command } $test_list { | |
267 | send_gdb "$command\n" | |
268 | gdb_expect { | |
269 | -re "^maint print psymbols \[^\n\]*\r\n$gdb_prompt $" { | |
270 | send_gdb "shell ls $psymbols_output\n" | |
27210e12 | 271 | gdb_expect { |
34c41c68 DE |
272 | -re "$psymbols_output_re\r\n$gdb_prompt $" { |
273 | # We want this grep to be as specific as possible, | |
274 | # so it's less likely to match symbol file names in | |
275 | # psymbols_output. Yes, this actually happened; | |
276 | # poor expect got tons of output, and timed out | |
277 | # trying to match it. --- Jim Blandy <jimb@cygnus.com> | |
278 | send_gdb "shell grep 'main.*function' $psymbols_output\n" | |
279 | gdb_expect { | |
280 | -re ".main., function, $hex.*$gdb_prompt $" { | |
281 | pass "$test_name 1" | |
282 | } | |
283 | -re ".*main. .., function, $hex.*$gdb_prompt $" { | |
284 | pass "$test_name 2" | |
285 | } | |
286 | -re ".*$gdb_prompt $" { fail "$test_name" } | |
287 | timeout { fail "$test_name (timeout)" } | |
288 | } | |
289 | gdb_test "shell rm -f $psymbols_output" ".*" \ | |
45fe4a03 | 290 | "${test_name}: shell rm -f psymbols_output" |
27210e12 | 291 | } |
34c41c68 DE |
292 | -re ".*$gdb_prompt $" { fail "$test_name" } |
293 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 294 | } |
65731a6b | 295 | } |
34c41c68 DE |
296 | -re ".*$gdb_prompt $" { fail "$test_name" } |
297 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 298 | } |
65731a6b | 299 | } |
65731a6b | 300 | } |
c906108c | 301 | |
c906108c | 302 | |
f8b41b00 | 303 | set msymbols_output [standard_output_file msymbols_output] |
37539ebe | 304 | set msymbols_output_re [string_to_regexp $msymbols_output] |
34c41c68 | 305 | send_gdb "maint print msymbols -objfile ${binfile} $msymbols_output\n" |
c906108c | 306 | gdb_expect { |
34c41c68 | 307 | -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { |
f8b41b00 | 308 | send_gdb "shell ls $msymbols_output\n" |
65731a6b | 309 | gdb_expect { |
37539ebe | 310 | -re "$msymbols_output_re\r\n$gdb_prompt $" { |
45fe4a03 AB |
311 | gdb_test "shell grep factorial $msymbols_output" \ |
312 | "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ | |
313 | "maint print msymbols, absolute pathname" | |
f8b41b00 TT |
314 | gdb_test "shell rm -f $msymbols_output" ".*" \ |
315 | "shell rm -f msymbols_output" | |
65731a6b | 316 | } |
34c41c68 DE |
317 | -re ".*$gdb_prompt $" { fail "maint print msymbols" } |
318 | timeout { fail "maint print msymbols (timeout)" } | |
65731a6b MS |
319 | } |
320 | } | |
34c41c68 DE |
321 | -re ".*$gdb_prompt $" { fail "maint print msymbols" } |
322 | timeout { fail "maint print msymbols (timeout)" } | |
65731a6b | 323 | } |
c906108c | 324 | |
dbdfa66c CV |
325 | # Check that maint print msymbols allows relative pathnames |
326 | set mydir [pwd] | |
08b3fe69 TT |
327 | gdb_test "cd [standard_output_file {}]" \ |
328 | "Working directory .*\..*" \ | |
65731a6b MS |
329 | "cd to objdir" |
330 | ||
34c41c68 DE |
331 | gdb_test_multiple "maint print msymbols -objfile ${testfile} msymbols_output2" "maint print msymbols" { |
332 | -re "^maint print msymbols \[^\n\]*\r\n$gdb_prompt $" { | |
dbdfa66c CV |
333 | gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" { |
334 | -re "msymbols_output2\r\n$gdb_prompt $" { | |
107c2d62 LM |
335 | gdb_test "shell grep factorial msymbols_output2" \ |
336 | "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \ | |
45fe4a03 | 337 | "maint print msymbols, relative pathname" |
107c2d62 | 338 | gdb_test "shell rm -f msymbols_output2" ".*" |
dbdfa66c | 339 | } |
dbdfa66c CV |
340 | } |
341 | } | |
dbdfa66c | 342 | } |
65731a6b MS |
343 | gdb_test "cd ${mydir}" \ |
344 | "Working directory [string_to_regexp ${mydir}]\..*" \ | |
345 | "cd to mydir" | |
346 | ||
c906108c | 347 | |
3bcbaac5 DJ |
348 | # Request symbols for one particular source file so that we don't try to |
349 | # dump the symbol information for the entire C library - over 500MB nowadays | |
350 | # for GNU libc. | |
adf40b2e | 351 | |
f8b41b00 | 352 | set symbols_output [standard_output_file symbols_output] |
37539ebe | 353 | set symbols_output_re [string_to_regexp $symbols_output] |
34c41c68 DE |
354 | set test_list [list \ |
355 | "maint print symbols -source" \ | |
356 | "maint print symbols -source ${srcdir}/${subdir}/${srcfile} $symbols_output" \ | |
357 | "maint print symbols -pc" \ | |
358 | "maint print symbols -pc main $symbols_output"] | |
359 | foreach { test_name command } $test_list { | |
360 | send_gdb "$command\n" | |
361 | gdb_expect { | |
362 | -re "^maint print symbols \[^\n\]*\r\n$gdb_prompt $" { | |
363 | send_gdb "shell ls $symbols_output\n" | |
364 | gdb_expect { | |
365 | -re "$symbols_output_re\r\n$gdb_prompt $" { | |
366 | # See comments for `maint print psymbols'. | |
367 | send_gdb "shell grep 'main(.*block' $symbols_output\n" | |
368 | gdb_expect { | |
369 | -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" { | |
370 | pass "$test_name" | |
371 | } | |
372 | -re ".*$gdb_prompt $" { fail "$test_name" } | |
373 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 374 | } |
34c41c68 | 375 | gdb_test "shell rm -f $symbols_output" ".*" \ |
45fe4a03 | 376 | "$test_name: shell rm -f symbols_output" |
65731a6b | 377 | } |
34c41c68 DE |
378 | -re ".*$gdb_prompt $" { fail "$test_name" } |
379 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 380 | } |
65731a6b | 381 | } |
34c41c68 DE |
382 | -re ".*$gdb_prompt $" { fail "$test_name" } |
383 | timeout { fail "$test_name (timeout)" } | |
65731a6b | 384 | } |
65731a6b | 385 | } |
c906108c | 386 | |
b4ba55a1 JB |
387 | set msg "maint print type" |
388 | gdb_test_multiple "maint print type argc" $msg { | |
e86ca25f | 389 | -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 |
390 | pass $msg |
391 | } | |
392 | } | |
c906108c | 393 | |
a0b3c4fd JM |
394 | if [istarget "hppa*-*-11*"] { |
395 | setup_xfail hppa*-*-*11* CLLbs14860 | |
65731a6b MS |
396 | gdb_test_multiple "maint print unwind &main" "maint print unwind" { |
397 | -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 $" { | |
398 | pass "maint print unwind" | |
399 | } | |
400 | -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 $" { | |
401 | xfail "maint print unwind" | |
402 | } | |
a0b3c4fd JM |
403 | } |
404 | } | |
c906108c SS |
405 | |
406 | set oldtimeout $timeout | |
407 | set timeout [expr $timeout + 300] | |
408 | ||
409 | # It'd be nice to check for every possible section. However, that's | |
410 | # problematic, since the relative ordering wanders from release to | |
411 | # release of the compilers. Instead, we'll just check for two | |
412 | # sections which appear to always come out in the same relative | |
413 | # order. (If that changes, then we should just check for one | |
414 | # section.) | |
415 | # | |
416 | # And by the way: This testpoint will break for PA64, where a.out's | |
417 | # are ELF files. | |
293e2f9e DJ |
418 | |
419 | # Standard GNU names. | |
420 | set text_section ".text" | |
421 | set data_section ".data" | |
422 | ||
65731a6b | 423 | gdb_test_multiple "maint info sections" "maint info sections" { |
f8b41b00 | 424 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*ER_RO.*$gdb_prompt $" { |
65731a6b MS |
425 | # Looks like RealView which uses different section names. |
426 | set text_section ER_RO | |
427 | set data_section ER_RW | |
428 | pass "maint info sections" | |
429 | } | |
f8b41b00 | 430 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*neardata.*$gdb_prompt $" { |
d93f7b5c YQ |
431 | # c6x doesn't have .data section. It has .neardata and .fardata section. |
432 | set data_section ".neardata" | |
433 | pass "maint info sections" | |
434 | } | |
f8b41b00 | 435 | -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*$gdb_prompt $" { |
65731a6b MS |
436 | pass "maint info sections" |
437 | } | |
438 | } | |
c906108c | 439 | |
8ddad156 MS |
440 | # Test for new option: maint info sections <section name> |
441 | # If you don't have a .text section, this will require tweaking. | |
65731a6b MS |
442 | |
443 | gdb_test_multiple "maint info sections $text_section" \ | |
444 | "maint info sections .text" { | |
445 | -re ".* \\.bss .*$gdb_prompt $" { | |
446 | fail "maint info sections .text" | |
447 | } | |
448 | -re ".* $data_section .*$gdb_prompt $" { | |
449 | fail "maint info sections .text" | |
450 | } | |
451 | -re ".* $text_section .*$gdb_prompt $" { | |
452 | pass "maint info sections .text" | |
453 | } | |
454 | } | |
8ddad156 MS |
455 | |
456 | # Test for new option: CODE section flag | |
457 | # If your data section is tagged CODE, xfail this test. | |
65731a6b MS |
458 | |
459 | gdb_test_multiple "maint info sections CODE" "maint info sections CODE" { | |
293e2f9e DJ |
460 | -re ".* $data_section .*$gdb_prompt $" { fail "maint info sections CODE" } |
461 | -re ".* $text_section .*$gdb_prompt $" { pass "maint info sections CODE" } | |
8ddad156 MS |
462 | } |
463 | ||
464 | # Test for new option: DATA section flag | |
465 | # If your text section is tagged DATA, xfail this test. | |
dbdfa66c | 466 | # |
58e8570a | 467 | # The "maint info sections DATA" test is marked for XFAIL on Windows, |
dbdfa66c CV |
468 | # because Windows has text sections marked DATA. |
469 | setup_xfail "*-*-*cygwin*" | |
58e8570a | 470 | setup_xfail "*-*-*mingw*" |
65731a6b MS |
471 | |
472 | gdb_test_multiple "maint info sections DATA" "maint info sections DATA" { | |
293e2f9e DJ |
473 | -re ".* $text_section .*$gdb_prompt $" { fail "maint info sections DATA" } |
474 | -re ".* $data_section .*$gdb_prompt $" { pass "maint info sections DATA" } | |
759f0f0b | 475 | -re ".* .rodata .*$gdb_prompt $" { pass "maint info sections DATA" } |
8ddad156 MS |
476 | } |
477 | ||
a1dea79a FF |
478 | set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] |
479 | ||
65731a6b MS |
480 | gdb_test_multiple "maint info breakpoints" "maint info breakpoints" { |
481 | -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 $" { | |
482 | pass "maint info breakpoints" | |
483 | } | |
484 | -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 $" { | |
485 | pass "maint info breakpoints (with shlib events)" | |
486 | } | |
c906108c SS |
487 | } |
488 | ||
65731a6b | 489 | gdb_test "maint print" \ |
0743fc83 | 490 | "List.*unambiguous\\..*" \ |
65731a6b | 491 | "maint print w/o args" |
c906108c | 492 | |
65731a6b | 493 | gdb_test "maint info" \ |
0743fc83 | 494 | "List.*unambiguous\\..*" \ |
65731a6b | 495 | "maint info w/o args" |
c906108c | 496 | |
65731a6b | 497 | gdb_test "maint" \ |
0743fc83 | 498 | "List.*unambiguous\\..*" \ |
65731a6b | 499 | "maint w/o args" |
c906108c | 500 | |
f610ab6d PA |
501 | # Test that "main info line-table" w/o a file name shows the symtab for |
502 | # $srcfile. | |
503 | set saw_srcfile 0 | |
94a72be7 AB |
504 | gdb_test_multiple "maint info line-table" \ |
505 | "maint info line-table w/o a file name" { | |
f610ab6d PA |
506 | -re "symtab: \[^\n\r\]+${srcfile} \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" { |
507 | set saw_srcfile 1 | |
508 | exp_continue | |
509 | } | |
510 | -re "symtab: \[^\n\r\]+ \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX\[ \t\]+LINE\[ \t\]+ADDRESS" { | |
511 | # Match each symtab to avoid overflowing expect's buffer. | |
512 | exp_continue | |
513 | } | |
94a72be7 AB |
514 | -re "symtab: \[^\n\r\]+ \\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) 0x0\\):\r\nNo line table.\r\n" { |
515 | # For symtabs with no linetable. | |
516 | exp_continue | |
517 | } | |
518 | -re "^$decimal\[ \t\]+$decimal\[ \t\]+$hex\r\n" { | |
f610ab6d PA |
519 | # Line table entries can be long too: |
520 | # | |
521 | # INDEX LINE ADDRESS | |
522 | # 0 29 0x00000000004006f6 | |
523 | # 1 30 0x00000000004006fa | |
524 | # 2 31 0x0000000000400704 | |
525 | # 3 42 0x0000000000400706 | |
526 | # 4 43 0x0000000000400719 | |
527 | # 5 44 0x0000000000400722 | |
528 | # 6 45 0x0000000000400740 | |
529 | # (...) | |
530 | # 454 129 0x00007ffff7df1d28 | |
94a72be7 | 531 | # 455 END 0x00007ffff7df1d3f |
f610ab6d PA |
532 | # |
533 | # Match each line to avoid overflowing expect's buffer. | |
534 | exp_continue | |
535 | } | |
94a72be7 AB |
536 | -re "^$decimal\[ \t\]+END\[ \t\]+$hex\r\n" { |
537 | # Matches an end marker in the above. | |
538 | exp_continue | |
539 | } | |
540 | -re "^$gdb_prompt $" { | |
541 | gdb_assert $saw_srcfile $gdb_test_name | |
f610ab6d PA |
542 | } |
543 | } | |
f2403c39 AB |
544 | |
545 | gdb_test "maint info line-table ${srcfile}" \ | |
546 | "symtab: \[^\n\r\]+${srcfile}.*INDEX.*LINE.*ADDRESS.*" \ | |
547 | "maint info line-table with filename of current symtab" | |
548 | ||
549 | gdb_test_no_output "maint info line-table ${srcfile2}" \ | |
550 | "maint info line-table with filename of symtab that is not currently expanded" | |
551 | ||
552 | gdb_test_no_output "maint expand-symtabs" | |
553 | ||
554 | gdb_test "maint info line-table ${srcfile2}" \ | |
555 | "symtab: \[^\n\r\]+${srcfile2}.*INDEX.*LINE.*ADDRESS.*" \ | |
556 | "maint info line-table with filename of symtab that is not current" | |
557 | ||
558 | gdb_test_no_output "maint info line-table xxx.c" \ | |
559 | "maint info line-table with invalid filename" | |
560 | ||
c906108c SS |
561 | set timeout $oldtimeout |
562 | ||
3c3bb058 AB |
563 | # Just check that the DWARF unwinders control flag is visible. |
564 | gdb_test "maint show dwarf unwinders" \ | |
565 | "The DWARF stack unwinders are currently (on|off)\\." | |
566 | ||
c906108c SS |
567 | #============test help on maint commands |
568 | ||
45fe4a03 AB |
569 | test_prefix_command_help {"maint info" "maintenance info"} { |
570 | "Commands for showing internal info about the program being debugged\\.\[\r\n\]+" | |
571 | } | |
c906108c | 572 | |
d8295fe9 VP |
573 | test_prefix_command_help {"maint print" "maintenance print"} { |
574 | "Maintenance command for printing GDB internal state\\.\[\r\n\]+" | |
575 | } | |
c906108c | 576 | |
d8295fe9 VP |
577 | test_prefix_command_help {"maint" "maintenance"} { |
578 | "Commands for use by GDB maintainers\\.\[\r\n\]+" | |
579 | "Includes commands to dump specific internal GDB structures in\[\r\n\]+" | |
439250fb | 580 | "a human readable form, to cause GDB to deliberately dump core, etc\\.\[\r\n\]+" |
d8295fe9 | 581 | } |
c906108c SS |
582 | |
583 | #set oldtimeout $timeout | |
584 | #set timeout [expr $timeout + 300] | |
585 | ||
65731a6b MS |
586 | gdb_test_multiple "maint dump-me" "maint dump-me" { |
587 | -re "Should GDB dump core.*\\(y or n\\) $" { | |
588 | gdb_test "n" ".*" "maint dump-me" | |
589 | } | |
9bdd0636 YQ |
590 | -re "Undefined maintenance command: .*$gdb_prompt $" { |
591 | # Command 'maint dump-me' is registered on non-win32 host. | |
592 | unsupported "maint dump-me" | |
593 | } | |
65731a6b | 594 | } |
c906108c | 595 | |
7be570e7 | 596 | send_gdb "maint internal-error\n" |
039cf96d AC |
597 | gdb_expect { |
598 | -re "A problem internal to GDB has been detected" { | |
599 | pass "maint internal-error" | |
600 | if [gdb_internal_error_resync] { | |
601 | pass "internal-error resync" | |
602 | } else { | |
603 | fail "internal-error resync" | |
7be570e7 JM |
604 | } |
605 | } | |
606 | -re ".*$gdb_prompt $" { | |
607 | fail "maint internal-error" | |
039cf96d | 608 | untested "internal-error resync" |
7be570e7 JM |
609 | } |
610 | timeout { | |
039cf96d AC |
611 | fail "maint internal-error (timeout)" |
612 | untested "internal-error resync" | |
7be570e7 JM |
613 | } |
614 | } | |
615 | ||
c906108c SS |
616 | #set timeout $oldtimeout |
617 | ||
99e8a4f9 SDJ |
618 | # Test that the commands work without an argument. For this test, we |
619 | # don't need an inferior loaded/running. See PR gdb/21164. | |
620 | gdb_exit | |
621 | gdb_start | |
622 | gdb_test_no_output "maint print symbols" | |
623 | gdb_test_no_output "maint print msymbols" | |
624 | gdb_test_no_output "maint print psymbols" | |
c906108c SS |
625 | |
626 | gdb_exit | |
627 | return 0 |