From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25814 invoked by alias); 22 Mar 2013 19:24:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25796 invoked by uid 89); 22 Mar 2013 19:24:06 -0000 X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 22 Mar 2013 19:24:02 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2MJNwYs009046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Mar 2013 15:23:59 -0400 Received: from host2.jankratochvil.net (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2MJFpM9019189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 22 Mar 2013 15:15:54 -0400 Date: Fri, 22 Mar 2013 20:31:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org, "Metzger, Markus T" Subject: [commit+7.6] [patch] Fix remote.c incorrectly using pop_target (wrt btrace) Message-ID: <20130322191550.GA28753@host2.jankratochvil.net> References: <20130311172836.GA22575@host2.jankratochvil.net> <513EFD81.6050401@codesourcery.com> <20130315195451.GB19841@host2.jankratochvil.net> <514C8D99.2060809@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <514C8D99.2060809@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-03/txt/msg00862.txt.bz2 On Fri, 22 Mar 2013 17:58:01 +0100, Pedro Alves wrote: > On 03/15/2013 07:54 PM, Jan Kratochvil wrote: > > > gdb/ > > 2013-03-15 Jan Kratochvil > > > > * remote.c (remote_unpush_target): New function. > > (remote_open_1): Remove two pop_target calls, update one comment, add > > comment to target_preopen call. Replace pop_target call by > > remote_unpush_target call. > > (interrupt_query, readchar, getpkt_or_notif_sane_1): Replace > > pop_target calls by remote_unpush_target calls. > > > > Thanks. I think this is fine. Checked in: http://sourceware.org/ml/gdb-cvs/2013-03/msg00193.html and for 7.6. http://sourceware.org/ml/gdb-cvs/2013-03/msg00194.html (This one has additional ", 0" for the QUITTING parameter.) > I notice that some targets, like spu-multiarch.c or dec-thread.c > don't seem to be very prepared to be brute-force deactivated. E.g., > those targets (and linux-thread-db.c and bsd-uthread.c too), probably > more) are deactivated when symbols or shared libraries are unloaded, > and their to_close methods don't take care of cleaning up the target's > variables / local state. A similar scenario that doesn't > involve remote, is when going from 'threaded core debugging' > -> 'non-threaded core debugging'. But since target_pre_inferior > discards the DSOs of the current inferior, and these targets are > generally not multi-inferior aware, I guess things end up alright. > This is very much a preexisting wart. I suspect we'll end up > getting back to this at some not-so-distant point. :-) OK, I did not notice before. Thanks, Jan http://sourceware.org/ml/gdb-cvs/2013-03/msg00193.html --- src/gdb/ChangeLog 2013/03/22 14:52:26 1.15301 +++ src/gdb/ChangeLog 2013/03/22 19:07:03 1.15302 @@ -1,3 +1,12 @@ +2013-03-22 Jan Kratochvil + + * remote.c (remote_unpush_target): New function. + (remote_open_1): Remove two pop_target calls, update one comment, add + comment to target_preopen call. Replace pop_target call by + remote_unpush_target call. + (interrupt_query, readchar, getpkt_or_notif_sane_1): Replace + pop_target calls by remote_unpush_target calls. + 2013-03-22 Pedro Alves * linux-nat.c (linux_child_follow_fork): Don't call --- src/gdb/remote.c 2013/03/20 15:46:24 1.530 +++ src/gdb/remote.c 2013/03/22 19:07:03 1.531 @@ -4188,6 +4188,14 @@ } } +/* Remove any of the remote.c targets from target stack. Upper targets depend + on it so remove them first. */ + +static void +remote_unpush_target (void) +{ + pop_all_targets_above (process_stratum - 1); +} static void remote_open_1 (char *name, int from_tty, @@ -4205,30 +4213,18 @@ wait_forever_enabled_p = 1; /* If we're connected to a running target, target_preopen will kill it. - But if we're connected to a target system with no running process, - then we will still be connected when it returns. Ask this question - first, before target_preopen has a chance to kill anything. */ + Ask this question first, before target_preopen has a chance to kill + anything. */ if (remote_desc != NULL && !have_inferiors ()) { - if (!from_tty - || query (_("Already connected to a remote target. Disconnect? "))) - pop_target (); - else + if (from_tty + && !query (_("Already connected to a remote target. Disconnect? "))) error (_("Still connected.")); } + /* Here the possibly existing remote target gets unpushed. */ target_preopen (from_tty); - unpush_target (target); - - /* This time without a query. If we were connected to an - extended-remote target and target_preopen killed the running - process, we may still be connected. If we are starting "target - remote" now, the extended-remote target will not have been - removed by unpush_target. */ - if (remote_desc != NULL && !have_inferiors ()) - pop_target (); - /* Make sure we send the passed signals list the next time we resume. */ xfree (last_pass_packet); last_pass_packet = NULL; @@ -4348,7 +4344,7 @@ /* Pop the partially set up target - unless something else did already before throwing the exception. */ if (remote_desc != NULL) - pop_target (); + remote_unpush_target (); if (target_async_permitted) wait_forever_enabled_p = 1; throw_exception (ex); @@ -5096,7 +5092,7 @@ if (query (_("Interrupted while waiting for the program.\n\ Give up (and stop debugging it)? "))) { - pop_target (); + remote_unpush_target (); deprecated_throw_reason (RETURN_QUIT); } } @@ -7051,11 +7047,11 @@ switch ((enum serial_rc) ch) { case SERIAL_EOF: - pop_target (); + remote_unpush_target (); error (_("Remote connection closed")); /* no return */ case SERIAL_ERROR: - pop_target (); + remote_unpush_target (); perror_with_name (_("Remote communication error. " "Target disconnected.")); /* no return */ @@ -7579,7 +7575,7 @@ if (forever) /* Watchdog went off? Kill the target. */ { QUIT; - pop_target (); + remote_unpush_target (); error (_("Watchdog timeout has expired. Target detached.")); } if (remote_debug)