gdb: rename gdbarch_tdep struct to fix g++ 4.8 build

After the commit:

  commit 08106042d9f5fdff60c129bf33190639f1a98b2a
  Date:   Thu May 19 13:20:17 2022 +0100

      gdb: move the type cast into gdbarch_tdep

GDB would no longer build using g++ 4.8.  The issue appears to be some
confusion caused by GDB having 'struct gdbarch_tdep', but also a
templated function called 'gdbarch_tdep'.  Prior to the above commit
the gdbarch_tdep function was not templated, and this compiled just
fine.  Note that the above commit compiles just fine with later
versions of g++, so this issue was clearly fixed at some point, though
I've not tried to track down exactly when.

In this commit I propose to fix the g++ 4.8 build problem by renaming
'struct gdbarch_tdep' to 'struct gdbarch_tdep_base'.  This rename
better represents that the struct is only ever used as a base class,
and removes the overloading of the name, which allows GDB to build
with g++ 4.8.

I've also updated the comment on 'struct gdbarch_tdep_base' to fix a
typo, and the comment on the 'gdbarch_tdep' function, to mention that
in maintainer mode a run-time type check is performed.
This commit is contained in:
Andrew Burgess 2022-07-25 12:07:11 +01:00
parent 27121f6740
commit ab25d9bbe4
45 changed files with 60 additions and 57 deletions

View File

@ -60,7 +60,7 @@ struct regset;
#define AARCH64_DISPLACED_MODIFIED_INSNS 1
/* Target-dependent structure in gdbarch. */
struct aarch64_gdbarch_tdep : gdbarch_tdep
struct aarch64_gdbarch_tdep : gdbarch_tdep_base
{
/* Lowest address at which instructions will appear. */
CORE_ADDR lowest_pc = 0;

View File

@ -70,7 +70,7 @@ struct regcache;
#define ALPHA_NUM_ARG_REGS 6
/* Target-dependent structure in gdbarch. */
struct alpha_gdbarch_tdep : gdbarch_tdep
struct alpha_gdbarch_tdep : gdbarch_tdep_base
{
CORE_ADDR vm_min_address = 0; /* Used by alpha_heuristic_proc_start. */

View File

@ -121,7 +121,7 @@ extern bool arc_debug;
/* Target-dependent information. */
struct arc_gdbarch_tdep : gdbarch_tdep
struct arc_gdbarch_tdep : gdbarch_tdep_base
{
/* Offset to PC value in jump buffer. If this is negative, longjmp
support will be disabled. */

View File

@ -1200,7 +1200,7 @@ gdbarch_free (struct gdbarch *arch)
/* See gdbarch.h. */
struct gdbarch_tdep *
struct gdbarch_tdep_base *
gdbarch_tdep_1 (struct gdbarch *gdbarch)
{
if (gdbarch_debug >= 2)

View File

@ -87,7 +87,7 @@ enum struct_return
};
/* Target-dependent structure in gdbarch. */
struct arm_gdbarch_tdep : gdbarch_tdep
struct arm_gdbarch_tdep : gdbarch_tdep_base
{
/* The ABI for this architecture. It should never be set to
ARM_ABI_AUTO. */

View File

@ -189,7 +189,7 @@ struct avr_unwind_cache
trad_frame_saved_reg *saved_regs;
};
struct avr_gdbarch_tdep : gdbarch_tdep
struct avr_gdbarch_tdep : gdbarch_tdep_base
{
/* Number of bytes stored to the stack by call instructions.
2 bytes for avr1-5 and avrxmega1-5, 3 bytes for avr6 and avrxmega6-7. */

View File

@ -96,7 +96,7 @@ enum bfin_abi
};
/* Target-dependent structure in gdbarch. */
struct bfin_gdbarch_tdep : gdbarch_tdep
struct bfin_gdbarch_tdep : gdbarch_tdep_base
{
/* Which ABI is in use? */
enum bfin_abi bfin_abi {};

View File

@ -58,7 +58,7 @@ enum bpf_regnum
#define BPF_NUM_REGS (BPF_PC_REGNUM + 1)
/* Target-dependent structure in gdbarch. */
struct bpf_gdbarch_tdep : gdbarch_tdep
struct bpf_gdbarch_tdep : gdbarch_tdep_base
{
};

View File

@ -26,7 +26,7 @@
#include "gdbarch.h"
/* CRIS architecture specific information. */
struct cris_gdbarch_tdep : gdbarch_tdep
struct cris_gdbarch_tdep : gdbarch_tdep_base
{
unsigned int cris_version = 0;
const char *cris_mode = nullptr;

View File

@ -31,7 +31,7 @@ enum lr_type_t
};
/* Target-dependent structure in gdbarch. */
struct csky_gdbarch_tdep : gdbarch_tdep
struct csky_gdbarch_tdep : gdbarch_tdep_base
{
/* Save FPU, VDSP ABI. */
unsigned int fpu_abi;

View File

@ -68,7 +68,7 @@ struct frv_unwind_cache /* was struct frame_extra_info */
of structures, each of which gives all the necessary info for one
register. Don't stick parallel arrays in here --- that's so
Fortran. */
struct frv_gdbarch_tdep : gdbarch_tdep
struct frv_gdbarch_tdep : gdbarch_tdep_base
{
/* Which ABI is in use? */
enum frv_abi frv_abi {};

View File

@ -22,7 +22,7 @@
#include "gdbarch.h"
struct ft32_gdbarch_tdep : gdbarch_tdep
struct ft32_gdbarch_tdep : gdbarch_tdep_base
{
/* Type for a pointer to a function. Used for the type of PC. */
struct type *pc_type = nullptr;

View File

@ -43,7 +43,7 @@ struct gdbarch
const struct target_desc * target_desc;
/* target specific vector. */
struct gdbarch_tdep *tdep;
struct gdbarch_tdep_base *tdep;
gdbarch_dump_tdep_ftype *dump_tdep;
/* per-architecture data-pointers. */
@ -258,7 +258,7 @@ struct gdbarch
struct gdbarch *
gdbarch_alloc (const struct gdbarch_info *info,
struct gdbarch_tdep *tdep)
struct gdbarch_tdep_base *tdep)
{
struct gdbarch *gdbarch;

View File

@ -61,11 +61,11 @@ struct inferior;
/* The base class for every architecture's tdep sub-class. The virtual
destructor ensures the class has RTTI information, which allows
gdb::checked_static_cast to be used, the gdbarch_tdep the function. */
gdb::checked_static_cast to be used in the gdbarch_tdep function. */
struct gdbarch_tdep
struct gdbarch_tdep_base
{
virtual ~gdbarch_tdep() = default;
virtual ~gdbarch_tdep_base() = default;
};
/* The architecture associated with the inferior through the
@ -151,20 +151,23 @@ using read_core_file_mappings_loop_ftype =
#include "gdbarch-gen.h"
/* An internal function that should _only_ be called from gdbarch_tdep.
Returns the gdbarch_tdep field held within GDBARCH. */
Returns the gdbarch_tdep_base field held within GDBARCH. */
extern struct gdbarch_tdep *gdbarch_tdep_1 (struct gdbarch *gdbarch);
extern struct gdbarch_tdep_base *gdbarch_tdep_1 (struct gdbarch *gdbarch);
/* Return the gdbarch_tdep object held within GDBARCH cast to the type
TDepType, which should be a sub-class of gdbarch_tdep. There is no
checking done that the gdbarch_tdep within GDBARCH actually is of the
type TDepType, we just assume the caller knows what they are doing. */
/* Return the gdbarch_tdep_base object held within GDBARCH cast to the type
TDepType, which should be a sub-class of gdbarch_tdep_base.
When GDB is compiled in maintainer mode a run-time check is performed
that the gdbarch_tdep_base within GDBARCH really is of type TDepType.
When GDB is compiled in release mode the run-time check is not
performed, and we assume the caller knows what they are doing. */
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
struct gdbarch_tdep_base *tdep = gdbarch_tdep_1 (gdbarch);
return gdb::checked_static_cast<TDepType *> (tdep);
}
@ -293,7 +296,7 @@ extern struct gdbarch_list *gdbarch_list_lookup_by_info (struct gdbarch_list *ar
parameters. set_gdbarch_*() functions are called to complete the
initialization of the object. */
extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep *tdep);
extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep_base *tdep);
/* Helper function. Free a partially-constructed ``struct gdbarch''.

View File

@ -267,7 +267,7 @@ with open("gdbarch.c", "w") as f:
print(f" {c.type} {c.name};", file=f)
print(file=f)
print(" /* target specific vector. */", file=f)
print(" struct gdbarch_tdep *tdep;", file=f)
print(" struct gdbarch_tdep_base *tdep;", file=f)
print(" gdbarch_dump_tdep_ftype *dump_tdep;", file=f)
print(file=f)
print(" /* per-architecture data-pointers. */", file=f)
@ -290,7 +290,7 @@ with open("gdbarch.c", "w") as f:
print(file=f)
print("struct gdbarch *", file=f)
print("gdbarch_alloc (const struct gdbarch_info *info,", file=f)
print(" struct gdbarch_tdep *tdep)", file=f)
print(" struct gdbarch_tdep_base *tdep)", file=f)
print("{", file=f)
print(" struct gdbarch *gdbarch;", file=f)
print("", file=f)

View File

@ -84,7 +84,7 @@ enum hppa_regnum
#define HPPA_INSN_SIZE 4
/* Target-dependent structure in gdbarch. */
struct hppa_gdbarch_tdep : gdbarch_tdep
struct hppa_gdbarch_tdep : gdbarch_tdep_base
{
/* The number of bytes in an address. For now, this field is designed
to allow us to differentiate hppa32 from hppa64 targets. */

View File

@ -57,7 +57,7 @@ enum struct_return
};
/* i386 architecture specific information. */
struct i386_gdbarch_tdep : gdbarch_tdep
struct i386_gdbarch_tdep : gdbarch_tdep_base
{
/* General-purpose registers. */
int *gregset_reg_offset = 0;

View File

@ -229,7 +229,7 @@ struct ia64_infcall_ops
void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr);
};
struct ia64_gdbarch_tdep : gdbarch_tdep
struct ia64_gdbarch_tdep : gdbarch_tdep_base
{
CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int)
= nullptr;

View File

@ -43,7 +43,7 @@
#define LM32_REG2(insn) ((insn >> 11) & 0x1f)
#define LM32_IMM16(insn) ((((long)insn & 0xffff) << 16) >> 16)
struct lm32_gdbarch_tdep : gdbarch_tdep
struct lm32_gdbarch_tdep : gdbarch_tdep_base
{
/* gdbarch target dependent data here. Currently unused for LM32. */
};

View File

@ -32,7 +32,7 @@ extern const struct regset loongarch_gregset;
extern const struct regset loongarch_fpregset;
/* Target-dependent structure in gdbarch. */
struct loongarch_gdbarch_tdep : gdbarch_tdep
struct loongarch_gdbarch_tdep : gdbarch_tdep_base
{
/* Features about the abi that impact how the gdbarch is configured. */
struct loongarch_gdbarch_features abi_features;

View File

@ -96,7 +96,7 @@ struct m32c_reg
#define M32C_MAX_DWARF_REGNUM (40)
struct m32c_gdbarch_tdep : gdbarch_tdep
struct m32c_gdbarch_tdep : gdbarch_tdep_base
{
/* All the registers for this variant, indexed by GDB register
number, and the number of registers present. */

View File

@ -22,7 +22,7 @@
#include "gdbarch.h"
struct m32r_gdbarch_tdep : gdbarch_tdep
struct m32r_gdbarch_tdep : gdbarch_tdep_base
{
/* gdbarch target dependent data here. Currently unused for M32R. */
};

View File

@ -124,7 +124,7 @@ enum insn_return_kind {
#define M68HC12_HARD_PC_REGNUM (SOFT_D32_REGNUM+1)
struct insn_sequence;
struct m68gc11_gdbarch_tdep : gdbarch_tdep
struct m68gc11_gdbarch_tdep : gdbarch_tdep_base
{
/* Stack pointer correction value. For 68hc11, the stack pointer points
to the next push location. An offset of 1 must be applied to obtain

View File

@ -69,7 +69,7 @@ enum m68k_flavour
/* Target-dependent structure in gdbarch. */
struct m68k_gdbarch_tdep : gdbarch_tdep
struct m68k_gdbarch_tdep : gdbarch_tdep_base
{
/* Offset to PC value in the jump buffer. If this is negative,
longjmp support will be disabled. */

View File

@ -116,7 +116,7 @@
options are present on the current processor. */
struct mep_gdbarch_tdep : gdbarch_tdep
struct mep_gdbarch_tdep : gdbarch_tdep_base
{
/* A CGEN cpu descriptor for this BFD architecture and machine.

View File

@ -23,7 +23,7 @@
#include "gdbarch.h"
/* Microblaze architecture-specific information. */
struct microblaze_gdbarch_tdep : gdbarch_tdep
struct microblaze_gdbarch_tdep : gdbarch_tdep_base
{
};

View File

@ -93,7 +93,7 @@ enum mips_fpu_type
};
/* MIPS specific per-architecture information. */
struct mips_gdbarch_tdep : gdbarch_tdep
struct mips_gdbarch_tdep : gdbarch_tdep_base
{
/* from the elf header */
int elf_flags = 0;

View File

@ -76,7 +76,7 @@ enum frame_kind {
};
/* mn10300 private data. */
struct mn10300_gdbarch_tdep : gdbarch_tdep
struct mn10300_gdbarch_tdep : gdbarch_tdep_base
{
int am33_mode;
};

View File

@ -22,7 +22,7 @@
#include "gdbarch.h"
struct moxie_gdbarch_tdep : gdbarch_tdep
struct moxie_gdbarch_tdep : gdbarch_tdep_base
{
/* gdbarch target dependent data here. Currently unused for MOXIE. */
};

View File

@ -105,7 +105,7 @@ enum
/* Architecture specific data. */
struct msp430_gdbarch_tdep : gdbarch_tdep
struct msp430_gdbarch_tdep : gdbarch_tdep_base
{
/* The ELF header flags specify the multilib used. */
int elf_flags = 0;

View File

@ -42,7 +42,7 @@ enum nds32_regnum
NDS32_FD0_REGNUM = NDS32_NUM_REGS,
};
struct nds32_gdbarch_tdep : gdbarch_tdep
struct nds32_gdbarch_tdep : gdbarch_tdep_base
{
/* The guessed FPU configuration. */
int fpu_freg = 0;

View File

@ -69,7 +69,7 @@
#define NIOS2_CDX_OPCODE_SIZE 2
/* Target-dependent structure in gdbarch. */
struct nios2_gdbarch_tdep : gdbarch_tdep
struct nios2_gdbarch_tdep : gdbarch_tdep_base
{
/* Assumes FRAME is stopped at a syscall (trap) instruction; returns
the expected next PC. */

View File

@ -63,7 +63,7 @@ show_or1k_debug (struct ui_file *file, int from_tty,
/* The target-dependent structure for gdbarch. */
struct or1k_gdbarch_tdep : gdbarch_tdep
struct or1k_gdbarch_tdep : gdbarch_tdep_base
{
int bytes_per_word = 0;
int bytes_per_address = 0;

View File

@ -205,7 +205,7 @@ enum powerpc_long_double_abi
POWERPC_LONG_DOUBLE_LAST
};
struct ppc_gdbarch_tdep : gdbarch_tdep
struct ppc_gdbarch_tdep : gdbarch_tdep_base
{
int wordsize = 0; /* Size in bytes of fixed-point word. */
int soft_float = 0; /* Avoid FP registers for arguments? */

View File

@ -76,7 +76,7 @@ enum
};
/* RISC-V specific per-architecture information. */
struct riscv_gdbarch_tdep : gdbarch_tdep
struct riscv_gdbarch_tdep : gdbarch_tdep_base
{
/* Features about the target hardware that impact how the gdbarch is
configured. Two gdbarch instances are compatible only if this field

View File

@ -210,7 +210,7 @@ enum
/* Architecture specific data. */
struct rl78_gdbarch_tdep : gdbarch_tdep
struct rl78_gdbarch_tdep : gdbarch_tdep_base
{
/* The ELF header flags specify the multilib used. */
int elf_flags = 0;

View File

@ -69,7 +69,7 @@ enum rx_frame_type {
};
/* Architecture specific data. */
struct rx_gdbarch_tdep : gdbarch_tdep
struct rx_gdbarch_tdep : gdbarch_tdep_base
{
/* The ELF header flags specify the multilib used. */
int elf_flags = 0;

View File

@ -458,7 +458,7 @@ constexpr gdb_byte s12z_break_insn[] = {0x00};
typedef BP_MANIPULATION (s12z_break_insn) s12z_breakpoint;
struct s12z_gdbarch_tdep : gdbarch_tdep
struct s12z_gdbarch_tdep : gdbarch_tdep_base
{
};

View File

@ -38,7 +38,7 @@ enum s390_vector_abi_kind
/* The tdep structure. */
struct s390_gdbarch_tdep : gdbarch_tdep
struct s390_gdbarch_tdep : gdbarch_tdep_base
{
/* Target description. */
const struct target_desc *tdesc = nullptr;

View File

@ -91,7 +91,7 @@ struct sh_corefile_regmap
unsigned int offset;
};
struct sh_gdbarch_tdep : gdbarch_tdep
struct sh_gdbarch_tdep : gdbarch_tdep_base
{
/* Non-NULL when debugging from a core file. Provides the offset
where each general-purpose register is stored inside the associated

View File

@ -57,7 +57,7 @@ struct sparc_fpregmap
/* SPARC architecture-specific information. */
struct sparc_gdbarch_tdep : gdbarch_tdep
struct sparc_gdbarch_tdep : gdbarch_tdep_base
{
/* Register numbers for the PN and nPC registers. The definitions
for (64-bit) UltraSPARC differ from the (32-bit) SPARC

View File

@ -46,7 +46,7 @@ extern const gdb_byte tic6x_bkpt_illegal_opcode_be[];
extern const gdb_byte tic6x_bkpt_illegal_opcode_le[];
/* Target-dependent structure in gdbarch. */
struct tic6x_gdbarch_tdep : gdbarch_tdep
struct tic6x_gdbarch_tdep : gdbarch_tdep_base
{
/* Return the expected next PC if FRAME is stopped at a syscall
instruction. */

View File

@ -265,7 +265,7 @@ enum v850_abi
/* Architecture specific data. */
struct v850_gdbarch_tdep : gdbarch_tdep
struct v850_gdbarch_tdep : gdbarch_tdep_base
{
/* Fields from the ELF header. */
int e_flags = 0;

View File

@ -167,7 +167,7 @@ struct ctype_cache
/* Xtensa-specific target dependencies. */
struct xtensa_gdbarch_tdep : gdbarch_tdep
struct xtensa_gdbarch_tdep : gdbarch_tdep_base
{
xtensa_gdbarch_tdep (xtensa_register_t *regmap)
: regmap (regmap)

View File

@ -55,7 +55,7 @@ __gdb_break_handler:
next frame - frame of caller, which has called current function
*/
struct z80_gdbarch_tdep : gdbarch_tdep
struct z80_gdbarch_tdep : gdbarch_tdep_base
{
/* Number of bytes used for address:
2 bytes for all Z80 family