From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32588 invoked by alias); 29 Sep 2010 15:04:36 -0000 Received: (qmail 32578 invoked by uid 22791); 29 Sep 2010 15:04:35 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Sep 2010 15:04:25 +0000 Received: (qmail 23985 invoked from network); 29 Sep 2010 15:04:24 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Sep 2010 15:04:23 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch] regression: Quit should not ask with core (PR 12071) Date: Wed, 29 Sep 2010 17:00:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.33-29-realtime; KDE/4.4.2; x86_64; ; ) Cc: Jan Kratochvil References: <20100929144316.GA16519@host1.dyn.jankratochvil.net> In-Reply-To: <20100929144316.GA16519@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201009291604.18270.pedro@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2010-09/txt/msg00489.txt.bz2 On Wednesday 29 September 2010 15:43:16, Jan Kratochvil wrote: > @@ -467,7 +467,7 @@ have_live_inferiors (void) > multiple target interfaces. */ > if (have_inferiors ()) > for (t = current_target.beneath; t != NULL; t = t->beneath) > - if (t->to_stratum == process_stratum) > + if (t->to_stratum == process_stratum && t->to_has_execution (t)) > return 1; This is about the same as removing the loop and calling "target_has_execution". But, that wouldn't be correct either, because the to_has_execution depends on the inferior selected (see default_child_has_execution). So, for example, if you have two inferiors in your gdb session, one of them is running as a process, while the other is still just a pseudo-inferior / file_stratum inferior yet, and you have the latter selected as current, your patch will make that have-live-inferiors check still return 0, while there _is_ one live inferior. The quickest fix is to iterate over all inferiors, and in turn, switch to the iterated inferior, and check target_has_execution. In pseudo-C: int have_live_inferiors (void) { struct inferior *inf; foreach (inf in inferiors) { thread = any_thread_of_inferior (inf); if (thread) { switch_to_thread (thread->ptid); if (target_has_execution) return 1; } } return 0; } Want to give that a try? -- Pedro Alves