[binutils-gdb] [gdb] Convert anonymous struct typedefs

Tom de Vries via Gdb-cvs <[email protected]> Mon, 13 Jul 2026 13:07:23 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D496c2954e6ca=
c1c2721a303c063edbbf96fb17e0

commit 496c2954e6cac1c2721a303c063edbbf96fb17e0
Author: Tom de Vries <[email protected]>
Date:   Mon Jul 13 15:06:35 2026 +0200

    [gdb] Convert anonymous struct typedefs
   =20
    Convert "typedef struct { ... } foo" into "struct foo { ... }".
   =20
    Generated by a script written by Claude Code.
   =20
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/arch/xtensa.h              |  4 ++--
 gdb/arm-linux-nat.c            |  4 ++--
 gdb/frv-linux-tdep.c           |  4 ++--
 gdb/go32-nat.c                 | 14 ++++++--------
 gdb/mn10300-linux-tdep.c       |  4 ++--
 gdb/nat/glibc_thread_db.h      | 24 ++++++++++++------------
 gdb/stubs/sh-stub.c            | 10 ++++------
 gdb/xtensa-tdep.h              | 12 ++++++------
 gdb/xtensa-xtregs.c            |  4 ++--
 gdbserver/linux-arm-low.cc     |  4 ++--
 gdbserver/linux-low.cc         |  8 ++++----
 gdbserver/xtensa-xtregs.cc     |  4 ++--
 gdbsupport/common-exceptions.h |  4 ++--
 gdbsupport/gdb_proc_service.h  |  4 ++--
 14 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
index 079a4515fef..711911f6c21 100644
--- a/gdb/arch/xtensa.h
+++ b/gdb/arch/xtensa.h
@@ -25,7 +25,7 @@
=20
 using xtensa_elf_greg_t =3D uint32_t;
=20
-typedef struct
+struct xtensa_elf_gregset_t
 {
   xtensa_elf_greg_t pc;
   xtensa_elf_greg_t ps;
@@ -38,7 +38,7 @@ typedef struct
   xtensa_elf_greg_t threadptr;
   xtensa_elf_greg_t reserved[7+48];
   xtensa_elf_greg_t ar[64];
-} xtensa_elf_gregset_t;
+};
=20
 #define XTENSA_ELF_NGREG (sizeof (xtensa_elf_gregset_t) \
 			  / sizeof (xtensa_elf_greg_t))
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 8f31e2bc56a..05da1a8bf69 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -687,13 +687,13 @@ arm_linux_nat_target::can_use_hw_breakpoint (enum bpt=
ype type,
 }
=20
 /* Enum describing the different types of ARM hardware break-/watch-points=
.  */
-typedef enum
+enum arm_hwbp_type
 {
   arm_hwbp_break =3D 0,
   arm_hwbp_load =3D 1,
   arm_hwbp_store =3D 2,
   arm_hwbp_access =3D 3
-} arm_hwbp_type;
+};
=20
 /* Type describing an ARM Hardware Breakpoint Control register value.  */
 using arm_hwbp_control_t =3D unsigned int;
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 66f434ed8b7..956990824cf 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -350,7 +350,7 @@ using frv_elf_greg_t =3D unsigned char[4];
 using frv_elf_gregset_t =3D struct { frv_elf_greg_t reg[FRV_ELF_NGREG]; };
=20
 using frv_elf_fpreg_t =3D unsigned char[4];
-typedef struct
+struct frv_elf_fpregset_t
 {
   frv_elf_fpreg_t fr[64];
   frv_elf_fpreg_t fner[2];
@@ -358,7 +358,7 @@ typedef struct
   frv_elf_fpreg_t acc[8];
   unsigned char accg[8];
   frv_elf_fpreg_t fsr[1];
-} frv_elf_fpregset_t;
+};
=20
 /* Register maps.  */
=20
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index f95e6bd11a3..c512d6bcd68 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -121,7 +121,7 @@
 #if __DJGPP_MINOR__ < 3
 /* This code will be provided from DJGPP 2.03 on.  Until then I code it
    here.  */
-typedef struct
+struct NPXREG
   {
     unsigned short sig0;
     unsigned short sig1;
@@ -129,10 +129,9 @@ typedef struct
     unsigned short sig3;
     unsigned short exponent:15;
     unsigned short sign:1;
-  }
-NPXREG;
+  };
=20
-typedef struct
+struct NPX
   {
     unsigned int control;
     unsigned int status;
@@ -142,8 +141,7 @@ typedef struct
     unsigned int dataptr;
     unsigned int datasel;
     NPXREG reg[8];
-  }
-NPX;
+  };
=20
 static NPX npx;
=20
@@ -184,10 +182,10 @@ load_npx (void)
 }
 /* -----------------------------------------------------------------------=
-- */
 /* Stubs for the missing redirection functions.  */
-typedef struct {
+struct cmdline_t {
   char *command;
   int redirected;
-} cmdline_t;
+};
=20
 void
 redir_cmdline_delete (cmdline_t *ptr)
diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c
index 95e3b123ce3..4ec236b2e5d 100644
--- a/gdb/mn10300-linux-tdep.c
+++ b/gdb/mn10300-linux-tdep.c
@@ -40,11 +40,11 @@ using mn10300_elf_greg_t =3D gdb_byte  [4];
 using mn10300_elf_gregset_t =3D mn10300_elf_greg_t[MN10300_ELF_NGREG];
=20
 using mn10300_elf_fpreg_t =3D gdb_byte  [4];
-typedef struct
+struct mn10300_elf_fpregset_t
 {
   mn10300_elf_fpreg_t fpregs[MN10300_ELF_NFPREG];
   gdb_byte    fpcr[4];
-} mn10300_elf_fpregset_t;
+};
=20
 /* elf_gregset_t register indices stolen from include/asm-mn10300/ptrace.h=
.  */
 #define MN10300_ELF_GREGSET_T_REG_INDEX_A3	0
diff --git a/gdb/nat/glibc_thread_db.h b/gdb/nat/glibc_thread_db.h
index fc5e7db12da..0831537146c 100644
--- a/gdb/nat/glibc_thread_db.h
+++ b/gdb/nat/glibc_thread_db.h
@@ -29,7 +29,7 @@
=20
=20
 /* Error codes of the library.  */
-typedef enum
+enum td_err_e
 {
   TD_OK,	  /* No error.  */
   TD_ERR,	  /* No further specified error.  */
@@ -56,12 +56,12 @@ typedef enum
   TD_NOTALLOC =3D TD_TLSDEFER,
   TD_VERSION,	  /* Version if libpthread and libthread_db do not match.  */
   TD_NOTLS	  /* There is no TLS segment in the given module.  */
-} td_err_e;
+};
=20
=20
 /* Possible thread states.  TD_THR_ANY_STATE is a pseudo-state used to
    select threads regardless of state in td_ta_thr_iter().  */
-typedef enum
+enum td_thr_state_e
 {
   TD_THR_ANY_STATE,
   TD_THR_UNKNOWN,
@@ -71,16 +71,16 @@ typedef enum
   TD_THR_ZOMBIE,
   TD_THR_SLEEP,
   TD_THR_STOPPED_ASLEEP
-} td_thr_state_e;
+};
=20
 /* Thread type: user or system.  TD_THR_ANY_TYPE is a pseudo-type used
    to select threads regardless of type in td_ta_thr_iter().  */
-typedef enum
+enum td_thr_type_e
 {
   TD_THR_ANY_TYPE,
   TD_THR_USER,
   TD_THR_SYSTEM
-} td_thr_type_e;
+};
=20
=20
 /* Types of the debugging library.  */
@@ -151,7 +151,7 @@ typedef struct td_thr_events
 #endif
=20
 /* Events reportable by the thread implementation.  */
-typedef enum
+enum td_event_e
 {
   TD_ALL_EVENTS,		 /* Pseudo-event number.  */
   TD_EVENT_NONE =3D TD_ALL_EVENTS, /* Depends on context.  */
@@ -172,16 +172,16 @@ typedef enum
   TD_MIN_EVENT_NUM =3D TD_READY,
   TD_MAX_EVENT_NUM =3D TD_TIMEOUT,
   TD_EVENTS_ENABLE =3D 31		/* Event reporting enabled.  */
-} td_event_e;
+};
=20
 /* Values representing the different ways events are reported.  */
-typedef enum
+enum td_notify_e
 {
   NOTIFY_BPT,			/* User must insert breakpoint at u.bptaddr. */
   NOTIFY_AUTOBPT,		/* Breakpoint at u.bptaddr is automatically
 				   inserted.  */
   NOTIFY_SYSCALL		/* System call u.syscallno will be invoked.  */
-} td_notify_e;
+};
=20
 /* Description how event type is reported.  */
 typedef struct td_notify
@@ -209,12 +209,12 @@ typedef struct td_event_msg
 } td_event_msg_t;
=20
 /* Structure containing event data available in each thread structure.  */
-typedef struct
+struct td_eventbuf_t
 {
   td_thr_events_t eventmask;	/* Mask of enabled events.  */
   td_event_e eventnum;		/* Number of last event.  */
   void *eventdata;		/* Data associated with event.  */
-} td_eventbuf_t;
+};
=20
=20
 /* Gathered statistics about the process.  */
diff --git a/gdb/stubs/sh-stub.c b/gdb/stubs/sh-stub.c
index 88509a85d78..0f8d3c7e124 100644
--- a/gdb/stubs/sh-stub.c
+++ b/gdb/stubs/sh-stub.c
@@ -266,12 +266,11 @@ enum regnames
     TICKS, STALLS, CYCLES, INSTS, PLR
   };
=20
-typedef struct
+struct stepData
   {
     short *memAddr;
     short oldInstr;
-  }
-stepData;
+  };
=20
 int registers[NUMREGBYTES / 4];
 stepData instrBuffer;
@@ -841,15 +840,14 @@ breakpoint (void)
=20
 /* SH1/SH2 exception vector table format */
=20
-typedef struct
+struct vec_type
   {
     void (*func_cold) ();
     int *stack_cold;
     void (*func_warm) ();
     int *stack_warm;
     void (*(handler[256 - 4])) ();
-  }
-vec_type;
+  };
=20
 /* vectable is the SH1/SH2 vector table. It must be at address 0
    or wherever your vbr points. */
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index 6733eee0263..ad71c6685e8 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -89,23 +89,23 @@ enum xtensa_target_flags_t
=20
 /*  Mask.  */
=20
-typedef struct
+struct xtensa_reg_mask_t
 {
   int reg_num;
   int bit_start;
   int bit_size;
-} xtensa_reg_mask_t;
+};
=20
-typedef struct
+struct xtensa_mask_t
 {
   int count;
   xtensa_reg_mask_t *mask;
-} xtensa_mask_t;
+};
=20
=20
 /*  Xtensa register representation.  */
=20
-typedef struct
+struct xtensa_register_t
 {
   const char *name;            	/* Register name.  */
   int offset;             	/* Offset.  */
@@ -124,7 +124,7 @@ typedef struct
   const xtensa_mask_t *mask;	/* Register is a compilation of other regs.  =
*/
   const char *fetch;		/* Instruction sequence to fetch register.  */
   const char *store;		/* Instruction sequence to store register.  */
-} xtensa_register_t;
+};
=20
 /*  For xtensa-config.c to expand to the structure above.  */
 #define XTREG(index,ofs,bsz,sz,al,tnum,flg,cp,ty,gr,name,fet,sto,mas,ct,x,=
y) \
diff --git a/gdb/xtensa-xtregs.c b/gdb/xtensa-xtregs.c
index 23e153f9ddb..fc0f7d55dbb 100644
--- a/gdb/xtensa-xtregs.c
+++ b/gdb/xtensa-xtregs.c
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  =
*/
=20
=20
-typedef struct
+struct xtensa_regtable_t
 {
   int gdb_regnum;
   int gdb_offset;
@@ -27,7 +27,7 @@ typedef struct
   int coproc;
   int dbnum;
   const char *name;
-} xtensa_regtable_t;
+};
=20
 #define XTENSA_ELF_XTREG_SIZE 4
=20
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index c0705588d60..34492c979f1 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -175,13 +175,13 @@ static struct
 } arm_linux_hwbp_cap;
=20
 /* Enum describing the different types of ARM hardware break-/watch-points=
.  */
-typedef enum
+enum arm_hwbp_type
 {
   arm_hwbp_break =3D 0,
   arm_hwbp_load =3D 1,
   arm_hwbp_store =3D 2,
   arm_hwbp_access =3D 3
-} arm_hwbp_type;
+};
=20
 /* Type describing an ARM Hardware Breakpoint Control register value.  */
 using arm_hwbp_control_t =3D unsigned int;
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 86ea2451c1c..f1be62225e2 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -104,7 +104,7 @@
=20
 #ifndef HAVE_ELF32_AUXV_T
 /* Copied from glibc's elf.h.  */
-typedef struct
+struct Elf32_auxv_t
 {
   uint32_t a_type;		/* Entry type */
   union
@@ -114,12 +114,12 @@ typedef struct
 	 though, since it does not work when using 32-bit definitions
 	 on 64-bit platforms and vice versa.  */
     } a_un;
-} Elf32_auxv_t;
+};
 #endif
=20
 #ifndef HAVE_ELF64_AUXV_T
 /* Copied from glibc's elf.h.  */
-typedef struct
+struct Elf64_auxv_t
 {
   uint64_t a_type;		/* Entry type */
   union
@@ -129,7 +129,7 @@ typedef struct
 	 though, since it does not work when using 32-bit definitions
 	 on 64-bit platforms and vice versa.  */
     } a_un;
-} Elf64_auxv_t;
+};
 #endif
=20
 /* See nat/linux-nat.h.  */
diff --git a/gdbserver/xtensa-xtregs.cc b/gdbserver/xtensa-xtregs.cc
index 87df8bfbdea..1d138186fd4 100644
--- a/gdbserver/xtensa-xtregs.cc
+++ b/gdbserver/xtensa-xtregs.cc
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  =
*/
=20
=20
-typedef struct {
+struct xtensa_regtable_t {
   int   gdb_regnum;
   int   gdb_offset;
   int   ptrace_cp_offset;
@@ -26,7 +26,7 @@ typedef struct {
   int   coproc;
   int   dbnum;
   char* name
-;} xtensa_regtable_t;
+;};
=20
 #define XTENSA_ELF_XTREG_SIZE	4
=20
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index 37c6e94d5a3..058260b5f27 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -44,13 +44,13 @@ enum return_reason
=20
 #define RETURN_MASK(reason)	(1 << (int)(-reason))
=20
-typedef enum
+enum return_mask
 {
   RETURN_MASK_FORCED_QUIT =3D RETURN_MASK (RETURN_FORCED_QUIT),
   RETURN_MASK_QUIT =3D RETURN_MASK (RETURN_QUIT),
   RETURN_MASK_ERROR =3D RETURN_MASK (RETURN_ERROR),
   RETURN_MASK_ALL =3D (RETURN_MASK_FORCED_QUIT | RETURN_MASK_QUIT | RETURN=
_MASK_ERROR)
-} return_mask;
+};
=20
 /* Describe all exceptions.  */
=20
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index c7a240306b5..6bac4aaea06 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -72,7 +72,7 @@ extern "C" {
 extern "C" {
=20
 /* Functions in this interface return one of these status codes.  */
-typedef enum
+enum ps_err_e
 {
   PS_OK,		/* Generic "call succeeded".  */
   PS_ERR,		/* Generic error.  */
@@ -81,7 +81,7 @@ typedef enum
   PS_BADADDR,		/* Bad address.  */
   PS_NOSYM,		/* Could not find given symbol.  */
   PS_NOFREGS		/* FPU register set not available for given LWP.  */
-} ps_err_e;
+};
=20
 #ifndef HAVE_LWPID_T
 using lwpid_t =3D unsigned int;