public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/5] gdb: change inferior::tdesc_info to non-pointer
Date: Fri,  3 Feb 2023 09:21:23 -0500	[thread overview]
Message-ID: <20230203142126.286866-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20230203142126.286866-1-simon.marchi@polymtl.ca>

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.  */
 
-- 
2.39.1


  parent reply	other threads:[~2023-02-03 14:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 14:21 [PATCH 0/5] Some target_desc_info cleanups Simon Marchi
2023-02-03 14:21 ` [PATCH 1/5] gdb: move target_desc_info to inferior.h Simon Marchi
2023-02-03 14:21 ` Simon Marchi [this message]
2023-02-03 14:21 ` [PATCH 3/5] gdb: remove get_tdesc_info Simon Marchi
2023-02-03 15:53   ` Andrew Burgess
2023-02-03 16:05     ` Simon Marchi
2023-02-03 14:21 ` [PATCH 4/5] gdb: remove copy_inferior_target_desc_info Simon Marchi
2023-02-03 15:54   ` Andrew Burgess
2023-02-03 16:05     ` Simon Marchi
2023-02-03 14:21 ` [PATCH 5/5] gdb: make target_desc_info_from_user_p a method of target_desc_info Simon Marchi
2023-02-06 18:41   ` Pedro Alves
2023-02-06 19:13     ` Simon Marchi
2023-02-03 15:56 ` [PATCH 0/5] Some target_desc_info cleanups Andrew Burgess
2023-02-03 16:07   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230203142126.286866-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).