old-cross-binutils/gdb/testsuite/boards/native-stdio-gdbserver.exp

90 lines
2.8 KiB
Text
Raw Normal View History

# Copyright 2011-2014 Free Software Foundation, Inc.
# 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
# (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is a dejagnu "board file" and is used to run the testsuite
# natively with gdbserver using stdio for comms.
#
# To use this file:
# bash$ cd ${build_dir}/gdb
# bash$ make check RUNTESTFLAGS="--target_board=native-stdio-gdbserver"
load_generic_config "gdbserver"
load_board_description "gdbserver-base"
# This gdbserver can only run a process once per session.
set_board_info gdb,do_reload_on_run 1
# There's no support for argument-passing (yet).
set_board_info noargs 1
# Hack the host,port to pass our peculiar remote connection string.
set_board_info sockethost ""
set_board_info gdb,socketport "stdio"
set_board_info gdb,get_remote_address ${board}_get_remote_address
set_board_info gdbserver,get_comm_port ${board}_get_comm_port
set_board_info use_gdb_stub 1
Teach the testsuite that GDBserver reliably reports program exits. Running catch-syscall.exp against a gdbserver that actually supports it, we get: FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited) FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited) FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited) FAIL: gdb.base/catch-syscall.exp: continue until exit at catch syscall with unused syscall (mlock) (the program exited) FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited) The fail pattern is: Catchpoint 2 (call to syscall exit_group), 0x000000323d4baa29 in _exit () from /lib64/libc.so.6 (gdb) PASS: gdb.base/catch-syscall.exp: program has called exit_group delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) break exit Breakpoint 3 at 0x323d438bf0 (gdb) continue Continuing. [Inferior 1 (process 21081) exited normally] That "break exit" + "continue" comes from: > # gdb_continue_to_end: > # The case where the target uses stubs has to be handled specially. If a > # stub is used, we set a breakpoint at exit because we cannot rely on > # exit() behavior of a remote target. > # The native-gdbserver.exp board, used to test against gdbserver in "target remote" mode, triggers that case ($use_gdb_stub is true). So gdb_continue_to_end doesn't work for catch-syscall.exp as here we catch the exit_group and continue from that, expecting to see a real program exit. I was about to post a patch that changes catch-syscall.exp to call a new function that just always does what gdb_continue_to_end does in the !$use_gdb_stub case. But, since GDBserver doesn't really need this, in the end I thought it better to teach the testsuite that there are stubs that know how to report program exits, by adding a new "exit_is_reliable" board variable that then gdb_continue_to_end checks. Tested on x86_64 Fedora 17, native and gdbserver. gdb/testsuite/ 2013-10-02 Pedro Alves <palves@redhat.com> * README (Board Settings): Document "exit_is_reliable". * lib/gdb.exp (gdb_continue_to_end): Check whether the board says running to exit reliably reports program exits. * boards/native-gdbserver.exp: Set exit_is_reliable in the board info. * boards/native-stdio-gdbserver.exp: Likewise.
2013-10-02 11:44:20 +00:00
set_board_info exit_is_reliable 1
# We will be using the standard GDB remote protocol.
set_board_info gdb_protocol "remote"
# Used to pass a value between ${board}_spawn and ${board}_get_remote_address.
set stdio_gdbserver_command "--unset--"
proc ${board}_get_remote_address { host port } {
global stdio_gdbserver_command
return "| $stdio_gdbserver_command"
}
proc ${board}_get_comm_port { port } {
return $port
}
proc ${board}_spawn { board cmd } {
global board_info
verbose -log "${board}_spawn: $board $cmd"
# Save the command to start gdbserver for later retrieval by
# ${board}_get_remote_address.
global stdio_gdbserver_command
set stdio_gdbserver_command $cmd
set baseboard [lindex [split $board "/"] 0]
# We don't spawn gdbserver here, that is done by the subsequent
# "target remote | ..." command.
set board_info($baseboard,isremote) 0
# Pretend as if we've started gdbserver, provide the test harness
# with what it's waiting for.
set result [remote_spawn $board "echo Listening on stdio"]
set board_info($baseboard,isremote) 1
return $result
}
proc ${board}_exec { hostname program args } {
global board_info
set baseboard [lindex [split $hostname "/"] 0]
set board_info($baseboard,isremote) 0
set result [remote_exec $hostname $program $args]
set board_info($baseboard,isremote) 1
return $result
}