Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / gdbserver-support.exp
index 0a8b1117bb5c095ae71321fab7ad6fd6571c8c4c..406a3ccc4bceb1dc8a85413baea6d81d90f990ca 100644 (file)
@@ -1,19 +1,18 @@
-# Copyright 2000, 2002, 2003, 2004, 2005, 2006, 2007
+# Copyright 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # 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 2 of the License, or
+# 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file is based on config/gdbserver.exp, which was written by
 # Michael Snyder (msnyder@redhat.com).
@@ -222,7 +221,7 @@ proc gdbserver_spawn { child_args } {
     # don't need to redirect output.
     expect_background {
        -i $server_spawn_id
-       -re "." { }
+       full_buffer { }
        eof {
            # The spawn ID is already closed now (but not yet waited for).
            wait -i $expect_out(spawn_id)
@@ -236,9 +235,36 @@ proc gdbserver_spawn { child_args } {
 # to it.  Return 0 on success, or non-zero on failure.
 
 proc gdbserver_run { child_args } {
+    global gdbserver_protocol
+    global gdbserver_gdbport
+
+    # Kill anything running before we try to start gdbserver, in case
+    # we are sharing a serial connection.
+    global gdb_prompt
+    send_gdb "kill\n"
+    gdb_expect 120 {
+       -re "Kill the program being debugged. .y or n. $" {
+           send_gdb "y\n"
+           verbose "\t\tKilling previous program being debugged"
+           exp_continue
+       }
+       -re "$gdb_prompt $" {
+           # OK.
+       }
+    }
+
     set res [gdbserver_spawn $child_args]
-    set protocol [lindex $res 0]
-    set gdbport [lindex $res 1]
+    set gdbserver_protocol [lindex $res 0]
+    set gdbserver_gdbport [lindex $res 1]
+
+    return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+}
+
+# Reconnect to the previous gdbserver session.
+
+proc gdbserver_reconnect { } {
+    global gdbserver_protocol
+    global gdbserver_gdbport
 
-    return [gdb_target_cmd $protocol $gdbport]
+    return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 }
This page took 0.024016 seconds and 4 git commands to generate.