From patchwork Sun Jan 12 01:01:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 37308 Received: (qmail 101037 invoked by alias); 12 Jan 2020 01:02:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 101027 invoked by uid 89); 12 Jan 2020 01:02:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=2020-01-12, 20200112, story, HX-Received:a5d X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 12 Jan 2020 01:02:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578790924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x5GjSP6JM5iVVmgEpLCOm7BX3UAdYdrSPgmjO/9Ly2U=; b=eV+q9iovB8p6z+98cLyygLRgKMO27UFsWAqPRyfcg7lIEwmNsWaBw2MNz6pcqyB6IZJVlX lqbPx4UjaIoiTLWdRj6x1GG3RIAGjP47l1yADL2LqY2bVUzs9WSCzwNZr94AbN94JRD1yF YJt+rODsHekYVW2z8PNEzY0hExr5FbE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-4Rtd213ENtmELKLJRSvLJw-1; Sat, 11 Jan 2020 20:02:01 -0500 Received: by mail-wr1-f69.google.com with SMTP id u12so3006793wrt.15 for ; Sat, 11 Jan 2020 17:02:01 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id o15sm8575606wra.83.2020.01.11.17.01.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Jan 2020 17:01:59 -0800 (PST) Subject: [pushed] Remove last traces of discard_all_inferiors (Re: [PATCH v2 18/24] Multi-target support) To: Simon Marchi , gdb-patches@sourceware.org References: <20191017225026.30496-1-palves@redhat.com> <20191017225026.30496-19-palves@redhat.com> <4cc39685-e1d8-72e4-98f2-304bd3fdf7a6@simark.ca> From: Pedro Alves Message-ID: Date: Sun, 12 Jan 2020 01:01:58 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <4cc39685-e1d8-72e4-98f2-304bd3fdf7a6@simark.ca> X-Mimecast-Spam-Score: 0 On 1/11/20 3:12 AM, Simon Marchi wrote: > On 2019-10-17 6:50 p.m., Pedro Alves wrote: >> @@ -539,14 +574,14 @@ extern void exit_inferior_num_silent (int num); >> >> extern void inferior_appeared (struct inferior *inf, int pid); >> >> -/* Get rid of all inferiors. */ >> -extern void discard_all_inferiors (void); > > I'm rebasing my -Wmissing-declarations patch series and see this: > > CXX inferior.o > /home/simark/src/binutils-gdb/gdb/inferior.c:264:1: error: no previous declaration for ‘void discard_all_inferiors()’ [-Werror=missing-declarations] > 264 | discard_all_inferiors (void) > | ^~~~~~~~~~~~~~~~~~~~~ > > The declaration of discard_all_inferiors was removed, but not the definition, I > guess the intent was to remove the definition as well? Whoops, yes, indeed. > > Also grepping for it finds one remaining use: > > bsd-kvm.c:159: discard_all_inferiors (); > > I presume that this call should just be removed too? I think we still need the exit_inferiors call. I suspect direct calls to exit_inferior shouldn't happen -- that we should use detach/kill/disconnect instead, but that's another story. Here's the minimal & obvious patch, which I've just now pushed. From 4ec89149dd83efecea15300bf425c9988f4cd5c0 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 12 Jan 2020 00:40:02 +0000 Subject: [PATCH] Remove last traces of discard_all_inferiors The multi-target patch should have removed all traces of discard_all_inferiors, but somehow one use stayed behind along with the definition of the function. discard_all_inferiors is bad now because it blindly exits inferiors of all target connections. It's best to remove it. gdb/ChangeLog: 2020-01-12 Pedro Alves * bsd-kvm.c (bsd_kvm_target::close): Call exit_inferior_silent directly for the current inferior instead of discard_all_inferiors. (discard_all_inferiors): Delete. --- gdb/ChangeLog | 7 +++++++ gdb/bsd-kvm.c | 2 +- gdb/inferior.c | 7 ------- 3 files changed, 8 insertions(+), 8 deletions(-) base-commit: 57d87c09a33acdce280f4c9ae4f55b885a5cee99 diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 735c46bf70..980114919d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-01-12 Pedro Alves + + * bsd-kvm.c (bsd_kvm_target::close): Call exit_inferior_silent + directly for the current inferior instead of + discard_all_inferiors. + (discard_all_inferiors): Delete. + 2020-01-11 Tom Tromey * tui/tui-wingeneral.c (box_win): Check cli_styling. diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index f864ba8b41..b1b1fee5f4 100644 --- a/gdb/bsd-kvm.c +++ b/gdb/bsd-kvm.c @@ -156,7 +156,7 @@ bsd_kvm_target::close () } inferior_ptid = null_ptid; - discard_all_inferiors (); + exit_inferior_silent (current_inferior ()); } static LONGEST diff --git a/gdb/inferior.c b/gdb/inferior.c index eb090dfde1..c2e9da3d3d 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -260,13 +260,6 @@ inferior_appeared (struct inferior *inf, int pid) gdb::observers::inferior_appeared.notify (inf); } -void -discard_all_inferiors (void) -{ - for (inferior *inf : all_non_exited_inferiors ()) - exit_inferior_silent (inf); -} - struct inferior * find_inferior_id (int num) {