diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-15 11:29:39 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-15 11:29:39 -0500 |
commit | 345bd07cce33565f1cd66acabdaf387ca3a7ccb3 (patch) | |
tree | bfa86d2102817e06235193c865d2580e802d0a1a /gdb/ia64-tdep.h | |
parent | eae06bb301512a21277dd48a4bff025c4dceda9e (diff) | |
download | gdb-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.zip gdb-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.tar.gz gdb-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.tar.bz2 |
gdb: fix gdbarch_tdep ODR violation
I would like to be able to use non-trivial types in gdbarch_tdep types.
This is not possible at the moment (in theory), because of the one
definition rule.
To allow it, rename all gdbarch_tdep types to <arch>_gdbarch_tdep, and
make them inherit from a gdbarch_tdep base class. The inheritance is
necessary to be able to pass pointers to all these <arch>_gdbarch_tdep
objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep.
These objects are never deleted through a base class pointer, so I
didn't include a virtual destructor. In the future, if gdbarch objects
deletable, I could imagine that the gdbarch_tdep objects could become
owned by the gdbarch objects, and then it would become useful to have a
virtual destructor (so that the gdbarch object can delete the owned
gdbarch_tdep object). But that's not necessary right now.
It turns out that RISC-V already has a gdbarch_tdep that is
non-default-constructible, so that provides a good motivation for this
change.
Most changes are fairly straightforward, mostly needing to add some
casts all over the place. There is however the xtensa architecture,
doing its own little weird thing to define its gdbarch_tdep. I did my
best to adapt it, but I can't test those changes.
Change-Id: Ic001903f91ddd106bd6ca09a79dabe8df2d69f3b
Diffstat (limited to 'gdb/ia64-tdep.h')
-rw-r--r-- | gdb/ia64-tdep.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h index 28bf446..82319d5 100644 --- a/gdb/ia64-tdep.h +++ b/gdb/ia64-tdep.h @@ -20,6 +20,8 @@ #ifndef IA64_TDEP_H #define IA64_TDEP_H +#include "gdbarch.h" + #ifdef HAVE_LIBUNWIND_IA64_H #include "libunwind-ia64.h" #include "ia64-libunwind-tdep.h" @@ -214,30 +216,33 @@ struct ia64_infcall_ops Should do nothing if this operation is not permitted by the OS. */ void (*allocate_new_rse_frame) (struct regcache *regcache, ULONGEST bsp, - int sof); + int sof) = nullptr; /* Store the argument stored in BUF into the appropriate location given the BSP and the SLOTNUM. */ void (*store_argument_in_slot) (struct regcache *regcache, CORE_ADDR bsp, - int slotnum, gdb_byte *buf); + int slotnum, gdb_byte *buf) = nullptr; /* For targets where we cannot call the function directly, store the address of the function we want to call at the location expected by the calling sequence. */ - void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr); + void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr) + = nullptr; }; -struct gdbarch_tdep +struct ia64_gdbarch_tdep : gdbarch_tdep { - CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int); - int (*pc_in_sigtramp) (CORE_ADDR); + CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int) + = nullptr; + int (*pc_in_sigtramp) (CORE_ADDR) = nullptr; /* Return the total size of THIS_FRAME's register frame. CFM is THIS_FRAME's cfm register value. Normally, the size of the register frame is always obtained by extracting the lowest 7 bits ("cfm & 0x7f"). */ - int (*size_of_register_frame) (struct frame_info *this_frame, ULONGEST cfm); + int (*size_of_register_frame) (struct frame_info *this_frame, ULONGEST cfm) + = nullptr; /* Determine the function address FADDR belongs to a shared library. If it does, then return the associated global pointer. If no shared @@ -245,10 +250,10 @@ struct gdbarch_tdep This pointer may be NULL. */ CORE_ADDR (*find_global_pointer_from_solib) (struct gdbarch *gdbarch, - CORE_ADDR faddr); + CORE_ADDR faddr) = nullptr; /* ISA-specific data types. */ - struct type *ia64_ext_type; + struct type *ia64_ext_type = nullptr; struct ia64_infcall_ops infcall_ops; }; |