From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 0A48C3858D20; Wed, 17 Apr 2024 17:24:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A48C3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713374675; bh=832pJ02Ei4AgFxCl2Gb7qyyFW/j/Ufr53adfTf142nM=; h=From:To:Subject:Date:From; b=EQokPoI+ZjtTuBQXAg1zlUI6hPpq54sVn7TzLnEd9A7lwwKanjnXVNGlMLvbYeHo3 5ui3L+vTNuAVh5oXu7e+Wu4EUahz7V/YJQsdZQ5vDP9uN3lpkc6afK4rPy787Hkuf2 0oi1uQVdRmufZOT2QzXQ7Qrt7yPh+Lfavhp5WN4s= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb+gdbserver/Linux: Remove USE_SIGTRAP_SIGINFO fallback X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: c7d73a715775ade814370212726d50ab4b7c6fe0 X-Git-Newrev: 5739a1b98daf68fd81fed9af9667a2b9671928f9 Message-Id: <20240417172435.0A48C3858D20@sourceware.org> Date: Wed, 17 Apr 2024 17:24:35 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5739a1b98daf= 68fd81fed9af9667a2b9671928f9 commit 5739a1b98daf68fd81fed9af9667a2b9671928f9 Author: Pedro Alves Date: Wed Apr 17 18:20:35 2024 +0100 gdb+gdbserver/Linux: Remove USE_SIGTRAP_SIGINFO fallback =20 It's been over 9 years (since commit faf09f0119da) since Linux GDB and GDBserver started relying on SIGTRAP si_code to tell whether a breakpoint triggered, which is important for non-stop mode. When that then-new code was added, I had left the then-old code as fallback, in case some architectured still needed it. Given AFAIK there haven't been complaints since, this commit finally removes the fallback code, along with USE_SIGTRAP_SIGINFO. =20 Change-Id: I140a5333a9fe70e90dbd186aca1f081549b2e63d Diff: --- gdb/linux-nat.c | 53 ++--------------------------------------------= ---- gdb/nat/linux-ptrace.h | 11 ++++------- gdbserver/linux-low.cc | 39 ++----------------------------------- 3 files changed, 8 insertions(+), 95 deletions(-) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 42051f218b3..55cab41bb61 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2633,18 +2633,6 @@ status_callback (struct lwp_info *lp) discard =3D 1; } =20 -#if !USE_SIGTRAP_SIGINFO - else if (!breakpoint_inserted_here_p (lwp_inferior (lp)->aspace, pc)) - { - linux_nat_debug_printf ("previous breakpoint of %s, at %s gone", - lp->ptid.to_string ().c_str (), - paddress (current_inferior ()->arch (), - lp->stop_pc)); - - discard =3D 1; - } -#endif - if (discard) { linux_nat_debug_printf ("pending event of %s cancelled.", @@ -2724,9 +2712,7 @@ save_stop_reason (struct lwp_info *lp) struct gdbarch *gdbarch; CORE_ADDR pc; CORE_ADDR sw_bp_pc; -#if USE_SIGTRAP_SIGINFO siginfo_t siginfo; -#endif =20 gdb_assert (lp->stop_reason =3D=3D TARGET_STOPPED_BY_NO_REASON); gdb_assert (lp->status !=3D 0); @@ -2744,7 +2730,6 @@ save_stop_reason (struct lwp_info *lp) pc =3D regcache_read_pc (regcache); sw_bp_pc =3D pc - gdbarch_decr_pc_after_break (gdbarch); =20 -#if USE_SIGTRAP_SIGINFO if (linux_nat_get_siginfo (lp->ptid, &siginfo)) { if (siginfo.si_signo =3D=3D SIGTRAP) @@ -2787,21 +2772,6 @@ save_stop_reason (struct lwp_info *lp) } } } -#else - if ((!lp->step || lp->stop_pc =3D=3D sw_bp_pc) - && software_breakpoint_inserted_here_p (inf->aspace, sw_bp_pc)) - { - /* The LWP was either continued, or stepped a software - breakpoint instruction. */ - lp->stop_reason =3D TARGET_STOPPED_BY_SW_BREAKPOINT; - } - - if (hardware_breakpoint_inserted_here_p (inf->aspace, pc)) - lp->stop_reason =3D TARGET_STOPPED_BY_HW_BREAKPOINT; - - if (lp->stop_reason =3D=3D TARGET_STOPPED_BY_NO_REASON) - check_stopped_by_watchpoint (lp); -#endif =20 if (lp->stop_reason =3D=3D TARGET_STOPPED_BY_SW_BREAKPOINT) { @@ -2847,7 +2817,7 @@ linux_nat_target::stopped_by_sw_breakpoint () bool linux_nat_target::supports_stopped_by_sw_breakpoint () { - return USE_SIGTRAP_SIGINFO; + return true; } =20 /* Returns true if the LWP had stopped for a hardware @@ -2868,7 +2838,7 @@ linux_nat_target::stopped_by_hw_breakpoint () bool linux_nat_target::supports_stopped_by_hw_breakpoint () { - return USE_SIGTRAP_SIGINFO; + return true; } =20 /* Select one LWP out of those that have events pending. */ @@ -3461,25 +3431,6 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitsta= tus *ourstatus, =20 gdb_assert (lp !=3D NULL); =20 - /* Now that we've selected our final event LWP, un-adjust its PC if - it was a software breakpoint, and we can't reliably support the - "stopped by software breakpoint" stop reason. */ - if (lp->stop_reason =3D=3D TARGET_STOPPED_BY_SW_BREAKPOINT - && !USE_SIGTRAP_SIGINFO) - { - struct regcache *regcache =3D get_thread_regcache (linux_target, lp-= >ptid); - struct gdbarch *gdbarch =3D regcache->arch (); - int decr_pc =3D gdbarch_decr_pc_after_break (gdbarch); - - if (decr_pc !=3D 0) - { - CORE_ADDR pc; - - pc =3D regcache_read_pc (regcache); - regcache_write_pc (regcache, pc + decr_pc); - } - } - /* We'll need this to determine whether to report a SIGSTOP as GDB_SIGNAL_0. Need to take a copy because resume_clear_callback clears it. */ diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h index a268432ad92..a3b4ca8d176 100644 --- a/gdb/nat/linux-ptrace.h +++ b/gdb/nat/linux-ptrace.h @@ -95,9 +95,9 @@ #define __WALL 0x40000000 /* Wait for any child. */ #endif =20 -/* True if whether a breakpoint/watchpoint triggered can be determined - from the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT). - That is, if the kernel can tell us whether the thread executed a +/* Whether a breakpoint/watchpoint triggered can be determined from + the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT). That + is, since the kernel can tell us whether the thread executed a software breakpoint, we trust it. The kernel will be determining that from the hardware (e.g., from which exception was raised in the CPU). Relying on whether a breakpoint is planted in memory at @@ -110,10 +110,7 @@ architectures. The moribund location mechanism helps with that somewhat but it is an heuristic, and can well fail. Getting that information out of the kernel and ultimately out of the CPU is the - way to go. That said, some architecture may get the si_code wrong, - and as such we're leaving fallback code in place. We'll remove - this after a while if no problem is reported. */ -#define USE_SIGTRAP_SIGINFO 1 + way to go. */ =20 /* The x86 kernel gets some of the si_code values backwards, like this: diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index d8842f0972d..9614cd7150c 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -824,9 +824,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) { CORE_ADDR pc; CORE_ADDR sw_breakpoint_pc; -#if USE_SIGTRAP_SIGINFO siginfo_t siginfo; -#endif =20 if (!low_supports_breakpoints ()) return false; @@ -846,7 +844,6 @@ linux_process_target::save_stop_reason (lwp_info *lwp) scoped_restore_current_thread restore_thread; switch_to_thread (get_lwp_thread (lwp)); =20 -#if USE_SIGTRAP_SIGINFO if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), (PTRACE_TYPE_ARG3) 0, &siginfo) =3D=3D 0) { @@ -888,21 +885,6 @@ linux_process_target::save_stop_reason (lwp_info *lwp) } } } -#else - /* We may have just stepped a breakpoint instruction. E.g., in - non-stop mode, GDB first tells the thread A to step a range, and - 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 =3D=3D sw_breakpoint_pc) - && low_breakpoint_at (sw_breakpoint_pc)) - lwp->stop_reason =3D TARGET_STOPPED_BY_SW_BREAKPOINT; - - if (hardware_breakpoint_inserted_here (pc)) - lwp->stop_reason =3D TARGET_STOPPED_BY_HW_BREAKPOINT; - - if (lwp->stop_reason =3D=3D TARGET_STOPPED_BY_NO_REASON) - check_stopped_by_watchpoint (lwp); -#endif =20 if (lwp->stop_reason =3D=3D TARGET_STOPPED_BY_SW_BREAKPOINT) { @@ -1704,23 +1686,6 @@ linux_process_target::thread_still_has_status_pendin= g (thread_info *thread) discard =3D 1; } =20 -#if !USE_SIGTRAP_SIGINFO - else if (lp->stop_reason =3D=3D TARGET_STOPPED_BY_SW_BREAKPOINT - && !low_breakpoint_at (pc)) - { - threads_debug_printf ("previous SW breakpoint of %ld gone", - lwpid_of (thread)); - discard =3D 1; - } - else if (lp->stop_reason =3D=3D TARGET_STOPPED_BY_HW_BREAKPOINT - && !hardware_breakpoint_inserted_here (pc)) - { - threads_debug_printf ("previous HW breakpoint of %ld gone", - lwpid_of (thread)); - discard =3D 1; - } -#endif - if (discard) { threads_debug_printf ("discarding pending breakpoint status"); @@ -5652,7 +5617,7 @@ linux_process_target::stopped_by_sw_breakpoint () bool linux_process_target::supports_stopped_by_sw_breakpoint () { - return USE_SIGTRAP_SIGINFO; + return true; } =20 /* Implement the stopped_by_hw_breakpoint target_ops @@ -5672,7 +5637,7 @@ linux_process_target::stopped_by_hw_breakpoint () bool linux_process_target::supports_stopped_by_hw_breakpoint () { - return USE_SIGTRAP_SIGINFO; + return true; } =20 /* Implement the supports_hardware_single_step target_ops method. */