diff options
author | Tom Tromey <tromey@adacore.com> | 2019-02-05 03:08:02 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-02-15 13:53:42 -0700 |
commit | 7657f14df7c697792b626efbd24ac44ad5642485 (patch) | |
tree | 5b636873519efe4f620656be3368bbc0c249332e /gdb/sparc-ravenscar-thread.c | |
parent | 5b6ea500d554b173e63e1f8f0344d568ad347463 (diff) | |
download | gdb-7657f14df7c697792b626efbd24ac44ad5642485.zip gdb-7657f14df7c697792b626efbd24ac44ad5642485.tar.gz gdb-7657f14df7c697792b626efbd24ac44ad5642485.tar.bz2 |
C++-ify ravenscar_arch_ops
This turns ravenscar_arch_ops into an abstract base class and updates
all the places where it is used. This is an improvement because it
avoids any possibility of forgetting to set one of the function
pointers. It also makes clear that these functions aren't intended to
be changed dynamically.
This version of the patch removes the prepare_to_store method, as it
is unused, and it is easy enough to add if it is ever needed.
gdb/ChangeLog
2019-02-15 Tom Tromey <tromey@adacore.com>
* sparc-ravenscar-thread.c (struct sparc_ravenscar_ops): Derive
from ravenscar_arch_ops.
(sparc_ravenscar_ops::fetch_registers)
(sparc_ravenscar_ops::store_registers): Now methods.
(sparc_ravenscar_prepare_to_store): Remove.
(sparc_ravenscar_ops): Redefine.
* ravenscar-thread.h (struct ravenscar_arch_ops): Add virtual
methods and destructor. Remove members.
* ravenscar-thread.c (ravenscar_thread_target::fetch_registers)
(ravenscar_thread_target::store_registers)
(ravenscar_thread_target::prepare_to_store): Update.
* ppc-ravenscar-thread.c (ppc_ravenscar_generic_prepare_to_store):
Remove.
(struct ppc_ravenscar_powerpc_ops): Derive from
ravenscar_arch_ops.
(ppc_ravenscar_powerpc_ops::fetch_registers)
(ppc_ravenscar_powerpc_ops::store_registers): Now methods.
(ppc_ravenscar_powerpc_ops): Redefine.
(struct ppc_ravenscar_e500_ops): Derive from ravenscar_arch_ops.
(ppc_ravenscar_e500_ops::fetch_registers)
(ppc_ravenscar_e500_ops::store_registers): Now methods.
(ppc_ravenscar_e500_ops): Redefine.
* aarch64-ravenscar-thread.c
(aarch64_ravenscar_generic_prepare_to_store): Remove.
(struct aarch64_ravenscar_ops): Derive from ravenscar_arch_ops.
(aarch64_ravenscar_fetch_registers)
(aarch64_ravenscar_store_registers): Now methods.
(aarch64_ravenscar_ops): Redefine.
Diffstat (limited to 'gdb/sparc-ravenscar-thread.c')
-rw-r--r-- | gdb/sparc-ravenscar-thread.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c index e09e453..c619f6e 100644 --- a/gdb/sparc-ravenscar-thread.c +++ b/gdb/sparc-ravenscar-thread.c @@ -25,11 +25,11 @@ #include "ravenscar-thread.h" #include "sparc-ravenscar-thread.h" -static void sparc_ravenscar_fetch_registers (struct regcache *regcache, - int regnum); -static void sparc_ravenscar_store_registers (struct regcache *regcache, - int regnum); -static void sparc_ravenscar_prepare_to_store (struct regcache *regcache); +struct sparc_ravenscar_ops : public ravenscar_arch_ops +{ + void fetch_registers (struct regcache *, int) override; + void store_registers (struct regcache *, int) override; +}; /* Register offsets from a referenced address (exempli gratia the Thread_Descriptor). The referenced address depends on the register @@ -100,8 +100,8 @@ register_in_thread_descriptor_p (int regnum) /* to_fetch_registers when inferior_ptid is different from the running thread. */ -static void -sparc_ravenscar_fetch_registers (struct regcache *regcache, int regnum) +void +sparc_ravenscar_ops::fetch_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); const int sp_regnum = gdbarch_sp_regnum (gdbarch); @@ -140,20 +140,11 @@ sparc_ravenscar_fetch_registers (struct regcache *regcache, int regnum) } } -/* to_prepare_to_store when inferior_ptid is different from the running - thread. */ - -static void -sparc_ravenscar_prepare_to_store (struct regcache *regcache) -{ - /* Nothing to do. */ -} - /* to_store_registers when inferior_ptid is different from the running thread. */ -static void -sparc_ravenscar_store_registers (struct regcache *regcache, int regnum) +void +sparc_ravenscar_ops::store_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); int buf_size = register_size (gdbarch, regnum); @@ -178,12 +169,7 @@ sparc_ravenscar_store_registers (struct regcache *regcache, int regnum) buf_size); } -static struct ravenscar_arch_ops sparc_ravenscar_ops = -{ - sparc_ravenscar_fetch_registers, - sparc_ravenscar_store_registers, - sparc_ravenscar_prepare_to_store -}; +static struct sparc_ravenscar_ops sparc_ravenscar_ops; /* Register ravenscar_arch_ops in GDBARCH. */ |