From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89738 invoked by alias); 13 Apr 2018 17:57:05 -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 89727 invoked by uid 89); 13 Apr 2018 17:57:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=themselves, Close, attaches, xfree X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Apr 2018 17:57:03 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2FF3081A88CE for ; Fri, 13 Apr 2018 17:57:02 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8C3310F1BF0 for ; Fri, 13 Apr 2018 17:57:01 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Eliminate target_ops::to_xclose Date: Fri, 13 Apr 2018 17:57:00 -0000 Message-Id: <20180413175700.19109-1-palves@redhat.com> X-SW-Source: 2018-04/txt/msg00257.txt.bz2 In the multi-target branch, I found no need for the target_close vs target_xclose distinction. Heap-allocated targets simply delete themselves in their target_close implementation, while singleton/static targets don't. The target_ops C++ification patches will add more commentary around target_ops's destructor, but there's no destructor yet... gdb/ChangeLog: yyyy-mm-dd Pedro Alves * bfd-target.c (target_bfd_xclose): Rename to ... (target_bfd_close): ... this. (target_bfd_reopen): Adjust. * target.c (target_close): Remove references to to_xclose. * target.h (target_ops::to_xclose): Delete. (target_ops::to_close): Update comments. --- gdb/bfd-target.c | 4 ++-- gdb/target.c | 4 +--- gdb/target.h | 9 +++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index f7928ee0b9..99b49aad13 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -68,7 +68,7 @@ target_bfd_get_section_table (struct target_ops *ops) } static void -target_bfd_xclose (struct target_ops *t) +target_bfd_close (struct target_ops *t) { struct target_bfd_data *data = (struct target_bfd_data *) t->to_data; @@ -95,7 +95,7 @@ target_bfd_reopen (struct bfd *abfd) t->to_doc = _("You should never see this"); t->to_get_section_table = target_bfd_get_section_table; t->to_xfer_partial = target_bfd_xfer_partial; - t->to_xclose = target_bfd_xclose; + t->to_close = target_bfd_close; t->to_data = data; t->to_magic = OPS_MAGIC; diff --git a/gdb/target.c b/gdb/target.c index e8d4ae7ea8..2ff028cfa8 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3416,9 +3416,7 @@ target_close (struct target_ops *targ) fileio_handles_invalidate_target (targ); - if (targ->to_xclose != NULL) - targ->to_xclose (targ); - else if (targ->to_close != NULL) + if (targ->to_close != NULL) targ->to_close (targ); if (targetdebug) diff --git a/gdb/target.h b/gdb/target.h index f208b10767..f329362285 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -418,11 +418,12 @@ struct target_ops stack. Targets should supply this routine, if only to provide an error message. */ void (*to_open) (const char *, int); - /* Old targets with a static target vector provide "to_close". - New re-entrant targets provide "to_xclose" and that is expected - to xfree everything (including the "struct target_ops"). */ - void (*to_xclose) (struct target_ops *targ); + + /* Close the target. This is where the target can handle + teardown. Heap-allocated targets should delete themselves + before returning. */ void (*to_close) (struct target_ops *); + /* Attaches to a process on the target side. Arguments are as passed to the `attach' command by the user. This routine can be called when the target is not on the target-stack, if the -- 2.14.3