From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from kwanyin.sergiodj.net (kwanyin.sergiodj.net [158.69.185.54]) by sourceware.org (Postfix) with ESMTPS id 654C4385B835 for ; Fri, 17 Apr 2020 21:26:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 654C4385B835 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] gdbserver/linux-low: turn 'fetch_register' into a method From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: Date: Fri, 17 Apr 2020 17:26:15 -0400 X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-testers@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-testers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Apr 2020 21:26:30 -0000 *** TEST RESULTS FOR COMMIT bd70b1f240b24d8c9b08868ca777f5a81d13c0c2 *** commit bd70b1f240b24d8c9b08868ca777f5a81d13c0c2 Author: Tankut Baris Aktemur AuthorDate: Thu Apr 2 15:11:24 2020 +0200 Commit: Tankut Baris Aktemur CommitDate: Thu Apr 2 15:11:24 2020 +0200 gdbserver/linux-low: turn 'fetch_register' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur Turn the 'fetch_register' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) : Remove. (class linux_process_target) : Declare. * linux-x86-low.cc (the_low_target) * linux-aarch64-low.cc (the_low_target) * linux-arm-low.cc (the_low_target) * linux-bfin-low.cc (the_low_target) * linux-cris-low.cc (the_low_target) * linux-crisv32-low.cc (the_low_target) * linux-m32r-low.cc (the_low_target) * linux-m68k-low.cc (the_low_target) * linux-nios2-low.cc (the_low_target) * linux-ppc-low.cc (the_low_target) * linux-s390-low.cc (the_low_target) * linux-sh-low.cc (the_low_target) * linux-sparc-low.cc (the_low_target) * linux-tic6x-low.cc (the_low_target) * linux-tile-low.cc (the_low_target) * linux-xtensa-low.cc (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) : Declare. (ia64_fetch_register): Turn into... (ia64_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) : Declare. (mips_fetch_register): Turn into... (mips_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) : Declare. (riscv_fetch_register): Turn into... (riscv_target::low_fetch_register): ...this. (the_low_target): Remove the op field. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::low_fetch_register) diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 8aaca90c06..5f543bb5fa 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,47 @@ +2020-04-02 Tankut Baris Aktemur + + Turn the 'fetch_register' linux target op into a method of + linux_process_target. + + * linux-low.h (struct linux_target_ops) : Remove. + (class linux_process_target) : Declare. + * linux-x86-low.cc (the_low_target) + * linux-aarch64-low.cc (the_low_target) + * linux-arm-low.cc (the_low_target) + * linux-bfin-low.cc (the_low_target) + * linux-cris-low.cc (the_low_target) + * linux-crisv32-low.cc (the_low_target) + * linux-m32r-low.cc (the_low_target) + * linux-m68k-low.cc (the_low_target) + * linux-nios2-low.cc (the_low_target) + * linux-ppc-low.cc (the_low_target) + * linux-s390-low.cc (the_low_target) + * linux-sh-low.cc (the_low_target) + * linux-sparc-low.cc (the_low_target) + * linux-tic6x-low.cc (the_low_target) + * linux-tile-low.cc (the_low_target) + * linux-xtensa-low.cc (the_low_target): Remove the op field. + * linux-ia64-low.cc (class ia64_target) : + Declare. + (ia64_fetch_register): Turn into... + (ia64_target::low_fetch_register): ...this. + (the_low_target): Remove the op field. + * linux-mips-low.cc (class mips_target) : + Declare. + (mips_fetch_register): Turn into... + (mips_target::low_fetch_register): ...this. + (the_low_target): Remove the op field. + * linux-riscv-low.cc (class riscv_target) : + Declare. + (riscv_fetch_register): Turn into... + (riscv_target::low_fetch_register): ...this. + (the_low_target): Remove the op field. + + Update the callers below. + + * linux-low.cc (linux_process_target::fetch_registers) + (linux_process_target::low_fetch_register) + 2020-04-02 Tankut Baris Aktemur Turn the 'cannot_fetch_register' and 'cannot_store_register' diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 19484219d7..0bcac19384 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -3085,7 +3085,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ aarch64_get_pc, aarch64_set_pc, aarch64_breakpoint_kind_from_pc, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index 896c5fd1e6..1bbf0e6977 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -1027,7 +1027,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, arm_breakpoint_kind_from_pc, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index e7cd1e2963..a8bb8f03ce 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -135,7 +135,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index 03ca52e39e..7956922f7e 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -132,7 +132,6 @@ cris_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index 03f0aa138e..828ac111d1 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -429,7 +429,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc index 471530a621..377df4f75c 100644 --- a/gdbserver/linux-ia64-low.cc +++ b/gdbserver/linux-ia64-low.cc @@ -38,6 +38,8 @@ protected: bool low_cannot_fetch_register (int regno) override; bool low_cannot_store_register (int regno) override; + + bool low_fetch_register (regcache *regcache, int regno) override; }; /* The singleton target ops object. */ @@ -304,8 +306,8 @@ ia64_target::low_cannot_fetch_register (int regno) #define IA64_FR0_REGNUM 128 #define IA64_FR1_REGNUM 129 -static int -ia64_fetch_register (struct regcache *regcache, int regnum) +bool +ia64_target::low_fetch_register (regcache *regcache, int regnum) { /* r0 cannot be fetched but is always zero. */ if (regnum == IA64_GR0_REGNUM) @@ -314,7 +316,7 @@ ia64_fetch_register (struct regcache *regcache, int regnum) gdb_assert (sizeof (zero) == register_size (regcache->tdesc, regnum)); supply_register (regcache, regnum, zero); - return 1; + return true; } /* fr0 cannot be fetched but is always zero. */ @@ -324,7 +326,7 @@ ia64_fetch_register (struct regcache *regcache, int regnum) gdb_assert (sizeof (f_zero) == register_size (regcache->tdesc, regnum)); supply_register (regcache, regnum, f_zero); - return 1; + return true; } /* fr1 cannot be fetched but is always one (1.0). */ @@ -335,10 +337,10 @@ ia64_fetch_register (struct regcache *regcache, int regnum) gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum)); supply_register (regcache, regnum, f_one); - return 1; + return true; } - return 0; + return false; } static struct usrregs_info ia64_usrregs_info = @@ -367,7 +369,6 @@ ia64_target::low_arch_setup () struct linux_target_ops the_low_target = { - ia64_fetch_register, }; /* The linux target ops object. */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index caa2d8dbd5..c77e92d17b 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5569,10 +5569,9 @@ linux_process_target::fetch_registers (regcache *regcache, int regno) if (regno == -1) { - if (the_low_target.fetch_register != NULL - && regs_info->usrregs != NULL) + if (regs_info->usrregs != NULL) for (regno = 0; regno < regs_info->usrregs->num_regs; regno++) - (*the_low_target.fetch_register) (regcache, regno); + low_fetch_register (regcache, regno); all = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache); if (regs_info->usrregs != NULL) @@ -5580,8 +5579,7 @@ linux_process_target::fetch_registers (regcache *regcache, int regno) } else { - if (the_low_target.fetch_register != NULL - && (*the_low_target.fetch_register) (regcache, regno)) + if (low_fetch_register (regcache, regno)) return; use_regsets = linux_register_in_regsets (regs_info, regno); @@ -5618,6 +5616,11 @@ linux_process_target::store_registers (regcache *regcache, int regno) } } +bool +linux_process_target::low_fetch_register (regcache *regcache, int regno) +{ + return false; +} /* A wrapper for the read_memory target op. */ diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 65c570e066..7ac9086fb9 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,13 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* 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 - REGNO was supplied, false if not, and we should fallback to the - standard ptrace methods. */ - int (*fetch_register) (struct regcache *regcache, int regno); - CORE_ADDR (*get_pc) (struct regcache *regcache); void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); @@ -598,6 +591,13 @@ protected: virtual bool low_cannot_fetch_register (int regno) = 0; virtual bool low_cannot_store_register (int regno) = 0; + + /* 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 + REGNO was supplied, false if not, and we should fallback to the + standard ptrace methods. */ + virtual bool low_fetch_register (regcache *regcache, int regno); }; extern linux_process_target *the_linux_target; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 912708db81..82a503401b 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -134,7 +134,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_from_pc */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index 08545aa946..6a3a2aab38 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -229,7 +229,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 0900dc88e0..ae925ffb6c 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -40,6 +40,8 @@ protected: bool low_cannot_fetch_register (int regno) override; bool low_cannot_store_register (int regno) override; + + bool low_fetch_register (regcache *regcache, int regno) override; }; /* The singleton target ops object. */ @@ -263,18 +265,18 @@ mips_target::low_cannot_store_register (int regno) return false; } -static int -mips_fetch_register (struct regcache *regcache, int regno) +bool +mips_target::low_fetch_register (regcache *regcache, int regno) { const struct target_desc *tdesc = current_process ()->tdesc; if (find_regno (tdesc, "r0") == regno) { supply_register_zeroed (regcache, regno); - return 1; + return true; } - return 0; + return false; } static CORE_ADDR @@ -950,7 +952,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_fetch_register, mips_get_pc, mips_set_pc, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index adbb0f2622..a58d9ca99f 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -251,7 +251,6 @@ nios2_target::get_regs_info () struct linux_target_ops the_low_target = { - NULL, linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 968538df37..096308a44d 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -3392,7 +3392,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ ppc_get_pc, ppc_set_pc, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc index 4f2e28beaf..69af59f720 100644 --- a/gdbserver/linux-riscv-low.cc +++ b/gdbserver/linux-riscv-low.cc @@ -45,6 +45,8 @@ protected: bool low_cannot_fetch_register (int regno) override; bool low_cannot_store_register (int regno) override; + + bool low_fetch_register (regcache *regcache, int regno) override; }; /* The singleton target ops object. */ @@ -188,17 +190,17 @@ riscv_target::get_regs_info () return &riscv_regs; } -/* Implementation of linux_target_ops method "fetch_register". */ +/* Implementation of linux target ops method "low_fetch_register". */ -static int -riscv_fetch_register (struct regcache *regcache, int regno) +bool +riscv_target::low_fetch_register (regcache *regcache, int regno) { const struct target_desc *tdesc = regcache->tdesc; if (regno != find_regno (tdesc, "zero")) - return 0; + return false; supply_register_zeroed (regcache, regno); - return 1; + return true; } /* Implementation of linux_target_ops method "get_pc". */ @@ -291,7 +293,6 @@ riscv_breakpoint_at (CORE_ADDR pc) /* RISC-V/Linux target operations. */ struct linux_target_ops the_low_target = { - riscv_fetch_register, riscv_get_pc, riscv_set_pc, riscv_breakpoint_kind_from_pc, diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 2ba0dec055..d25fafa4cd 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -2812,7 +2812,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ s390_get_pc, s390_set_pc, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index b4fd534547..42bd427d47 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -164,7 +164,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index 4e0d930f80..b68ed2d36a 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -319,7 +319,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_64bit, /* No sparc_set_pc is needed. */ NULL, diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index be6eb98b45..5cfdd091c3 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -407,7 +407,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ tic6x_get_pc, tic6x_set_pc, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index b9af7af7fb..a6138e78aa 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -196,7 +196,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, linux_get_pc_64bit, linux_set_pc_64bit, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 8c9ab733ea..475d77767f 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -2885,7 +2885,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ x86_get_pc, x86_set_pc, NULL, /* breakpoint_kind_from_pc */ diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index 876c2ad63e..d71b2c97fa 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -302,7 +302,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, NULL, /* breakpoint_kind_from_pc */