From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3495 invoked by alias); 17 Jan 2003 15:12:50 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3484 invoked from network); 17 Jan 2003 15:12:48 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 17 Jan 2003 15:12:48 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 18Za3f-0008EJ-00 for ; Fri, 17 Jan 2003 11:13:31 -0600 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 18ZYAs-0004fl-00 for ; Fri, 17 Jan 2003 10:12:50 -0500 Date: Fri, 17 Jan 2003 15:12:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: RFC: PowerPC/Linux signal handlers Message-ID: <20030117151249.GA27317@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2003-01/txt/msg00640.txt.bz2 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 ----- Date: Thu, 16 Jan 2003 17:55:02 +1100 From: Anton Blanchard Subject: Bug#176963: gdb understand signal trampolines on ppc To: Debian Bug Tracking System Reply-To: Anton Blanchard , 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 #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