]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbarch: Use an anonymous union for target data in `gdbarch_info'
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 7 Aug 2017 14:53:54 +0000 (15:53 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Mon, 7 Aug 2017 14:53:54 +0000 (15:53 +0100)
As an update to commit ede5f15146ae ("gdbarch.h: Change
gdbarch_info::tdep_info's type to void *") replace the definition of the
`tdep_info' member in `struct gdbarch_info' with an anonymous union,
comprising the original member, with its type reverted to `struct
gdbarch_tdep_info *', a `tdesc_data' member of a `struct tdesc_arch_data
*' type and an `id' member of an `int *' type.  Remove now unnecessary
casts throughout use places then, making code easier to read an less
prone to errors, which may happen with casting.

gdb/
* gdbarch.sh (gdbarch_info): Replace the `tdep_info' member with
a union of `tdep_info', `tdesc_data' and `id'.
* aarch64-tdep.c (aarch64_gdbarch_init): Use `info.tdesc_data'
rather than `info.tdep_info'.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_gdbarch_init): Likewise.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-tdep.c (rs6000_gdbarch_init): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Use `info.id' rather than
`info.tdep_info'.
(ppc_linux_init_abi): Use `info.tdesc_data' rather than
`info.tdep_info'.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* spu-multiarch.c (spu_gdbarch): Use `info.id' rather than
`info.tdep_info'.
* spu-tdep.c (spu_gdbarch_init): Likewise.
* gdbarch.h: Regenerate.

15 files changed:
gdb/ChangeLog
gdb/aarch64-tdep.c
gdb/amd64-linux-tdep.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-linux-tdep.c
gdb/i386-tdep.c
gdb/mips-linux-tdep.c
gdb/mips-tdep.c
gdb/nds32-tdep.c
gdb/ppc-linux-tdep.c
gdb/rs6000-tdep.c
gdb/sparc-tdep.c
gdb/spu-multiarch.c
gdb/spu-tdep.c

index affff94ab2c53bed2496f7676070a93b07a28c70..818f43878f4ee92ea3557ed9c42b648212edc190 100644 (file)
@@ -1,3 +1,26 @@
+2017-08-07  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * gdbarch.sh (gdbarch_info): Replace the `tdep_info' member with
+       a union of `tdep_info', `tdesc_data' and `id'.
+       * aarch64-tdep.c (aarch64_gdbarch_init): Use `info.tdesc_data'
+       rather than `info.tdep_info'.
+       * amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
+       * i386-linux-tdep.c (i386_linux_init_abi): Likewise.
+       * i386-tdep.c (i386_gdbarch_init): Likewise.
+       * mips-linux-tdep.c (mips_linux_init_abi): Likewise.
+       * mips-tdep.c (mips_gdbarch_init): Likewise.
+       * nds32-tdep.c (nds32_gdbarch_init): Likewise.
+       * rs6000-tdep.c (rs6000_gdbarch_init): Likewise.
+       * ppc-linux-tdep.c (ppu2spu_sniffer): Use `info.id' rather than
+       `info.tdep_info'.
+       (ppc_linux_init_abi): Use `info.tdesc_data' rather than
+       `info.tdep_info'.
+       * sparc-tdep.c (sparc32_gdbarch_init): Likewise.
+       * spu-multiarch.c (spu_gdbarch): Use `info.id' rather than
+       `info.tdep_info'.
+       * spu-tdep.c (spu_gdbarch_init): Likewise.
+       * gdbarch.h: Regenerate.
+
 2017-08-07  Leszek Swirski  <leszeks@google.com>
 
        * dwarf2read.c (dwarf2_string_attr): Allow DW_FORM_GNU_strp_alt.
index 75bb00f0b6ad9a6d7857d48c80efce9d3ca2163d..78162810b29fbc8adb75027b0f01abf74bfb865d 100644 (file)
@@ -2997,7 +2997,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Hook in the ABI-specific overrides, if they have been registered.  */
   info.target_desc = tdesc;
-  info.tdep_info = (void *) tdesc_data;
+  info.tdesc_data = tdesc_data;
   gdbarch_init_osabi (info, gdbarch);
 
   dwarf2_frame_set_init_reg (gdbarch, aarch64_dwarf2_frame_init_reg);
index cf2478924b6961fff747ca317db0a7c31808fb34..31d2b160dc8c59e6abefcea16ab2cc87fbb56be2 100644 (file)
@@ -1863,8 +1863,7 @@ static void
 amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  struct tdesc_arch_data *tdesc_data
-    = (struct tdesc_arch_data *) info.tdep_info;
+  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
   int valid_p;
 
@@ -2077,8 +2076,7 @@ static void
 amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  struct tdesc_arch_data *tdesc_data
-    = (struct tdesc_arch_data *) info.tdep_info;
+  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
   int valid_p;
 
index 1c95301f6f2846b914c9c813c56677d5f965ef70..ceb867fcd193611172839b594d4f46e35225cfbe 100644 (file)
@@ -1647,7 +1647,21 @@ struct gdbarch_info
   bfd *abfd;
 
   /* Use default: NULL (ZERO).  */
-  void *tdep_info;
+  union
+    {
+      /* Architecture-specific information.  The generic form for targets
+        that have extra requirements.  */
+      struct gdbarch_tdep_info *tdep_info;
+
+      /* Architecture-specific target description data.  Numerous targets
+        need only this, so give them an easy way to hold it.  */
+      struct tdesc_arch_data *tdesc_data;
+
+      /* SPU file system ID.  This is a single integer, so using the
+        generic form would only complicate code.  Other targets may
+        reuse this member if suitable.  */
+      int *id;
+    };
 
   /* Use default: GDB_OSABI_UNINITIALIZED (-1).  */
   enum gdb_osabi osabi;
index 3aab17f958c6effd52b13c75136dee0e1b026570..36451b1a2fb1fe44a6075e03581fb9321e024e8d 100755 (executable)
@@ -1474,7 +1474,21 @@ struct gdbarch_info
   bfd *abfd;
 
   /* Use default: NULL (ZERO).  */
-  void *tdep_info;
+  union
+    {
+      /* Architecture-specific information.  The generic form for targets
+        that have extra requirements.  */
+      struct gdbarch_tdep_info *tdep_info;
+
+      /* Architecture-specific target description data.  Numerous targets
+        need only this, so give them an easy way to hold it.  */
+      struct tdesc_arch_data *tdesc_data;
+
+      /* SPU file system ID.  This is a single integer, so using the
+        generic form would only complicate code.  Other targets may
+        reuse this member if suitable.  */
+      int *id;
+    };
 
   /* Use default: GDB_OSABI_UNINITIALIZED (-1).  */
   enum gdb_osabi osabi;
index 708de97a8fbd5ad2b30eb113d4b31448b8018149..dd21b7057f12238c7d0e81f178e1ff07ea7a2cfa 100644 (file)
@@ -855,8 +855,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   const struct target_desc *tdesc = info.target_desc;
-  struct tdesc_arch_data *tdesc_data
-    = (struct tdesc_arch_data *) info.tdep_info;
+  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
   int valid_p;
 
index bd728f03dc3a378c30446cae4af36d381552497a..b1e5afd5537919b5edfac166d1d9eca0c6daa975 100644 (file)
@@ -8604,7 +8604,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Hook in ABI-specific overrides, if they have been registered.
      Note: If INFO specifies a 64 bit arch, this is where we turn
      a 32-bit i386 into a 64-bit amd64.  */
-  info.tdep_info = tdesc_data;
+  info.tdesc_data = tdesc_data;
   gdbarch_init_osabi (info, gdbarch);
 
   if (!i386_validate_tdesc_p (tdep, tdesc_data))
index f144a2ef50fa31c0248b7abd1061bb3047d5940c..001fd40027b77f5322d69205be0f0fed600486e4 100644 (file)
@@ -1616,8 +1616,7 @@ mips_linux_init_abi (struct gdbarch_info info,
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum mips_abi abi = mips_abi (gdbarch);
-  struct tdesc_arch_data *tdesc_data
-    = (struct tdesc_arch_data *) info.tdep_info;
+  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
 
   linux_init_abi (info, gdbarch);
 
index 8bd11eeb492875c7c586f03050bdf658c47749f0..75e45ef0841478d2c4e06440707fdbcf08c7b044 100644 (file)
@@ -8785,7 +8785,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   mips_register_g_packet_guesses (gdbarch);
 
   /* Hook in OS ABI-specific overrides, if they have been registered.  */
-  info.tdep_info = tdesc_data;
+  info.tdesc_data = tdesc_data;
   gdbarch_init_osabi (info, gdbarch);
 
   /* The hook may have adjusted num_regs, fetch the final value and
index ae84567fdc27f31d39c0a85806ab90bc4848d7b8..7725248aaa4fdb4cf1ffbdae70262aed39617a34 100644 (file)
@@ -2134,7 +2134,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   nds32_add_reggroups (gdbarch);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
-  info.tdep_info = (void *) tdesc_data;
+  info.tdesc_data = tdesc_data;
   gdbarch_init_osabi (info, gdbarch);
 
   /* Override tdesc_register callbacks for system registers.  */
index 5b86e1571d3dab9495cacd659d084c7efb72b439..324b29d90c1266a73f172da20a6015174189625f 100644 (file)
@@ -1350,7 +1350,7 @@ ppu2spu_sniffer (const struct frame_unwind *self,
       info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu);
       info.byte_order = BFD_ENDIAN_BIG;
       info.osabi = GDB_OSABI_LINUX;
-      info.tdep_info = &data.id;
+      info.id = &data.id;
       data.gdbarch = gdbarch_find_by_info (info);
       if (!data.gdbarch)
        return 0;
@@ -1650,8 +1650,7 @@ ppc_linux_init_abi (struct gdbarch_info info,
                     struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-  struct tdesc_arch_data *tdesc_data
-    = (struct tdesc_arch_data *) info.tdep_info;
+  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   static const char *const stap_integer_prefixes[] = { "i", NULL };
   static const char *const stap_register_indirection_prefixes[] = { "(",
                                                                    NULL };
index 97a975ec23c2a839996d64a110d9d429c1f1a04c..59d689635112372eabcc9905212e81f31e95a624 100644 (file)
@@ -6529,7 +6529,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
   info.target_desc = tdesc;
-  info.tdep_info = tdesc_data;
+  info.tdesc_data = tdesc_data;
   gdbarch_init_osabi (info, gdbarch);
 
   switch (info.osabi)
index dce85275ac4e87ad787a0e83237e2e752d3e9aea..6135e0b9fb6578d0ceaef97cb8aabaa4aa1156ad 100644 (file)
@@ -1906,7 +1906,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
         }
 
       /* Target description may have changed. */
-      info.tdep_info = tdesc_data;
+      info.tdesc_data = tdesc_data;
       tdesc_use_registers (gdbarch, tdesc, tdesc_data);
     }
 
index abc46535cf8800b29e857336bdf0215148547f8e..3da502cea5e1411238f652d4111a6460e3b5c69b 100644 (file)
@@ -107,7 +107,7 @@ spu_gdbarch (int spufs_fd)
   info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu);
   info.byte_order = BFD_ENDIAN_BIG;
   info.osabi = GDB_OSABI_LINUX;
-  info.tdep_info = &spufs_fd;
+  info.id = &spufs_fd;
   return gdbarch_find_by_info (info);
 }
 
index 1ab9a9cf6526919fa0a4cb708a622269da0035ce..ca1a3fc99f99a506446925a20bd3598631930a53 100644 (file)
@@ -2668,8 +2668,8 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   int id = -1;
 
   /* Which spufs ID was requested as address space?  */
-  if (info.tdep_info)
-    id = *(int *)info.tdep_info;
+  if (info.id)
+    id = *info.id;
   /* For objfile architectures of SPU solibs, decode the ID from the name.
      This assumes the filename convention employed by solib-spu.c.  */
   else if (info.abfd)