binutils-gdb/gdb/testsuite/gdb.base/async.exp

116 lines
3.3 KiB
Plaintext
Raw Normal View History

# Copyright 1999-2016 Free Software Foundation, Inc.
1999-08-31 03:14:27 +02:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
1999-08-31 03:14:27 +02:00
# (at your option) any later version.
#
1999-08-31 03:14:27 +02:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
1999-08-31 03:14:27 +02:00
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1999-08-31 03:14:27 +02:00
#
# test running programs
#
standard_testfile
1999-08-31 03:14:27 +02:00
if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
untested $testfile.exp
return -1
}
1999-08-31 03:14:27 +02:00
#
# set it up at a breakpoint so we can play with it
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
gdb_test "break baz" ".*" ""
1999-08-31 03:14:27 +02:00
#
# Make sure we get a 'completed' message when the target is done.
#
gdb_test_no_output "set exec-done-display on"
1999-08-31 03:14:27 +02:00
# Test a background execution command. COMMAND is the command to
# send. BEFORE_PROMPT is the pattern expected before the GDB prompt
# is output. AFTER_PROMPT is the pattern expected after the prompt
# and before "completed". MESSAGE is optional, and is the pass/fail
# message to br printed. If omitted, then the command string is used
# as message.
proc test_background {command before_prompt after_prompt {message ""}} {
global gdb_prompt
if {$message eq ""} {
set message $command
}
send_gdb "$command\n"
gdb_expect {
-re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
pass "$message"
return 0
}
-re "$gdb_prompt.*completed\.\r\n" {
fail "$message"
}
-re ".*Asynchronous execution not supported on this target\..*" {
unsupported "Asynchronous execution not supported: $message"
}
timeout {
fail "$message (timeout)"
}
}
return -1
1999-08-31 03:14:27 +02:00
}
if {[test_background "next&" "" ".*z = 9.*"] < 0} {
return
}
1999-08-31 03:14:27 +02:00
test_background "step&" "" ".*y = foo \\(\\).*" "step& #1"
1999-08-31 03:14:27 +02:00
test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2"
1999-08-31 03:14:27 +02:00
test_background "stepi&" "" ".*$hex.*x = 5.*"
1999-08-31 03:14:27 +02:00
Tweak gdb.base/async.exp I see two fails in async.exp on arm-none-eabi target: nexti&^M (gdb) 0x000001ba 14 x = 5; x = 5;^M completed.^M FAIL: gdb.base/async.exp: nexti& finish&^M Run till exit from #0 0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M (gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M 32 y = foo ();^M Value returned is $1 = 8^M completed.^M FAIL: gdb.base/async.exp: finish& The corresponding test is "test_background "nexti&" "" ".*y = 3.*"", and it assumes that GDB "nexti" into the next source line. It is wrong on arm. After "nexti", it still stops at the same source line, and it fails. When gdb does "finish", if the PC is in the middle of a source line, the PC address is printed too. See stack.c:print_frame, if (opts.addressprint) if (!sal.symtab || frame_show_address (frame, sal) || print_what == LOC_AND_ADDRESS) { annotate_frame_address (); if (pc_p) ui_out_field_core_addr (uiout, "addr", gdbarch, pc); else ui_out_field_string (uiout, "addr", "<unavailable>"); annotate_frame_address_end (); ui_out_text (uiout, " in "); } frame_show_address checks whether PC is the middle of a source line. Since after "nexti", the inferior stops at the middle of a source line, when we do "finish" the PC address is displayed. In sum, GDB works well, but test case needs update. This patch is to add a statement at the same line to make sure "nexti" doesn't go to the new line, match the next instruction address in the output and match the hex address the output of "finish". gdb/testsuite: 2014-06-06 Yao Qi <yao@codesourcery.com> * gdb.base/async.c (foo): Add one statement. * gdb.base/async.exp: Get the next instruction address and match the output of "nexti" by instruction address. Match the hex address in the output of "finish".
2014-06-06 08:32:42 +02:00
# Get the next instruction address.
set next_insn_addr ""
set test "get next insn"
gdb_test_multiple {x/2i $pc} "$test" {
-re "=> $hex .* 0x(\[0-9a-f\]*) .*$gdb_prompt $" {
set next_insn_addr $expect_out(1,string)
pass "$test"
}
}
# We nexti into the same source line. The current PC is printed out.
test_background "nexti&" "" ".* 0x0*$next_insn_addr.* x = 5; .*"
1999-08-31 03:14:27 +02:00
Tweak gdb.base/async.exp I see two fails in async.exp on arm-none-eabi target: nexti&^M (gdb) 0x000001ba 14 x = 5; x = 5;^M completed.^M FAIL: gdb.base/async.exp: nexti& finish&^M Run till exit from #0 0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M (gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M 32 y = foo ();^M Value returned is $1 = 8^M completed.^M FAIL: gdb.base/async.exp: finish& The corresponding test is "test_background "nexti&" "" ".*y = 3.*"", and it assumes that GDB "nexti" into the next source line. It is wrong on arm. After "nexti", it still stops at the same source line, and it fails. When gdb does "finish", if the PC is in the middle of a source line, the PC address is printed too. See stack.c:print_frame, if (opts.addressprint) if (!sal.symtab || frame_show_address (frame, sal) || print_what == LOC_AND_ADDRESS) { annotate_frame_address (); if (pc_p) ui_out_field_core_addr (uiout, "addr", gdbarch, pc); else ui_out_field_string (uiout, "addr", "<unavailable>"); annotate_frame_address_end (); ui_out_text (uiout, " in "); } frame_show_address checks whether PC is the middle of a source line. Since after "nexti", the inferior stops at the middle of a source line, when we do "finish" the PC address is displayed. In sum, GDB works well, but test case needs update. This patch is to add a statement at the same line to make sure "nexti" doesn't go to the new line, match the next instruction address in the output and match the hex address the output of "finish". gdb/testsuite: 2014-06-06 Yao Qi <yao@codesourcery.com> * gdb.base/async.c (foo): Add one statement. * gdb.base/async.exp: Get the next instruction address and match the output of "nexti" by instruction address. Match the hex address in the output of "finish".
2014-06-06 08:32:42 +02:00
# PC is in the middle of a source line, so the PC address is displayed.
test_background "finish&" \
Tweak gdb.base/async.exp I see two fails in async.exp on arm-none-eabi target: nexti&^M (gdb) 0x000001ba 14 x = 5; x = 5;^M completed.^M FAIL: gdb.base/async.exp: nexti& finish&^M Run till exit from #0 0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M (gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M 32 y = foo ();^M Value returned is $1 = 8^M completed.^M FAIL: gdb.base/async.exp: finish& The corresponding test is "test_background "nexti&" "" ".*y = 3.*"", and it assumes that GDB "nexti" into the next source line. It is wrong on arm. After "nexti", it still stops at the same source line, and it fails. When gdb does "finish", if the PC is in the middle of a source line, the PC address is printed too. See stack.c:print_frame, if (opts.addressprint) if (!sal.symtab || frame_show_address (frame, sal) || print_what == LOC_AND_ADDRESS) { annotate_frame_address (); if (pc_p) ui_out_field_core_addr (uiout, "addr", gdbarch, pc); else ui_out_field_string (uiout, "addr", "<unavailable>"); annotate_frame_address_end (); ui_out_text (uiout, " in "); } frame_show_address checks whether PC is the middle of a source line. Since after "nexti", the inferior stops at the middle of a source line, when we do "finish" the PC address is displayed. In sum, GDB works well, but test case needs update. This patch is to add a statement at the same line to make sure "nexti" doesn't go to the new line, match the next instruction address in the output and match the hex address the output of "finish". gdb/testsuite: 2014-06-06 Yao Qi <yao@codesourcery.com> * gdb.base/async.c (foo): Add one statement. * gdb.base/async.exp: Get the next instruction address and match the output of "nexti" by instruction address. Match the hex address in the output of "finish".
2014-06-06 08:32:42 +02:00
"Run till exit from #0 $hex in foo \\(\\) at.*async.c.*\r\n" \
".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*"
set jump_here [gdb_get_line_number "jump here"]
test_background "jump $jump_here&" \
".*Continuing at $hex.*" \
".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \
"jump&"
1999-08-31 03:14:27 +02:00
set until_here [gdb_get_line_number "until here"]
test_background "until $until_here&" \
".*" \
".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \
"until&"
1999-08-31 03:14:27 +02:00
gdb_test_no_output "set exec-done-display off"