Target FP: Make use of MPFR if available
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / annota1.exp
1 # Copyright 1999-2017 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
18
19 # This testcase cannot use runto_main because of the different prompt
20 # we get when using annotation level 2.
21 #
22 if ![target_can_use_run_cmd] {
23 return 0
24 }
25
26 set breakpoints_invalid "\r\n\032\032breakpoints-invalid\r\n"
27
28 #
29 # test running programs
30 #
31
32 standard_testfile .c
33
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
35 untested "failed to compile"
36 return -1
37 }
38
39
40 clean_restart ${binfile}
41
42 # The commands we test here produce many lines of output; disable "press
43 # <return> to continue" prompts.
44 gdb_test_no_output "set height 0"
45
46 #
47 # break in main
48 #
49
50 set main_line [gdb_get_line_number "break main"]
51
52 gdb_test "break ${srcfile}:${main_line}" \
53 "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
54 "breakpoint main"
55
56
57 #
58 # NOTE: this prompt is OK only when the annotation level is > 1
59 # NOTE: When this prompt is in use the gdb_test procedure cannot be used because
60 # it assumes that the last char after the gdb_prompt is a white space. This is not
61 # true with this annotated prompt. So we must use send_gdb and gdb_expect.
62 #
63
64 set old_gdb_prompt $gdb_prompt
65 set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
66
67 #
68 # Escape all the characters in the path that need it. For instance
69 # the directory name could contain '+'.
70 #
71 set escapedsrcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
72
73
74 #
75 # set the annotation level to 2
76 #
77 # of course, this will test:
78 # annotate-pre-prompt
79 # annotate-prompt
80 # annotate-post-prompt (in the next block)
81 #
82 send_gdb "set annotate 2\n"
83 gdb_expect {
84 -re "set annotate 2\r\n$gdb_prompt$" { pass "annotation set at level 2" }
85 -re ".*$gdb_prompt$" { fail "annotation set at level 2" }
86 timeout { fail "annotation set at level 2 (timeout)" }
87 }
88
89
90 #
91 # info break will test:
92 # annotate-breakpoints-headers
93 # annotate-field
94 # annotate-breakpoints-table
95 # annotate-record
96 # annotate-breakpoints-table-end
97 #
98 gdb_test_multiple "info break" "breakpoint info" {
99 -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1 \r\n\032\032field 1\r\nbreakpoint \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny \r\n\032\032field 4\r\n$hex +\r\n\032\032field 5\r\nin main at ${escapedsrcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" {
100 pass "breakpoint info"
101 }
102 -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1 \r\n\032\032field 1\r\nbreakpoint \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny \r\n\032\032field 4\r\n$hex +\r\n\032\032field 5\r\nin main at .*${srcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" {
103 setup_xfail "*-*-*" 1270
104 fail "breakpoint info"
105 }
106 }
107
108
109 #
110 # run to a break point will test:
111 # annotate-frames-invalid
112 # annotate-breakpoints-invalid (a.k.a. breakpoints-changed)
113 # annotate-starting
114 # annotate-breakpoint
115 # annotate-frame-begin
116 # annotate-frame-function-name
117 # annotate-frame-args
118 # annotate-frame-source-begin
119 # annotate-frame-source-file
120 # annotate-frame-source-file-end
121 # annotate-frame-source-line
122 # annotate-frame-source-end
123 # annotate-source
124 # annotate-frame-end
125 # annotate-stopped
126 #
127 #exp_internal 1
128 set binexp [string_to_regexp $binfile]
129 gdb_test_multiple "run" "run until main breakpoint" {
130 -re "\r\n\032\032post-prompt\r\nStarting program: $binexp \(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+\r\nDo \"set use-deprecated-index-sections on\" before the file is read\r\nto use the section anyway\\.\)?\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032breakpoint 1\r\n\r\nBreakpoint 1, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*annota1.c\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$main_line\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped.*$gdb_prompt$" {
131 pass "run until main breakpoint"
132 }
133 }
134 #exp_internal 0
135 #exit 0
136
137 #
138 # Let's do a next, to get to a point where the array is initialized
139 # We don't care about the annotated output for this operation, it is the same as
140 # the one produced by run above
141 #
142 gdb_test_multiple "next" "go after array init line" {
143 -re "source .*annota1.c.*$gdb_prompt$" {
144 pass "go after array init line"
145 }
146 }
147
148
149 #
150 # printing the array will test:
151 # annotate-value-history-begin
152 # annotate-value-history-value
153 # annotate-array-section-begin
154 # annotate-elt
155 # FIXME: annotate-elt-rep and annotate-elt-rep-end not tested
156 # annotate-array-section-end
157 # annotate-value-history-end
158 # FIXME: annotate-value-begin and annotate-value-end not tested (the gdb output
159 # command would cause them to be used)
160 #
161 gdb_test_multiple "print my_array" "print array" {
162 -re "\r\n\032\032post-prompt\r\n\r\n\032\032value-history-begin 1 -\r\n.*= \r\n\032\032value-history-value\r\n.\r\n\032\032array-section-begin 0 -\r\n1\r\n\032\032elt\r\n, 2\r\n\032\032elt\r\n, 3\r\n\032\032elt\r\n\r\n\032\032array-section-end\r\n.\r\n\r\n\032\032value-history-end\r\n$gdb_prompt$" {
163 pass "print array"
164 }
165 }
166
167
168 #
169 # this should generate an error message, so to test:
170 # annotate-error-begin
171 # FIXME: annotate-error not tested
172 #
173
174 #exp_internal 1
175 gdb_test_multiple "print non_existent_value" "print non_existent_value" {
176 -re "\r\n\032\032post-prompt\r\n\r\n\032\032error-begin\r\nNo symbol \"non_existent_value\" in current context.\r\n\r\n\032\032error\r\n$gdb_prompt$" {
177 pass "print non_existent_value"
178 }
179 }
180
181
182 #
183 # break at signal handler. So that, once we are in the sig handler, if we do a bt
184 # we can test annotate-signal-handler-caller
185 #
186 gdb_test_multiple "break handle_USR1" "break handle_USR1" {
187 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
188 pass "break handle_USR1"
189 }
190 }
191
192 #
193 # break at printf. When we are stopped at printf, we can test
194 #
195 gdb_test_multiple "break printf" "break printf" {
196 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex.*\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
197 pass "break printf"
198 }
199 -re "\r\n\032\032post-prompt\r\nwarning: Breakpoint address adjusted from $hex to $hex.\r\n\r\n\032\032breakpoints-invalid\r\nBreakpoint.*at $hex.*$gdb_prompt$" {
200 pass "break printf"
201 }
202 }
203
204 #
205 # get to printf
206 #
207 set pat_begin "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n${breakpoints_invalid}"
208 set pat_adjust "warning: Breakpoint 3 address previously adjusted from $hex to $hex.\r\n"
209 set pat_end "\r\n\032\032breakpoint 3\r\n\r\nBreakpoint 3, \r\n\032\032frame-begin 0 $hex\r\n\r\n(\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n)*.*\032\032frame-function-name\r\n.*printf(@.*)?\r\n\032\032frame-args\r\n.*\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$"
210
211 gdb_test_multiple "continue" "continue to printf" {
212 -re "${pat_begin}($pat_adjust)?$pat_end" {
213 pass "continue to printf"
214 }
215 -re ".*$gdb_prompt$" { fail "continue to printf" }
216 }
217
218 #
219 # test:
220 # annotate-frame-where
221 # annotate-frame-address
222 # annotate-frame-address-end
223 #
224 set pat_begin "\r\n\032\032post-prompt\r\n\r\n\032\032frame-begin 0 $hex\r\n.0 \r\n(\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n)*\032\032frame-function-name\r\n.*printf(@.*)?\r\n\032\032frame-args\r\n \\(.*frame-end\r\n\r\n\032\032frame-begin 1 $hex\r\n.1 \r\n\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n"
225
226 set pat_end "\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032frame-end\r\n(\r\n\032\032frame-begin .*\r\n\r\n\032\032frame-end\r\n)*$gdb_prompt$"
227
228 gdb_test_multiple "backtrace" "backtrace from shlibrary" {
229 -re "$pat_begin$escapedsrcfile$pat_end" {
230 pass "backtrace from shlibrary"
231 }
232 -re "$pat_begin.*$srcfile$pat_end" {
233 setup_xfail "*-*-*" 1270
234 fail "backtrace from shlibrary"
235 }
236 }
237
238
239 #
240 # test printing a frame with some arguments:
241 # annotate-arg-begin
242 # annotate-arg-name-end
243 # annotate-arg-value
244 # annotate-arg-end
245 #
246
247 if [target_info exists gdb,nosignals] {
248 unsupported "send SIGUSR1"
249 unsupported "backtrace @ signal handler"
250 } else {
251 gdb_test_multiple "signal SIGUSR1" "send SIGUSR1" {
252 -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n${escapedsrcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
253 pass "send SIGUSR1"
254 }
255 -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*${srcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
256 setup_xfail "*-*-*" 1270
257 fail "send SIGUSR1"
258 }
259 }
260
261 #
262 # test:
263 # annotate-signal-handler-caller
264 #
265 gdb_test_multiple "backtrace" "backtrace @ signal handler" {
266 -re "frame-begin 0 $hex\r\n#0.*frame-end.*frame-begin 1 $hex\r\n#1.*(\032\032signal-handler-caller\r\n.signal handler called.\r\n\r\n)+\032\032frame-end\r\n\r\n\032\032frame-begin 2 $hex\r\n#2.*(frame-begin 3 $hex\r\n#3.*)*frame-end.*$gdb_prompt$" {
267 pass "backtrace @ signal handler"
268 }
269 }
270 }
271
272 #
273 # delete all the breakpoints
274 #
275 gdb_test_multiple "delete 1" "delete bp 1" {
276 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
277 pass "delete bp 1"
278 }
279 }
280
281 gdb_test_multiple "delete 2" "delete bp 2" {
282 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
283 pass "delete bp 2"
284 }
285 }
286
287 gdb_test_multiple "delete 3" "delete bp 3" {
288 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
289 pass "delete bp 3"
290 }
291 }
292
293 #
294 # break in main, after value is initialized. This is in preparation
295 # to test the annotate output for the display command.
296 #
297 set test "break in main"
298 gdb_test_multiple "break ${srcfile}:${main_line}" $test {
299 -re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
300 pass $test
301 }
302 -re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
303 setup_xfail "*-*-*" 1270
304 fail $test
305 }
306 }
307
308 #
309 # display the value; test:
310 # annotate-display-begin
311 # annotate-display-number-end
312 # annotate-display-format
313 # annotate-display-expression
314 # annotate-display-expression-end
315 # annotate-display-end
316 # FIXME: annotate-display-value not tested
317 #
318 gdb_test_multiple "display value" "set up display" {
319 -re "post-prompt\r\n\r\n\032\032display-begin\r\n1\r\n\032\032display-number-end\r\n: \r\n\032\032display-format\r\n\r\n\032\032display-expression\r\nvalue\r\n\032\032display-expression-end\r\n = \r\n\032\032display-expression\r\n7\r\n\r\n\032\032display-end\r\n$gdb_prompt$" {
320 pass "set up display"
321 }
322 }
323
324
325 # should ask query. Test annotate-query.
326 # we don't care about anything else here, only the query.
327
328 send_gdb "run\n"
329 gdb_expect {
330 -re "pre-query.*already.*\\(y or n\\).*query\r\n" {
331 send_gdb "y\n"
332 gdb_expect {
333 -re ".*post-query.*$gdb_prompt$" \
334 { pass "re-run" }
335 -re ".*$gdb_prompt$" { fail "re-run" }
336 timeout { fail "re-run (timeout)" }
337 }
338 }
339 -re ".*$gdb_prompt$" { fail "re-run" }
340 timeout { fail "re-run (timeout)" }
341 }
342
343 #
344 # Test that breakpoints-invalid is issued once and only once for
345 # breakpoint ignore count changes, after annotation stopped.
346 #
347
348 set value_inc_line [gdb_get_line_number "increment value"]
349
350 gdb_test_multiple "break $value_inc_line" "break at value++" {
351 -re "Breakpoint 5 at $hex: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" {
352 pass "break at value++"
353 }
354 }
355
356 gdb_test_multiple "ignore 5 4" "ignore 5 4" {
357 -re "Will ignore next 4 crossings of breakpoint 5.*$gdb_prompt$" {
358 pass "ignore 5 4"
359 }
360 }
361
362 gdb_test_multiple "continue" "annotate ignore count change" {
363 -re ".*breakpoints-invalid.*breakpoints-invalid.*$gdb_prompt$" {
364 fail "annotate ignore count change"
365 }
366 -re ".*$srcfile:$value_inc_line:.*\032\032stopped\r\n$gdb_prompt$" {
367 pass "annotate ignore count change"
368 }
369 }
370
371 # check that ignore command is working, or the above can provide
372 # misleading assurance ...
373
374 gdb_test_multiple "next" "next to exit loop" {
375 -re "source .*annota1.c.*$gdb_prompt$" {
376 }
377 }
378
379 set after_loop_line [gdb_get_line_number "after loop"]
380
381 gdb_test_multiple "next" "breakpoint ignore count" {
382 -re ".*$srcfile:$after_loop_line:.*$gdb_prompt$" {
383 pass "breakpoint ignore count"
384 }
385 }
386
387 # Get the inferior's PID for later.
388
389 set test "get inferior pid"
390 set pid -1
391 gdb_test_multiple "info inferior 1" "$test" {
392 -re "process (\[0-9\]*).*$gdb_prompt$" {
393 set pid $expect_out(1,string)
394 pass "$test"
395 }
396 }
397
398 #
399 # Send a signal that is not handled; test:
400 # annotate-signalled
401 # annotate-signal-name
402 # annotate-signal-name-end
403 # annotate-signal-string
404 # annotate-signal-string-end
405 # FIXME: annotate-signal not tested (requires that the inferior be
406 # stopped by a "random" signal)
407
408 if [target_info exists gdb,nosignals] {
409 unsupported "signal sent"
410 } else {
411 gdb_test_multiple "signal SIGTRAP" "signal sent" {
412 -re ".*\032\032post-prompt\r\nContinuing with signal SIGTRAP.\r\n\r\n\032\032starting\(\r\n\r\n\032\032frames-invalid\)+\r\n\r\n\032\032signalled\r\n\r\nProgram terminated with signal \r\n\032\032signal-name\r\nSIGTRAP\r\n\032\032signal-name-end\r\n, \r\n\032\032signal-string\r\nTrace.breakpoint trap\r\n\032\032signal-string-end\r\n.\r\nThe program no longer exists.\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
413 pass "signal sent"
414 }
415 }
416 }
417
418 # Check for production of a core file and remove it!
419
420 set test "cleanup core file"
421 if { [remote_file host exists core] } {
422 remote_file host delete core
423 pass "$test (removed)"
424 } elseif { $pid != -1 && [remote_file host exists core.$pid] } {
425 remote_file host delete core.$pid
426 pass "$test (removed)"
427 } else {
428 pass "$test (not dumped)"
429 }
430
431 proc thread_test {} {
432 global subdir srcdir testfile srcfile binfile
433 global gdb_prompt old_gdb_prompt
434 set srcfile watch_thread_num.c
435 set binfile [standard_output_file ${testfile}-watch_thread_num]
436 set gdb_prompt $old_gdb_prompt
437
438 if { ![get_compiler_info] && [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
439
440 gdb_exit
441 gdb_start
442 gdb_reinitialize_dir $srcdir/$subdir
443 gdb_load ${binfile}
444 if { ![runto main] } then {
445 fail "run to main"
446 return
447 }
448
449 set linenum [gdb_get_line_number "all threads started"]
450 gdb_breakpoint "$linenum"
451
452 set gdb_prompt \
453 "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
454
455 gdb_test_multiple "set annotate 2" "" {
456 -re "set annotate 2\r\n$gdb_prompt$" {
457 }
458 }
459
460 gdb_test_multiple "continue" "new thread" {
461 -re "\032\032new-thread.*\r\n$gdb_prompt$" {
462 pass "new thread"
463 }
464 }
465 }
466 }
467
468 proc thread_switch {} {
469 gdb_test_multiple "thread 1" "thread switch" {
470 -re ".*\032\032thread-changed" {
471 pass "thread switch"
472 }
473 }
474 }
475
476 thread_test
477 thread_switch
478
479 # restore the original prompt for the rest of the testsuite
480
481 set gdb_prompt $old_gdb_prompt
This page took 0.039237 seconds and 4 git commands to generate.