Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: PowerPC/Linux signal handlers
@ 2003-01-17 15:12 Daniel Jacobowitz
  2003-01-17 18:55 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-01-17 15:12 UTC (permalink / raw)
  To: gdb-patches

Kevin, any comments on this patch?

[From a copyright perspective I think it's OK; this is an obvious patch
once someone tells us that the used syscall numbers have changed. 
Anyone have a different opinion?]

----- Forwarded message from Anton Blanchard <anton@samba.org> -----

Date: Thu, 16 Jan 2003 17:55:02 +1100
From: Anton Blanchard <anton@samba.org>
Subject: Bug#176963: gdb understand signal trampolines on ppc
To: Debian Bug Tracking System <submit@bugs.debian.org>
Reply-To: Anton Blanchard <anton@samba.org>, 176963@bugs.debian.org

Package: gdb
Version: 5.3-2
Severity: normal
Tags: patch

Hi,

gdb looks for the old li r0,0x7777 instruction when matching signal
trampolines. This means it only works for old kernels and only for non
rt signals. The following patch makes it look for non rt and rt signals
as well as old and new kernels.

eg I set a breakpoint on a signal handler function.

before:

Breakpoint 1, foohandler (sig=10) at /home/anton/signaltest.c:5
5		printf("in handler\n");
(gdb) bt
#0  foohandler (sig=10) at /home/anton/signaltest.c:5
#1  0xffffebf8 in ?? ()

and with the patch below:

Breakpoint 1, foohandler (sig=10) at /home/anton/signaltest.c:5
5		printf("in handler\n");
(gdb) bt
#0  foohandler (sig=10) at /home/anton/signaltest.c:5
#1  <signal handler called>
#2  0x0feda0f0 in kill () from /lib/libc.so.6
#3  0x0fed9f10 in raise () from /lib/libc.so.6
#4  0x10000508 in main () at /home/anton/signaltest.c:11
#5  0x0fec3e24 in __libc_start_main () from /lib/libc.so.6

-- System Information:
Debian Release: testing/unstable
Architecture: powerpc
Kernel: Linux krispykreme 2.4.20-pre4 #229 Wed Aug 28 16:09:40 EST 2002 ppc
Locale: LANG=C, LC_CTYPE=C

Versions of packages gdb depends on:
ii  libc6                     2.3.1-9        GNU C Library: Shared libraries an
ii  libncurses5               5.3.20021109-2 Shared libraries for terminal hand
ii  libreadline4              4.3-4          GNU readline and history libraries

-- no debconf information

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



----- End forwarded message -----

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: PowerPC/Linux signal handlers
  2003-01-17 15:12 RFC: PowerPC/Linux signal handlers Daniel Jacobowitz
@ 2003-01-17 18:55 ` Kevin Buettner
  2003-02-04 18:21   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-01-17 18:55 UTC (permalink / raw)
  To: Daniel Jacobowitz, gdb-patches

On Jan 17, 10:12am, Daniel Jacobowitz wrote:

> Kevin, any comments on this patch?

It's fine with me so long as the new function is indented to adhere to
GNU coding standards.

> [From a copyright perspective I think it's OK; this is an obvious patch
> once someone tells us that the used syscall numbers have changed. 
> Anyone have a different opinion?]

I agree, but wait a few days for dissenting opinions.

Kevin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: PowerPC/Linux signal handlers
  2003-01-17 18:55 ` Kevin Buettner
@ 2003-02-04 18:21   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-02-04 18:21 UTC (permalink / raw)
  To: gdb-patches

On Fri, Jan 17, 2003 at 09:55:31AM -0700, Kevin Buettner wrote:
> On Jan 17, 10:12am, Daniel Jacobowitz wrote:
> 
> > Kevin, any comments on this patch?
> 
> It's fine with me so long as the new function is indented to adhere to
> GNU coding standards.
> 
> > [From a copyright perspective I think it's OK; this is an obvious patch
> > once someone tells us that the used syscall numbers have changed. 
> > Anyone have a different opinion?]
> 
> I agree, but wait a few days for dissenting opinions.

I've checked this in.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-04 18:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-17 15:12 RFC: PowerPC/Linux signal handlers Daniel Jacobowitz
2003-01-17 18:55 ` Kevin Buettner
2003-02-04 18:21   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox