From 256304449f3723704990160e7fa4496c02b92b2f Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 21 Jul 2001 20:16:44 +0000 Subject: * i386bsd-nat.c: Do not include . (_initialize_i386bsd_nat) [KERN_PS_STRINGS]: Move FreeBSD-specific code to ... * i386fbsd-nat.c: ... here. New file. * config/i386/fbsd.mh (NATDEPFILES): Add i386-fbsd.o. * config/i386/nm-fbsd.h (CHILD_RESUME): Define. * Makefile.in (ALLDEPFILES): Add i386fbsd-nat.c. (i386fbsd-nat.o): Add dependencies. --- gdb/ChangeLog | 11 +++++ gdb/Makefile.in | 4 +- gdb/config/i386/fbsd.mh | 2 +- gdb/config/i386/nm-fbsd.h | 3 ++ gdb/i386bsd-nat.c | 25 ------------ gdb/i386fbsd-nat.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 gdb/i386fbsd-nat.c (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f6ac92a..cc7d05f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2001-07-21 Mark Kettenis + + * i386bsd-nat.c: Do not include . + (_initialize_i386bsd_nat) [KERN_PS_STRINGS]: Move FreeBSD-specific + code to ... + * i386fbsd-nat.c: ... here. New file. + * config/i386/fbsd.mh (NATDEPFILES): Add i386-fbsd.o. + * config/i386/nm-fbsd.h (CHILD_RESUME): Define. + * Makefile.in (ALLDEPFILES): Add i386fbsd-nat.c. + (i386fbsd-nat.o): Add dependencies. + 2001-07-19 Daniel Jacobowitz * signals.c: New file. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 09c01d6..a90fab8 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1151,7 +1151,7 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \ hp-psymtab-read.c hp-symtab-read.c \ i386-tdep.c i386b-nat.c i386mach-nat.c i386v-nat.c i386-linux-nat.c \ i386aix-nat.c i386m3-nat.c i386v4-nat.c i386ly-tdep.c \ - i386bsd-nat.c i386bsd-tdep.c \ + i386bsd-nat.c i386bsd-tdep.c i386fbsd-nat.c \ i387-tdep.c \ i386-linux-tdep.c i386-nat.c \ i960-tdep.c \ @@ -1537,6 +1537,8 @@ i386bsd-tdep.o: i386bsd-tdep.c $(defs_h) $(frame_h) $(gdb_core_h) \ i386bsd-nat.o: i386bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) +i386fbsd-nat.o: i386fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) + i386ly-nat.o: i386ly-nat.c $(defs_h) $(frame_h) $(inferior_h) target.h i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(inferior_h) target.h $(gdbcore_h) \ diff --git a/gdb/config/i386/fbsd.mh b/gdb/config/i386/fbsd.mh index 7742b0f..93e0702 100644 --- a/gdb/config/i386/fbsd.mh +++ b/gdb/config/i386/fbsd.mh @@ -1,6 +1,6 @@ # Host: Intel 386 running FreeBSD XDEPFILES= # NOTE: Do not spread NATDEPFILES over several lines - it hurts BSD make. -NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i387-nat.o i386bsd-nat.o i386-nat.o +NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i386-nat.o i387-nat.o i386bsd-nat.o i386fbsd-nat.o XM_FILE= xm-fbsd.h NAT_FILE= nm-fbsd.h diff --git a/gdb/config/i386/nm-fbsd.h b/gdb/config/i386/nm-fbsd.h index 79199bb..939b880 100644 --- a/gdb/config/i386/nm-fbsd.h +++ b/gdb/config/i386/nm-fbsd.h @@ -53,6 +53,9 @@ extern unsigned long i386bsd_dr_get_status (void); /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ #define FETCH_INFERIOR_REGISTERS +/* Override child_resume in `infptrace.c' to work around a kernel bug. */ +#define CHILD_RESUME + /* We can attach and detach. */ #define ATTACH_DETACH diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index 5b5a1fe..9827afc 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -323,8 +323,6 @@ kernel_u_size (void) /* See i386bsd-tdep.c. */ extern int i386bsd_sigcontext_pc_offset; -#include - void _initialize_i386bsd_nat (void) { @@ -337,27 +335,4 @@ _initialize_i386bsd_nat (void) /* Override the default value for the offset of the program counter in the sigcontext structure. */ i386bsd_sigcontext_pc_offset = offsetof (struct sigcontext, sc_pc); - - /* FreeBSD provides a kern.ps_strings sysctl that we can use to - locate the sigtramp. That way we can still recognize a sigtramp - if it's location is changed in a new kernel. 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 KERN_PS_STRINGS - { - int mib[2]; - int ps_strings; - size_t len; - - mib[0] = CTL_KERN; - mib[1] = KERN_PS_STRINGS; - len = sizeof (ps_strings); - if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0) - { - i386bsd_sigtramp_start = ps_strings - 128; - i386bsd_sigtramp_end = ps_strings; - } - } -#endif } diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c new file mode 100644 index 0000000..1c19ac8 --- /dev/null +++ b/gdb/i386fbsd-nat.c @@ -0,0 +1,102 @@ +/* Native-dependent code for FreeBSD/i386. + Copyright 2001 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 "inferior.h" +#include "regcache.h" + +#include +#include +#include + +/* Prevent warning from -Wmissing-prototypes. */ +void _initialize_i386fbsd_nat (void); + +/* Resume execution of the inferior process. + If STEP is nonzero, single-step it. + If SIGNAL is nonzero, give it that signal. */ + +void +child_resume (ptid_t ptid, int step, enum target_signal signal) +{ + pid_t pid = ptid_get_pid (ptid); + int request = PT_STEP; + + if (pid == -1) + /* Resume all threads. This only gets used in the non-threaded + case, where "resume all threads" and "resume inferior_ptid" are + the same. */ + pid = ptid_get_pid (inferior_ptid); + + if (!step) + { + unsigned int eflags; + + /* Workaround for a bug in FreeBSD. Make sure that the trace + flag is off when doing a continue. There is a code path + through the kernel which leaves the flag set when it should + have been cleared. If a process has a signal pending (such + as SIGALRM) and we do a PT_STEP, the process never really has + a chance to run because the kernel needs to notify the + debugger that a signal is being sent. Therefore, the process + never goes through the kernel's trap() function which would + normally clear it. */ + + eflags = read_register (PS_REGNUM); + if (eflags & 0x0100) + write_register (PS_REGNUM, eflags & ~0x0100); + + request = PT_CONTINUE; + } + + /* An addres of (caddr_t) 1 tells ptrace to continue from where it + was. (If GDB wanted it to start some other way, we have already + written a new PC value to the child.) */ + if (ptrace (request, pid, (caddr_t) 1, + target_signal_to_host (signal)) == -1) + perror_with_name ("ptrace"); +} + +void +_initialize_i386fbsd_nat (void) +{ + /* FreeBSD provides a kern.ps_strings sysctl that we can use to + locate the sigtramp. That way we can still recognize a sigtramp + if it's location is changed in a new kernel. 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 KERN_PS_STRINGS + { + int mib[2]; + int ps_strings; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0) + { + i386bsd_sigtramp_start = ps_strings - 128; + i386bsd_sigtramp_end = ps_strings; + } + } +#endif +} -- cgit v1.1