From patchwork Fri May 6 08:51:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Werner X-Patchwork-Id: 1366 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:51:27 -0000 Delivered-To: patches@linaro.org Received: by 10.224.184.145 with SMTP id ck17cs131260qab; Fri, 6 May 2011 01:51:42 -0700 (PDT) Received: by 10.216.145.200 with SMTP id p50mr4400244wej.79.1304671901537; Fri, 06 May 2011 01:51:41 -0700 (PDT) Received: from mtagate2.uk.ibm.com (mtagate2.uk.ibm.com [194.196.100.162]) by mx.google.com with ESMTPS id m10si8233878wbm.90.2011.05.06.01.51.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 May 2011 01:51:40 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) client-ip=194.196.100.162; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of ken.werner@linaro.org) smtp.mail=ken.werner@linaro.org Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p468pdFM003258 for ; Fri, 6 May 2011 08:51:39 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p468qpT51953936 for ; Fri, 6 May 2011 09:52:51 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p468pcho007841 for ; Fri, 6 May 2011 02:51:38 -0600 Received: from localhost.localdomain (dyn-9-152-224-51.boeblingen.de.ibm.com [9.152.224.51]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p468pb1Y007777; Fri, 6 May 2011 02:51:37 -0600 From: Ken Werner To: libunwind-devel@nongnu.org Subject: [PATCH 1/2] Add support for RT signal frame detection on ARM. Date: Fri, 6 May 2011 10:51:26 +0200 Message-Id: <1304671887-696-2-git-send-email-ken.werner@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1304671887-696-1-git-send-email-ken.werner@linaro.org> References: <1304671887-696-1-git-send-email-ken.werner@linaro.org> This patch adds a few more patterns to the check that detects if the IP points to a sigreturn sequence. Signed-off-by: Ken Werner --- src/arm/Gis_signal_frame.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/arm/Gis_signal_frame.c b/src/arm/Gis_signal_frame.c index e472185..284289f 100644 --- a/src/arm/Gis_signal_frame.c +++ b/src/arm/Gis_signal_frame.c @@ -29,11 +29,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef __linux__ #include +/* ARM EABI sigreturn (the syscall number is loaded into r7) */ +#define MOV_R7_SIGRETURN (0xe3a07000UL | __NR_sigreturn) +#define MOV_R7_RT_SIGRETURN (0xe3a07000UL | __NR_rt_sigreturn) + +/* ARM OABI sigreturn (using SWI) */ #define ARM_SIGRETURN (0xef000000UL |(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)) -#define THUMB_SIGRETURN (0xdf00UL << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE)) -#define MOV_R7_SIGRETURN (0xe3a07000UL | (__NR_sigreturn - __NR_SYSCALL_BASE)) +#define ARM_RT_SIGRETURN (0xef000000UL |(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)) + +/* Thumb sigreturn (two insns, syscall number is loaded into r7) */ +#define THUMB_SIGRETURN (0xdf00UL << 16 | 0x2700 | __NR_sigreturn) +#define THUMB_RT_SIGRETURN (0xdf00UL << 16 | 0x2700 | __NR_rt_sigreturn) #endif +/* Returns 1 in case of a non-RT signal frame and 2 in case of a RT signal + frame. */ PROTECTED int unw_is_signal_frame (unw_cursor_t *cursor) { @@ -50,13 +60,19 @@ unw_is_signal_frame (unw_cursor_t *cursor) arg = c->dwarf.as_arg; ip = c->dwarf.ip; + if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) return ret; - ret = (w0 == ARM_SIGRETURN) || (w0 == MOV_R7_SIGRETURN) - || (w0 == THUMB_SIGRETURN); - fprintf (stderr, "w0=%8.8x ret=%d\n", w0, ret); - Debug (16, "returning %d\n", ret); - return ret; + + /* Return 1 if the IP points to a non-RT sigreturn sequence. */ + if (w0 == MOV_R7_SIGRETURN || w0 == ARM_SIGRETURN || w0 == THUMB_SIGRETURN) + return 1; + /* Return 2 if the IP points to a RT sigreturn sequence. */ + else if (w0 == MOV_R7_RT_SIGRETURN || w0 == ARM_RT_SIGRETURN + || w0 == THUMB_RT_SIGRETURN) + return 2; + + return 0; #else printf ("%s: implement me\n", __FUNCTION__); return -UNW_ENOINFO;