From benh@kernel.crashing.org Thu Jan 16 06:59:08 2003
Return-Path: <benh@kernel.crashing.org>
Delivered-To: dburcaw@terraplex.com
Received: from zion.wanadoo.fr (unknown [217.167.51.129]) by
	newhope.terraplex.com (Postfix) with ESMTP id 1964D1FAA7 for
	<dburcaw@terrasoftsolutions.com>; Thu, 16 Jan 2003 06:59:08 -0700 (MST)
Received: from benh by zion.wanadoo.fr with local (Exim 3.36 #1 (Debian))
	id 18ZAaZ-0000Jm-00 for <dburcaw@terrasoftsolutions.com>; Thu, 16 Jan 2003
	15:01:47 +0100
Subject: [Fwd: gdb patch]
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Dan Burcaw <dburcaw@terrasoftsolutions.com>
Content-Type: text/plain
Organization: 
Message-Id: <1042725707.1144.2.camel@zion.wanadoo.fr>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.2.0 
Date: 16 Jan 2003 15:01:47 +0100
Sender: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Status:  O
X-Evolution-Source: pop://dburcaw@66.7.161.3
Content-Transfer-Encoding: 8bit

-----Forwarded Message-----

From: Anton Blanchard <anton@samba.org>
To: benh@kernel.crashing.org
Subject: gdb patch
Date: 16 Jan 2003 20:20:54 +1100


diff -ru gdb-5.3_orig/gdb/ppc-linux-tdep.c gdb-5.3/gdb/ppc-linux-tdep.c
--- gdb-5.3_orig/gdb/ppc-linux-tdep.c	2002-07-31 05:03:49.000000000 +1000
+++ gdb-5.3/gdb/ppc-linux-tdep.c	2003-01-16 17:44:38.000000000 +1100
@@ -35,10 +35,16 @@
 #include "solib-svr4.h"
 #include "ppc-tdep.h"
 
-/* The following two instructions are used in the signal trampoline
-   code on GNU/Linux PPC.  */
-#define INSTR_LI_R0_0x7777	0x38007777
-#define INSTR_SC		0x44000002
+/* The following instructions are used in the signal trampoline
+   code on GNU/Linux PPC. The kernel used to use magic syscalls
+   0x6666 and 0x7777 but now uses the sigreturn syscalls. We
+   check for both. */
+#define INSTR_LI_R0_0x6666		0x38006666
+#define INSTR_LI_R0_0x7777		0x38007777
+#define INSTR_LI_R0_NR_sigreturn	0x38000077
+#define INSTR_LI_R0_NR_rt_sigreturn	0x380000AC
+
+#define INSTR_SC			0x44000002
 
 /* Since the *-tdep.c files are platform independent (i.e, they may be
    used to build cross platform debuggers), we can't include system
@@ -177,6 +183,25 @@
   return (pc == handler || pc == handler + 4);
 }
 
+static inline int insn_is_sigreturn(unsigned int pcinsn)
+{
+	int result;
+
+	switch(pcinsn) {
+		case INSTR_LI_R0_0x6666:
+		case INSTR_LI_R0_0x7777:
+		case INSTR_LI_R0_NR_sigreturn:
+		case INSTR_LI_R0_NR_rt_sigreturn:
+			result = 1;
+			break;
+		default:
+			result = 0;
+			break;
+	}
+
+	return result;
+}
+
 /*
  * The signal handler trampoline is on the stack and consists of exactly
  * two instructions.  The easiest and most accurate way of determining
@@ -196,11 +221,11 @@
   pcinsn = extract_unsigned_integer (buf + 4, 4);
 
   return (
-	   (pcinsn == INSTR_LI_R0_0x7777
+	   (insn_is_sigreturn (pcinsn)
 	    && extract_unsigned_integer (buf + 8, 4) == INSTR_SC)
 	   ||
 	   (pcinsn == INSTR_SC
-	    && extract_unsigned_integer (buf, 4) == INSTR_LI_R0_0x7777));
+	    && insn_is_sigreturn (extract_unsigned_integer (buf, 4))));
 }
 
 CORE_ADDR
-- 
Benjamin Herrenschmidt <benh@kernel.crashing.org>
