From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32322 invoked by alias); 30 Jul 2004 22:45:36 -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 32311 invoked from network); 30 Jul 2004 22:45:34 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.77.109) by sourceware.org with SMTP; 30 Jul 2004 22:45:34 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i6UMjUJ8020656; Sat, 31 Jul 2004 00:45:30 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i6UMjUMA029365; Sat, 31 Jul 2004 00:45:30 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id i6UMjUIY029362; Sat, 31 Jul 2004 00:45:30 +0200 (CEST) Date: Fri, 30 Jul 2004 22:45:00 -0000 Message-Id: <200407302245.i6UMjUIY029362@elgar.kettenis.dyndns.org> From: Mark Kettenis To: cagney@gnu.org CC: gdb-patches@sources.redhat.com In-reply-to: <41012AC0.4090203@gnu.org> (message from Andrew Cagney on Fri, 23 Jul 2004 11:12:00 -0400) Subject: Re: [PATCH] Fix OpenBSD signal trampoline recognition References: <200407231343.i6NDhnoK020951@elgar.kettenis.dyndns.org> <41012AC0.4090203@gnu.org> X-SW-Source: 2004-07/txt/msg00527.txt.bz2 Date: Fri, 23 Jul 2004 11:12:00 -0400 From: Andrew Cagney > + goto retry; We really don't need a goto, right? Right, so I've checked in the attached. Mark Index: ChangeLog from Mark Kettenis * sparc64obsd-tdep.c (sparc64obsd_sigreturn_offset): New variable. (sparc64obsd_pc_in_sigtramp): Reorganize to avoid goto. Index: sparc64obsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc64obsd-tdep.c,v retrieving revision 1.7 diff -u -p -r1.7 sparc64obsd-tdep.c --- sparc64obsd-tdep.c 23 Jul 2004 13:43:36 -0000 1.7 +++ sparc64obsd-tdep.c 30 Jul 2004 22:42:35 -0000 @@ -74,43 +74,40 @@ sparc64obsd_supply_gregset (const struct The signal trampoline will be mapped at an address that is page aligned. We recognize the signal trampoline by the looking for the - sigreturn system call. */ + sigreturn system call. The offset where we can find the code that + makes this system call varies from release to release. For OpenBSD + 3.6 and later releases we can find the code at offset 0xec. For + OpenBSD 3.5 and earlier releases, we find it at offset 0xe8. */ static const int sparc64obsd_page_size = 8192; +static const int sparc64obsd_sigreturn_offset[] = { 0xec, 0xe8, -1 }; static int sparc64obsd_pc_in_sigtramp (CORE_ADDR pc, char *name) { CORE_ADDR start_pc = (pc & ~(sparc64obsd_page_size - 1)); unsigned long insn; - int offset = 0; + const int *offset; if (name) return 0; - retry: - /* Check for "restore %g0, SYS_sigreturn, %g1". */ - insn = sparc_fetch_instruction (start_pc + offset + 0xec); - if (insn != 0x83e82067) + for (offset = sparc64obsd_sigreturn_offset; *offset != -1; offset++) { - if (offset == 0) - { - /* In OpenBSD 3.5 and earlier releases, the code - implementing the sigreturn system call was at a different - offset within the signal trampoline. Try again. */ - offset = -4; - goto retry; - } + /* Check for "restore %g0, SYS_sigreturn, %g1". */ + insn = sparc_fetch_instruction (start_pc + *offset); + if (insn != 0x83e82067) + continue; + + /* Check for "t ST_SYSCALL". */ + insn = sparc_fetch_instruction (start_pc + *offset + 8); + if (insn != 0x91d02000) + continue; - return 0; - } - - /* Check for "t ST_SYSCALL". */ - insn = sparc_fetch_instruction (start_pc + offset + 0xf4); - if (insn != 0x91d02000) - return 0; + return 1; + } - return 1; + return 0; } static struct sparc_frame_cache *