1 /* Native-dependent code for DragonFly/i386. 2 3 Copyright (C) 2001, 2002, 2003, 2004, 2007, 2008, 2009 4 Free Software Foundation, Inc. 5 6 This file is part of GDB. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 21 #include "defs.h" 22 #include "inferior.h" 23 #include "regcache.h" 24 #include "target.h" 25 26 #include <sys/types.h> 27 #include <sys/ptrace.h> 28 #include <sys/sysctl.h> 29 30 #include "fbsd-nat.h" 31 #include "i386-tdep.h" 32 #include "i386-nat.h" 33 #include "i386bsd-nat.h" 34 35 /* Prevent warning from -Wmissing-prototypes. */ 36 void _initialize_i386dfly_nat (void); 37 38 void 39 _initialize_i386dfly_nat (void) 40 { 41 struct target_ops *t; 42 43 /* Add some extra features to the common *BSD/i386 target. */ 44 t = i386bsd_target (); 45 46 #ifdef HAVE_PT_GETDBREGS 47 48 i386_use_watchpoints (t); 49 50 i386_dr_low.set_control = i386bsd_dr_set_control; 51 i386_dr_low.set_addr = i386bsd_dr_set_addr; 52 i386_dr_low.reset_addr = i386bsd_dr_reset_addr; 53 i386_dr_low.get_status = i386bsd_dr_get_status; 54 i386_set_debug_register_length (4); 55 56 #endif /* HAVE_PT_GETDBREGS */ 57 58 59 t->to_pid_to_exec_file = fbsd_pid_to_exec_file; 60 t->to_find_memory_regions = fbsd_find_memory_regions; 61 t->to_make_corefile_notes = fbsd_make_corefile_notes; 62 add_target (t); 63 64 /* DragonFly provides a kern.ps_strings sysctl that we can use to 65 locate the sigtramp. That way we can still recognize a sigtramp 66 if its location is changed in a new kernel. Of course this is 67 still based on the assumption that the sigtramp is placed 68 directly under the location where the program arguments and 69 environment can be found. */ 70 #ifdef KERN_PS_STRINGS 71 { 72 int mib[2]; 73 u_long ps_strings; 74 size_t len; 75 76 mib[0] = CTL_KERN; 77 mib[1] = KERN_PS_STRINGS; 78 len = sizeof (ps_strings); 79 if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0) 80 { 81 i386dfly_sigtramp_start_addr = ps_strings - 128; 82 i386dfly_sigtramp_end_addr = ps_strings; 83 } 84 } 85 #endif 86 } 87