From patchwork Fri Mar 6 21:31:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 38495 Received: (qmail 52044 invoked by alias); 6 Mar 2020 21:32:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51807 invoked by uid 89); 6 Mar 2020 21:32:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mga17.intel.com Received: from mga17.intel.com (HELO mga17.intel.com) (192.55.52.151) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 21:32:21 +0000 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:32:20 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga008.jf.intel.com with ESMTP; 06 Mar 2020 13:32:19 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 026LWIWv022462; Fri, 6 Mar 2020 21:32:18 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 026LWImp020439; Fri, 6 Mar 2020 22:32:18 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 026LWHAP020435; Fri, 6 Mar 2020 22:32:18 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 14/31] gdbserver/linux-low: turn 'breakpoint_at' into a method Date: Fri, 6 Mar 2020 22:31:22 +0100 Message-Id: <57c78a1670f509b6167fe2065fa64dff37dd22c5.1583529167.git.tankut.baris.aktemur@intel.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-03-06 Tankut Baris Aktemur Turn the 'breakpoint_at' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) : Declare. Update the callers below: * linux-low.cc (linux_process_target::save_stop_reason) (linux_process_target::thread_still_has_status_pending) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) : Declare. (x86_breakpoint_at): Turn into... (x86_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) : Declare. (aarch64_breakpoint_at): Turn into... (aarch64_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) : Declare. (arm_target::low_breakpoint_at): Define. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) : Declare. (bfin_breakpoint_at): Turn into... (bfin_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) : Declare. (cris_breakpoint_at): Turn into... (cris_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) : Declare. (crisv32_breakpoint_at): Turn into... (crisv32_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) : Declare. (ia64_target::low_breakpoint_at): Define. * linux-m32r-low.cc (class m32r_target) : Declare. (m32r_breakpoint_at): Turn into... (m32r_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) : Declare. (m68k_breakpoint_at): Turn into... (m68k_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) : Declare. (mips_breakpoint_at): Turn into... (mips_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) : Declare. (nios2_breakpoint_at): Turn into... (nios2_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) : Declare. (ppc_breakpoint_at): Turn into... (ppc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) : Declare. (riscv_breakpoint_at): Turn into... (riscv_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) : Declare. (s390_breakpoint_at): Turn into... (s390_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) : Declare. (sh_breakpoint_at): Turn into... (sh_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) : Declare. (sparc_breakpoint_at): Turn into... (sparc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) : Declare. (tic6x_breakpoint_at): Turn into... (tic6x_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) : Declare. (tile_breakpoint_at): Turn into... (tile_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) : Declare. (xtensa_breakpoint_at): Turn into... (xtensa_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. --- gdbserver/linux-aarch64-low.cc | 16 ++++++++-------- gdbserver/linux-arm-low.cc | 9 ++++++++- gdbserver/linux-bfin-low.cc | 11 ++++++----- gdbserver/linux-cris-low.cc | 14 +++++++------- gdbserver/linux-crisv32-low.cc | 14 +++++++------- gdbserver/linux-ia64-low.cc | 9 +++++++++ gdbserver/linux-low.cc | 8 ++++---- gdbserver/linux-low.h | 5 +++-- gdbserver/linux-m32r-low.cc | 14 +++++++------- gdbserver/linux-m68k-low.cc | 11 ++++++----- gdbserver/linux-mips-low.cc | 13 +++++++------ gdbserver/linux-nios2-low.cc | 19 ++++++++++--------- gdbserver/linux-ppc-low.cc | 13 +++++++------ gdbserver/linux-riscv-low.cc | 19 ++++++++++--------- gdbserver/linux-s390-low.cc | 7 ++++--- gdbserver/linux-sh-low.cc | 13 +++++++------ gdbserver/linux-sparc-low.cc | 13 +++++++------ gdbserver/linux-tic6x-low.cc | 13 +++++++------ gdbserver/linux-tile-low.cc | 13 +++++++------ gdbserver/linux-x86-low.cc | 13 +++++++------ gdbserver/linux-xtensa-low.cc | 10 +++++----- 21 files changed, 143 insertions(+), 114 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index d8b2402bd6b..a4b8ed37d53 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -77,6 +77,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -237,21 +239,20 @@ aarch64_target::low_set_pc (regcache *regcache, CORE_ADDR pc) (aarch64_default_breakpoint). */ static const gdb_byte aarch64_breakpoint[] = {0x00, 0x00, 0x20, 0xd4}; -/* Implementation of linux_target_ops method "breakpoint_at". */ +/* Implementation of linux target ops method "low_breakpoint_at". */ -static int -aarch64_breakpoint_at (CORE_ADDR where) +bool +aarch64_target::low_breakpoint_at (CORE_ADDR where) { if (is_64bit_tdesc ()) { gdb_byte insn[aarch64_breakpoint_len]; - the_target->read_memory (where, (unsigned char *) &insn, - aarch64_breakpoint_len); + read_memory (where, (unsigned char *) &insn, aarch64_breakpoint_len); if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0) - return 1; + return true; - return 0; + return false; } else return arm_breakpoint_at (where); @@ -3104,7 +3105,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - aarch64_breakpoint_at, aarch64_supports_z_point_type, aarch64_insert_point, aarch64_remove_point, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index 0dca30fb58d..8ad56d4899c 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -87,6 +87,8 @@ protected: void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; std::vector low_get_next_pcs (regcache *regcache) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -129,6 +131,12 @@ arm_target::sw_breakpoint_from_kind (int kind, int *size) return arm_sw_breakpoint_from_kind (kind, size); } +bool +arm_target::low_breakpoint_at (CORE_ADDR pc) +{ + return arm_breakpoint_at (pc); +} + /* Information describing the hardware breakpoint capabilities. */ static struct { @@ -1087,7 +1095,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - arm_breakpoint_at, arm_supports_z_point_type, arm_insert_point, arm_remove_point, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index 48373ccb178..8d380b29d53 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -48,6 +48,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -115,19 +117,19 @@ bfin_target::sw_breakpoint_from_kind (int kind, int *size) return bfin_breakpoint; } -static int -bfin_breakpoint_at (CORE_ADDR where) +bool +bfin_target::low_breakpoint_at (CORE_ADDR where) { unsigned char insn[bfin_breakpoint_len]; read_inferior_memory(where, insn, bfin_breakpoint_len); if (insn[0] == bfin_breakpoint[0] && insn[1] == bfin_breakpoint[1]) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } void @@ -163,7 +165,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - bfin_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index e7e389d049d..fac925f0be5 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -45,6 +45,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -120,19 +122,18 @@ cris_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &cris_breakpoint; } -static int -cris_breakpoint_at (CORE_ADDR where) +bool +cris_target::low_breakpoint_at (CORE_ADDR where) { unsigned short insn; - the_target->read_memory (where, (unsigned char *) &insn, - cris_breakpoint_len); + read_memory (where, (unsigned char *) &insn, cris_breakpoint_len); if (insn == cris_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } void @@ -160,7 +161,6 @@ cris_target::get_regs_info () } struct linux_target_ops the_low_target = { - cris_breakpoint_at, }; /* The linux target ops object. */ diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index ad22ac0f9cc..a7dc77942e3 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -45,6 +45,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -130,19 +132,18 @@ crisv32_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &cris_breakpoint; } -static int -cris_breakpoint_at (CORE_ADDR where) +bool +crisv32_target::low_breakpoint_at (CORE_ADDR where) { unsigned short insn; - the_target->read_memory (where, (unsigned char *) &insn, - cris_breakpoint_len); + read_memory (where, (unsigned char *) &insn, cris_breakpoint_len); if (insn == cris_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } static void @@ -457,7 +458,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - cris_breakpoint_at, cris_supports_z_point_type, cris_insert_point, cris_remove_point, diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc index 0eb0ac53453..dc1bf3dc4d0 100644 --- a/gdbserver/linux-ia64-low.cc +++ b/gdbserver/linux-ia64-low.cc @@ -44,6 +44,8 @@ protected: bool low_cannot_store_register (int regno) override; bool low_fetch_register (regcache *regcache, int regno) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -57,6 +59,13 @@ ia64_target::sw_breakpoint_from_kind (int kind, int *size) "implemented by this target"); } +bool +ia64_target::low_breakpoint_at (CORE_ADDR pc) +{ + gdb_assert_no_reached ("linux target op low_breakpoint_at is not " + "implemented by this target"); +} + /* Defined in auto-generated file reg-ia64.c. */ void init_registers_ia64 (void); extern const struct target_desc *tdesc_ia64; diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 2747c9f6b43..3172ed5c502 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -856,7 +856,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) then the user inserts a breakpoint inside the range. In that case we need to report the breakpoint PC. */ if ((!lwp->stepping || lwp->stop_pc == sw_breakpoint_pc) - && (*the_low_target.breakpoint_at) (sw_breakpoint_pc)) + && low_breakpoint_at (sw_breakpoint_pc)) lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT; if (hardware_breakpoint_inserted_here (pc)) @@ -1710,7 +1710,7 @@ linux_process_target::thread_still_has_status_pending (thread_info *thread) #if !USE_SIGTRAP_SIGINFO else if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT - && !(*the_low_target.breakpoint_at) (pc)) + && !low_breakpoint_at (pc)) { if (debug_threads) debug_printf ("previous SW breakpoint of %ld gone\n", @@ -3185,7 +3185,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, event_child->stop_pc += increment_pc; low_set_pc (regcache, event_child->stop_pc); - if (!(*the_low_target.breakpoint_at) (event_child->stop_pc)) + if (!low_breakpoint_at (event_child->stop_pc)) event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON; } } @@ -3200,7 +3200,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, && (WSTOPSIG (w) == SIGTRAP || ((WSTOPSIG (w) == SIGILL || WSTOPSIG (w) == SIGSEGV) - && (*the_low_target.breakpoint_at) (event_child->stop_pc)))); + && low_breakpoint_at (event_child->stop_pc)))); if (maybe_internal_trap) { diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index e289d5d06a0..77cea4a235d 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,8 +131,6 @@ struct lwp_info; struct linux_target_ops { - int (*breakpoint_at) (CORE_ADDR pc); - /* Breakpoint and watchpoint related functions. See target.h for comments. */ int (*supports_z_point_type) (char z_type); @@ -668,6 +666,9 @@ class linux_process_target : public process_stratum_target 'supports_software_single_step' to return true. */ virtual std::vector low_get_next_pcs (regcache *regcache); + /* Return true if there is a breakpoint at PC. */ + virtual bool low_breakpoint_at (CORE_ADDR pc) = 0; + /* How many bytes the PC should be decremented after a break. */ int m_decr_pc_after_break; }; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 4422951c342..0666dd2d093 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -48,6 +48,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -114,19 +116,18 @@ m32r_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &m32r_breakpoint; } -static int -m32r_breakpoint_at (CORE_ADDR where) +bool +m32r_target::low_breakpoint_at (CORE_ADDR where) { unsigned short insn; - the_target->read_memory (where, (unsigned char *) &insn, - m32r_breakpoint_len); + read_memory (where, (unsigned char *) &insn, m32r_breakpoint_len); if (insn == m32r_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } void @@ -162,7 +163,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - m32r_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index 5b6a1e391db..ca3024bdac8 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -44,6 +44,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -183,16 +185,16 @@ m68k_target::sw_breakpoint_from_kind (int kind, int *size) return m68k_breakpoint; } -static int -m68k_breakpoint_at (CORE_ADDR pc) +bool +m68k_target::low_breakpoint_at (CORE_ADDR pc) { unsigned char c[2]; read_inferior_memory (pc, c, 2); if (c[0] == 0x4E && c[1] == 0x4F) - return 1; + return true; - return 0; + return false; } #include @@ -257,7 +259,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - m68k_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index b02c9272764..82c0b2a1c07 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -52,6 +52,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -328,18 +330,18 @@ mips_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &mips_breakpoint; } -static int -mips_breakpoint_at (CORE_ADDR where) +bool +mips_target::low_breakpoint_at (CORE_ADDR where) { unsigned int insn; - the_target->read_memory (where, (unsigned char *) &insn, 4); + read_memory (where, (unsigned char *) &insn, 4); if (insn == mips_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } /* Mark the watch registers of lwp, represented by ENTRY, as changed. */ @@ -968,7 +970,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_breakpoint_at, mips_supports_z_point_type, mips_insert_point, mips_remove_point, diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index 4fa80cd751b..4323bb9d655 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -56,6 +56,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -165,24 +167,24 @@ nios2_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &nios2_breakpoint; } -/* Implement the breakpoint_at linux_target_ops method. */ +/* Implement the low_breakpoint_at linux target ops method. */ -static int -nios2_breakpoint_at (CORE_ADDR where) +bool +nios2_target::low_breakpoint_at (CORE_ADDR where) { unsigned int insn; /* For R2, first check for the 2-byte CDX trap.n breakpoint encoding. */ #if defined(__nios2_arch__) && __nios2_arch__ == 2 - the_target->read_memory (where, (unsigned char *) &insn, 2); + read_memory (where, (unsigned char *) &insn, 2); if (insn == CDX_BREAKPOINT) - return 1; + return true; #endif - the_target->read_memory (where, (unsigned char *) &insn, 4); + read_memory (where, (unsigned char *) &insn, 4); if (insn == nios2_breakpoint) - return 1; - return 0; + return true; + return false; } /* Fetch the thread-local storage pointer for libthread_db. */ @@ -279,7 +281,6 @@ nios2_target::get_regs_info () struct linux_target_ops the_low_target = { - nios2_breakpoint_at, }; /* The linux target ops object. */ diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 66b5f9bc565..39b2e3fcd37 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -69,6 +69,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -309,18 +311,18 @@ ppc_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &ppc_breakpoint; } -static int -ppc_breakpoint_at (CORE_ADDR where) +bool +ppc_target::low_breakpoint_at (CORE_ADDR where) { unsigned int insn; - the_target->read_memory (where, (unsigned char *) &insn, 4); + read_memory (where, (unsigned char *) &insn, 4); if (insn == ppc_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } /* Implement supports_z_point_type target-ops. @@ -3408,7 +3410,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - ppc_breakpoint_at, ppc_supports_z_point_type, ppc_insert_point, ppc_remove_point, diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc index 701c4370a32..ace4eb6d5c0 100644 --- a/gdbserver/linux-riscv-low.cc +++ b/gdbserver/linux-riscv-low.cc @@ -59,6 +59,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -285,10 +287,10 @@ riscv_target::sw_breakpoint_from_kind (int kind, int *size) } } -/* Implementation of linux_target_ops method "breakpoint_at". */ +/* Implementation of linux target ops method "low_breakpoint_at". */ -static int -riscv_breakpoint_at (CORE_ADDR pc) +bool +riscv_target::low_breakpoint_at (CORE_ADDR pc) { union { @@ -297,21 +299,20 @@ riscv_breakpoint_at (CORE_ADDR pc) } buf; - if (target_read_memory (pc, buf.bytes, sizeof (buf.insn)) == 0 + if (read_memory (pc, buf.bytes, sizeof (buf.insn)) == 0 && (buf.insn == riscv_cbreakpoint || (buf.insn == riscv_ibreakpoint[0] - && target_read_memory (pc + sizeof (buf.insn), buf.bytes, - sizeof (buf.insn)) == 0 + && read_memory (pc + sizeof (buf.insn), buf.bytes, + sizeof (buf.insn)) == 0 && buf.insn == riscv_ibreakpoint[1]))) - return 1; + return true; else - return 0; + return false; } /* RISC-V/Linux target operations. */ struct linux_target_ops the_low_target = { - riscv_breakpoint_at, }; /* The linux target ops object. */ diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 68ab1ef7273..e296e3cf08d 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -79,6 +79,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -664,8 +666,8 @@ s390_target::low_arch_setup () } -static int -s390_breakpoint_at (CORE_ADDR pc) +bool +s390_target::low_breakpoint_at (CORE_ADDR pc) { unsigned char c[s390_breakpoint_len]; read_inferior_memory (pc, c, s390_breakpoint_len); @@ -2828,7 +2830,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_breakpoint_at, s390_supports_z_point_type, NULL, NULL, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index 7f55f34a0bc..174bd9cfe4f 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -44,6 +44,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -120,18 +122,18 @@ sh_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &sh_breakpoint; } -static int -sh_breakpoint_at (CORE_ADDR where) +bool +sh_target::low_breakpoint_at (CORE_ADDR where) { unsigned short insn; - the_target->read_memory (where, (unsigned char *) &insn, 2); + read_memory (where, (unsigned char *) &insn, 2); if (insn == sh_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } /* Support for hardware single step. */ @@ -192,7 +194,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - sh_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index 1998267196d..06c81702319 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -67,6 +67,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; /* No low_set_pc is needed. */ + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -280,20 +282,20 @@ sparc_target::sw_breakpoint_from_kind (int kind, int *size) return sparc_breakpoint; } -static int -sparc_breakpoint_at (CORE_ADDR where) +bool +sparc_target::low_breakpoint_at (CORE_ADDR where) { unsigned char insn[INSN_SIZE]; - the_target->read_memory (where, (unsigned char *) insn, sizeof (insn)); + read_memory (where, (unsigned char *) insn, sizeof (insn)); if (memcmp (sparc_breakpoint, insn, sizeof (insn)) == 0) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses TRAP Always. */ - return 0; + return false; } void @@ -341,7 +343,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - sparc_breakpoint_at, NULL, /* supports_z_point_type */ NULL, NULL, NULL, NULL, NULL, NULL diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 596177e0b20..a9d05c971fd 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -63,6 +63,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -273,18 +275,18 @@ tic6x_target::low_set_pc (regcache *regcache, CORE_ADDR pc) supply_register_by_name (regcache, "PC", newpc.buf); } -static int -tic6x_breakpoint_at (CORE_ADDR where) +bool +tic6x_target::low_breakpoint_at (CORE_ADDR where) { unsigned int insn; - the_target->read_memory (where, (unsigned char *) &insn, 4); + read_memory (where, (unsigned char *) &insn, 4); if (insn == tic6x_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } /* Fetch the thread-local storage pointer for libthread_db. */ @@ -423,7 +425,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - tic6x_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 40350e026c8..68e76a356a3 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -48,6 +48,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -129,18 +131,18 @@ tile_target::sw_breakpoint_from_kind (int kind, int *size) return (const gdb_byte *) &tile_breakpoint; } -static int -tile_breakpoint_at (CORE_ADDR where) +bool +tile_target::low_breakpoint_at (CORE_ADDR where) { uint64_t insn; - the_target->read_memory (where, (unsigned char *) &insn, 8); + read_memory (where, (unsigned char *) &insn, 8); if (insn == tile_breakpoint) - return 1; + return true; /* If necessary, recognize more trap instructions here. GDB only uses the one. */ - return 0; + return false; } static void @@ -224,7 +226,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - tile_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 121b367e5fc..f24e3912f37 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -123,6 +123,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -553,16 +555,16 @@ x86_target::low_set_pc (regcache *regcache, CORE_ADDR pc) static const gdb_byte x86_breakpoint[] = { 0xCC }; #define x86_breakpoint_len 1 -static int -x86_breakpoint_at (CORE_ADDR pc) +bool +x86_target::low_breakpoint_at (CORE_ADDR pc) { unsigned char c; - the_target->read_memory (pc, &c, 1); + read_memory (pc, &c, 1); if (c == 0xCC) - return 1; + return true; - return 0; + return false; } /* Low-level function vector. */ @@ -2901,7 +2903,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - x86_breakpoint_at, x86_supports_z_point_type, x86_insert_point, x86_remove_point, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index d4d0780d894..ef0ac89a469 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -45,6 +45,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + bool low_breakpoint_at (CORE_ADDR pc) override; }; /* The singleton target ops object. */ @@ -265,13 +267,12 @@ xtensa_target::sw_breakpoint_from_kind (int kind, int *size) return xtensa_breakpoint; } -static int -xtensa_breakpoint_at (CORE_ADDR where) +bool +xtensa_target::low_breakpoint_at (CORE_ADDR where) { unsigned long insn; - the_target->read_memory (where, (unsigned char *) &insn, - xtensa_breakpoint_len); + read_memory (where, (unsigned char *) &insn, xtensa_breakpoint_len); return memcmp((char *) &insn, xtensa_breakpoint, xtensa_breakpoint_len) == 0; } @@ -330,7 +331,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - xtensa_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */