diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-04-02 15:11:24 +0200 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-04-02 15:11:24 +0200 |
commit | daca57a7de50f97a4e8df917447561617a0298b2 (patch) | |
tree | c73e1076e18bd72edf5d8fc252349c7f33ed5121 /gdbserver | |
parent | aa8d21c9bb43baaa35f456a3d371942a26cdce4e (diff) | |
download | gdb-daca57a7de50f97a4e8df917447561617a0298b2.zip gdb-daca57a7de50f97a4e8df917447561617a0298b2.tar.gz gdb-daca57a7de50f97a4e8df917447561617a0298b2.tar.bz2 |
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods
gdbserver/ChangeLog:
2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Turn the 'cannot_fetch_register' and 'cannot_store_register'
linux target ops into methods of linux_process_target.
* linux-low.h (struct linux_target_ops): Remove the low target ops.
(class linux_process_target) <fetch_register>
<store_register>
<usr_fetch_inferior_registers>
<usr_store_inferior_registers>
<low_cannot_fetch_register>
<low_cannot_fetch_register> Declare.
* linux-low.cc (fetch_register): Turn into...
(linux_process_target::fetch_register): ...this.
(store_register): Turn into ...
(linux_process_target::store_register): ...this.
(usr_fetch_inferior_registers): Turn into...
(linux_process_target::usr_fetch_inferior_registers): ...this.
(usr_store_inferior_registers): Turn into...
(linux_process_target::usr_store_inferior_registers): ...this.
* linux-x86-low.cc (class x86_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(x86_cannot_store_register): Turn into...
(x86_target::low_cannot_store_register): ...this.
(x86_cannot_fetch_register): Turn into...
(x86_target::low_cannot_fetch_register): ...this.
(the_low_target): Remove the target op fields.
* linux-aarch64-low.cc (class aarch64_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(aarch64_target::low_cannot_fetch_register)
(aarch64_target::low_cannot_store_register): Define.
(the_low_target): Remove the op fields.
* linux-arm-low.cc (class arm_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(arm_cannot_fetch_register): Turn into...
(arm_target::low_cannot_fetch_register): ...this.
(arm_cannot_store_register): Turn into...
(arm_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-bfin-low.cc (class bfin_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(bfin_cannot_fetch_register): Turn into...
(bfin_target::low_cannot_fetch_register): ...this.
(bfin_cannot_store_register): Turn into...
(bfin_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-cris-low.cc (class cris_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(cris_cannot_fetch_register): Turn into...
(cris_target::low_cannot_fetch_register): ...this.
(cris_cannot_store_register): Turn into...
(cris_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-crisv32-low.cc (class crisv32_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(crisv32_target::low_cannot_fetch_register)
(crisv32_target::low_cannot_store_register): Define.
(the_low_target): Remove the op fields.
* linux-ia64-low.cc (class ia64_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(ia64_cannot_fetch_register): Turn into...
(ia64_target::low_cannot_fetch_register): ...this.
(ia64_cannot_store_register): Turn into...
(ia64_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-m32r-low.cc (class m32r_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(m32r_cannot_fetch_register): Turn into...
(m32r_target::low_cannot_fetch_register): ...this.
(m32r_cannot_store_register): Turn into...
(m32r_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-m68k-low.cc (class m68k_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(m68k_cannot_fetch_register): Turn into...
(m68k_target::low_cannot_fetch_register): ...this.
(m68k_cannot_store_register): Turn into...
(m68k_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-mips-low.cc (class mips_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(mips_cannot_fetch_register): Turn into...
(mips_target::low_cannot_fetch_register): ...this.
(mips_cannot_store_register): Turn into...
(mips_target::low_cannot_store_register): ...this.
(get_usrregs_info): Inline at the call sites in
low_cannot_fetch_register and low_cannot_store_register,
and remove.
(the_low_target): Remove the op fields.
* linux-nios2-low.cc (class nios2_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(nios2_cannot_fetch_register): Turn into...
(nios2_target::low_cannot_fetch_register): ...this.
(nios2_cannot_store_register): Turn into...
(nios2_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-ppc-low.cc (class ppc_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(ppc_cannot_fetch_register): Turn into...
(ppc_target::low_cannot_fetch_register): ...this.
(ppc_cannot_store_register): Turn into...
(ppc_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-riscv-low.cc (class riscv_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(riscv_target::low_cannot_fetch_register)
(riscv_target::low_cannot_store_register): Define.
(the_low_target): Remove the op fields.
* linux-s390-low.cc (class s390_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(s390_cannot_fetch_register): Turn into...
(s390_target::low_cannot_fetch_register): ...this.
(s390_cannot_store_register): Turn into...
(s390_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-sh-low.cc (class sh_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(sh_cannot_fetch_register): Turn into...
(sh_target::low_cannot_fetch_register): ...this.
(sh_cannot_store_register): Turn into...
(sh_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-sparc-low.cc (class sparc_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(sparc_cannot_fetch_register): Turn into...
(sparc_target::low_cannot_fetch_register): ...this.
(sparc_cannot_store_register): Turn into...
(sparc_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-tic6x-low.cc (class tic6x_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(tic6x_cannot_fetch_register): Turn into...
(tic6x_target::low_cannot_fetch_register): ...this.
(tic6x_cannot_store_register): Turn into...
(tic6x_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-tile-low.cc (class tile_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(tile_cannot_fetch_register): Turn into...
(tile_target::low_cannot_fetch_register): ...this.
(tile_cannot_store_register): Turn into...
(tile_target::low_cannot_store_register): ...this.
(the_low_target): Remove the op fields.
* linux-xtensa-low.cc (class xtensa_target)
<low_cannot_fetch_register>
<low_cannot_store_register>: Declare.
(xtensa_target::low_cannot_fetch_register)
(xtensa_target::low_cannot_store_register): Define.
(the_low_target): Remove the op fields.
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/ChangeLog | 168 | ||||
-rw-r--r-- | gdbserver/linux-aarch64-low.cc | 20 | ||||
-rw-r--r-- | gdbserver/linux-arm-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-bfin-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-cris-low.cc | 18 | ||||
-rw-r--r-- | gdbserver/linux-crisv32-low.cc | 20 | ||||
-rw-r--r-- | gdbserver/linux-ia64-low.cc | 18 | ||||
-rw-r--r-- | gdbserver/linux-low.cc | 59 | ||||
-rw-r--r-- | gdbserver/linux-low.h | 37 | ||||
-rw-r--r-- | gdbserver/linux-m32r-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-m68k-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-mips-low.cc | 48 | ||||
-rw-r--r-- | gdbserver/linux-nios2-low.cc | 28 | ||||
-rw-r--r-- | gdbserver/linux-ppc-low.cc | 22 | ||||
-rw-r--r-- | gdbserver/linux-riscv-low.cc | 20 | ||||
-rw-r--r-- | gdbserver/linux-s390-low.cc | 18 | ||||
-rw-r--r-- | gdbserver/linux-sh-low.cc | 18 | ||||
-rw-r--r-- | gdbserver/linux-sparc-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-tic6x-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/linux-tile-low.cc | 26 | ||||
-rw-r--r-- | gdbserver/linux-x86-low.cc | 18 | ||||
-rw-r--r-- | gdbserver/linux-xtensa-low.cc | 20 |
22 files changed, 453 insertions, 189 deletions
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index bbfc628..8aaca90 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,5 +1,173 @@ 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Turn the 'cannot_fetch_register' and 'cannot_store_register' + linux target ops into methods of linux_process_target. + + * linux-low.h (struct linux_target_ops): Remove the low target ops. + (class linux_process_target) <fetch_register> + <store_register> + <usr_fetch_inferior_registers> + <usr_store_inferior_registers> + <low_cannot_fetch_register> + <low_cannot_fetch_register> Declare. + * linux-low.cc (fetch_register): Turn into... + (linux_process_target::fetch_register): ...this. + (store_register): Turn into ... + (linux_process_target::store_register): ...this. + (usr_fetch_inferior_registers): Turn into... + (linux_process_target::usr_fetch_inferior_registers): ...this. + (usr_store_inferior_registers): Turn into... + (linux_process_target::usr_store_inferior_registers): ...this. + * linux-x86-low.cc (class x86_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (x86_cannot_store_register): Turn into... + (x86_target::low_cannot_store_register): ...this. + (x86_cannot_fetch_register): Turn into... + (x86_target::low_cannot_fetch_register): ...this. + (the_low_target): Remove the target op fields. + * linux-aarch64-low.cc (class aarch64_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (aarch64_target::low_cannot_fetch_register) + (aarch64_target::low_cannot_store_register): Define. + (the_low_target): Remove the op fields. + * linux-arm-low.cc (class arm_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (arm_cannot_fetch_register): Turn into... + (arm_target::low_cannot_fetch_register): ...this. + (arm_cannot_store_register): Turn into... + (arm_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-bfin-low.cc (class bfin_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (bfin_cannot_fetch_register): Turn into... + (bfin_target::low_cannot_fetch_register): ...this. + (bfin_cannot_store_register): Turn into... + (bfin_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-cris-low.cc (class cris_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (cris_cannot_fetch_register): Turn into... + (cris_target::low_cannot_fetch_register): ...this. + (cris_cannot_store_register): Turn into... + (cris_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-crisv32-low.cc (class crisv32_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (crisv32_target::low_cannot_fetch_register) + (crisv32_target::low_cannot_store_register): Define. + (the_low_target): Remove the op fields. + * linux-ia64-low.cc (class ia64_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (ia64_cannot_fetch_register): Turn into... + (ia64_target::low_cannot_fetch_register): ...this. + (ia64_cannot_store_register): Turn into... + (ia64_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-m32r-low.cc (class m32r_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (m32r_cannot_fetch_register): Turn into... + (m32r_target::low_cannot_fetch_register): ...this. + (m32r_cannot_store_register): Turn into... + (m32r_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-m68k-low.cc (class m68k_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (m68k_cannot_fetch_register): Turn into... + (m68k_target::low_cannot_fetch_register): ...this. + (m68k_cannot_store_register): Turn into... + (m68k_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-mips-low.cc (class mips_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (mips_cannot_fetch_register): Turn into... + (mips_target::low_cannot_fetch_register): ...this. + (mips_cannot_store_register): Turn into... + (mips_target::low_cannot_store_register): ...this. + (get_usrregs_info): Inline at the call sites in + low_cannot_fetch_register and low_cannot_store_register, + and remove. + (the_low_target): Remove the op fields. + * linux-nios2-low.cc (class nios2_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (nios2_cannot_fetch_register): Turn into... + (nios2_target::low_cannot_fetch_register): ...this. + (nios2_cannot_store_register): Turn into... + (nios2_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-ppc-low.cc (class ppc_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (ppc_cannot_fetch_register): Turn into... + (ppc_target::low_cannot_fetch_register): ...this. + (ppc_cannot_store_register): Turn into... + (ppc_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-riscv-low.cc (class riscv_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (riscv_target::low_cannot_fetch_register) + (riscv_target::low_cannot_store_register): Define. + (the_low_target): Remove the op fields. + * linux-s390-low.cc (class s390_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (s390_cannot_fetch_register): Turn into... + (s390_target::low_cannot_fetch_register): ...this. + (s390_cannot_store_register): Turn into... + (s390_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-sh-low.cc (class sh_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (sh_cannot_fetch_register): Turn into... + (sh_target::low_cannot_fetch_register): ...this. + (sh_cannot_store_register): Turn into... + (sh_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-sparc-low.cc (class sparc_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (sparc_cannot_fetch_register): Turn into... + (sparc_target::low_cannot_fetch_register): ...this. + (sparc_cannot_store_register): Turn into... + (sparc_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-tic6x-low.cc (class tic6x_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (tic6x_cannot_fetch_register): Turn into... + (tic6x_target::low_cannot_fetch_register): ...this. + (tic6x_cannot_store_register): Turn into... + (tic6x_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-tile-low.cc (class tile_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (tile_cannot_fetch_register): Turn into... + (tile_target::low_cannot_fetch_register): ...this. + (tile_cannot_store_register): Turn into... + (tile_target::low_cannot_store_register): ...this. + (the_low_target): Remove the op fields. + * linux-xtensa-low.cc (class xtensa_target) + <low_cannot_fetch_register> + <low_cannot_store_register>: Declare. + (xtensa_target::low_cannot_fetch_register) + (xtensa_target::low_cannot_store_register): Define. + (the_low_target): Remove the op fields. + +2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Turn the 'regs_info' linux target op into a method of linux_process_target. diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index ebbfbe6..1948421 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -60,12 +60,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static aarch64_target the_aarch64_target; +bool +aarch64_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +aarch64_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Per-process arch-specific data we want to keep. */ struct arch_process_info @@ -3067,8 +3085,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* cannot_fetch_register */ - NULL, /* cannot_store_register */ NULL, /* fetch_register */ aarch64_get_pc, aarch64_set_pc, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index c59e8bd..896c5fd 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -65,6 +65,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -166,14 +170,14 @@ static struct arm_get_next_pcs_ops get_next_pcs_ops = { arm_linux_get_next_pcs_fixup, }; -static int -arm_cannot_store_register (int regno) +bool +arm_target::low_cannot_store_register (int regno) { return (regno >= arm_num_regs); } -static int -arm_cannot_fetch_register (int regno) +bool +arm_target::low_cannot_fetch_register (int regno) { return (regno >= arm_num_regs); } @@ -1023,8 +1027,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - arm_cannot_fetch_register, - arm_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index fee79b7..e7cd1e2 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -59,14 +63,14 @@ static int bfin_regmap[] = #define bfin_num_regs ARRAY_SIZE (bfin_regmap) -static int -bfin_cannot_store_register (int regno) +bool +bfin_target::low_cannot_store_register (int regno) { return (regno >= bfin_num_regs); } -static int -bfin_cannot_fetch_register (int regno) +bool +bfin_target::low_cannot_fetch_register (int regno) { return (regno >= bfin_num_regs); } @@ -131,8 +135,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - bfin_cannot_fetch_register, - bfin_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index dcb7d3f..03ca52e 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -31,6 +31,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -58,20 +62,20 @@ static int cris_regmap[] = { }; -static int -cris_cannot_store_register (int regno) +bool +cris_target::low_cannot_store_register (int regno) { if (cris_regmap[regno] == -1) - return 1; + return true; return (regno >= cris_num_regs); } -static int -cris_cannot_fetch_register (int regno) +bool +cris_target::low_cannot_fetch_register (int regno) { if (cris_regmap[regno] == -1) - return 1; + return true; return (regno >= cris_num_regs); } @@ -128,8 +132,6 @@ cris_target::get_regs_info () } struct linux_target_ops the_low_target = { - cris_cannot_fetch_register, - cris_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index b7763ab..03f0aa1 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -31,12 +31,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static crisv32_target the_crisv32_target; +bool +crisv32_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +crisv32_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Defined in auto-generated file reg-crisv32.c. */ void init_registers_crisv32 (void); extern const struct target_desc *tdesc_crisv32; @@ -411,8 +429,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, - NULL, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc index d6508d2..471530a 100644 --- a/gdbserver/linux-ia64-low.cc +++ b/gdbserver/linux-ia64-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -283,16 +287,16 @@ static int ia64_regmap[] = -1, }; -static int -ia64_cannot_store_register (int regno) +bool +ia64_target::low_cannot_store_register (int regno) { - return 0; + return false; } -static int -ia64_cannot_fetch_register (int regno) +bool +ia64_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } /* GDB register numbers. */ @@ -363,8 +367,6 @@ ia64_target::low_arch_setup () struct linux_target_ops the_low_target = { - ia64_cannot_fetch_register, - ia64_cannot_store_register, ia64_fetch_register, }; diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 546ca73..caa2d8d 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5418,10 +5418,10 @@ register_addr (const struct usrregs_info *usrregs, int regnum) return addr; } -/* Fetch one register. */ -static void -fetch_register (const struct usrregs_info *usrregs, - struct regcache *regcache, int regno) + +void +linux_process_target::fetch_register (const usrregs_info *usrregs, + regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -5430,7 +5430,7 @@ fetch_register (const struct usrregs_info *usrregs, if (regno >= usrregs->num_regs) return; - if ((*the_low_target.cannot_fetch_register) (regno)) + if (low_cannot_fetch_register (regno)) return; regaddr = register_addr (usrregs, regno); @@ -5466,10 +5466,9 @@ fetch_register (const struct usrregs_info *usrregs, supply_register (regcache, regno, buf); } -/* Store one register. */ -static void -store_register (const struct usrregs_info *usrregs, - struct regcache *regcache, int regno) +void +linux_process_target::store_register (const usrregs_info *usrregs, + regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -5478,7 +5477,7 @@ store_register (const struct usrregs_info *usrregs, if (regno >= usrregs->num_regs) return; - if ((*the_low_target.cannot_store_register) (regno)) + if (low_cannot_store_register (regno)) return; regaddr = register_addr (usrregs, regno); @@ -5514,22 +5513,21 @@ store_register (const struct usrregs_info *usrregs, if (errno == ESRCH) return; - if ((*the_low_target.cannot_store_register) (regno) == 0) + + if (!low_cannot_store_register (regno)) error ("writing register %d: %s", regno, safe_strerror (errno)); } regaddr += sizeof (PTRACE_XFER_TYPE); } } +#endif /* HAVE_LINUX_USRREGS */ -/* Fetch all registers, or just one, from the child process. - If REGNO is -1, do this for all registers, skipping any that are - assumed to have been retrieved by regsets_fetch_inferior_registers, - unless ALL is non-zero. - Otherwise, REGNO specifies which register (so we can save time). */ -static void -usr_fetch_inferior_registers (const struct regs_info *regs_info, - struct regcache *regcache, int regno, int all) +void +linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info, + regcache *regcache, + int regno, int all) { +#ifdef HAVE_LINUX_USRREGS struct usrregs_info *usr = regs_info->usrregs; if (regno == -1) @@ -5540,17 +5538,15 @@ usr_fetch_inferior_registers (const struct regs_info *regs_info, } else fetch_register (usr, regcache, regno); +#endif } -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers, skipping any that are - assumed to have been saved by regsets_store_inferior_registers, - unless ALL is non-zero. - Otherwise, REGNO specifies which register (so we can save time). */ -static void -usr_store_inferior_registers (const struct regs_info *regs_info, - struct regcache *regcache, int regno, int all) +void +linux_process_target::usr_store_inferior_registers (const regs_info *regs_info, + regcache *regcache, + int regno, int all) { +#ifdef HAVE_LINUX_USRREGS struct usrregs_info *usr = regs_info->usrregs; if (regno == -1) @@ -5561,15 +5557,8 @@ usr_store_inferior_registers (const struct regs_info *regs_info, } else store_register (usr, regcache, regno); -} - -#else /* !HAVE_LINUX_USRREGS */ - -#define usr_fetch_inferior_registers(regs_info, regcache, regno, all) do {} while (0) -#define usr_store_inferior_registers(regs_info, regcache, regno, all) do {} while (0) - #endif - +} void linux_process_target::fetch_registers (regcache *regcache, int regno) diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 697b4af..65c570e 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,11 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* Return 0 if we can fetch/store the register, 1 if we cannot - fetch/store the register. */ - int (*cannot_fetch_register) (int); - int (*cannot_store_register) (int); - /* Hook to fetch a register in some non-standard way. Used for example by backends that have read-only registers with hardcoded values (e.g., IA64's gr0/fr0/fr1). Returns true if register @@ -566,11 +561,43 @@ private: /* Call low_arch_setup on THREAD. */ void arch_setup_thread (thread_info *thread); +#ifdef HAVE_LINUX_USRREGS + /* Fetch one register. */ + void fetch_register (const usrregs_info *usrregs, regcache *regcache, + int regno); + + /* Store one register. */ + void store_register (const usrregs_info *usrregs, regcache *regcache, + int regno); +#endif + + /* Fetch all registers, or just one, from the child process. + If REGNO is -1, do this for all registers, skipping any that are + assumed to have been retrieved by regsets_fetch_inferior_registers, + unless ALL is non-zero. + Otherwise, REGNO specifies which register (so we can save time). */ + void usr_fetch_inferior_registers (const regs_info *regs_info, + regcache *regcache, int regno, int all); + + /* Store our register values back into the inferior. + If REGNO is -1, do this for all registers, skipping any that are + assumed to have been saved by regsets_store_inferior_registers, + unless ALL is non-zero. + Otherwise, REGNO specifies which register (so we can save time). */ + void usr_store_inferior_registers (const regs_info *regs_info, + regcache *regcache, int regno, int all); + protected: /* The architecture-specific "low" methods are listed below. */ /* Architecture-specific setup for the current thread. */ virtual void low_arch_setup () = 0; + + /* Return false if we can fetch/store the register, true if we cannot + fetch/store the register. */ + virtual bool low_cannot_fetch_register (int regno) = 0; + + virtual bool low_cannot_store_register (int regno) = 0; }; extern linux_process_target *the_linux_target; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 2a5c6ea..912708d 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -58,14 +62,14 @@ static int m32r_regmap[] = { #endif }; -static int -m32r_cannot_store_register (int regno) +bool +m32r_target::low_cannot_store_register (int regno) { return (regno >= m32r_num_regs); } -static int -m32r_cannot_fetch_register (int regno) +bool +m32r_target::low_cannot_fetch_register (int regno) { return (regno >= m32r_num_regs); } @@ -130,8 +134,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - m32r_cannot_fetch_register, - m32r_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index cbecc7a..08545aa 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -30,6 +30,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -71,14 +75,14 @@ static int m68k_regmap[] = #endif }; -static int -m68k_cannot_store_register (int regno) +bool +m68k_target::low_cannot_store_register (int regno) { return (regno >= m68k_num_regs); } -static int -m68k_cannot_fetch_register (int regno) +bool +m68k_target::low_cannot_fetch_register (int regno) { return (regno >= m68k_num_regs); } @@ -225,8 +229,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - m68k_cannot_fetch_register, - m68k_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 8231217..0900dc8 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -36,6 +36,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -170,14 +174,6 @@ mips_target::low_arch_setup () current_process ()->tdesc = mips_read_description (); } -static struct usrregs_info * -get_usrregs_info (void) -{ - const struct regs_info *regs_info = the_linux_target->get_regs_info (); - - return regs_info->usrregs; -} - /* Per-process arch-specific data we want to keep. */ struct arch_process_info @@ -218,53 +214,53 @@ struct arch_lwp_info ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE, or FCRIR via ptrace(). */ -static int -mips_cannot_fetch_register (int regno) +bool +mips_target::low_cannot_fetch_register (int regno) { const struct target_desc *tdesc; - if (get_usrregs_info ()->regmap[regno] == -1) - return 1; + if (get_regs_info ()->usrregs->regmap[regno] == -1) + return true; tdesc = current_process ()->tdesc; /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR. */ if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) - return 1; + return true; if (find_regno (tdesc, "r0") == regno) - return 1; + return true; - return 0; + return false; } -static int -mips_cannot_store_register (int regno) +bool +mips_target::low_cannot_store_register (int regno) { const struct target_desc *tdesc; - if (get_usrregs_info ()->regmap[regno] == -1) - return 1; + if (get_regs_info ()->usrregs->regmap[regno] == -1) + return true; tdesc = current_process ()->tdesc; /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR. */ if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) - return 1; + return true; if (find_regno (tdesc, "r0") == regno) - return 1; + return true; if (find_regno (tdesc, "cause") == regno) - return 1; + return true; if (find_regno (tdesc, "badvaddr") == regno) - return 1; + return true; if (find_regno (tdesc, "fir") == regno) - return 1; + return true; - return 0; + return false; } static int @@ -954,8 +950,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_cannot_fetch_register, - mips_cannot_store_register, mips_fetch_register, mips_get_pc, mips_set_pc, diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index 2e19b8d..adbb0f2 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -42,6 +42,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -90,26 +94,20 @@ nios2_target::low_arch_setup () current_process ()->tdesc = tdesc_nios2_linux; } -/* Implement the cannot_fetch_register linux_target_ops method. */ +/* Implement the low_cannot_fetch_register linux target ops method. */ -static int -nios2_cannot_fetch_register (int regno) +bool +nios2_target::low_cannot_fetch_register (int regno) { - if (nios2_regmap[regno] == -1) - return 1; - - return 0; + return (nios2_regmap[regno] == -1); } -/* Implement the cannot_store_register linux_target_ops method. */ +/* Implement the low_cannot_store_register linux target ops method. */ -static int -nios2_cannot_store_register (int regno) +bool +nios2_target::low_cannot_store_register (int regno) { - if (nios2_regmap[regno] == -1) - return 1; - - return 0; + return (nios2_regmap[regno] == -1); } /* Breakpoint support. Also see comments on nios2_breakpoint_from_pc @@ -253,8 +251,6 @@ nios2_target::get_regs_info () struct linux_target_ops the_low_target = { - nios2_cannot_fetch_register, - nios2_cannot_store_register, NULL, linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index fe63e7b..968538d 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -55,6 +55,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -160,8 +164,8 @@ ppc_check_regset (int tid, int regset_id, int regsetsize) return 0; } -static int -ppc_cannot_store_register (int regno) +bool +ppc_target::low_cannot_store_register (int regno) { const struct target_desc *tdesc = current_process ()->tdesc; @@ -169,21 +173,21 @@ ppc_cannot_store_register (int regno) /* Some kernels do not allow us to store fpscr. */ if (!(ppc_hwcap & PPC_FEATURE_HAS_SPE) && regno == find_regno (tdesc, "fpscr")) - return 1; + return true; #endif /* Some kernels do not allow us to store orig_r3 or trap. */ if (regno == find_regno (tdesc, "orig_r3") || regno == find_regno (tdesc, "trap")) - return 1; + return true; - return 0; + return false; } -static int -ppc_cannot_fetch_register (int regno) +bool +ppc_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } static void @@ -3388,8 +3392,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - ppc_cannot_fetch_register, - ppc_cannot_store_register, NULL, /* fetch_register */ ppc_get_pc, ppc_set_pc, diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc index 092f497..4f2e28b 100644 --- a/gdbserver/linux-riscv-low.cc +++ b/gdbserver/linux-riscv-low.cc @@ -41,12 +41,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static riscv_target the_riscv_target; +bool +riscv_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +riscv_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Implementation of linux target ops method "low_arch_setup". */ void @@ -273,8 +291,6 @@ riscv_breakpoint_at (CORE_ADDR pc) /* RISC-V/Linux target operations. */ struct linux_target_ops the_low_target = { - NULL, /* cannot_fetch_register */ - NULL, /* cannot_store_register */ riscv_fetch_register, riscv_get_pc, riscv_set_pc, diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 464f60d..2ba0dec 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -62,6 +62,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -157,16 +161,16 @@ static int s390_regmap_3264[] = { #endif -static int -s390_cannot_fetch_register (int regno) +bool +s390_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } -static int -s390_cannot_store_register (int regno) +bool +s390_target::low_cannot_store_register (int regno) { - return 0; + return false; } static void @@ -2808,8 +2812,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_cannot_fetch_register, - s390_cannot_store_register, NULL, /* fetch_register */ s390_get_pc, s390_set_pc, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index d47cd40..b4fd534 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -30,6 +30,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -63,16 +67,16 @@ static int sh_regmap[] = { REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60, }; -static int -sh_cannot_store_register (int regno) +bool +sh_target::low_cannot_store_register (int regno) { - return 0; + return false; } -static int -sh_cannot_fetch_register (int regno) +bool +sh_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } /* Correct in either endianness, obviously. */ @@ -160,8 +164,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - sh_cannot_fetch_register, - sh_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index 7be5c15..4e0d930 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -53,6 +53,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -119,14 +123,14 @@ static const struct regs_range_t fpregs_ranges[] = { void init_registers_sparc64 (void); extern const struct target_desc *tdesc_sparc64; -static int -sparc_cannot_store_register (int regno) +bool +sparc_target::low_cannot_store_register (int regno) { return (regno >= sparc_num_regs || sparc_regmap[regno] == -1); } -static int -sparc_cannot_fetch_register (int regno) +bool +sparc_target::low_cannot_fetch_register (int regno) { return (regno >= sparc_num_regs || sparc_regmap[regno] == -1); } @@ -315,8 +319,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - sparc_cannot_fetch_register, - sparc_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_64bit, /* No sparc_set_pc is needed. */ diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 1f8d2f6..be6eb98 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -49,6 +49,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -223,14 +227,14 @@ tic6x_read_description (enum c6x_feature feature) return *tdesc; } -static int -tic6x_cannot_fetch_register (int regno) +bool +tic6x_target::low_cannot_fetch_register (int regno) { return (tic6x_regmap[regno] == -1); } -static int -tic6x_cannot_store_register (int regno) +bool +tic6x_target::low_cannot_store_register (int regno) { return (tic6x_regmap[regno] == -1); } @@ -403,8 +407,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - tic6x_cannot_fetch_register, - tic6x_cannot_store_register, NULL, /* fetch_register */ tic6x_get_pc, tic6x_set_pc, diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 6f173cc..b9af7af 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -63,26 +67,26 @@ static int tile_regmap[] = 56 }; -static int -tile_cannot_fetch_register (int regno) +bool +tile_target::low_cannot_fetch_register (int regno) { if (regno >= 0 && regno < 56) - return 0; + return false; else if (regno == 64) - return 0; + return false; else - return 1; + return true; } -static int -tile_cannot_store_register (int regno) +bool +tile_target::low_cannot_store_register (int regno) { if (regno >= 0 && regno < 56) - return 0; + return false; else if (regno == 64) - return 0; + return false; else - return 1; + return true; } static uint64_t tile_breakpoint = 0x400b3cae70166000ULL; @@ -192,8 +196,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - tile_cannot_fetch_register, - tile_cannot_store_register, NULL, linux_get_pc_64bit, linux_set_pc_64bit, diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 4fdeeef..8c9ab73 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -109,6 +109,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -301,23 +305,23 @@ x86_get_thread_area (int lwpid, CORE_ADDR *addr) -static int -x86_cannot_store_register (int regno) +bool +x86_target::low_cannot_store_register (int regno) { #ifdef __x86_64__ if (is_64bit_tdesc ()) - return 0; + return false; #endif return regno >= I386_NUM_REGS; } -static int -x86_cannot_fetch_register (int regno) +bool +x86_target::low_cannot_fetch_register (int regno) { #ifdef __x86_64__ if (is_64bit_tdesc ()) - return 0; + return false; #endif return regno >= I386_NUM_REGS; @@ -2881,8 +2885,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - x86_cannot_fetch_register, - x86_cannot_store_register, NULL, /* fetch_register */ x86_get_pc, x86_set_pc, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index ee2cd3b..876c2ad 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -31,12 +31,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static xtensa_target the_xtensa_target; +bool +xtensa_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +xtensa_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Defined in auto-generated file reg-xtensa.c. */ void init_registers_xtensa (void); extern const struct target_desc *tdesc_xtensa; @@ -284,8 +302,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, - 0, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, |