From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 1F09A3858D20; Fri, 3 Feb 2023 16:17:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F09A3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675441047; bh=k4ydBpa9KzxlQoK9oAj9BWXoVd3lUf937TtS7yasad0=; h=From:To:Subject:Date:From; b=Xk/8hmEOGjMm0NRlYh9iM6j0yoM/HdCPQxCFf/ajWHZjG1h9/Xok5+jdo+wNO/f2L 64axpWcgzLiwAFJeqeZwVdWZPL7H5faUuChNUsnYSNpeO0QzysyMdFd1wfjyIbkIJW ibEBZFW5SQKToYNj4CjvdCXqJzc1PR3Drv9nO8PE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: change inferior::tdesc_info to non-pointer X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 650160322c09b9b36d4415b56518ab9e71e8acba X-Git-Newrev: 79846903c6289b2ff12d1830bc2cbf900710556c Message-Id: <20230203161727.1F09A3858D20@sourceware.org> Date: Fri, 3 Feb 2023 16:17:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D79846903c628= 9b2ff12d1830bc2cbf900710556c commit 79846903c6289b2ff12d1830bc2cbf900710556c Author: Simon Marchi Date: Fri Feb 3 09:21:23 2023 -0500 gdb: change inferior::tdesc_info to non-pointer =20 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. =20 Remove target_desc_info_free, as it's no longer needed. =20 Change-Id: Ica2b97071226f31c40e86222a2f6922454df1229 Diff: --- 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 b0ecca8b63a..dfe523664de 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -69,8 +69,6 @@ private_inferior::~private_inferior () =3D default; =20 inferior::~inferior () { - inferior *inf =3D 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 () =3D=3D dummy_stratum); =20 m_continuations.clear (); - target_desc_info_free (inf->tdesc_info); } =20 inferior::inferior (int pid_) @@ -964,7 +961,7 @@ clone_inferior_command (const char *args, int from_tty) =20 /* 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); =20 clone_program_space (pspace, orginf->pspace); diff --git a/gdb/inferior.h b/gdb/inferior.h index 5b5eab00546..d902881bfe2 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -633,7 +633,7 @@ public: =20 /* 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 =3D NULL; + target_desc_info tdesc_info; =20 /* 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 076feed0008..049e42c7ea7 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 =3D NULL; }; =20 -/* Get the inferior INF's target description info, allocating one on - the stop if necessary. */ +/* Get the inferior INF's target description info. */ =20 static struct target_desc_info * get_tdesc_info (struct inferior *inf) { - if (inf->tdesc_info =3D=3D NULL) - inf->tdesc_info =3D new target_desc_info; - - return inf->tdesc_info; + return &inf->tdesc_info; } =20 /* A handle for architecture-specific data associated with the @@ -482,14 +478,6 @@ copy_inferior_target_desc_info (struct inferior *desti= nf, struct inferior *srcin *dest =3D *src; } =20 -/* 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. */ =20 static std::string tdesc_filename_cmd_string; diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h index 93bf382a18e..c337c177c8e 100644 --- a/gdb/target-descriptions.h +++ b/gdb/target-descriptions.h @@ -55,10 +55,6 @@ const struct target_desc *target_current_description (vo= id); void copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcinf); =20 -/* 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. */