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] Detect SW breakpoints in Cell/B.E. combined debugging


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

commit 1db33b5a028820d1eb656bffff727090a5504253
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date:   Thu Aug 27 19:20:29 2015 +0200

    Detect SW breakpoints in Cell/B.E. combined debugging
    
    The Linux target and gdbserver now check the siginfo si_code
    reported on a SIGTRAP to detect whether the trap indicates
    a software breakpoint was hit.
    
    Unfortunately, on Cell/B.E., the kernel uses an si_code value
    of TRAP_BRKPT when a SW breakpoint was hit in PowerPC code,
    but a si_code value of SI_KERNEL when a SW breakpoint was
    hit in SPU code.
    
    This patch updates Linux target and gdbserver to accept both
    si_code values to indicate SW breakpoint on PowerPC.
    
    ChangeLog:
    
    	* nat/linux-ptrace.h (GDB_ARCH_TRAP_BRKPT): Replace by ...
    	(GDB_ARCH_IS_TRAP_BRKPT): ... this.  Add __powerpc__ case.
    	* linux-nat.c (check_stopped_by_breakpoint): Use
    	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
    
    gdbserver/ChangeLog:
    
    	* linux-low.c (check_stopped_by_breakpoint): Use
    	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.

Diff:
---
 gdb/ChangeLog             |  7 +++++++
 gdb/gdbserver/ChangeLog   |  5 +++++
 gdb/gdbserver/linux-low.c |  2 +-
 gdb/linux-nat.c           |  2 +-
 gdb/nat/linux-ptrace.h    | 15 +++++++++++----
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8319083..61e9851 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2015-08-08  Ulrich Weigand  <uweigand@de.ibm.com>
 
+	* nat/linux-ptrace.h (GDB_ARCH_TRAP_BRKPT): Replace by ...
+	(GDB_ARCH_IS_TRAP_BRKPT): ... this.  Add __powerpc__ case.
+	* linux-nat.c (check_stopped_by_breakpoint): Use
+	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
+
+2015-08-08  Ulrich Weigand  <uweigand@de.ibm.com>
+
 	* linux-thread-db.c (thread_db_get_thread_local_address): If the
 	thread was not yet discovered, use thread_from_lwp instead of
 	calling thread_db_find_new_threads_1.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 0be3030..cc733d8 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-27  Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
+
+	* linux-low.c (check_stopped_by_breakpoint): Use
+	GDB_ARCH_IS_TRAP_BRKPT instead of GDB_ARCH_TRAP_BRKPT.
+
 2015-08-27  Pedro Alves  <palves@redhat.com>
 
 	* proc-service.c (ps_pdwrite): Return PS_ERR/PS_OK explicily.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index a8fa91c..f4c6029 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -651,7 +651,7 @@ check_stopped_by_breakpoint (struct lwp_info *lwp)
     {
       if (siginfo.si_signo == SIGTRAP)
 	{
-	  if (siginfo.si_code == GDB_ARCH_TRAP_BRKPT)
+	  if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
 	    {
 	      if (debug_threads)
 		{
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 4da361d..51541d5 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2801,7 +2801,7 @@ check_stopped_by_breakpoint (struct lwp_info *lp)
     {
       if (siginfo.si_signo == SIGTRAP)
 	{
-	  if (siginfo.si_code == GDB_ARCH_TRAP_BRKPT)
+	  if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
 	    {
 	      if (debug_linux_nat)
 		fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 41f668c..8bff908 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -135,12 +135,19 @@ struct buffer;
    running to a breakpoint and checking what comes out of
    siginfo->si_code.
 
-   The generic Linux target code should use GDB_ARCH_TRAP_BRKPT
-   instead of TRAP_BRKPT to abstract out this x86 peculiarity.  */
+   The ppc kernel does use TRAP_BRKPT for software breakpoints
+   in PowerPC code, but it uses SI_KERNEL for software breakpoints
+   in SPU code on a Cell/B.E.  However, SI_KERNEL is never seen
+   on a SIGTRAP for any other reason.
+
+   The generic Linux target code should use GDB_ARCH_IS_TRAP_BRKPT
+   instead of TRAP_BRKPT to abstract out these peculiarities.  */
 #if defined __i386__ || defined __x86_64__
-# define GDB_ARCH_TRAP_BRKPT SI_KERNEL
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL)
+#elif defined __powerpc__
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
 #else
-# define GDB_ARCH_TRAP_BRKPT TRAP_BRKPT
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT)
 #endif
 
 #ifndef TRAP_HWBKPT


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