From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29172 invoked by alias); 8 Aug 2007 14:24:44 -0000 Received: (qmail 28802 invoked by uid 22791); 8 Aug 2007 14:24:39 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 14:24:33 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 91965982C5; Wed, 8 Aug 2007 14:24:32 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 4A9B5982A4; Wed, 8 Aug 2007 14:24:32 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1IImSb-0000hn-Fi; Wed, 08 Aug 2007 10:24:29 -0400 Date: Wed, 08 Aug 2007 14:24:00 -0000 From: Daniel Jacobowitz To: Petr Koloros Cc: GDB Mailing list Subject: Re: Restart remote application Message-ID: <20070808142429.GA32455@caradoc.them.org> Mail-Followup-To: Petr Koloros , GDB Mailing list References: <20070808132955.GB10087@pko.sysgo.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070808132955.GB10087@pko.sysgo.cz> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00085.txt.bz2 On Wed, Aug 08, 2007 at 03:29:56PM +0200, Petr Koloros wrote: > Hi all, > > I'm having problems with restarting the remote application. Some time ago it > was advised to use extended protocol and 'run' command but it doesn't work. The extended protocol doesn't work very well. I have a sketch for improvements to running more than one remote application, and some code, which I hope I'll be working on for the next release of GDB after 6.7. However, what you're describing here normally works. Here's some bits of that code plus another related fix I noticed; does it help for you? -- Daniel Jacobowitz CodeSourcery 2007-08-08 Daniel Jacobowitz * remote.c (remote_wait, remote_async_wait): Stop if we receive an error. (extended_remote_mourn): Mourn the target and reset inferior_ptid. * linux-low.c (linux_kill): Clear the inferior list. (linux_detach): Clear the process list. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.265 diff -u -p -r1.265 remote.c --- remote.c 3 Jul 2007 15:58:42 -0000 1.265 +++ remote.c 8 Aug 2007 14:21:59 -0000 @@ -3219,8 +3219,12 @@ remote_wait (ptid_t ptid, struct target_ switch (buf[0]) { case 'E': /* Error of some sort. */ + /* We're out of sync with the target now. Did it continue or not? + Not is more likely, so report a stop. */ warning (_("Remote failure reply: %s"), buf); - continue; + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = TARGET_SIGNAL_0; + goto got_status; case 'F': /* File-I/O request. */ remote_fileio_request (buf); continue; @@ -3432,8 +3436,12 @@ remote_async_wait (ptid_t ptid, struct t switch (buf[0]) { case 'E': /* Error of some sort. */ + /* We're out of sync with the target now. Did it continue or not? + Not is more likely, so report a stop. */ warning (_("Remote failure reply: %s"), buf); - continue; + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = TARGET_SIGNAL_0; + goto got_status; case 'F': /* File-I/O request. */ remote_fileio_request (buf); continue; @@ -5135,14 +5143,16 @@ remote_async_mourn (void) static void extended_remote_mourn (void) { - /* We do _not_ want to mourn the target like this; this will - remove the extended remote target from the target stack, - and the next time the user says "run" it'll fail. + /* Unlike "target remote", we do not want to unpush the target; then + the next time the user says "run", we won't be connected. */ - FIXME: What is the right thing to do here? */ -#if 0 - remote_mourn_1 (&extended_remote_ops); -#endif + /* Call common code to mark the inferior as not running. */ + generic_mourn_inferior (); + + /* Assume that the target has been restarted. Set inferior_ptid + so that bits of core GDB realizes there's something here, e.g., + so that the user can say "kill" again. */ + inferior_ptid = pid_to_ptid (MAGIC_NULL_PID); } /* Worker function for remote_mourn. */ Index: gdbserver/linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.59 diff -u -p -r1.59 linux-low.c --- gdbserver/linux-low.c 2 Jul 2007 15:35:36 -0000 1.59 +++ gdbserver/linux-low.c 8 Aug 2007 14:21:59 -0000 @@ -280,6 +280,10 @@ linux_kill (void) /* Make sure it died. The loop is most likely unnecessary. */ wstat = linux_wait_for_event (thread); } while (WIFSTOPPED (wstat)); + + clear_inferiors (); + free (all_processes.head); + all_processes.head = all_processes.tail = NULL; } static void @@ -318,6 +322,8 @@ linux_detach (void) delete_all_breakpoints (); for_each_inferior (&all_threads, linux_detach_one_process); clear_inferiors (); + free (all_processes.head); + all_processes.head = all_processes.tail = NULL; return 0; }