[PATCH] Fix sigtramp recognition for OpenBSD/i386 native GDB
Mark Kettenis
kettenis@chello.nl
Thu Jul 4 08:18:00 GMT 2002
This patch fixes sigtramp recognition on native OpenBSD/i386.
Cross-debugging remains broken. I have no way to distingush OpenBSD
a.out from NetBSD a.out, yet the two use a different memory layout.
Let's hope someone gets a bright idea...
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* i386bsd-tdep.c (i386nbsd_sigtramp_start, i386nbsd_sigtramp_end):
New variables.
(i386nbsd_init_abi): Use these to initialize tdep->sigtramp_start
and tdep->sigtramp_end.
* i386obsd-nat.c: New file.
* config/i386/obsd.mh (NATDEPFILES): Add i386obsd-nat.o.
Index: i386bsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386bsd-tdep.c
--- i386bsd-tdep.c 2 Jul 2002 09:12:37 -0000 1.6
+++ i386bsd-tdep.c 4 Jul 2002 15:11:52 -0000
@@ -113,6 +113,9 @@ i386bsd_init_abi (struct gdbarch_info in
/* NetBSD 1.0 or later. */
+CORE_ADDR i386nbsd_sigtramp_start = 0xbfbfdf20;
+CORE_ADDR i386nbsd_sigtramp_end = 0xbfbfdff0;
+
/* From <machine/signal.h>. */
int i386nbsd_sc_pc_offset = 44;
int i386nbsd_sc_sp_offset = 56;
@@ -129,8 +132,8 @@ i386nbsd_init_abi (struct gdbarch_info i
tdep->struct_return = reg_struct_return;
/* NetBSD uses a different memory layout. */
- tdep->sigtramp_start = 0xbfbfdf20;
- tdep->sigtramp_end = 0xbfbfdff0;
+ tdep->sigtramp_start = i386nbsd_sigtramp_start;
+ tdep->sigtramp_end = i386nbsd_sigtramp_end;
/* NetBSD has a `struct sigcontext' that's different from the
origional 4.3 BSD. */
Index: config/i386/obsd.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/obsd.mh,v
retrieving revision 1.4
diff -u -p -r1.4 obsd.mh
--- config/i386/obsd.mh 30 Jun 2002 17:19:54 -0000 1.4
+++ config/i386/obsd.mh 4 Jul 2002 15:11:52 -0000
@@ -3,7 +3,7 @@
XM_FILE= xm-i386.h
NAT_FILE= nm-obsd.h
-NATDEPFILES= fork-child.o infptrace.o inftarg.o i386bsd-nat.o \
+NATDEPFILES= fork-child.o infptrace.o inftarg.o i386bsd-nat.o i386obsd-nat.o \
solib.o solib-sunos.o
# The OpenBSD yacc generates yyname and yyrule tables that conflict at
--- /dev/null Thu Jul 4 17:09:42 2002
+++ i386obsd-nat.c Thu Jul 4 17:09:42 2002
@@ -0,0 +1,60 @@
+/* Native-dependent code for OpenBSD/i386.
+ Copyright 2002 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+/* Prevent warning from -Wmissing-prototypes. */
+void _initialize_i386fbsd_nat (void);
+
+void
+_initialize_i386obsd_nat (void)
+{
+ /* OpenBSD provides a vm.psstrings sysctl that we can use to locate
+ the sigtramp. That way we can still recognize a sigtramp if its
+ location is changed in a new kernel. This is especially
+ important for OpenBSD, since it uses a different memory layout
+ than NetBSD, yet we cannot distinguish between the two.
+
+ Of course this is still based on the assumption that the sigtramp
+ is placed directly under the location where the program arguments
+ and environment can be found. */
+#ifdef VM_PSSTRINGS
+ {
+ struct _ps_strings _ps;
+ int mib[2];
+ size_t len;
+
+ extern CORE_ADDR i386nbsd_sigtramp_start;
+ extern CORE_ADDR i386nbsd_sigtramp_end;
+
+ mib[0] = CTL_VM;
+ mib[1] = VM_PSSTRINGS;
+ len = sizeof (_ps);
+ if (sysctl (mib, 2, &_ps, &len, NULL, 0) == 0)
+ {
+ i386nbsd_sigtramp_start = (CORE_ADDR)_ps.val - 128;
+ i386nbsd_sigtramp_end = (CORE_ADDR)_ps.val;
+ }
+ }
+#endif
+}
More information about the Gdb-patches
mailing list