* i386-tdep.h (i386fbsd_sigtramp_start, i386fbsd_sigtramp_end,
[platform/upstream/binutils.git] / gdb / i386obsd-nat.c
1 /* Native-dependent code for OpenBSD/i386.
2    Copyright 2002, 2003 Free Software Foundation, Inc.
3
4    This file is part of GDB.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22
23 #include <sys/param.h>
24 #include <sys/sysctl.h>
25
26 #include "i386-tdep.h"
27
28 /* Prevent warning from -Wmissing-prototypes.  */
29 void _initialize_i386obsd_nat (void);
30
31 void
32 _initialize_i386obsd_nat (void)
33 {
34   /* OpenBSD provides a vm.psstrings sysctl that we can use to locate
35      the sigtramp.  That way we can still recognize a sigtramp if its
36      location is changed in a new kernel.  This is especially
37      important for OpenBSD, since it uses a different memory layout
38      than NetBSD, yet we cannot distinguish between the two.
39
40      Of course this is still based on the assumption that the sigtramp
41      is placed directly under the location where the program arguments
42      and environment can be found.  */
43 #ifdef VM_PSSTRINGS
44   {
45     struct _ps_strings _ps;
46     int mib[2];
47     size_t len;
48
49     mib[0] = CTL_VM;
50     mib[1] = VM_PSSTRINGS;
51     len = sizeof (_ps);
52     if (sysctl (mib, 2, &_ps, &len, NULL, 0) == 0)
53       {
54         i386obsd_sigtramp_start = (CORE_ADDR)_ps.val - 128;
55         i386obsd_sigtramp_end = (CORE_ADDR)_ps.val;
56       }
57   }
58 #endif
59 }