From patchwork Fri Feb 3 14:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 64256 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04C753857C45 for ; Fri, 3 Feb 2023 14:21:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04C753857C45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675434119; bh=n5Zt8gpkGrifD8UqwpHAk3kaR/zxmnSpNWQzmxb29jo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=l4vGBv6kUrIYLgTaG3nfW4ZKPQBafR0hpTmsroqxnJzIv1YA6mTiDoWoE+KMrpk+1 W/okippfo96Bjz7c8tHvg/9WJG11MAyKa9w+S4kpzMu/ank8jsSLmo5dzrnt20gEUU AkI+YJXnfGloeeMEMlMlehp09VfR1uvxcvE5hleM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 3A8133858409 for ; Fri, 3 Feb 2023 14:21:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A8133858409 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 313ELSd0018794 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 3 Feb 2023 09:21:33 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 313ELSd0018794 Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 78B041E128; Fri, 3 Feb 2023 09:21:28 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/5] gdb: change inferior::tdesc_info to non-pointer Date: Fri, 3 Feb 2023 09:21:23 -0500 Message-Id: <20230203142126.286866-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203142126.286866-1-simon.marchi@polymtl.ca> References: <20230203142126.286866-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 3 Feb 2023 14:21:28 +0000 X-Spam-Status: No, score=-3189.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I initially made this field a unique pointer, to have automatic memory management. But I then thought that the field didn't really need to be allocated separately from struct inferior. So make it a regular non-pointer field of inferior. Remove target_desc_info_free, as it's no longer needed. Change-Id: Ica2b97071226f31c40e86222a2f6922454df1229 --- gdb/inferior.c | 5 +---- gdb/inferior.h | 2 +- gdb/target-descriptions.c | 16 ++-------------- gdb/target-descriptions.h | 4 ---- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index b0ecca8b63a3..dfe523664de0 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -69,8 +69,6 @@ private_inferior::~private_inferior () = default; inferior::~inferior () { - inferior *inf = this; - /* Before the inferior is deleted, all target_ops should be popped from the target stack, this leaves just the dummy_target behind. If this is not done, then any target left in the target stack will be left @@ -81,7 +79,6 @@ inferior::~inferior () gdb_assert (m_target_stack.top ()->stratum () == dummy_stratum); m_continuations.clear (); - target_desc_info_free (inf->tdesc_info); } inferior::inferior (int pid_) @@ -964,7 +961,7 @@ clone_inferior_command (const char *args, int from_tty) /* If the original inferior had a user specified target description, make the clone use it too. */ - if (target_desc_info_from_user_p (inf->tdesc_info)) + if (target_desc_info_from_user_p (&inf->tdesc_info)) copy_inferior_target_desc_info (inf, orginf); clone_program_space (pspace, orginf->pspace); diff --git a/gdb/inferior.h b/gdb/inferior.h index 5b5eab00546c..d902881bfe24 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -633,7 +633,7 @@ class inferior : public refcounted_object, /* Info about an inferior's target description (if it's fetched; the user supplied description's filename, if any; etc.). */ - target_desc_info *tdesc_info = NULL; + target_desc_info tdesc_info; /* The architecture associated with the inferior through the connection to the target. diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 076feed0008c..049e42c7ea77 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -436,16 +436,12 @@ struct tdesc_arch_data gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p = NULL; }; -/* Get the inferior INF's target description info, allocating one on - the stop if necessary. */ +/* Get the inferior INF's target description info. */ static struct target_desc_info * get_tdesc_info (struct inferior *inf) { - if (inf->tdesc_info == NULL) - inf->tdesc_info = new target_desc_info; - - return inf->tdesc_info; + return &inf->tdesc_info; } /* A handle for architecture-specific data associated with the @@ -482,14 +478,6 @@ copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcin *dest = *src; } -/* See target-descriptions.h. */ - -void -target_desc_info_free (struct target_desc_info *tdesc_info) -{ - delete tdesc_info; -} - /* The string manipulated by the "set tdesc filename ..." command. */ static std::string tdesc_filename_cmd_string; diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h index 93bf382a18ea..c337c177c8e8 100644 --- a/gdb/target-descriptions.h +++ b/gdb/target-descriptions.h @@ -55,10 +55,6 @@ const struct target_desc *target_current_description (void); void copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcinf); -/* Free a target_desc_info object. */ - -void target_desc_info_free (struct target_desc_info *tdesc_info); - /* Returns true if INFO indicates the target description had been supplied by the user. */