This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-7.11-branch] MIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=da611eed9a74de742e9436b6fdd92041b6e9bbf1

commit da611eed9a74de742e9436b6fdd92041b6e9bbf1
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Apr 15 23:52:00 2016 +0100

    MIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT
    
    This makes the MIPS Linux backends recognize TRAP_BRKPT and
    TRAP_HWBKPT in siginfo.si_code in addition to SI_KERNEL, since Linux
    4.6 now reports the finer-grained si_code values too.
    
    Refs:
     https://sourceware.org/ml/gdb-patches/2016-02/msg00756.html
     https://sourceware.org/ml/gdb-patches/2016-04/msg00090.html
    
    On kernels that report SI_KERNEL (<= 4.5), we'll enter the "ambiguous"
    path of save_stop_reason:
    
    	  if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
    	      && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
    	    {
    	      /* The si_code is ambiguous on this arch -- check debug
    		 registers.  */
    	      if (!check_stopped_by_watchpoint (lp))
    		lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
    	    }
    
    while on kernels that report the finer-grained si_code values (>= 4.6),
    we'll enter the corresponding branches:
    
    	  else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
    	    {
    	    }
    	  else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
    	    {
    	      ...
    
    gdb/ChangeLog:
    2016-04-15  Pedro Alves  <palves@redhat.com>
    
    	* nat/linux-ptrace.h [__mips__] (GDB_ARCH_IS_TRAP_BRKPT): Also
    	accept TRAP_BRKPT.
    	 [__mips__] (GDB_ARCH_IS_TRAP_HWBKPT): Also accept TRAP_HWBKPT.

Diff:
---
 gdb/ChangeLog          |  6 ++++++
 gdb/nat/linux-ptrace.h | 11 +++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9d9355..de9ea3a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2016-04-15  Pedro Alves  <palves@redhat.com>
 
+	* nat/linux-ptrace.h [__mips__] (GDB_ARCH_IS_TRAP_BRKPT): Also
+	accept TRAP_BRKPT.
+	 [__mips__] (GDB_ARCH_IS_TRAP_HWBKPT): Also accept TRAP_HWBKPT.
+
+2016-04-15  Pedro Alves  <palves@redhat.com>
+
 	* linux-nat.c (save_sigtrap) Delete.
 	(stop_wait_callback): Call save_stop_reason instead of
 	save_sigtrap.
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index b9123c9..0a23bcb 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -140,8 +140,8 @@ struct buffer;
    in SPU code on a Cell/B.E.  However, SI_KERNEL is never seen
    on a SIGTRAP for any other reason.
 
-   The MIPS kernel uses SI_KERNEL for all kernel generated traps.
-   Since:
+   The MIPS kernel up until 4.5 used SI_KERNEL for all kernel
+   generated traps.  Since:
 
      - MIPS doesn't do hardware single-step.
      - We don't need to care about exec SIGTRAPs --- we assume
@@ -152,6 +152,9 @@ struct buffer;
    software breakpoints and hardware watchpoints, which can be done by
    peeking the debug registers.
 
+   Beginning with Linux 4.6, the MIPS port reports proper TRAP_BRKPT and
+   TRAP_HWBKPT codes, so we also match them.
+
    The generic Linux target code should use GDB_ARCH_IS_TRAP_* instead
    of TRAP_* to abstract out these peculiarities.  */
 #if defined __i386__ || defined __x86_64__
@@ -161,8 +164,8 @@ struct buffer;
 # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
 # define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)
 #elif defined __mips__
-# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL)
-# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL)
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL || (X) == TRAP_HWBKPT)
 #else
 # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT)
 # define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]