]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* sparc64obsd-tdep.c (sparc64obsd_sigreturn_offset): New variable.
authorMark Kettenis <kettenis@gnu.org>
Fri, 30 Jul 2004 22:45:52 +0000 (22:45 +0000)
committerMark Kettenis <kettenis@gnu.org>
Fri, 30 Jul 2004 22:45:52 +0000 (22:45 +0000)
(sparc64obsd_pc_in_sigtramp): Reorganize to avoid goto.

gdb/ChangeLog
gdb/sparc64obsd-tdep.c

index 9cfaf44ce4412026b4f0837990a21a70fb142ad0..732224fb358841d07e99aa909b646b5c770f37e3 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-31  Mark Kettenis  <kettenis@gnu.org>
+
+       * sparc64obsd-tdep.c (sparc64obsd_sigreturn_offset): New variable.
+       (sparc64obsd_pc_in_sigtramp): Reorganize to avoid goto.
+
 2004-07-30  Andrew Cagney  <cagney@gnu.org>
 
        * GDB 6.2 released from gdb_6_2-branch.
index 8ad88b556aae02c8cfd7b8b71ef14f170c52a48f..bb6626deebc58790b90ab3b8a437858f8b43165b 100644 (file)
@@ -74,43 +74,40 @@ sparc64obsd_supply_gregset (const struct regset *regset,
 
    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;
-       }
-
-      return 0;
-    }
+      /* 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 + 0xf4);
-  if (insn != 0x91d02000)
-    return 0;
+      /* Check for "t ST_SYSCALL".  */
+      insn = sparc_fetch_instruction (start_pc + *offset + 8);
+      if (insn != 0x91d02000)
+       continue;
+
+      return 1;
+  }
 
-  return 1;
+  return 0;
 }
 
 static struct sparc_frame_cache *