| 1 | /* Native-dependent code for OpenBSD/i386. |
| 2 | Copyright 2002 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 | /* Prevent warning from -Wmissing-prototypes. */ |
| 27 | void _initialize_i386obsd_nat (void); |
| 28 | |
| 29 | void |
| 30 | _initialize_i386obsd_nat (void) |
| 31 | { |
| 32 | /* OpenBSD provides a vm.psstrings sysctl that we can use to locate |
| 33 | the sigtramp. That way we can still recognize a sigtramp if its |
| 34 | location is changed in a new kernel. This is especially |
| 35 | important for OpenBSD, since it uses a different memory layout |
| 36 | than NetBSD, yet we cannot distinguish between the two. |
| 37 | |
| 38 | Of course this is still based on the assumption that the sigtramp |
| 39 | is placed directly under the location where the program arguments |
| 40 | and environment can be found. */ |
| 41 | #ifdef VM_PSSTRINGS |
| 42 | { |
| 43 | struct _ps_strings _ps; |
| 44 | int mib[2]; |
| 45 | size_t len; |
| 46 | |
| 47 | extern CORE_ADDR i386nbsd_sigtramp_start; |
| 48 | extern CORE_ADDR i386nbsd_sigtramp_end; |
| 49 | |
| 50 | mib[0] = CTL_VM; |
| 51 | mib[1] = VM_PSSTRINGS; |
| 52 | len = sizeof (_ps); |
| 53 | if (sysctl (mib, 2, &_ps, &len, NULL, 0) == 0) |
| 54 | { |
| 55 | i386nbsd_sigtramp_start = (CORE_ADDR)_ps.val - 128; |
| 56 | i386nbsd_sigtramp_end = (CORE_ADDR)_ps.val; |
| 57 | } |
| 58 | } |
| 59 | #endif |
| 60 | } |