aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-08-07 15:53:54 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-08-07 15:53:54 +0100
commit0dba2a6c09c4010dfb2eb5abdd991208374947c4 (patch)
tree260d403ab4971933f926804ce310f6f2f4b13e02 /gdb
parent16eb6b2db49e6cf2fdca56efd37689fcc170cd37 (diff)
downloadgdb-0dba2a6c09c4010dfb2eb5abdd991208374947c4.zip
gdb-0dba2a6c09c4010dfb2eb5abdd991208374947c4.tar.gz
gdb-0dba2a6c09c4010dfb2eb5abdd991208374947c4.tar.bz2
gdbarch: Use an anonymous union for target data in `gdbarch_info'
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog23
-rw-r--r--gdb/aarch64-tdep.c2
-rw-r--r--gdb/amd64-linux-tdep.c6
-rw-r--r--gdb/gdbarch.h16
-rwxr-xr-xgdb/gdbarch.sh16
-rw-r--r--gdb/i386-linux-tdep.c3
-rw-r--r--gdb/i386-tdep.c2
-rw-r--r--gdb/mips-linux-tdep.c3
-rw-r--r--gdb/mips-tdep.c2
-rw-r--r--gdb/nds32-tdep.c2
-rw-r--r--gdb/ppc-linux-tdep.c5
-rw-r--r--gdb/rs6000-tdep.c2
-rw-r--r--gdb/sparc-tdep.c2
-rw-r--r--gdb/spu-multiarch.c2
-rw-r--r--gdb/spu-tdep.c4
15 files changed, 68 insertions, 22 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index affff94..818f438 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 75bb00f..7816281 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -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);
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index cf24789..31d2b16 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -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;
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 1c95301..ceb867f 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -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;
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 3aab17f..36451b1 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -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;
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 708de97..dd21b70 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -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;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index bd728f0..b1e5afd 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -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))
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index f144a2e..001fd40 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -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);
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 8bd11ee..75e45ef 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -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
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index ae84567..7725248 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -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. */
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 5b86e15..324b29d 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -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 };
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 97a975e..59d6896 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -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)
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index dce8527..6135e0b 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -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);
}
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index abc4653..3da502c 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -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);
}
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 1ab9a9c..ca1a3fc 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -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)