1# Copyright 2000-2019 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# Test framework for GDB (remote protocol) using a "gdbserver",
17# ie. a debug agent running as a native process on the same or
18# a different host.
19
20#
21# This module to be used for testing gdb with a "gdbserver"
22# built either from libremote or from gdb/gdbserver.
23#
24
25#
26# To be addressed or set in your baseboard config file:
27#
28#   set_board_info gdb_protocol "remote"
29#	Unles you have a gdbserver that uses a different protocol...
30#
31#   set_board_info use_gdb_stub 1
32#	This tells the rest of the test suite not to do things
33#	like "run" which don't work well on remote targets.
34#
35#   set_board_info gdb,do_reload_on_run 1
36#	Unles you have a gdbserver that can handle multiple sessions.
37#
38#   set_board_info noargs 1
39#	At present there is no provision in the remote protocol
40#	for passing arguments.  This test framework does not
41#	address the issue, so it's best to set this variable
42#	in your baseboard configuration file.
43#	FIXME: there's no reason why the test harness couldn't
44#	pass commandline args when it spawns gdbserver.
45#
46#   set_board_info gdb,noinferiorio 1
47#	Neither the traditional gdbserver nor the one in libremote
48#	can presently capture stdout and relay it to GDB via the
49#	'O' packet.  This means that tests involving printf will
50#	fail unles you set this varibale in your baseboard
51#	configuration file.
52#
53#   set_board_info gdb,no_hardware_watchpoints 1
54#	Unles you have a gdbserver that supports hardware watchpoints.
55#	FIXME: gdb should detect if the target doesn't support them,
56#	and fall back to using software watchpoints.
57#
58#   set_board_info gdb_server_prog
59#	This will be the path to the gdbserver program you want to test.
60#	Defaults to "gdbserver".
61#
62#   set_board_info sockethost
63#	The name of the host computer whose socket is being used.
64#	Defaults to "localhost".  Note: old gdbserver requires
65#	that you define this, but libremote/gdbserver does not.
66#
67#   set_board_info gdb,socketport
68#	Port id to use for socket connection.  If not set explicitly,
69#	it will start at "2345" and increment for each use.
70#
71
72# The guts live in gdbserver-support.exp now.
73
74load_lib gdbserver-support.exp
75
76proc gdbserver_gdb_load { } {
77    return [gdbserver_spawn ""]
78}
79
80proc gdb_reload { } {
81    return [gdbserver_run ""]
82}
83
84proc gdb_reconnect { } {
85    return [gdbserver_reconnect]
86}
87