This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Convert *BSD/i386 to use target vector inheritance
- From: Mark Kettenis <kettenis at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 19 Sep 2004 22:49:56 +0200 (CEST)
- Subject: [PATCH] Convert *BSD/i386 to use target vector inheritance
Huge patch that doesn't really change much, but it's a step in the
right direction.
Committed,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* i386bsd-nat.c: Include "i386bsd-nat.h" and "inf-ptrace.h".
(i386bsd_fetch_inferior_registers): Rename from
fetch_inferior_registers. Make static.
(i386bsd_store_inferior_registers): Rename from
store_inferior_registers. Make static.
(i386bsd_target): New function.
* i386bsd-nat.h: New file.
* i386fbsd-nat.c: Include "target.h", "fbsd-nat.h" and
"i386bsd-nat.h".
(i386fbsd_resume): Rename from child_resume. Make static.
(_initialize_i386fbsd_nat): Construct and add target vector.
* i386nbsd-nat.c: Include "target.h" and "i386bsd-nat.h".
(_initialize_i386nbsd_nat): Construct and add target vector.
* config/i386/nm-fbsd.h: (CHILD_RESUME, CHILD_PID_TO_EXEC_FILE):
Remove defines.
* config/i386/fbsd.mh (NATDEPFILES): Add inf-child.o, inf-ptrace.o
and fbsd-nat.o. Remove inftarg.o and fbsd-proc.o.
* config/i386/nbsdaout.mh (NATDEPFILES): Add inf-child.o,
inf-ptrace.o, i386bsd-nat.o and bsd-kvm.o. Remove inftarg.o.
(LOADLIBES): New variable.
* config/i386/nbsdelf.mh (NATDEPFILES): Add inf-child.o and
inf-ptrace.o. Remove inftarg.o.
* config/i386/obsd.mh (NATDEPFILES): Add inf-child.o and
inf-ptrace.o. Remove inftarg.o.
* config/i386/obsdaout.mh (NATDEPFILES): Add inf-child.o,
inf-ptrace.o, i386nbsd-nat.o and bsd-kvm.o. Remove inftarg.o.
(LOADLIBES): New variable.
* Makefile.in (i386bsd_nat_h): New variable.
(i386bsd-nat.o, i386fbsd-nat.o, i386nbsd-nat.o): Update
dependencies.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.623
diff -u -p -r1.623 Makefile.in
--- Makefile.in 19 Sep 2004 17:21:28 -0000 1.623
+++ Makefile.in 19 Sep 2004 20:45:55 -0000
@@ -699,6 +699,7 @@ glibc_tdep_h = glibc-tdep.h
gnu_nat_h = gnu-nat.h
gregset_h = gregset.h
hppa_tdep_h = hppa-tdep.h
+i386bsd_nat_h = i386bsd-nat.h
i386_linux_tdep_h = i386-linux-tdep.h
i386_tdep_h = i386-tdep.h
i387_tdep_h = i387-tdep.h
@@ -1974,13 +1975,15 @@ hpread.o: hpread.c $(defs_h) $(bfd_h) $(
hpux-thread.o: hpux-thread.c $(defs_h) $(gdbthread_h) $(target_h) \
$(inferior_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h)
i386bsd-nat.o: i386bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
- $(gdb_assert_h) $(i386_tdep_h) $(i387_tdep_h)
+ $(gdb_assert_h) $(i386_tdep_h) $(i387_tdep_h) $(i386bsd_nat_h) \
+ $(inf_ptrace_h)
i386bsd-tdep.o: i386bsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
$(gdbcore_h) $(regcache_h) $(osabi_h) $(gdb_string_h) $(i386_tdep_h)
i386-cygwin-tdep.o: i386-cygwin-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
$(i386_tdep_h)
i386fbsd-nat.o: i386fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
- $(i386_tdep_h) $(bsd_kvm_h)
+ $(target_h) $(fbsd_nat_h) $(i386_tdep_h) $(i386bsd_nat_h) \
+ $(bsd_kvm_h)
i386fbsd-tdep.o: i386fbsd-tdep.c $(defs_h) $(arch_utils_h) $(osabi_h) \
$(i386_tdep_h) $(i387_tdep_h) $(solib_svr4_h)
i386gnu-nat.o: i386gnu-nat.c $(defs_h) $(inferior_h) $(floatformat_h) \
@@ -1999,7 +2002,7 @@ i386ly-tdep.o: i386ly-tdep.c $(defs_h) $
$(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
i386nbsd-nat.o: i386nbsd-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \
- $(i386_tdep_h) $(bsd_kvm_h)
+ $(target_h) $(i386_tdep_h) $(i386bsd_nat_h) $(bsd_kvm_h)
i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
$(gdbcore_h) $(regcache_h) $(regset_h) $(osabi_h) $(symtab_h) \
$(gdb_assert_h) $(gdb_string_h) $(i386_tdep_h) $(i387_tdep_h) \
Index: i386bsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-nat.c,v
retrieving revision 1.31
diff -u -p -r1.31 i386bsd-nat.c
--- i386bsd-nat.c 14 Aug 2004 23:37:04 -0000 1.31
+++ i386bsd-nat.c 19 Sep 2004 20:45:55 -0000
@@ -33,6 +33,8 @@
#include "i386-tdep.h"
#include "i387-tdep.h"
+#include "i386bsd-nat.h"
+#include "inf-ptrace.h"
/* In older BSD versions we cannot get at some of the segment
@@ -128,8 +130,8 @@ i386bsd_collect_gregset (const struct re
/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
for all registers (including the floating point registers). */
-void
-fetch_inferior_registers (int regnum)
+static void
+i386bsd_fetch_inferior_registers (int regnum)
{
if (regnum == -1 || GETREGS_SUPPLIES (regnum))
{
@@ -178,8 +180,8 @@ fetch_inferior_registers (int regnum)
/* Store register REGNUM back into the inferior. If REGNUM is -1, do
this for all registers (including the floating point registers). */
-void
-store_inferior_registers (int regnum)
+static void
+i386bsd_store_inferior_registers (int regnum)
{
if (regnum == -1 || GETREGS_SUPPLIES (regnum))
{
@@ -235,6 +237,20 @@ store_inferior_registers (int regnum)
#endif
}
}
+
+/* Create a prototype *BSD/i386 target. The client can override it
+ with local methods. */
+
+struct target_ops *
+i386bsd_target (void)
+{
+ struct target_ops *t;
+
+ t = inf_ptrace_target ();
+ t->to_fetch_registers = i386bsd_fetch_inferior_registers;
+ t->to_store_registers = i386bsd_store_inferior_registers;
+ return t;
+}
/* Support for debug registers. */
Index: i386bsd-nat.h
===================================================================
RCS file: i386bsd-nat.h
diff -N i386bsd-nat.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ i386bsd-nat.h 19 Sep 2004 20:45:55 -0000
@@ -0,0 +1,30 @@
+/* Native-dependent code for modern i386 BSD's.
+
+ Copyright 2004 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. */
+
+#ifndef I386BSD_NAT_H
+#define I386BSD_NAT_H
+
+/* Create a prototype *BSD/i386 target. The client can override it
+ with local methods. */
+
+extern struct target_ops *i386bsd_target (void);
+
+#endif /* i386bsd-nat.h */
Index: i386fbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386fbsd-nat.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386fbsd-nat.c
--- i386fbsd-nat.c 22 May 2004 17:21:35 -0000 1.6
+++ i386fbsd-nat.c 19 Sep 2004 20:45:56 -0000
@@ -22,19 +22,21 @@
#include "defs.h"
#include "inferior.h"
#include "regcache.h"
+#include "target.h"
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/sysctl.h>
+#include "fbsd-nat.h"
#include "i386-tdep.h"
+#include "i386bsd-nat.h"
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
+/* 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)
+static void
+i386fbsd_resume (ptid_t ptid, int step, enum target_signal signal)
{
pid_t pid = ptid_get_pid (ptid);
int request = PT_STEP;
@@ -119,6 +121,16 @@ void _initialize_i386fbsd_nat (void);
void
_initialize_i386fbsd_nat (void)
{
+ struct target_ops *t;
+
+ /* Add some extra features to the common *BSD/i386 target. */
+ t = i386bsd_target ();
+ t->to_resume = i386fbsd_resume;
+ t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+ t->to_find_memory_regions = fbsd_find_memory_regions;
+ t->to_make_corefile_notes = fbsd_make_corefile_notes;
+ add_target (t);
+
/* FreeBSD provides a kern.ps_strings sysctl that we can use to
locate the sigtramp. That way we can still recognize a sigtramp
if its location is changed in a new kernel. Of course this is
Index: i386nbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 i386nbsd-nat.c
--- i386nbsd-nat.c 27 Jun 2004 16:22:43 -0000 1.13
+++ i386nbsd-nat.c 19 Sep 2004 20:45:56 -0000
@@ -22,8 +22,10 @@
#include "defs.h"
#include "gdbcore.h"
#include "regcache.h"
+#include "target.h"
#include "i386-tdep.h"
+#include "i386bsd-nat.h"
/* Support for debugging kernel virtual memory images. */
@@ -77,6 +79,9 @@ void _initialize_i386nbsd_nat (void);
void
_initialize_i386nbsd_nat (void)
{
+ /* We've got nothing to add to the common *BSD/i386 target. */
+ add_target (i386bsd_target ());
+
/* Support debugging kernel virtual memory images. */
bsd_kvm_add_target (i386nbsd_supply_pcb);
}
Index: config/i386/nm-fbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-fbsd.h,v
retrieving revision 1.9
diff -u -p -r1.9 nm-fbsd.h
--- config/i386/nm-fbsd.h 13 Mar 2004 13:07:20 -0000 1.9
+++ config/i386/nm-fbsd.h 19 Sep 2004 20:45:56 -0000
@@ -54,12 +54,6 @@ extern unsigned long i386bsd_dr_get_stat
/* Get generic BSD native definitions. */
#include "config/nm-bsd.h"
-
-/* Override child_resume in `infptrace.c' to work around a kernel bug. */
-#define CHILD_RESUME
-
-/* Override child_pid_to_exec_file in 'inftarg.c'. */
-#define CHILD_PID_TO_EXEC_FILE
/* Support for the user struct. */
Index: config/i386/fbsd.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/fbsd.mh,v
retrieving revision 1.16
diff -u -p -r1.16 fbsd.mh
--- config/i386/fbsd.mh 29 Jul 2004 20:04:20 -0000 1.16
+++ config/i386/fbsd.mh 19 Sep 2004 20:45:56 -0000
@@ -1,7 +1,7 @@
# Host: FreeBSD/i386
-NATDEPFILES= fork-child.o infptrace.o inftarg.o \
- i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
- gcore.o fbsd-proc.o bsd-kvm.o
+NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o \
+ fbsd-nat.o i386-nat.o i386bsd-nat.o i386fbsd-nat.o \
+ gcore.o bsd-kvm.o
NAT_FILE= nm-fbsd.h
LOADLIBES= -lkvm
Index: config/i386/nbsdaout.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nbsdaout.mh,v
retrieving revision 1.4
diff -u -p -r1.4 nbsdaout.mh
--- config/i386/nbsdaout.mh 29 Jul 2004 21:24:55 -0000 1.4
+++ config/i386/nbsdaout.mh 19 Sep 2004 20:45:56 -0000
@@ -1,4 +1,7 @@
# Host: NetBSD/i386 a.out
-NATDEPFILES= fork-child.o infptrace.o inftarg.o i386bsd-nat.o \
+NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o
+ i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o \
solib.o solib-sunos.o
NAT_FILE= nm-nbsdaout.h
+
+LOADLIBES= -lkvm
Index: config/i386/nbsdelf.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nbsdelf.mh,v
retrieving revision 1.18
diff -u -p -r1.18 nbsdelf.mh
--- config/i386/nbsdelf.mh 3 Sep 2004 19:08:18 -0000 1.18
+++ config/i386/nbsdelf.mh 19 Sep 2004 20:45:56 -0000
@@ -1,5 +1,5 @@
# Host: NetBSD/i386 ELF
-NATDEPFILES= fork-child.o infptrace.o inftarg.o \
+NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o \
i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o
NAT_FILE= config/nm-nbsd.h
Index: config/i386/obsd.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/obsd.mh,v
retrieving revision 1.10
diff -u -p -r1.10 obsd.mh
--- config/i386/obsd.mh 29 Jul 2004 20:04:21 -0000 1.10
+++ config/i386/obsd.mh 19 Sep 2004 20:45:56 -0000
@@ -1,7 +1,6 @@
# Host: OpenBSD/i386 ELF
-NATDEPFILES= fork-child.o infptrace.o inftarg.o \
+NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o \
i386bsd-nat.o i386obsd-nat.o i386nbsd-nat.o bsd-kvm.o
NAT_FILE= nm-obsd.h
LOADLIBES= -lkvm
-
Index: config/i386/obsdaout.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/obsdaout.mh,v
retrieving revision 1.3
diff -u -p -r1.3 obsdaout.mh
--- config/i386/obsdaout.mh 29 Jul 2004 20:04:21 -0000 1.3
+++ config/i386/obsdaout.mh 19 Sep 2004 20:45:56 -0000
@@ -1,4 +1,7 @@
# Host: OpenBSD/i386 a.out
-NATDEPFILES= fork-child.o infptrace.o inftarg.o i386bsd-nat.o i386obsd-nat.o \
+NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o \
+ i386bsd-nat.o i386nbsd-nat.o i386obsd-nat.o bsd-kvm.o \
solib.o solib-sunos.o
NAT_FILE= nm-obsd.h
+
+LOADLIBES= -lkvm