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 | bf9ae9d8c37a4e1dfd192f266c20ea5786fd1bbd (patch) | |
tree | 4d2f804cb70628cc5880077267d5681a54d52e56 /gdbserver/linux-low.cc | |
parent | df95181f00dacf335deb4415e3e6061548b917ba (diff) | |
download | gdb-bf9ae9d8c37a4e1dfd192f266c20ea5786fd1bbd.zip gdb-bf9ae9d8c37a4e1dfd192f266c20ea5786fd1bbd.tar.gz gdb-bf9ae9d8c37a4e1dfd192f266c20ea5786fd1bbd.tar.bz2 |
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods
gdbserver/ChangeLog:
2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Turn the 'get_pc' and 'set_pc' linux target ops into methods
of linux_process_target.
* linux-low.h (struct linux_target_ops): Remove the ops.
(class linux_process_target) <low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
* linux-low.cc (supports_breakpoints): Turn into...
(linux_process_target::low_supports_breakpoints): ...this.
(linux_process_target::low_get_pc): Define.
(linux_process_target::low_set_pc): Define.
Update the callers below.
(linux_process_target::get_pc)
(linux_process_target::save_stop_reason)
(linux_process_target::maybe_move_out_of_jump_pad)
(linux_process_target::wait_1)
(linux_process_target::resume_one_lwp_throw)
(linux_process_target::resume)
(linux_process_target::proceed_all_lwps)
(linux_process_target::read_pc)
(linux_process_target::write_pc)
* linux-x86-low.cc (class linux_process_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(x86_target::low_supports_breakpoints): Define.
(x86_get_pc): Turn into...
(x86_target::low_get_pc): ...this.
(x86_set_pc): Turn into...
(x86_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-arm-low.cc (class arm_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(arm_target::low_supports_breakpoints)
(arm_target::low_get_pc)
(arm_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-bfin-low.cc (class bfin_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(bfin_target::low_supports_breakpoints)
(bfin_target::low_get_pc)
(bfin_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-cris-low.cc (class cris_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(cris_target::low_supports_breakpoints)
(cris_target::low_get_pc)
(cris_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-crisv32-low.cc (class crisv32_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(crisv32_target::low_supports_breakpoints)
(crisv32_target::low_get_pc)
(crisv32_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-m32r-low.cc (class m32r_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(m32r_target::low_supports_breakpoints)
(m32r_target::low_get_pc)
(m32r_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-m68k-low.cc (class m68k_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(m68k_target::low_supports_breakpoints)
(m68k_target::low_get_pc)
(m68k_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-nios2-low.cc (class nios2_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(nios2_target::low_supports_breakpoints)
(nios2_target::low_get_pc)
(nios2_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-sh-low.cc (class sh_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(sh_target::low_supports_breakpoints)
(sh_target::low_get_pc)
(sh_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-xtensa-low.cc (class xtensa_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(xtensa_target::low_supports_breakpoints)
(xtensa_target::low_get_pc)
(xtensa_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-sparc-low.cc (class sparc_target)
<low_supports_breakpoints>
<low_get_pc>: Declare.
(sparc_target::low_supports_breakpoints)
(sparc_target::low_get_pc): Define.
(the_low_target): Remove the op fields.
* linux-tile-low.cc (class tile_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(tile_target::low_supports_breakpoints)
(tile_target::low_get_pc)
(tile_target::low_set_pc): Define.
(the_low_target): Remove the op fields.
* linux-aarch64-low.cc (class aarch64_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(aarch64_target::low_supports_breakpoints): Define.
(aarch64_get_pc): Turn into...
(aarch64_target::low_get_pc): ...this.
(aarch64_set_pc): Turn into...
(aarch64_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-mips-low.cc (class mips_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(mips_target::low_supports_breakpoints): Define.
(mips_get_pc): Turn into...
(mips_target::low_get_pc): ...this.
(mips_set_pc): Turn into...
(mips_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-ppc-low.cc (class ppc_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(ppc_target::low_supports_breakpoints): Define.
(ppc_get_pc): Turn into...
(ppc_target::low_get_pc): ...this.
(ppc_set_pc): Turn into...
(ppc_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-riscv-low.cc (class riscv_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(riscv_target::low_supports_breakpoints): Define.
(riscv_get_pc): Turn into...
(riscv_target::low_get_pc): ...this.
(riscv_set_pc): Turn into...
(riscv_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-s390-low.cc (class s390_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(s390_target::low_supports_breakpoints): Define.
(s390_get_pc): Turn into...
(s390_target::low_get_pc): ...this.
(s390_set_pc): Turn into...
(s390_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
* linux-tic6x-low.cc (class tic6x_target)
<low_supports_breakpoints>
<low_get_pc>
<low_set_pc>: Declare.
(tic6x_target::low_supports_breakpoints): Define.
(tic6x_get_pc): Turn into...
(tic6x_target::low_get_pc): ...this.
(tic6x_set_pc): Turn into...
(tic6x_target::low_set_pc): ...this.
(the_low_target): Remove the op fields.
Diffstat (limited to 'gdbserver/linux-low.cc')
-rw-r--r-- | gdbserver/linux-low.cc | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 65edde8..47b2ef9 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -301,13 +301,22 @@ can_software_single_step (void) return (the_low_target.get_next_pcs != NULL); } -/* True if the low target supports memory breakpoints. If so, we'll - have a GET_PC implementation. */ +bool +linux_process_target::low_supports_breakpoints () +{ + return false; +} -static int -supports_breakpoints (void) +CORE_ADDR +linux_process_target::low_get_pc (regcache *regcache) +{ + return 0; +} + +void +linux_process_target::low_set_pc (regcache *regcache, CORE_ADDR newpc) { - return (the_low_target.get_pc != NULL); + gdb_assert_not_reached ("linux target op low_set_pc is not implemented"); } /* Returns true if this target can support fast tracepoints. This @@ -728,14 +737,14 @@ linux_process_target::get_pc (lwp_info *lwp) struct regcache *regcache; CORE_ADDR pc; - if (the_low_target.get_pc == NULL) + if (!low_supports_breakpoints ()) return 0; saved_thread = current_thread; current_thread = get_lwp_thread (lwp); regcache = get_thread_regcache (current_thread, 1); - pc = (*the_low_target.get_pc) (regcache); + pc = low_get_pc (regcache); if (debug_threads) debug_printf ("pc is 0x%lx\n", (long) pc); @@ -785,7 +794,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) siginfo_t siginfo; #endif - if (the_low_target.get_pc == NULL) + if (!low_supports_breakpoints ()) return false; pc = get_pc (lwp); @@ -868,7 +877,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) { struct regcache *regcache = get_thread_regcache (current_thread, 1); - (*the_low_target.set_pc) (regcache, sw_breakpoint_pc); + low_set_pc (regcache, sw_breakpoint_pc); } /* Update this so we record the correct stop PC below. */ @@ -2092,7 +2101,7 @@ linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat) } regcache = get_thread_regcache (current_thread, 1); - (*the_low_target.set_pc) (regcache, status.tpoint_addr); + low_set_pc (regcache, status.tpoint_addr); lwp->stop_pc = status.tpoint_addr; /* Cancel any fast tracepoint lock this thread was @@ -3170,7 +3179,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, = get_thread_regcache (current_thread, 1); event_child->stop_pc += increment_pc; - (*the_low_target.set_pc) (regcache, event_child->stop_pc); + low_set_pc (regcache, event_child->stop_pc); if (!(*the_low_target.breakpoint_at) (event_child->stop_pc)) event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON; @@ -3183,7 +3192,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, not support internal breakpoints at all, we also report the SIGTRAP without further processing; it's of no concern to us. */ maybe_internal_trap - = (supports_breakpoints () + = (low_supports_breakpoints () && (WSTOPSIG (w) == SIGTRAP || ((WSTOPSIG (w) == SIGILL || WSTOPSIG (w) == SIGSEGV) @@ -3478,11 +3487,11 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, decr_pc_after_break adjustment to the inferior's regcache ourselves. */ - if (the_low_target.set_pc != NULL) + if (low_supports_breakpoints ()) { struct regcache *regcache = get_thread_regcache (current_thread, 1); - (*the_low_target.set_pc) (regcache, event_child->stop_pc); + low_set_pc (regcache, event_child->stop_pc); } if (step_over_finished) @@ -3693,7 +3702,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, { struct regcache *regcache = get_thread_regcache (current_thread, 1); - (*the_low_target.set_pc) (regcache, event_child->stop_pc + decr_pc); + low_set_pc (regcache, event_child->stop_pc + decr_pc); } } @@ -4285,11 +4294,11 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, step = single_step (lwp); } - if (proc->tdesc != NULL && the_low_target.get_pc != NULL) + if (proc->tdesc != NULL && low_supports_breakpoints ()) { struct regcache *regcache = get_thread_regcache (current_thread, 1); - lwp->stop_pc = (*the_low_target.get_pc) (regcache); + lwp->stop_pc = low_get_pc (regcache); if (debug_threads) { @@ -4915,7 +4924,7 @@ linux_process_target::resume (thread_resume *resume_info, size_t n) other threads stopped, then resume all threads again. Make sure to queue any signals that would otherwise be delivered or queued. */ - if (!any_pending && supports_breakpoints ()) + if (!any_pending && low_supports_breakpoints ()) need_step_over = find_thread ([this] (thread_info *thread) { return thread_needs_step_over (thread); @@ -5077,7 +5086,7 @@ linux_process_target::proceed_all_lwps () resume any threads - have it step over the breakpoint with all other threads stopped, then resume all threads again. */ - if (supports_breakpoints ()) + if (low_supports_breakpoints ()) { need_step_over = find_thread ([this] (thread_info *thread) { @@ -6453,18 +6462,18 @@ linux_process_target::supports_tracepoints () CORE_ADDR linux_process_target::read_pc (regcache *regcache) { - if (the_low_target.get_pc == NULL) + if (!low_supports_breakpoints ()) return 0; - return (*the_low_target.get_pc) (regcache); + return low_get_pc (regcache); } void linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc) { - gdb_assert (the_low_target.set_pc != NULL); + gdb_assert (low_supports_breakpoints ()); - (*the_low_target.set_pc) (regcache, pc); + low_set_pc (regcache, pc); } bool |