1130803Smarcel/* Native-dependent code for OpenBSD/i386.
2130803Smarcel
3130803Smarcel   Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
4130803Smarcel
5130803Smarcel   This file is part of GDB.
6130803Smarcel
7130803Smarcel   This program is free software; you can redistribute it and/or modify
8130803Smarcel   it under the terms of the GNU General Public License as published by
9130803Smarcel   the Free Software Foundation; either version 2 of the License, or
10130803Smarcel   (at your option) any later version.
11130803Smarcel
12130803Smarcel   This program is distributed in the hope that it will be useful,
13130803Smarcel   but WITHOUT ANY WARRANTY; without even the implied warranty of
14130803Smarcel   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15130803Smarcel   GNU General Public License for more details.
16130803Smarcel
17130803Smarcel   You should have received a copy of the GNU General Public License
18130803Smarcel   along with this program; if not, write to the Free Software
19130803Smarcel   Foundation, Inc., 59 Temple Place - Suite 330,
20130803Smarcel   Boston, MA 02111-1307, USA.  */
21130803Smarcel
22130803Smarcel#include "defs.h"
23130803Smarcel
24130803Smarcel#include <sys/param.h>
25130803Smarcel#include <sys/sysctl.h>
26130803Smarcel
27130803Smarcel#include "i386-tdep.h"
28130803Smarcel
29130803Smarcel/* Prevent warning from -Wmissing-prototypes.  */
30130803Smarcelvoid _initialize_i386obsd_nat (void);
31130803Smarcel
32130803Smarcelvoid
33130803Smarcel_initialize_i386obsd_nat (void)
34130803Smarcel{
35130803Smarcel  /* OpenBSD provides a vm.psstrings sysctl that we can use to locate
36130803Smarcel     the sigtramp.  That way we can still recognize a sigtramp if its
37130803Smarcel     location is changed in a new kernel.  This is especially
38130803Smarcel     important for OpenBSD, since it uses a different memory layout
39130803Smarcel     than NetBSD, yet we cannot distinguish between the two.
40130803Smarcel
41130803Smarcel     Of course this is still based on the assumption that the sigtramp
42130803Smarcel     is placed directly under the location where the program arguments
43130803Smarcel     and environment can be found.  */
44130803Smarcel#ifdef VM_PSSTRINGS
45130803Smarcel  {
46130803Smarcel    struct _ps_strings _ps;
47130803Smarcel    int mib[2];
48130803Smarcel    size_t len;
49130803Smarcel
50130803Smarcel    mib[0] = CTL_VM;
51130803Smarcel    mib[1] = VM_PSSTRINGS;
52130803Smarcel    len = sizeof (_ps);
53130803Smarcel    if (sysctl (mib, 2, &_ps, &len, NULL, 0) == 0)
54130803Smarcel      {
55130803Smarcel	i386obsd_sigtramp_start_addr = (CORE_ADDR)_ps.val - 128;
56130803Smarcel	i386obsd_sigtramp_end_addr = (CORE_ADDR)_ps.val;
57130803Smarcel      }
58130803Smarcel  }
59130803Smarcel#endif
60130803Smarcel}
61