From 330a0c4aafb887f2059d6c0dbc0e6721806252a7 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 10 Nov 2025 12:40:29 -0500 Subject: [PATCH] gdb/mips: make mips_tdesc_gp{32,64} target_desc_up Change the types to target_desc_up so it's not needed to `.release()` them. This is similar to this review comment: https: //inbox.sourceware.org/gdb-patches/87seeuak0z.fsf@tromey.com/ Change-Id: I45e0e77b00701aa979e8f7f15f397836b4e19849 Approved-By: Maciej W. Rozycki Tested-By: Maciej W. Rozycki --- gdb/mips-linux-tdep.c | 4 ++-- gdb/mips-tdep.c | 20 ++++++++++---------- gdb/mips-tdep.h | 5 +++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index b668bcb3578..cec0ddd6b4d 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -565,10 +565,10 @@ mips_linux_core_read_description (struct gdbarch *gdbarch, switch (bfd_section_size (section)) { case sizeof (mips_elf_gregset_t): - return mips_tdesc_gp32; + return mips_tdesc_gp32.get (); case sizeof (mips64_elf_gregset_t): - return mips_tdesc_gp64; + return mips_tdesc_gp64.get (); default: return NULL; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index d072b9a4d33..2bd2db0bc77 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -209,8 +209,8 @@ static unsigned int mips_debug = 0; #define PROPERTY_GP32 "internal: transfers-32bit-registers" #define PROPERTY_GP64 "internal: transfers-64bit-registers" -struct target_desc *mips_tdesc_gp32; -struct target_desc *mips_tdesc_gp64; +target_desc_up mips_tdesc_gp32; +target_desc_up mips_tdesc_gp64; /* The current set of options to be passed to the disassembler. */ static std::string mips_disassembler_options; @@ -8057,14 +8057,14 @@ mips_register_g_packet_guesses (struct gdbarch *gdbarch) { /* If the size matches the set of 32-bit or 64-bit integer registers, assume that's what we've got. */ - register_remote_g_packet_guess (gdbarch, 38 * 4, mips_tdesc_gp32); - register_remote_g_packet_guess (gdbarch, 38 * 8, mips_tdesc_gp64); + register_remote_g_packet_guess (gdbarch, 38 * 4, mips_tdesc_gp32.get ()); + register_remote_g_packet_guess (gdbarch, 38 * 8, mips_tdesc_gp64.get ()); /* If the size matches the full set of registers GDB traditionally knows about, including floating point, for either 32-bit or 64-bit, assume that's what we've got. */ - register_remote_g_packet_guess (gdbarch, 90 * 4, mips_tdesc_gp32); - register_remote_g_packet_guess (gdbarch, 90 * 8, mips_tdesc_gp64); + register_remote_g_packet_guess (gdbarch, 90 * 4, mips_tdesc_gp32.get ()); + register_remote_g_packet_guess (gdbarch, 90 * 8, mips_tdesc_gp64.get ()); /* Otherwise we don't have a useful guess. */ } @@ -8985,11 +8985,11 @@ INIT_GDB_FILE (mips_tdep) /* Create feature sets with the appropriate properties. The values are not important. */ - mips_tdesc_gp32 = allocate_target_description ().release (); - set_tdesc_property (mips_tdesc_gp32, PROPERTY_GP32, ""); + mips_tdesc_gp32 = allocate_target_description (); + set_tdesc_property (mips_tdesc_gp32.get (), PROPERTY_GP32, ""); - mips_tdesc_gp64 = allocate_target_description ().release (); - set_tdesc_property (mips_tdesc_gp64, PROPERTY_GP64, ""); + mips_tdesc_gp64 = allocate_target_description (); + set_tdesc_property (mips_tdesc_gp64.get (), PROPERTY_GP64, ""); /* Add root prefix command for all "set mips"/"show mips" commands. */ add_setshow_prefix_cmd ("mips", no_class, diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h index f9effb054fa..ee1f4417554 100644 --- a/gdb/mips-tdep.h +++ b/gdb/mips-tdep.h @@ -20,6 +20,7 @@ #ifndef GDB_MIPS_TDEP_H #define GDB_MIPS_TDEP_H +#include "gdbsupport/tdesc.h" #include "objfiles.h" #include "gdbarch.h" @@ -190,8 +191,8 @@ extern void mips_write_pc (struct regcache *regcache, CORE_ADDR pc); /* Target descriptions which only indicate the size of general registers. */ -extern struct target_desc *mips_tdesc_gp32; -extern struct target_desc *mips_tdesc_gp64; +extern target_desc_up mips_tdesc_gp32; +extern target_desc_up mips_tdesc_gp64; /* Return non-zero if PC is in a MIPS SVR4 lazy binding stub section. */