aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/boards/native-stdio-gdbserver.exp
blob: 2ec2a47f89b4f1698e469a9db6fd1e925ea4bb9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright 2011-2015 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
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
}