6ec0d1e03b145cedcb27411cac993e140066fbc2
[external/binutils.git] / gdb / testsuite / gdb.server / run-without-local-binary.exp
1 # Copyright 2017-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 load_lib gdbserver-support.exp
17
18 if {[skip_gdbserver_tests]} {
19     return
20 }
21
22 standard_testfile normal.c
23
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
25     return -1
26 }
27
28 # Test running GDB without providing a local binary for it.  In order
29 # to do that, we unset GDBFLAGS before running GDB.  We also start
30 # gdbserver "by hand".  For more details about this test, see PR
31 # remote/21852.
32 save_vars { GDBFLAGS } {
33     set GDBFLAGS ""
34     gdb_exit
35     gdb_start
36
37     gdb_test_no_output "set remote exec-file $binfile" \
38         "set remote exec-file"
39
40     # Make sure we're disconnected, in case we're testing with an
41     # extended-remote board, therefore already connected.
42     gdb_test "disconnect" ".*" "disconnect"
43
44     # Let's start gdbserver in extended-remote mode now.  We cannot
45     # use gdbserver_start_extended here because it starts gdbserver,
46     # then GDB *with* a local binary, and the connect both.
47     set res [gdbserver_start "--multi" ""]
48     set gdbserver_protocol [lindex $res 0]
49     if { [string first "extended-" $gdbserver_protocol] != 0} {
50         set gdbserver_protocol "extended-$gdbserver_protocol"
51     }
52     set gdbserver_gdbport [lindex $res 1]
53     set use_gdb_stub 0
54
55     gdb_test "target ${gdbserver_protocol} ${gdbserver_gdbport}" \
56         "Remote debugging using [string_to_regexp $gdbserver_gdbport]" \
57         "connect to gdbserver"
58
59     gdb_test "run" \
60         "\\\[Inferior $decimal \\\(process $decimal\\\) exited normally\\\]" \
61         "run test program until the end"
62 }