* [RFC] Use target vector inheritance for GNU/Linux
@ 2004-12-05 18:48 Daniel Jacobowitz
2004-12-06 14:41 ` Mark Kettenis
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Daniel Jacobowitz @ 2004-12-05 18:48 UTC (permalink / raw)
To: gdb-patches
This patch converts all GNU/Linux targets to inf-ptrace.c and target vector
inheritance. I was going to do them one at a time, but because the common
native-specific code is so large for GNU/Linux, it was too awkward.
A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
target can call it, and pass the result to add_target - after specializing
whatever methods it needs to. Sometimes it's necessary to specialize a
method between inf_ptrace_target and linux_target, so it accepts an optional
argument. This wouldn't be necessary if all target methods took a
target_ops parameter, so they could call the overridden method.
One use of deprecated_child_ops was particularly thorny, so I updated the
to_follow_fork method to take a struct target_ops and push the correct
target. I made to_follow_fork a non-inherited method, like to_xfer_partial.
This patch leaves some completely dead macros in config/nm-linux.h, and some
mostly-but-not-quite dead macros in various other nm-files. I'll be back.
I didn't want to change more than absolutely necessary, once I was committed
to doing all targets. My next step will be merging the two target vectors
in linux-nat.c.
I've tested this patch with the full testsuite on x86_64-linux and
i386-linux, partial testsuite on ia64-linux [it gets hung up in an
infinite loop in sigaltstack.exp with or without the patch], and smoke
testing on s390x [the machine I was using didn't have expect].
Comments? Proofreading? I'm going to let this sit for a couple of days,
because (while mechanical) it's very large - I think I got everything, but
since I don't have the resources to test on every single GNU/Linux native
target, I can't be sure.
--
Daniel Jacobowitz
2004-12-05 Daniel Jacobowitz <dan@debian.org>
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (saved_post_startup_inferior): New.
(child_post_startup_inferior): Use it.
(_initialize_i386_linux_nat): New function. Call add_target.
* arm-linux-nat.c (_initialize_arm_linux_nat): New function.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): New function.
* hppah-nat.c (child_follow_fork): Add OPS argument.
* i386-linux-nat.c (i386_linux_resume): Renamed from child_resume.
(saved_post_startup_inferior): New.
(child_post_startup_inferior): Use it.
(_initialize_amd64_linux_nat): Set it. Call add_target.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(saved_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* inf-child.c (inf_child_follow_fork): Add OPS argument.
* inf-ptrace.c (inf_ptrace_follow_fork): Likewise.
* inftarg.c (child_follow_fork): Likewise.
* linux-nat.c (saved_attach, saved_create_inferior, saved_detach)
(saved_mourn_inferior, saved_resume, saved_xfer_partial): New.
(child_follow_fork): Add OPS argument. Don't use deprecated_child_ops.
(linux_nat_attach): Use saved_attach.
(linux_nat_detach): Use saved_detach.
(resume_callback, linux_nat_resume, linux_nat_wait): Use saved_resume.
(linux_nat_create_inferior): Use saved_create_inferior.
(linux_nat_mourn_inferior): Use saved_mourn_inferior.
(linux_nat_xfer_memory): Remove.
(init_linux_nat_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
(linux_proc_xfer_memory): Change arguments. Make static.
(_initialize_linux_nat): Don't touch deprecated_child_ops.
(fetch_register, fetch_inferior_registers, store_register)
(store_inferior_registers, linux_xfer_partial, linux_target): New
functions.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(linux_target): New prototype.
* linux-thread-db.c (thread_db_xfer_partial): Renamed from
thread_db_xfer_memory. Update.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (_initialize_m68k_linux_nat): Call add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): New function.
* s390-nat.c (_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Call
add_target.
* target.c (update_current_target): Do not inherit to_follow_fork.
(target_follow_fork): New function.
(debug_to_follow_fork): Remove.
(setup_target_debug): Don't set to_follow_fork.
* target.h (struct target_ops): Add struct target_ops * to
to_follow_fork.
(child_follow_fork): Add struct target_ops * argument.
(target_follow_fork): Replace macro with prototype.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Update comments.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Likewise.
* config/ia64/nm-linux.h (NATIVE_XFER_UNWIND_TABLE)
(ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
Index: Makefile.in
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/Makefile.in,v
retrieving revision 1.674
diff -u -p -r1.674 Makefile.in
--- Makefile.in 23 Nov 2004 21:14:32 -0000 1.674
+++ Makefile.in 5 Dec 2004 17:59:49 -0000
@@ -1351,7 +1351,7 @@ MAKEOVERRIDES=
ALLDEPFILES = \
aix-thread.c \
- alpha-nat.c alphabsd-nat.c \
+ alpha-nat.c alphabsd-nat.c alpha-linux-nat.c \
alpha-tdep.c alpha-linux-tdep.c alphabsd-tdep.c alphanbsd-tdep.c \
alpha-osf1-tdep.c alphafbsd-tdep.c alpha-mdebug-tdep.c \
amd64-nat.c amd64-tdep.c \
@@ -1393,6 +1393,7 @@ ALLDEPFILES = \
m32r-linux-nat.c m32r-linux-tdep.c \
m68k-tdep.c \
m68kbsd-nat.c m68kbsd-tdep.c \
+ m68klinux-nat.c m68klinux-tdep.c \
m88k-tdep.c m88kbsd-nat.c \
mcore-tdep.c \
mips-linux-nat.c mips-linux-tdep.c \
@@ -1416,6 +1417,7 @@ ALLDEPFILES = \
ser-go32.c ser-pipe.c ser-tcp.c \
sh-tdep.c sh64-tdep.c shnbsd-tdep.c shnbsd-nat.c \
solib.c solib-irix.c solib-svr4.c solib-sunos.c \
+ sparc-linux-nat.c \
sparc-linux-tdep.c sparc-nat.c sparc-sol2-nat.c sparc-sol2-tdep.c \
sparc-tdep.c sparc-sol2-nat.c sparc-sol2-tdep.c sparc64-linux-nat.c \
sparc64-linux-tdep.c sparc64-nat.c sparc64-sol2-tdep.c \
@@ -1645,6 +1647,7 @@ alphabsd-tdep.o: alphabsd-tdep.c $(defs_
$(alphabsd_tdep_h)
alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(osabi_h) \
$(alpha_tdep_h)
+alpha-linux-nat.o: alpha-linux-nat.c $(defs_h) $(target_h) $(linux_nat_h)
alpha-linux-tdep.o: alpha-linux-tdep.c $(defs_h) $(frame_h) $(gdb_assert_h) \
$(osabi_h) $(alpha_tdep_h)
alpha-mdebug-tdep.o: alpha-mdebug-tdep.c $(defs_h) $(frame_h) \
@@ -1675,7 +1678,7 @@ amd64fbsd-tdep.o: amd64fbsd-tdep.c $(def
amd64-linux-nat.o: amd64-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
$(regcache_h) $(linux_nat_h) $(gdb_assert_h) $(gdb_string_h) \
$(gdb_proc_service_h) $(gregset_h) $(amd64_tdep_h) \
- $(i386_linux_tdep_h) $(amd64_nat_h)
+ $(i386_linux_tdep_h) $(amd64_nat_h) $(target_h)
amd64-linux-tdep.o: amd64-linux-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
$(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \
$(solib_svr4_h)
@@ -1708,7 +1711,8 @@ arch-utils.o: arch-utils.c $(defs_h) $(a
$(gdb_assert_h) $(sim_regno_h) $(gdbcore_h) $(osabi_h) $(version_h) \
$(floatformat_h)
arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
- $(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h)
+ $(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h) \
+ $(target_h) $(linux_nat_h)
arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
$(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \
$(doublest_h) $(solib_svr4_h) $(osabi_h) $(arm_tdep_h) \
@@ -1979,7 +1983,8 @@ hppa-hpux-tdep.o: hppa-hpux-tdep.c $(def
$(trad_frame_h) $(symtab_h) $(objfiles_h) $(inferior_h) $(infcall_h) \
$(observer_h) $(hppa_tdep_h)
hppa-linux-nat.o: hppa-linux-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \
- $(gdb_string_h) $(inferior_h) $(hppa_tdep_h) $(gregset_h)
+ $(gdb_string_h) $(inferior_h) $(hppa_tdep_h) $(gregset_h) \
+ $(target_h) $(linux_nat_h)
hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
$(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \
$(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(value_h) \
@@ -2014,7 +2019,7 @@ i386gnu-tdep.o: i386gnu-tdep.c $(defs_h)
i386-linux-nat.o: i386-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
$(regcache_h) $(linux_nat_h) $(gdb_assert_h) $(gdb_string_h) \
$(gregset_h) $(i387_tdep_h) $(i386_tdep_h) $(i386_linux_tdep_h) \
- $(gdb_proc_service_h)
+ $(gdb_proc_service_h) $(inf_ptrace_h) $(target_h)
i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
$(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
$(dwarf2_frame_h) $(gdb_string_h) $(i386_tdep_h) \
@@ -2059,7 +2064,8 @@ ia64-aix-nat.o: ia64-aix-nat.c $(defs_h)
$(objfiles_h) $(gdb_stat_h)
ia64-aix-tdep.o: ia64-aix-tdep.c $(defs_h)
ia64-linux-nat.o: ia64-linux-nat.c $(defs_h) $(gdb_string_h) $(inferior_h) \
- $(target_h) $(gdbcore_h) $(regcache_h) $(gdb_wait_h) $(gregset_h)
+ $(target_h) $(gdbcore_h) $(regcache_h) $(gdb_wait_h) $(gregset_h) \
+ $(linux_nat_h)
ia64-linux-tdep.o: ia64-linux-tdep.c $(defs_h) $(ia64_tdep_h) \
$(arch_utils_h) $(gdbcore_h) $(regcache_h)
ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(gdbcore_h) \
@@ -2140,7 +2146,7 @@ linespec.o: linespec.c $(defs_h) $(symta
linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_string_h) \
$(gdb_wait_h) $(gdb_assert_h) $(linux_nat_h) $(gdbthread_h) \
$(gdbcmd_h) $(regcache_h) $(elf_bfd_h) $(gregset_h) $(gdbcore_h) \
- $(gdbthread_h) $(gdb_stat_h)
+ $(gdbthread_h) $(gdb_stat_h) $(inf_ptrace_h)
lynx-nat.o: lynx-nat.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
$(gdbcore_h) $(regcache_h)
m2-exp.o: m2-exp.c $(defs_h) $(gdb_string_h) $(expression_h) $(language_h) \
@@ -2155,7 +2161,7 @@ m2-valprint.o: m2-valprint.c $(defs_h) $
$(m2_lang_h)
m32r-linux-nat.o: m32r-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
$(regcache_h) $(linux_nat_h) $(gdb_assert_h) $(gdb_string_h) \
- $(gregset_h) $(m32r_tdep_h)
+ $(gregset_h) $(m32r_tdep_h) $(target_h)
m32r-linux-tdep.o: m32r-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
$(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
$(gdb_string_h) $(glibc_tdep_h) $(solib_svr4_h) $(trad_frame_h) \
@@ -2184,7 +2190,7 @@ m68kbsd-tdep.o: m68kbsd-tdep.c $(defs_h)
m68klinux-nat.o: m68klinux-nat.c $(defs_h) $(frame_h) $(inferior_h) \
$(language_h) $(gdbcore_h) $(gdb_string_h) $(regcache_h) \
$(m68k_tdep_h) $(gdb_stat_h) $(floatformat_h) $(target_h) \
- $(gregset_h)
+ $(gregset_h) $(target_h) $(linux_nat_h)
m68klinux-tdep.o: m68klinux-tdep.c $(defs_h) $(gdbcore_h) $(doublest_h) \
$(floatformat_h) $(frame_h) $(target_h) $(gdb_string_h) \
$(gdbtypes_h) $(osabi_h) $(regcache_h) $(objfiles_h) $(symtab_h) \
@@ -2240,7 +2246,8 @@ mips64obsd-tdep.o: mips64obsd-tdep.c $(d
$(regset_h) $(trad_frame_h) $(tramp_frame_h) $(gdb_assert_h) \
$(gdb_string_h) $(mips_tdep_h) $(solib_svr4_h)
mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h)
-mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h)
+mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) $(target_h) \
+ $(linux_nat_h)
mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \
$(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \
$(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \
@@ -2335,7 +2342,8 @@ ppcbug-rom.o: ppcbug-rom.c $(defs_h) $(g
$(serial_h) $(regcache_h)
ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdb_string_h) $(frame_h) \
$(inferior_h) $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \
- $(gdb_wait_h) $(gregset_h) $(ppc_tdep_h)
+ $(gdb_wait_h) $(gregset_h) $(ppc_tdep_h) $(target_h) \
+ $(linux_nat_h)
ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
$(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \
$(objfiles_h) $(regcache_h) $(value_h) $(osabi_h) $(regset_h) \
@@ -2440,7 +2448,7 @@ rs6000-tdep.o: rs6000-tdep.c $(defs_h) $
$(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \
$(frame_unwind_h) $(frame_base_h)
s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \
- $(s390_tdep_h)
+ $(s390_tdep_h) $(target_h) $(linux_nat_h)
s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \
$(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(objfiles_h) \
$(tm_h) $(__bfd_bfd_h) $(floatformat_h) $(regcache_h) \
@@ -2532,7 +2540,7 @@ sparc64fbsd-tdep.o: sparc64fbsd-tdep.c $
$(target_h) $(trad_frame_h) $(gdb_assert_h) $(gdb_string_h) \
$(sparc64_tdep_h)
sparc64-linux-nat.o: sparc64-linux-nat.c $(defs_h) $(sparc64_tdep_h) \
- $(sparc_nat_h)
+ $(sparc_nat_h) $(target_h) $(linux_nat_h)
sparc64-linux-tdep.o: sparc64-linux-tdep.c $(defs_h) $(gdbarch_h) $(osabi_h) \
$(sparc64_tdep_h)
sparc64-nat.o: sparc64-nat.c $(defs_h) $(gdbarch_h) $(sparc64_tdep_h) \
@@ -2554,6 +2562,7 @@ sparc64-tdep.o: sparc64-tdep.c $(defs_h)
$(gdbtypes_h) $(inferior_h) $(symtab_h) $(objfiles_h) $(osabi_h) \
$(regcache_h) $(target_h) $(value_h) $(gdb_assert_h) $(gdb_string_h) \
$(sparc64_tdep_h)
+sparc-linux-nat.o: sparc-linux-nat.c $(defs_h) $(target_h) $(linux_nat_h)
sparc-linux-tdep.o: sparc-linux-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
$(frame_unwind_h) $(gdbarch_h) $(gdbcore_h) $(osabi_h) $(regcache_h) \
$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
Index: alpha-linux-nat.c
===================================================================
RCS file: alpha-linux-nat.c
diff -N alpha-linux-nat.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ alpha-linux-nat.c 5 Dec 2004 17:52:07 -0000
@@ -0,0 +1,32 @@
+/* Low level Alpha GNU/Linux interface, for GDB when running native.
+ 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. */
+
+#include "defs.h"
+#include "target.h"
+#include "linux-nat.h"
+
+void _initialialize_alpha_linux_nat (void);
+
+void
+_initialize_alpha_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: amd64-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/amd64-linux-nat.c,v
retrieving revision 1.8
diff -u -p -r1.8 amd64-linux-nat.c
--- amd64-linux-nat.c 9 Apr 2004 21:16:05 -0000 1.8
+++ amd64-linux-nat.c 5 Dec 2004 05:41:41 -0000
@@ -360,11 +360,15 @@ ps_get_thread_area (const struct ps_proc
}
\f
+static void (*saved_post_startup_inferior) (ptid_t ptid);
+
+/* FIXME drow/2004-12-04: This function can be made static once the single-
+ and multi-threaded vectors in linux-nat.c are unified. */
void
child_post_startup_inferior (ptid_t ptid)
{
i386_cleanup_dregs ();
- linux_child_post_startup_inferior (ptid);
+ saved_post_startup_inferior (ptid);
}
\f
@@ -374,6 +378,8 @@ void _initialize_amd64_linux_nat (void);
void
_initialize_amd64_linux_nat (void)
{
+ struct target_ops *t;
+
amd64_native_gregset32_reg_offset = amd64_linux_gregset32_reg_offset;
amd64_native_gregset32_num_regs = I386_LINUX_NUM_REGS;
amd64_native_gregset64_reg_offset = amd64_linux_gregset64_reg_offset;
@@ -382,4 +388,14 @@ _initialize_amd64_linux_nat (void)
== amd64_native_gregset32_num_regs);
gdb_assert (ARRAY_SIZE (amd64_linux_gregset64_reg_offset)
== amd64_native_gregset64_num_regs);
+
+ /* Fill in the generic GNU/Linux methods. */
+ t = linux_target (NULL);
+
+ /* Override the GNU/Linux inferior startup hook. */
+ saved_post_startup_inferior = t->to_post_startup_inferior;
+ t->to_post_startup_inferior = child_post_startup_inferior;
+
+ /* Register the target. */
+ add_target (t);
}
Index: arm-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/arm-linux-nat.c,v
retrieving revision 1.21
diff -u -p -r1.21 arm-linux-nat.c
--- arm-linux-nat.c 24 Jul 2004 01:00:19 -0000 1.21
+++ arm-linux-nat.c 5 Dec 2004 06:12:09 -0000
@@ -1,5 +1,5 @@
/* GNU/Linux on ARM native support.
- Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@@ -23,6 +23,8 @@
#include "gdbcore.h"
#include "gdb_string.h"
#include "regcache.h"
+#include "target.h"
+#include "linux-nat.h"
#include "arm-tdep.h"
@@ -706,8 +708,12 @@ get_linux_version (unsigned int *vmajor,
return ((*vmajor << 16) | (*vminor << 8) | *vrelease);
}
+void _initialize_arm_linux_nat (void);
+
void
_initialize_arm_linux_nat (void)
{
os_version = get_linux_version (&os_major, &os_minor, &os_release);
+
+ add_target (linux_target (NULL));
}
Index: hppa-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/hppa-linux-nat.c,v
retrieving revision 1.8
diff -u -p -r1.8 hppa-linux-nat.c
--- hppa-linux-nat.c 24 Jul 2004 01:00:19 -0000 1.8
+++ hppa-linux-nat.c 5 Dec 2004 06:11:08 -0000
@@ -24,6 +24,8 @@
#include "regcache.h"
#include "gdb_string.h"
#include "inferior.h"
+#include "target.h"
+#include "linux-nat.h"
#include <sys/procfs.h>
#include <sys/ptrace.h>
@@ -374,3 +376,11 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
regcache_raw_collect (current_regcache, i, to);
}
}
+
+void _initialize_hppa_linux_nat (void);
+
+void
+_initialize_hppa_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: hppah-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/hppah-nat.c,v
retrieving revision 1.35
diff -u -p -r1.35 hppah-nat.c
--- hppah-nat.c 20 Nov 2004 23:56:18 -0000 1.35
+++ hppah-nat.c 5 Dec 2004 02:20:15 -0000
@@ -422,7 +422,7 @@ enum {
} saved_vfork_state = STATE_NONE;
int
-child_follow_fork (int follow_child)
+child_follow_fork (struct target_ops *ops, int follow_child)
{
ptid_t last_ptid;
struct target_waitstatus last_status;
Index: i386-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/i386-linux-nat.c,v
retrieving revision 1.61
diff -u -p -r1.61 i386-linux-nat.c
--- i386-linux-nat.c 8 Sep 2004 14:46:09 -0000 1.61
+++ i386-linux-nat.c 5 Dec 2004 06:09:39 -0000
@@ -23,7 +23,9 @@
#include "inferior.h"
#include "gdbcore.h"
#include "regcache.h"
+#include "target.h"
#include "linux-nat.h"
+#include "inf-ptrace.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -754,8 +756,8 @@ static const unsigned char linux_syscall
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
+i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
{
int pid = PIDGET (ptid);
@@ -813,9 +815,32 @@ child_resume (ptid_t ptid, int step, enu
perror_with_name ("ptrace");
}
+static void (*saved_post_startup_inferior) (ptid_t ptid);
+
+/* FIXME drow/2004-12-04: This function can be made static once the single-
+ and multi-threaded vectors in linux-nat.c are unified. */
void
child_post_startup_inferior (ptid_t ptid)
{
i386_cleanup_dregs ();
- linux_child_post_startup_inferior (ptid);
+ saved_post_startup_inferior (ptid);
+}
+
+void
+_initialize_i386_linux_nat (void)
+{
+ struct target_ops *t = inf_ptrace_target ();
+
+ /* Override the default ptrace resume method. */
+ t->to_resume = i386_linux_resume;
+
+ /* Fill in the generic GNU/Linux methods. */
+ t = linux_target (t);
+
+ /* Override the GNU/Linux inferior startup hook. */
+ saved_post_startup_inferior = t->to_post_startup_inferior;
+ t->to_post_startup_inferior = child_post_startup_inferior;
+
+ /* Register the target. */
+ add_target (t);
}
Index: ia64-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/ia64-linux-nat.c,v
retrieving revision 1.26
diff -u -p -r1.26 ia64-linux-nat.c
--- ia64-linux-nat.c 13 Oct 2004 21:40:41 -0000 1.26
+++ ia64-linux-nat.c 5 Dec 2004 05:49:30 -0000
@@ -27,6 +27,7 @@
#include "target.h"
#include "gdbcore.h"
#include "regcache.h"
+#include "linux-nat.h"
#include <signal.h>
#include <sys/ptrace.h>
@@ -665,12 +666,33 @@ ia64_linux_stopped_by_watchpoint (void)
return ia64_linux_stopped_data_address (&addr);
}
-LONGEST
-ia64_linux_xfer_unwind_table (struct target_ops *ops,
- enum target_object object,
- const char *annex,
- void *readbuf, const void *writebuf,
- ULONGEST offset, LONGEST len)
+LONGEST (*saved_xfer_partial) (struct target_ops *, enum target_object,
+ const char *, void *, const void *,
+ ULONGEST, LONGEST);
+
+static LONGEST
+ia64_linux_xfer_partial (struct target_ops *ops,
+ enum target_object object,
+ const char *annex,
+ void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
{
- return syscall (__NR_getunwind, readbuf, len);
+ if (object == TARGET_OBJECT_UNWIND_TABLE && writebuf == NULL && offset == 0)
+ return syscall (__NR_getunwind, readbuf, len);
+
+ return saved_xfer_partial (ops, object, annex, readbuf, writebuf,
+ offset, len);
+}
+
+void _initialize_ia64_linux_nat (void);
+
+void
+_initialize_ia64_linux_nat (void)
+{
+ struct target_ops *t = linux_target (NULL);
+
+ saved_xfer_partial = t->to_xfer_partial;
+ t->to_xfer_partial = ia64_linux_xfer_partial;
+
+ add_target (t);
}
Index: inf-child.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/inf-child.c,v
retrieving revision 1.4
diff -u -p -r1.4 inf-child.c
--- inf-child.c 29 Sep 2004 15:33:02 -0000 1.4
+++ inf-child.c 5 Dec 2004 02:20:42 -0000
@@ -123,7 +123,7 @@ inf_child_remove_vfork_catchpoint (int p
}
static int
-inf_child_follow_fork (int follow_child)
+inf_child_follow_fork (struct target_ops *ops, int follow_child)
{
/* This version of Unix doesn't support following fork or vfork
events. */
Index: inf-ptrace.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/inf-ptrace.c,v
retrieving revision 1.14
diff -u -p -r1.14 inf-ptrace.c
--- inf-ptrace.c 21 Nov 2004 13:51:53 -0000 1.14
+++ inf-ptrace.c 5 Dec 2004 02:44:58 -0000
@@ -394,7 +394,7 @@ inf_ptrace_remove_vfork_catchpoint (int
}
static int
-inf_ptrace_follow_fork (int follow_child)
+inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
{
/* This version of Unix doesn't support following fork or vfork events. */
return 0;
Index: inftarg.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/inftarg.c,v
retrieving revision 1.35
diff -u -p -r1.35 inftarg.c
--- inftarg.c 7 Nov 2004 21:33:29 -0000 1.35
+++ inftarg.c 5 Dec 2004 02:20:28 -0000
@@ -404,7 +404,7 @@ child_remove_vfork_catchpoint (int pid)
#if !defined(CHILD_FOLLOW_FORK)
int
-child_follow_fork (int follow_child)
+child_follow_fork (struct target_ops *ops, int follow_child)
{
/* This version of Unix doesn't support following fork or vfork events. */
return 0;
Index: linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/linux-nat.c,v
retrieving revision 1.17
diff -u -p -r1.17 linux-nat.c
--- linux-nat.c 21 Nov 2004 20:10:02 -0000 1.17
+++ linux-nat.c 5 Dec 2004 06:01:28 -0000
@@ -22,6 +22,7 @@
#include "defs.h"
#include "inferior.h"
#include "target.h"
+#include "inf-ptrace.h"
#include "gdb_string.h"
#include "gdb_wait.h"
#include "gdb_assert.h"
@@ -81,10 +82,31 @@
#define __WALL 0x40000000 /* Wait for any child. */
#endif
+/* Saved functions from the target vector. We override these in
+ linux_target, but we also want to call the originals. */
+
+static void (*saved_attach) (char *, int);
+static void (*saved_create_inferior) (char *, char *, char **, int);
+static void (*saved_detach) (char *, int);
+static void (*saved_mourn_inferior) (void);
+static void (*saved_resume) (ptid_t, int, enum target_signal);
+static LONGEST (*saved_xfer_partial) (struct target_ops *, enum target_object,
+ const char *, void *, const void *,
+ ULONGEST, LONGEST);
+
+
static int debug_linux_nat;
static int linux_parent_pid;
+static LONGEST linux_xfer_partial (struct target_ops *, enum target_object,
+ const char *, void *, const void *,
+ ULONGEST, LONGEST);
+
+static LONGEST linux_proc_xfer_memory (void *, const void *, ULONGEST,
+ LONGEST);
+
+
struct simple_pid_list
{
int pid;
@@ -324,7 +346,7 @@ child_post_startup_inferior (ptid_t ptid
#endif
int
-child_follow_fork (int follow_child)
+child_follow_fork (struct target_ops *ops, int follow_child)
{
ptid_t last_ptid;
struct target_waitstatus last_status;
@@ -446,7 +468,10 @@ child_follow_fork (int follow_child)
target_detach (NULL, 0);
inferior_ptid = pid_to_ptid (child_pid);
- push_target (&deprecated_child_ops);
+
+ /* Reinstall ourselves, since we might have been removed in
+ target_detach (which does other necessary cleanup). */
+ push_target (ops);
/* Reset breakpoints in the child as appropriate. */
follow_inferior_reset_breakpoints ();
@@ -898,7 +923,7 @@ linux_nat_attach (char *args, int from_t
/* FIXME: We should probably accept a list of process id's, and
attach all of them. */
- deprecated_child_ops.to_attach (args, from_tty);
+ saved_attach (args, from_tty);
/* Add the initial process as the first LWP to the list. */
lp = add_lwp (BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid)));
@@ -1008,7 +1033,7 @@ linux_nat_detach (char *args, int from_t
sigemptyset (&blocked_mask);
inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
- deprecated_child_ops.to_detach (args, from_tty);
+ saved_detach (args, from_tty);
}
/* Resume LP. */
@@ -1020,7 +1045,7 @@ resume_callback (struct lwp_info *lp, vo
{
struct thread_info *tp;
- child_resume (pid_to_ptid (GET_LWP (lp->ptid)), 0, TARGET_SIGNAL_0);
+ saved_resume (pid_to_ptid (GET_LWP (lp->ptid)), 0, TARGET_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"RC: PTRACE_CONT %s, 0, 0 (resume sibling)\n",
@@ -1094,7 +1119,7 @@ linux_nat_resume (ptid_t ptid, int step,
if (resume_all)
iterate_over_lwps (resume_callback, NULL);
- child_resume (ptid, step, signo);
+ saved_resume (ptid, step, signo);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LLR: %s %s, %s (resume event thread)\n",
@@ -1884,7 +1909,7 @@ retry:
/* Resume the thread. It should halt immediately returning the
pending SIGSTOP. */
registers_changed ();
- child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
+ saved_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
TARGET_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
@@ -2086,7 +2111,7 @@ retry:
lp->signalled = 0;
registers_changed ();
- child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
+ saved_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
TARGET_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
@@ -2146,7 +2171,7 @@ retry:
newly attached threads may cause an unwanted delay in
getting them running. */
registers_changed ();
- child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo);
+ saved_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LLW: %s %s, %s (preempt 'handle')\n",
@@ -2295,7 +2320,7 @@ static void
linux_nat_create_inferior (char *exec_file, char *allargs, char **env,
int from_tty)
{
- deprecated_child_ops.to_create_inferior (exec_file, allargs, env, from_tty);
+ saved_create_inferior (exec_file, allargs, env, from_tty);
}
static void
@@ -2310,25 +2335,7 @@ linux_nat_mourn_inferior (void)
sigprocmask (SIG_SETMASK, &normal_mask, NULL);
sigemptyset (&blocked_mask);
- deprecated_child_ops.to_mourn_inferior ();
-}
-
-static int
-linux_nat_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
-{
- struct cleanup *old_chain = save_inferior_ptid ();
- int xfer;
-
- if (is_lwp (inferior_ptid))
- inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
-
- xfer = linux_proc_xfer_memory (memaddr, myaddr, len, write, attrib, target);
- if (xfer == 0)
- xfer = child_xfer_memory (memaddr, myaddr, len, write, attrib, target);
-
- do_cleanups (old_chain);
- return xfer;
+ saved_mourn_inferior ();
}
static int
@@ -2380,7 +2387,7 @@ init_linux_nat_ops (void)
honor the LWP id, so we can use them directly. */
linux_nat_ops.to_fetch_registers = fetch_inferior_registers;
linux_nat_ops.to_store_registers = store_inferior_registers;
- linux_nat_ops.deprecated_xfer_memory = linux_nat_xfer_memory;
+ linux_nat_ops.to_xfer_partial = linux_xfer_partial;
linux_nat_ops.to_kill = linux_nat_kill;
linux_nat_ops.to_create_inferior = linux_nat_create_inferior;
linux_nat_ops.to_mourn_inferior = linux_nat_mourn_inferior;
@@ -2935,14 +2942,16 @@ linux_nat_info_proc_cmd (char *args, int
}
}
-int
-linux_proc_xfer_memory (CORE_ADDR addr, char *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
+static LONGEST
+linux_proc_xfer_memory (void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
{
- int fd, ret;
+ int fd;
+ LONGEST ret;
char filename[64];
- if (write)
+ /* We can't write to memory this way. */
+ if (writebuf != NULL)
return 0;
/* Don't bother for one word. */
@@ -2961,9 +2970,9 @@ linux_proc_xfer_memory (CORE_ADDR addr,
32-bit platforms (for instance, SPARC debugging a SPARC64
application). */
#ifdef HAVE_PREAD64
- if (pread64 (fd, myaddr, len, addr) != len)
+ if (pread64 (fd, readbuf, len, offset) != len)
#else
- if (lseek (fd, addr, SEEK_SET) == -1 || read (fd, myaddr, len) != len)
+ if (lseek (fd, offset, SEEK_SET) == -1 || read (fd, readbuf, len) != len)
#endif
ret = 0;
else
@@ -3060,9 +3069,6 @@ _initialize_linux_nat (void)
struct sigaction action;
extern void thread_db_init (struct target_ops *);
- deprecated_child_ops.to_find_memory_regions = linux_nat_find_memory_regions;
- deprecated_child_ops.to_make_corefile_notes = linux_nat_make_corefile_notes;
-
add_info ("proc", linux_nat_info_proc_cmd,
"Show /proc process information about any running process.\n\
Specify any process id, or use the program being debugged by default.\n\
@@ -3162,3 +3168,176 @@ lin_thread_get_thread_signals (sigset_t
/* ... except during a sigsuspend. */
sigdelset (&suspend_mask, cancel);
}
+
+#ifndef FETCH_INFERIOR_REGISTERS
+
+/* Fetch register REGNUM from the inferior. */
+
+static void
+fetch_register (int regnum)
+{
+ CORE_ADDR addr;
+ size_t size;
+ PTRACE_TYPE_RET *buf;
+ int tid, i;
+
+ if (CANNOT_FETCH_REGISTER (regnum))
+ {
+ regcache_raw_supply (current_regcache, regnum, NULL);
+ return;
+ }
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ /* This isn't really an address. But ptrace thinks of it as one. */
+ addr = register_addr (regnum, 0);
+ size = register_size (current_gdbarch, regnum);
+
+ gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
+ buf = alloca (size);
+
+ /* Read the register contents from the inferior a chuck at the time. */
+ for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
+ {
+ errno = 0;
+ buf[i] = ptrace (PT_READ_U, tid, (PTRACE_TYPE_ARG3) addr, 0);
+ if (errno != 0)
+ error ("Couldn't read register %s (#%d): %s.", REGISTER_NAME (regnum),
+ regnum, safe_strerror (errno));
+
+ addr += sizeof (PTRACE_TYPE_RET);
+ }
+ regcache_raw_supply (current_regcache, regnum, buf);
+}
+
+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
+ for all registers. */
+
+void
+fetch_inferior_registers (int regnum)
+{
+ if (regnum == -1)
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ fetch_register (regnum);
+ else
+ fetch_register (regnum);
+}
+
+/* Store register REGNUM into the inferior. */
+
+static void
+store_register (int regnum)
+{
+ CORE_ADDR addr;
+ size_t size;
+ PTRACE_TYPE_RET *buf;
+ int tid, i;
+
+ if (CANNOT_STORE_REGISTER (regnum))
+ return;
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ /* This isn't really an address. But ptrace thinks of it as one. */
+ addr = register_addr (regnum, 0);
+ size = register_size (current_gdbarch, regnum);
+
+ gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
+ buf = alloca (size);
+
+ /* Write the register contents into the inferior a chunk at the time. */
+ regcache_raw_collect (current_regcache, regnum, buf);
+ for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
+ {
+ errno = 0;
+ ptrace (PT_WRITE_U, tid, (PTRACE_TYPE_ARG3) addr, buf[i]);
+ if (errno != 0)
+ error ("Couldn't write register %s (#%d): %s.", REGISTER_NAME (regnum),
+ regnum, safe_strerror (errno));
+
+ addr += sizeof (PTRACE_TYPE_RET);
+ }
+}
+
+/* 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)
+{
+ if (regnum == -1)
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ store_register (regnum);
+ else
+ store_register (regnum);
+}
+
+#endif /* not FETCH_INFERIOR_REGISTERS. */
+
+/* Handle GNU/Linux specific target objects. */
+
+static LONGEST
+linux_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ if (object == TARGET_OBJECT_AUXV)
+ return procfs_xfer_auxv (ops, object, annex, readbuf, writebuf,
+ offset, len);
+
+ if (object == TARGET_OBJECT_MEMORY)
+ {
+ LONGEST ret;
+ ret = linux_proc_xfer_memory (readbuf, writebuf, offset, len);
+ if (ret != 0)
+ return ret;
+ }
+
+ return saved_xfer_partial (ops, object, annex, readbuf, writebuf,
+ offset, len);
+}
+
+/* Create a generic GNU/Linux target vector. If T is non-NULL, base
+ the new target vector on it. */
+
+struct target_ops *
+linux_target (struct target_ops *t)
+{
+ if (t == NULL)
+ t = inf_ptrace_target ();
+
+ /* Save inf-ptrace methods that we enhance. */
+ saved_attach = t->to_attach;
+ saved_create_inferior = t->to_create_inferior;
+ saved_detach = t->to_attach;
+ saved_mourn_inferior = t->to_mourn_inferior;
+ saved_resume = t->to_resume;
+ saved_xfer_partial = t->to_xfer_partial;
+
+ /* FIXME drow/2004-12-04: For now, these functions must keep the standard
+ names because only some GNU/Linux targets use inf-ptrace.o. When all
+ have been converted, these functions can be renamed and made static. */
+
+ t->to_wait = child_wait;
+ t->to_kill = kill_inferior;
+ t->to_pid_to_exec_file = child_pid_to_exec_file;
+ t->to_insert_fork_catchpoint = child_insert_fork_catchpoint;
+ t->to_insert_vfork_catchpoint = child_insert_vfork_catchpoint;
+ t->to_insert_exec_catchpoint = child_insert_exec_catchpoint;
+ t->to_post_startup_inferior = linux_child_post_startup_inferior;
+ t->to_post_attach = child_post_attach;
+ t->to_follow_fork = child_follow_fork;
+ t->to_fetch_registers = fetch_inferior_registers;
+ t->to_store_registers = store_inferior_registers;
+ t->to_xfer_partial = linux_xfer_partial;
+ t->to_find_memory_regions = linux_nat_find_memory_regions;
+ t->to_make_corefile_notes = linux_nat_make_corefile_notes;
+
+ return t;
+}
Index: linux-nat.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/linux-nat.h,v
retrieving revision 1.6
diff -u -p -r1.6 linux-nat.h
--- linux-nat.h 29 Mar 2004 18:07:14 -0000 1.6
+++ linux-nat.h 4 Dec 2004 23:00:31 -0000
@@ -68,10 +68,6 @@ struct lwp_info
struct mem_attrib;
struct target_ops;
-extern int linux_proc_xfer_memory (CORE_ADDR addr, char *myaddr, int len,
- int write, struct mem_attrib *attrib,
- struct target_ops *target);
-
/* Find process PID's pending signal set from /proc/pid/status. */
void linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored);
@@ -86,3 +82,5 @@ extern void linux_child_post_startup_inf
struct lwp_info *iterate_over_lwps (int (*callback) (struct lwp_info *,
void *),
void *data);
+
+struct target_ops *linux_target (struct target_ops *);
Index: linux-thread-db.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/linux-thread-db.c,v
retrieving revision 1.1
diff -u -p -r1.1 linux-thread-db.c
--- linux-thread-db.c 14 Nov 2004 18:47:50 -0000 1.1
+++ linux-thread-db.c 4 Dec 2004 22:58:10 -0000
@@ -969,9 +969,10 @@ thread_db_wait (ptid_t ptid, struct targ
return ptid;
}
-static int
-thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
+static LONGEST
+thread_db_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
{
struct cleanup *old_chain = save_inferior_ptid ();
int xfer;
@@ -987,8 +988,8 @@ thread_db_xfer_memory (CORE_ADDR memaddr
}
xfer =
- target_beneath->deprecated_xfer_memory (memaddr, myaddr, len, write,
- attrib, target);
+ target_beneath->to_xfer_partial (ops, object, annex, readbuf, writebuf,
+ offset, len);
do_cleanups (old_chain);
return xfer;
@@ -1339,7 +1340,7 @@ init_thread_db_ops (void)
thread_db_ops.to_wait = thread_db_wait;
thread_db_ops.to_fetch_registers = thread_db_fetch_registers;
thread_db_ops.to_store_registers = thread_db_store_registers;
- thread_db_ops.deprecated_xfer_memory = thread_db_xfer_memory;
+ thread_db_ops.to_xfer_partial = thread_db_xfer_partial;
thread_db_ops.to_kill = thread_db_kill;
thread_db_ops.to_create_inferior = thread_db_create_inferior;
thread_db_ops.to_post_startup_inferior = thread_db_post_startup_inferior;
Index: m32r-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/m32r-linux-nat.c,v
retrieving revision 1.1
diff -u -p -r1.1 m32r-linux-nat.c
--- m32r-linux-nat.c 1 Oct 2004 07:29:34 -0000 1.1
+++ m32r-linux-nat.c 5 Dec 2004 06:12:57 -0000
@@ -24,6 +24,7 @@
#include "gdbcore.h"
#include "regcache.h"
#include "linux-nat.h"
+#include "target.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -233,3 +234,11 @@ store_inferior_registers (int regno)
internal_error (__FILE__, __LINE__,
"Got request to store bad register number %d.", regno);
}
+
+void _initialize_m32r_linux_nat (void);
+
+void
+_initialize_m32r_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: m68klinux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/m68klinux-nat.c,v
retrieving revision 1.26
diff -u -p -r1.26 m68klinux-nat.c
--- m68klinux-nat.c 7 Sep 2004 21:55:11 -0000 1.26
+++ m68klinux-nat.c 5 Dec 2004 17:54:14 -0000
@@ -1,7 +1,7 @@
/* Motorola m68k native support for GNU/Linux.
- Copyright 1996, 1998, 2000, 2001, 2002 Free Software Foundation,
- Inc.
+ Copyright 1996, 1998, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -27,6 +27,8 @@
#include "gdbcore.h"
#include "gdb_string.h"
#include "regcache.h"
+#include "target.h"
+#include "linux-nat.h"
#include "m68k-tdep.h"
@@ -616,8 +618,11 @@ static struct core_fns linux_elf_core_fn
NULL /* next */
};
+void _initialize_m68k_linux_nat (void);
+
void
_initialize_m68k_linux_nat (void)
{
deprecated_add_core_fns (&linux_elf_core_fns);
+ add_target (linux_target (NULL));
}
Index: mips-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/mips-linux-nat.c,v
retrieving revision 1.9
diff -u -p -r1.9 mips-linux-nat.c
--- mips-linux-nat.c 30 Oct 2004 22:54:40 -0000 1.9
+++ mips-linux-nat.c 5 Dec 2004 06:09:14 -0000
@@ -1,6 +1,6 @@
/* Native-dependent code for GNU/Linux on MIPS processors.
- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@@ -21,6 +21,8 @@
#include "defs.h"
#include "mips-tdep.h"
+#include "target.h"
+#include "linux-nat.h"
/* Pseudo registers can not be read. ptrace does not provide a way to
read (or set) MIPS_PS_REGNUM, and there's no point in reading or
@@ -62,3 +64,11 @@ mips_linux_cannot_store_register (int re
else
return 1;
}
+
+void _initialize_mips_linux_nat (void);
+
+void
+_initialize_mips_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: ppc-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.52
diff -u -p -r1.52 ppc-linux-nat.c
--- ppc-linux-nat.c 4 Aug 2004 17:45:30 -0000 1.52
+++ ppc-linux-nat.c 5 Dec 2004 06:12:39 -0000
@@ -1,7 +1,7 @@
/* PPC GNU/Linux native support.
Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@@ -27,6 +27,8 @@
#include "gdbcore.h"
#include "regcache.h"
#include "gdb_assert.h"
+#include "target.h"
+#include "linux-nat.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -872,3 +874,11 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
right_fill_reg (tdep->ppc_fpscr_regnum, (fpp + 8 * 32));
}
}
+
+void _initialize_ppc_linux_nat (void);
+
+void
+_initialize_ppc_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: s390-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/s390-nat.c,v
retrieving revision 1.12
diff -u -p -r1.12 s390-nat.c
--- s390-nat.c 18 Feb 2004 04:17:35 -0000 1.12
+++ s390-nat.c 5 Dec 2004 17:42:29 -0000
@@ -25,6 +25,8 @@
#include "tm.h"
#include "regcache.h"
#include "inferior.h"
+#include "target.h"
+#include "linux-nat.h"
#include "s390-tdep.h"
@@ -357,3 +359,10 @@ kernel_u_size (void)
return sizeof (struct user);
}
+void _initialize_s390_nat (void);
+
+void
+_initialize_s390_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: sparc-linux-nat.c
===================================================================
RCS file: sparc-linux-nat.c
diff -N sparc-linux-nat.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sparc-linux-nat.c 5 Dec 2004 17:59:03 -0000
@@ -0,0 +1,32 @@
+/* Native-dependent code for GNU/Linux SPARC.
+ 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. */
+
+#include "defs.h"
+#include "target.h"
+#include "linux-nat.h"
+
+void _initialialize_sparc_linux_nat (void);
+
+void
+_initialize_sparc_linux_nat (void)
+{
+ add_target (linux_target (NULL));
+}
Index: sparc64-linux-nat.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/sparc64-linux-nat.c,v
retrieving revision 1.2
diff -u -p -r1.2 sparc64-linux-nat.c
--- sparc64-linux-nat.c 3 Jan 2004 10:08:44 -0000 1.2
+++ sparc64-linux-nat.c 5 Dec 2004 06:08:02 -0000
@@ -1,6 +1,6 @@
/* Native-dependent code for GNU/Linux UltraSPARC.
- Copyright 2003 Free Software Foundation, Inc.
+ Copyright 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
@@ -23,6 +23,8 @@
#include "sparc64-tdep.h"
#include "sparc-nat.h"
+#include "target.h"
+#include "linux-nat.h"
static const struct sparc_gregset sparc64_linux_ptrace_gregset =
{
@@ -45,4 +47,6 @@ void
_initialize_sparc64_linux_nat (void)
{
sparc_gregset = &sparc64_linux_ptrace_gregset;
+
+ add_target (linux_target (NULL));
}
Index: target.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/target.c,v
retrieving revision 1.90
diff -u -p -r1.90 target.c
--- target.c 8 Oct 2004 20:29:55 -0000 1.90
+++ target.c 5 Dec 2004 02:44:28 -0000
@@ -420,7 +420,7 @@ update_current_target (void)
INHERIT (to_remove_fork_catchpoint, t);
INHERIT (to_insert_vfork_catchpoint, t);
INHERIT (to_remove_vfork_catchpoint, t);
- INHERIT (to_follow_fork, t);
+ /* Do not inherit to_follow_fork. */
INHERIT (to_insert_exec_catchpoint, t);
INHERIT (to_remove_exec_catchpoint, t);
INHERIT (to_reported_exec_events_per_exec_call, t);
@@ -577,9 +577,6 @@ update_current_target (void)
de_fault (to_remove_vfork_catchpoint,
(int (*) (int))
tcomplain);
- de_fault (to_follow_fork,
- (int (*) (int))
- target_ignore);
de_fault (to_insert_exec_catchpoint,
(int (*) (int))
tcomplain);
@@ -1466,6 +1463,31 @@ target_async_mask (int mask)
}
/* Look through the list of possible targets for a target that can
+ follow forks. */
+
+int
+target_follow_fork (int follow_child)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_follow_fork != NULL)
+ {
+ int retval = t->to_follow_fork (t, follow_child);
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_follow_fork (%d) = %d\n",
+ follow_child, retval);
+ return retval;
+ }
+ }
+
+ /* Some target returned a fork event, but did not know how to follow it. */
+ internal_error (__FILE__, __LINE__,
+ "could not find a target to follow fork");
+}
+
+/* Look through the list of possible targets for a target that can
execute a run or attach command without any other data. This is
used to locate the default process stratum.
@@ -2310,17 +2332,6 @@ debug_to_remove_vfork_catchpoint (int pi
}
static int
-debug_to_follow_fork (int follow_child)
-{
- int retval = debug_target.to_follow_fork (follow_child);
-
- fprintf_unfiltered (gdb_stdlog, "target_follow_fork (%d) = %d\n",
- follow_child, retval);
-
- return retval;
-}
-
-static int
debug_to_insert_exec_catchpoint (int pid)
{
int retval;
@@ -2516,7 +2527,6 @@ setup_target_debug (void)
current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
- current_target.to_follow_fork = debug_to_follow_fork;
current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
Index: target.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/target.h,v
retrieving revision 1.65
diff -u -p -r1.65 target.h
--- target.h 8 Oct 2004 20:29:55 -0000 1.65
+++ target.h 5 Dec 2004 02:19:54 -0000
@@ -362,7 +362,7 @@ struct target_ops
int (*to_remove_fork_catchpoint) (int);
int (*to_insert_vfork_catchpoint) (int);
int (*to_remove_vfork_catchpoint) (int);
- int (*to_follow_fork) (int);
+ int (*to_follow_fork) (struct target_ops *, int);
int (*to_insert_exec_catchpoint) (int);
int (*to_remove_exec_catchpoint) (int);
int (*to_reported_exec_events_per_exec_call) (void);
@@ -581,7 +581,7 @@ extern int child_remove_vfork_catchpoint
extern void child_acknowledge_created_inferior (int);
-extern int child_follow_fork (int);
+extern int child_follow_fork (struct target_ops *, int);
extern int child_insert_exec_catchpoint (int);
@@ -746,8 +746,7 @@ extern void target_load (char *arg, int
This function returns 1 if the inferior should not be resumed
(i.e. there is another event pending). */
-#define target_follow_fork(follow_child) \
- (*current_target.to_follow_fork) (follow_child)
+int target_follow_fork (int follow_child);
/* On some targets, we can catch an inferior exec event when it
occurs. These functions insert/remove an already-created
Index: config/alpha/alpha-linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/alpha/alpha-linux.mh,v
retrieving revision 1.17
diff -u -p -r1.17 alpha-linux.mh
--- config/alpha/alpha-linux.mh 14 Nov 2004 18:47:50 -0000 1.17
+++ config/alpha/alpha-linux.mh 5 Dec 2004 18:00:21 -0000
@@ -1,6 +1,6 @@
# Host: Little-endian Alpha running Linux
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o corelow.o alpha-nat.o \
+NATDEPFILES= inf-ptrace.o corelow.o alpha-nat.o alpha-linux-nat.o \
fork-child.o proc-service.o linux-thread-db.o gcore.o \
linux-nat.o
Index: config/arm/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/arm/linux.mh,v
retrieving revision 1.15
diff -u -p -r1.15 linux.mh
--- config/arm/linux.mh 14 Nov 2004 18:47:51 -0000 1.15
+++ config/arm/linux.mh 5 Dec 2004 06:16:27 -0000
@@ -1,7 +1,7 @@
# Host: ARM based machine running GNU/Linux
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
core-regset.o arm-linux-nat.o gcore.o \
proc-service.o linux-thread-db.o linux-nat.o
Index: config/i386/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/i386/linux.mh,v
retrieving revision 1.17
diff -u -p -r1.17 linux.mh
--- config/i386/linux.mh 14 Nov 2004 18:47:51 -0000 1.17
+++ config/i386/linux.mh 4 Dec 2004 20:45:08 -0000
@@ -1,7 +1,7 @@
# Host: Intel 386 running GNU/Linux.
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
core-aout.o i386-nat.o i386-linux-nat.o \
proc-service.o linux-thread-db.o gcore.o \
linux-nat.o
Index: config/i386/linux64.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/i386/linux64.mh,v
retrieving revision 1.5
diff -u -p -r1.5 linux64.mh
--- config/i386/linux64.mh 14 Nov 2004 18:47:51 -0000 1.5
+++ config/i386/linux64.mh 5 Dec 2004 06:16:34 -0000
@@ -1,5 +1,5 @@
# Host: GNU/Linux x86-64
-NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
proc-service.o linux-thread-db.o gcore.o
NAT_FILE= nm-linux64.h
Index: config/i386/nm-linux.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/i386/nm-linux.h,v
retrieving revision 1.21
diff -u -p -r1.21 nm-linux.h
--- config/i386/nm-linux.h 20 Sep 2004 16:39:35 -0000 1.21
+++ config/i386/nm-linux.h 5 Dec 2004 06:03:11 -0000
@@ -79,16 +79,15 @@ extern int cannot_store_register (int re
#define FILL_FPXREGSET
#endif
-/* Override child_resume in `infptrace.c'. */
-#define DEPRECATED_CHILD_RESUME
-
/* `linux-nat.c' and `i386-nat.c' have their own versions of
child_post_startup_inferior. Define this to use the copy in
`i386-linux-nat.c' instead, which calls both.
- NOTE drow/2003-08-17: This is ugly beyond words, but properly
- fixing it will require some serious surgery. Ideally the target
- stack could be used for this. */
+ NOTE drow/2004-12-05: This can be removed once the GNU/Linux
+ single-threaded and multi-threaded vectors are unified. Until
+ then linux-nat.c needs to reference the right function named
+ 'child_post_startup_inferior'. */
+
#define LINUX_CHILD_POST_STARTUP_INFERIOR
#endif /* nm-linux.h */
Index: config/i386/nm-linux64.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/i386/nm-linux64.h,v
retrieving revision 1.2
diff -u -p -r1.2 nm-linux64.h
--- config/i386/nm-linux64.h 15 Aug 2004 16:10:23 -0000 1.2
+++ config/i386/nm-linux64.h 5 Dec 2004 06:03:17 -0000
@@ -57,7 +57,13 @@ extern unsigned long amd64_linux_dr_get_
/* `linux-nat.c' and `i386-nat.c' have their own versions of
child_post_startup_inferior. Define this to use the copy in
- `x86-86-linux-nat.c' instead, which calls both. */
+ `amd64-linux-nat.c' instead, which calls both.
+
+ NOTE drow/2004-12-05: This can be removed once the GNU/Linux
+ single-threaded and multi-threaded vectors are unified. Until
+ then linux-nat.c needs to reference the right function named
+ 'child_post_startup_inferior'. */
+
#define LINUX_CHILD_POST_STARTUP_INFERIOR
#endif /* nm-linux64.h */
Index: config/ia64/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/ia64/linux.mh,v
retrieving revision 1.18
diff -u -p -r1.18 linux.mh
--- config/ia64/linux.mh 14 Nov 2004 18:47:51 -0000 1.18
+++ config/ia64/linux.mh 5 Dec 2004 06:16:39 -0000
@@ -1,7 +1,7 @@
# Host: Intel IA-64 running GNU/Linux
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o gcore.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o gcore.o \
core-aout.o core-regset.o ia64-linux-nat.o \
proc-service.o linux-thread-db.o linux-nat.o
Index: config/ia64/nm-linux.h
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/ia64/nm-linux.h,v
retrieving revision 1.16
diff -u -p -r1.16 nm-linux.h
--- config/ia64/nm-linux.h 8 Oct 2004 17:30:48 -0000 1.16
+++ config/ia64/nm-linux.h 5 Dec 2004 05:49:21 -0000
@@ -75,15 +75,4 @@ extern int ia64_linux_insert_watchpoint
extern int ia64_linux_remove_watchpoint (ptid_t ptid, CORE_ADDR addr,
int len);
-#include "target.h"
-
-#define NATIVE_XFER_UNWIND_TABLE ia64_linux_xfer_unwind_table
-extern LONGEST ia64_linux_xfer_unwind_table (struct target_ops *ops,
- enum target_object object,
- const char *annex,
- void *readbuf,
- const void *writebuf,
- ULONGEST offset,
- LONGEST len);
-
#endif /* #ifndef NM_LINUX_H */
Index: config/m32r/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/m32r/linux.mh,v
retrieving revision 1.2
diff -u -p -r1.2 linux.mh
--- config/m32r/linux.mh 14 Nov 2004 18:47:51 -0000 1.2
+++ config/m32r/linux.mh 5 Dec 2004 06:16:45 -0000
@@ -1,7 +1,7 @@
# Host: M32R based machine running GNU/Linux
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
m32r-linux-nat.o gcore.o proc-service.o linux-thread-db.o \
linux-nat.o
Index: config/m68k/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/m68k/linux.mh,v
retrieving revision 1.16
diff -u -p -r1.16 linux.mh
--- config/m68k/linux.mh 14 Nov 2004 18:47:51 -0000 1.16
+++ config/m68k/linux.mh 5 Dec 2004 06:16:50 -0000
@@ -1,7 +1,7 @@
# Host: Motorola m68k running GNU/Linux.
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+NATDEPFILES= inf-ptrace.o fork-child.o \
corelow.o core-aout.o m68klinux-nat.o gcore.o \
proc-service.o linux-thread-db.o linux-nat.o
Index: config/mips/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/mips/linux.mh,v
retrieving revision 1.9
diff -u -p -r1.9 linux.mh
--- config/mips/linux.mh 14 Nov 2004 18:47:51 -0000 1.9
+++ config/mips/linux.mh 5 Dec 2004 06:16:57 -0000
@@ -1,6 +1,6 @@
# Host: Linux/MIPS
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o mips-linux-nat.o \
+NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
linux-thread-db.o proc-service.o gcore.o \
linux-nat.o
Index: config/pa/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/pa/linux.mh,v
retrieving revision 1.5
diff -u -p -r1.5 linux.mh
--- config/pa/linux.mh 14 Nov 2004 18:47:51 -0000 1.5
+++ config/pa/linux.mh 5 Dec 2004 06:17:05 -0000
@@ -1,7 +1,7 @@
# Host: Hewlett-Packard PA-RISC machine, running Linux
XDEPFILES=
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o gcore.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o gcore.o \
core-regset.o hppa-linux-nat.o \
proc-service.o linux-thread-db.o linux-nat.o
Index: config/powerpc/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/powerpc/linux.mh,v
retrieving revision 1.18
diff -u -p -r1.18 linux.mh
--- config/powerpc/linux.mh 14 Nov 2004 18:47:51 -0000 1.18
+++ config/powerpc/linux.mh 5 Dec 2004 06:17:11 -0000
@@ -3,7 +3,7 @@
XM_CLIBS=
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
gcore.o linux-nat.o
Index: config/powerpc/ppc64-linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/powerpc/ppc64-linux.mh,v
retrieving revision 1.7
diff -u -p -r1.7 ppc64-linux.mh
--- config/powerpc/ppc64-linux.mh 14 Nov 2004 18:47:51 -0000 1.7
+++ config/powerpc/ppc64-linux.mh 5 Dec 2004 06:17:16 -0000
@@ -3,7 +3,7 @@
XM_CLIBS=
NAT_FILE= nm-ppc64-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o \
+NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
gcore.o linux-nat.o
Index: config/s390/s390.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/s390/s390.mh,v
retrieving revision 1.12
diff -u -p -r1.12 s390.mh
--- config/s390/s390.mh 14 Nov 2004 18:47:52 -0000 1.12
+++ config/s390/s390.mh 5 Dec 2004 06:17:28 -0000
@@ -1,5 +1,5 @@
# Host: S390, running Linux
NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o s390-nat.o \
+NATDEPFILES= inf-ptrace.o fork-child.o corelow.o s390-nat.o \
gcore.o linux-thread-db.o proc-service.o linux-nat.o
LOADLIBES = -ldl -rdynamic
Index: config/sparc/linux.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/sparc/linux.mh,v
retrieving revision 1.15
diff -u -p -r1.15 linux.mh
--- config/sparc/linux.mh 14 Nov 2004 18:47:52 -0000 1.15
+++ config/sparc/linux.mh 5 Dec 2004 18:00:27 -0000
@@ -1,8 +1,7 @@
# Host: GNU/Linux SPARC
NAT_FILE= nm-linux.h
-NATDEPFILES= sparc-nat.o sparc-sol2-nat.o \
+NATDEPFILES= sparc-nat.o sparc-sol2-nat.o sparc-linux-nat.o \
corelow.o core-regset.o fork-child.o inf-ptrace.o \
- infptrace.o inftarg.o \
proc-service.o linux-thread-db.o \
gcore.o linux-nat.o
Index: config/sparc/linux64.mh
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/sparc/linux64.mh,v
retrieving revision 1.6
diff -u -p -r1.6 linux64.mh
--- config/sparc/linux64.mh 14 Nov 2004 18:47:52 -0000 1.6
+++ config/sparc/linux64.mh 5 Dec 2004 06:18:38 -0000
@@ -2,7 +2,7 @@
NAT_FILE= nm-linux.h
NATDEPFILES= sparc-nat.o sparc64-nat.o sparc-sol2-nat.o sparc64-linux-nat.o \
corelow.o core-regset.o \
- fork-child.o inf-ptrace.o infptrace.o inftarg.o \
+ fork-child.o inf-ptrace.o \
proc-service.o linux-thread-db.o \
gcore.o linux-nat.o
Index: config/djgpp/fnchange.lst
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/config/djgpp/fnchange.lst,v
retrieving revision 1.85
diff -u -p -r1.85 fnchange.lst
--- config/djgpp/fnchange.lst 20 Nov 2004 18:08:32 -0000 1.85
+++ config/djgpp/fnchange.lst 5 Dec 2004 18:15:50 -0000
@@ -79,6 +79,8 @@
@V@/gdb/alphabsd-nat.c @V@/gdb/alphb-nat.c
@V@/gdb/alphabsd-tdep.c @V@/gdb/alphb-tdep.c
@V@/gdb/alphanbsd-tdep.c @V@/gdb/alphnb-tdep.c
+@V@/gdb/alpha-linux-nat.c @V@/gdb/alphl-nat.c
+@V@/gdb/alpha-linux-tdep.c @V@/gdb/alphl-tdep.c
@V@/gdb/arm-linux-nat.c @V@/gdb/armlin-nat.c
@V@/gdb/arm-linux-tdep.c @V@/gdb/armlin-tdep.c
@V@/gdb/armnbsd-nat.c @V@/gdb/armnbd-nat.c
@@ -186,6 +188,8 @@
@V@/gdb/sparc64-sol2-tdep.c @V@/gdb/sp64s2-tdep.c
@V@/gdb/sparcnbsd-nat.c @V@/gdb/spnb-nat.c
@V@/gdb/sparcnbsd-tdep.c @V@/gdb/spnb-tdep.c
+@V@/gdb/sparc-linux-nat.c @V@/gdb/splx-nat.c
+@V@/gdb/sparc-linux-tdep.c @V@/gdb/splx-tdep.c
@V@/gdb/sparc-sol2-nat.c @V@/gdb/spsol2-nat.c
@V@/gdb/sparc-sol2-tdep.c @V@/gdb/spsol2-tdep.c
@V@/gdb/testsuite/.gdbinit @V@/gdb/testsuite/gdb.ini
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-05 18:48 [RFC] Use target vector inheritance for GNU/Linux Daniel Jacobowitz
@ 2004-12-06 14:41 ` Mark Kettenis
2004-12-06 14:43 ` Daniel Jacobowitz
2004-12-12 17:53 ` Andrew Cagney
2004-12-12 17:59 ` Andrew Cagney
2 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-06 14:41 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
Date: Sun, 5 Dec 2004 13:45:50 -0500
From: Daniel Jacobowitz <drow@false.org>
This patch converts all GNU/Linux targets to inf-ptrace.c and target vector
inheritance. I was going to do them one at a time, but because the common
native-specific code is so large for GNU/Linux, it was too awkward.
Daniel, thanks for attacking this.
A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
target can call it, and pass the result to add_target - after specializing
whatever methods it needs to. Sometimes it's necessary to specialize a
method between inf_ptrace_target and linux_target, so it accepts an optional
argument.
Yes, indeed, in particual the way the various Linux ports deal with
reading and writing registers is really different.
This wouldn't be necessary if all target methods took a
target_ops parameter, so they could call the overridden method.
I don't think so. The target_ops parameter is intended to provide a
way for strata to "inherit" stuff from other strata (i.e. the
core_stratum inheriting the to_xfer_partial method from the
file_stratum). Here we're talking about inheriting stuff from a
prototype vector within a single stratum.
One use of deprecated_child_ops was particularly thorny, so I updated the
to_follow_fork method to take a struct target_ops and push the correct
target. I made to_follow_fork a non-inherited method, like to_xfer_partial.
The comment just above target.c:update_current_target() suggests that
this is a step in the right direction.
This patch leaves some completely dead macros in config/nm-linux.h, and some
mostly-but-not-quite dead macros in various other nm-files. I'll be back.
I didn't want to change more than absolutely necessary, once I was committed
to doing all targets. My next step will be merging the two target vectors
in linux-nat.c.
I've tested this patch with the full testsuite on x86_64-linux and
i386-linux, partial testsuite on ia64-linux [it gets hung up in an
infinite loop in sigaltstack.exp with or without the patch], and smoke
testing on s390x [the machine I was using didn't have expect].
I'll try to test & cleanup sparc and possibly sparc64.
Comments? Proofreading? I'm going to let this sit for a couple of days,
because (while mechanical) it's very large - I think I got everything, but
since I don't have the resources to test on every single GNU/Linux native
target, I can't be sure.
I'm just wondering whether the saved_xxx variables should be called
linux_saved_xxx instead. Probably not...
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-06 14:41 ` Mark Kettenis
@ 2004-12-06 14:43 ` Daniel Jacobowitz
0 siblings, 0 replies; 12+ messages in thread
From: Daniel Jacobowitz @ 2004-12-06 14:43 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Mon, Dec 06, 2004 at 03:10:42PM +0100, Mark Kettenis wrote:
> A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
> target can call it, and pass the result to add_target - after specializing
> whatever methods it needs to. Sometimes it's necessary to specialize a
> method between inf_ptrace_target and linux_target, so it accepts an optional
> argument.
>
> Yes, indeed, in particual the way the various Linux ports deal with
> reading and writing registers is really different.
>
> This wouldn't be necessary if all target methods took a
> target_ops parameter, so they could call the overridden method.
>
> I don't think so. The target_ops parameter is intended to provide a
> way for strata to "inherit" stuff from other strata (i.e. the
> core_stratum inheriting the to_xfer_partial method from the
> file_stratum). Here we're talking about inheriting stuff from a
> prototype vector within a single stratum.
Right now the only thing I need this for is to find a method in this
target and stratum. i386-linux-nat.c provides to_resume, and
linux-nat.c used to call child_resume directly (because it can't use
target_resume, which would go through thread-db and back to linux-nat
again). So I have to somehow pass the pointer to the i386 resume to
linux-nat.c, and this seemed like the right way.
So from a short-term, literal perspective, what I wrote is correct: the
only reason that there is a target_ops argument to linux_target would
be unnecessary if there were more target methods that took their own
target_ops argument.
Long-term, with the target_ops arguments added, I'm really not sure.
The only difference would be whether the i386-linux version calls or is
called by the generic GNU/Linux version; and for all the examples I've
looked at, it doesn't matter.
> I've tested this patch with the full testsuite on x86_64-linux and
> i386-linux, partial testsuite on ia64-linux [it gets hung up in an
> infinite loop in sigaltstack.exp with or without the patch], and smoke
> testing on s390x [the machine I was using didn't have expect].
>
> I'll try to test & cleanup sparc and possibly sparc64.
Thank you very much! Randolph has also tested hppa-linux for me.
> Comments? Proofreading? I'm going to let this sit for a couple of days,
> because (while mechanical) it's very large - I think I got everything, but
> since I don't have the resources to test on every single GNU/Linux native
> target, I can't be sure.
>
> I'm just wondering whether the saved_xxx variables should be called
> linux_saved_xxx instead. Probably not...
Possibly, by analogy to the methods using them. I can rename if you'd
prefer.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-05 18:48 [RFC] Use target vector inheritance for GNU/Linux Daniel Jacobowitz
2004-12-06 14:41 ` Mark Kettenis
@ 2004-12-12 17:53 ` Andrew Cagney
2004-12-12 17:59 ` Andrew Cagney
2 siblings, 0 replies; 12+ messages in thread
From: Andrew Cagney @ 2004-12-12 17:53 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> One use of deprecated_child_ops was particularly thorny, so I updated the
> to_follow_fork method to take a struct target_ops and push the correct
> target. I made to_follow_fork a non-inherited method, like to_xfer_partial.
This change is ok (you've even copied across the debug printing!), but
commit it now so that it's not burried in amongst the other changes.
Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-05 18:48 [RFC] Use target vector inheritance for GNU/Linux Daniel Jacobowitz
2004-12-06 14:41 ` Mark Kettenis
2004-12-12 17:53 ` Andrew Cagney
@ 2004-12-12 17:59 ` Andrew Cagney
2004-12-12 21:45 ` Mark Kettenis
2 siblings, 1 reply; 12+ messages in thread
From: Andrew Cagney @ 2004-12-12 17:59 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> -LONGEST
> -ia64_linux_xfer_unwind_table (struct target_ops *ops,
> - enum target_object object,
> - const char *annex,
> - void *readbuf, const void *writebuf,
> - ULONGEST offset, LONGEST len)
> +LONGEST (*saved_xfer_partial) (struct target_ops *, enum target_object,
> + const char *, void *, const void *,
> + ULONGEST, LONGEST);
> +
> +static LONGEST
> +ia64_linux_xfer_partial (struct target_ops *ops,
> + enum target_object object,
> + const char *annex,
> + void *readbuf, const void *writebuf,
> + ULONGEST offset, LONGEST len)
> {
> - return syscall (__NR_getunwind, readbuf, len);
> + if (object == TARGET_OBJECT_UNWIND_TABLE && writebuf == NULL && offset == 0)
> + return syscall (__NR_getunwind, readbuf, len);
> +
> + return saved_xfer_partial (ops, object, annex, readbuf, writebuf,
> + offset, len);
> +}
Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
FIXME. It should be calling super.xfer_partial but that's not available :-(
+#ifndef FETCH_INFERIOR_REGISTERS
+
+/* Fetch register REGNUM from the inferior. */
+
+static void
+fetch_register (int regnum)
+{
Why is this wrapped in in an #ifdef?
+/* Create a generic GNU/Linux target vector. If T is non-NULL, base
+ the new target vector on it. */
+
+struct target_ops *
+linux_target (struct target_ops *t)
Can this be renamed to inf_linux_target (to be consistent with the other
inf_*_target() methods?
> A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
> target can call it, and pass the result to add_target - after specializing
> whatever methods it needs to. Sometimes it's necessary to specialize a
> method between inf_ptrace_target and linux_target, so it accepts an optional
> argument. This wouldn't be necessary if all target methods took a
> target_ops parameter, so they could call the overridden method.
As in this?
> +void
> +_initialize_i386_linux_nat (void)
> +{
> + struct target_ops *t = inf_ptrace_target ();
> +
> + /* Override the default ptrace resume method. */
> + t->to_resume = i386_linux_resume;
> +
> + /* Fill in the generic GNU/Linux methods. */
> + t = linux_target (t);
which is violating the inheritance structure. Can you instead add a
one-of method (deprecated_set_super_linux_resume?) to handle this case?
We can then see about fixing the problem (I'm left wondering if that
method is still needed).
> + /* FIXME drow/2004-12-04: For now, these functions must keep the standard
> + names because only some GNU/Linux targets use inf-ptrace.o. When all
> + have been converted, these functions can be renamed and made static. */
Is this still true? I thought the patch was so large because it touched
all the linux targets.
Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-12 17:59 ` Andrew Cagney
@ 2004-12-12 21:45 ` Mark Kettenis
2004-12-13 20:45 ` Andrew Cagney
0 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-12 21:45 UTC (permalink / raw)
To: cagney; +Cc: drow, gdb-patches
Date: Sun, 12 Dec 2004 12:51:29 -0500
From: Andrew Cagney <cagney@gnu.org>
> -LONGEST
> -ia64_linux_xfer_unwind_table (struct target_ops *ops,
> - enum target_object object,
> - const char *annex,
> - void *readbuf, const void *writebuf,
> - ULONGEST offset, LONGEST len)
> +LONGEST (*saved_xfer_partial) (struct target_ops *, enum target_object,
> + const char *, void *, const void *,
> + ULONGEST, LONGEST);
> +
> +static LONGEST
> +ia64_linux_xfer_partial (struct target_ops *ops,
> + enum target_object object,
> + const char *annex,
> + void *readbuf, const void *writebuf,
> + ULONGEST offset, LONGEST len)
> {
> - return syscall (__NR_getunwind, readbuf, len);
> + if (object == TARGET_OBJECT_UNWIND_TABLE && writebuf == NULL && offset == 0)
> + return syscall (__NR_getunwind, readbuf, len);
> +
> + return saved_xfer_partial (ops, object, annex, readbuf, writebuf,
> + offset, len);
> +}
Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
FIXME. It should be calling super.xfer_partial but that's not available :-(
Can you explain what you're hinting at here Andrew? What makes this
specific saved_xfer_partial so different from the other saved_xxx
instances that the patch introduces?
+#ifndef FETCH_INFERIOR_REGISTERS
+
+/* Fetch register REGNUM from the inferior. */
+
+static void
+fetch_register (int regnum)
+{
Why is this wrapped in in an #ifdef?
Some of the Linux target still need the crufty old code to read
registers using PTRACE_PEEKUSR. The new inf-ptrace.c doesn't provide
that functionality, so I guess Daniel inlined that bit of code here.
This is related to the FIXME below, and of course only temporary.
I'm working on something that will help resolving this problem, by
re-adding PT_READ_U support back into inf-ptrace.c in a clean fashion.
In the meantime, this hack allows us to go forwards.
+/* Create a generic GNU/Linux target vector. If T is non-NULL, base
+ the new target vector on it. */
+
+struct target_ops *
+linux_target (struct target_ops *t)
Can this be renamed to inf_linux_target (to be consistent with the other
inf_*_target() methods?
Apparently I don't agre with this since I already introduced
i386bsd_target and sparc_target; linux_target is consistent with that.
> A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
> target can call it, and pass the result to add_target - after specializing
> whatever methods it needs to. Sometimes it's necessary to specialize a
> method between inf_ptrace_target and linux_target, so it accepts an optional
> argument. This wouldn't be necessary if all target methods took a
> target_ops parameter, so they could call the overridden method.
As in this?
> +void
> +_initialize_i386_linux_nat (void)
> +{
> + struct target_ops *t = inf_ptrace_target ();
> +
> + /* Override the default ptrace resume method. */
> + t->to_resume = i386_linux_resume;
> +
> + /* Fill in the generic GNU/Linux methods. */
> + t = linux_target (t);
which is violating the inheritance structure. Can you instead add a
one-of method (deprecated_set_super_linux_resume?) to handle this case?
We can then see about fixing the problem (I'm left wondering if that
method is still needed).
No it isn't. At a very low level, all Linux ports are slightly
different. Most ports will need to adjust the generic ptrace target
before it can be inherited by the generic Linux target. In fact I
think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
out, you'll see that *all* Linux ports will need to do this trick of
adjusting the ptrace target before passing it to linux_target().
(And yes, I'm fairly certain the method is still needed. While the
problem may have been fixed in recent kernels, there are many older
Linux kernels out there.)
> + /* FIXME drow/2004-12-04: For now, these functions must keep the standard
> + names because only some GNU/Linux targets use inf-ptrace.o. When all
> + have been converted, these functions can be renamed and made static. */
Is this still true? I thought the patch was so large because it touched
all the linux targets.
Yes it is true. Daniels patch touches most (if not all) Linux
targets, but doesn't resolve all the issues. Some more work is
necessary. However, most of that work is non-mechanical. Given the
fact that many Linux targets are not actively maintained making the
acceptance of this patch depend on this patch depend on that work
would probably mean it will be dropped.
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-12 21:45 ` Mark Kettenis
@ 2004-12-13 20:45 ` Andrew Cagney
2004-12-13 22:29 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Cagney @ 2004-12-13 20:45 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
Mark Kettenis wrote:
> Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
> FIXME. It should be calling super.xfer_partial but that's not available :-(
>
> Can you explain what you're hinting at here Andrew? What makes this
> specific saved_xfer_partial so different from the other saved_xxx
> instances that the patch introduces?
Nothing? Changing those to be consistent with this would be a logical
next step.
> +#ifndef FETCH_INFERIOR_REGISTERS
> +
> +/* Fetch register REGNUM from the inferior. */
> +
> +static void
> +fetch_register (int regnum)
> +{
>
> Why is this wrapped in in an #ifdef?
>
> Some of the Linux target still need the crufty old code to read
> registers using PTRACE_PEEKUSR. The new inf-ptrace.c doesn't provide
> that functionality, so I guess Daniel inlined that bit of code here.
> This is related to the FIXME below, and of course only temporary.
So a fixme or other comment needs to be added at the point of this macro?
> +/* Create a generic GNU/Linux target vector. If T is non-NULL, base
> + the new target vector on it. */
> +
> +struct target_ops *
> +linux_target (struct target_ops *t)
>
> Can this be renamed to inf_linux_target (to be consistent with the other
> inf_*_target() methods?
>
> Apparently I don't agre with this since I already introduced
> i386bsd_target and sparc_target; linux_target is consistent with that.
You also added inf_ttrace_target.
> > A new function, linux_target, is added to linux-nat.c. Then any GNU/Linux
> > target can call it, and pass the result to add_target - after specializing
> > whatever methods it needs to. Sometimes it's necessary to specialize a
> > method between inf_ptrace_target and linux_target, so it accepts an optional
> > argument. This wouldn't be necessary if all target methods took a
> > target_ops parameter, so they could call the overridden method.
>
> As in this?
>
> > +void
> > +_initialize_i386_linux_nat (void)
> > +{
> > + struct target_ops *t = inf_ptrace_target ();
> > +
> > + /* Override the default ptrace resume method. */
> > + t->to_resume = i386_linux_resume;
> > +
> > + /* Fill in the generic GNU/Linux methods. */
> > + t = linux_target (t);
>
> which is violating the inheritance structure. Can you instead add a
> one-of method (deprecated_set_super_linux_resume?) to handle this case?
> We can then see about fixing the problem (I'm left wondering if that
> method is still needed).
>
> No it isn't. At a very low level, all Linux ports are slightly
> different. Most ports will need to adjust the generic ptrace target
> before it can be inherited by the generic Linux target. In fact I
> think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
> out, you'll see that *all* Linux ports will need to do this trick of
> adjusting the ptrace target before passing it to linux_target().
>
> (And yes, I'm fairly certain the method is still needed. While the
> problem may have been fixed in recent kernels, there are many older
> Linux kernels out there.)
You're on the right track, however the inheritance structure that the C
code is trying to mimic is:
i386LinuxInferior IS-A LinuxInferior IS-A PtraceInferior
with the i386LinuxInferior.resume method overriding LinuxInferior.resume
(which overrid PtraceInferior.resume); and not:
LinuxInferior IS-A i386LinuxInferior IS-A PtraceInferior
That the current inferior code doesn't facilitate this is a recognized
problem, but not one that we should get hung-up over. Hence my
suggestion of deprecated_set_super_linux_resume as a workaround until
that is fixed.
Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-13 20:45 ` Andrew Cagney
@ 2004-12-13 22:29 ` Mark Kettenis
2004-12-13 22:57 ` Andrew Cagney
0 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-13 22:29 UTC (permalink / raw)
To: cagney; +Cc: drow, gdb-patches
Date: Mon, 13 Dec 2004 15:41:56 -0500
From: Andrew Cagney <cagney@gnu.org>
Mark Kettenis wrote:
> Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
> FIXME. It should be calling super.xfer_partial but that's not available :-(
>
> Can you explain what you're hinting at here Andrew? What makes this
> specific saved_xfer_partial so different from the other saved_xxx
> instances that the patch introduces?
Nothing? Changing those to be consistent with this would be a logical
next step.
I suspect I don't see the big picture like you do, and I don't see why
you'd want a super.xfer_partial_hack. This construction isn't a hack
at all; it explicitly shows how the method is inherited. However,
super_xfer_partial is perhaps a better name than saved_xfer_partial.
> +#ifndef FETCH_INFERIOR_REGISTERS
> +
> +/* Fetch register REGNUM from the inferior. */
> +
> +static void
> +fetch_register (int regnum)
> +{
>
> Why is this wrapped in in an #ifdef?
>
> Some of the Linux target still need the crufty old code to read
> registers using PTRACE_PEEKUSR. The new inf-ptrace.c doesn't provide
> that functionality, so I guess Daniel inlined that bit of code here.
> This is related to the FIXME below, and of course only temporary.
So a fixme or other comment needs to be added at the point of this macro?
Wouldn't hurt, although that FIXME below is already there.
> +/* Create a generic GNU/Linux target vector. If T is non-NULL, base
> + the new target vector on it. */
> +
> +struct target_ops *
> +linux_target (struct target_ops *t)
>
> Can this be renamed to inf_linux_target (to be consistent with the other
> inf_*_target() methods?
>
> Apparently I don't agre with this since I already introduced
> i386bsd_target and sparc_target; linux_target is consistent with that.
You also added inf_ttrace_target.
Yup, since that one lives in inf-ttrace.c. The inf_ttrace_ prefix is
consistent with the naming of the other functions in the file, just as
i386bsd_target and sparc_target are consistent with the files they're
in.
> No it isn't. At a very low level, all Linux ports are slightly
> different. Most ports will need to adjust the generic ptrace target
> before it can be inherited by the generic Linux target. In fact I
> think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
> out, you'll see that *all* Linux ports will need to do this trick of
> adjusting the ptrace target before passing it to linux_target().
>
> (And yes, I'm fairly certain the method is still needed. While the
> problem may have been fixed in recent kernels, there are many older
> Linux kernels out there.)
You're on the right track, however the inheritance structure that the C
code is trying to mimic is:
i386LinuxInferior IS-A LinuxInferior IS-A PtraceInferior
Ah but that's not how the Linux-interfaces work (unless we drop
support for multi-threading). LinuxInferior needs platform-dependent
functionality that PtraceInferior doesn't (and shouldn't) provide.
with the i386LinuxInferior.resume method overriding LinuxInferior.resume
(which overrid PtraceInferior.resume); and not:
But having i386LinuxInferior override LinuxInferior.resume really
sucks because then it too has to do this insane dance of fiddling with
LWPs because of the braindamaged Linux threading model.
LinuxInferior IS-A i386LinuxInferior IS-A PtraceInferior
This reflects reality better, although it might even be:
i386LinuxInferior IS-A LinuxInferior IS-A i386LinuxPtraceInferior
IS-A PtraceInferior
But that breaks some OO rules of course.
That the current inferior code doesn't facilitate this is a recognized
problem, but not one that we should get hung-up over. Hence my
suggestion of deprecated_set_super_linux_resume as a workaround until
that is fixed.
It's not a problem with the current inferior code. There may be some
issues with the inferior code (like the ptrace_ops_hack), but this is
a fundamental problem with the Linux threads debugging interface.
Perhaps there simply shouldn't be a LinuxInferior:
i386LinuxInferior IS-A PtraceInferior
where we'de have some Linux-specific helper functions that can be used
to implement i386LinuxInferior.
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-13 22:29 ` Mark Kettenis
@ 2004-12-13 22:57 ` Andrew Cagney
2004-12-14 2:06 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Cagney @ 2004-12-13 22:57 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
Mark Kettenis wrote:
> Date: Mon, 13 Dec 2004 15:41:56 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> Mark Kettenis wrote:
>
> > Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
> > FIXME. It should be calling super.xfer_partial but that's not available :-(
> >
> > Can you explain what you're hinting at here Andrew? What makes this
> > specific saved_xfer_partial so different from the other saved_xxx
> > instances that the patch introduces?
>
> Nothing? Changing those to be consistent with this would be a logical
> next step.
>
> I suspect I don't see the big picture like you do, and I don't see why
> you'd want a super.xfer_partial_hack. This construction isn't a hack
> at all; it explicitly shows how the method is inherited. However,
> super_xfer_partial is perhaps a better name than saved_xfer_partial.
What big picture? You're starting to make this sound like a conspiracy
;-) If we had an O-O language we could call t.super.xfer_partial; we
don't so we hack around it using the global variable
super_xfer_partial_hack.
As I noted later, we should fix things so that the global variable hack
isn't needed. But hey, in the mean time, lets fix it's name and move on.
> > No it isn't. At a very low level, all Linux ports are slightly
> > different. Most ports will need to adjust the generic ptrace target
> > before it can be inherited by the generic Linux target. In fact I
> > think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
> > out, you'll see that *all* Linux ports will need to do this trick of
> > adjusting the ptrace target before passing it to linux_target().
> >
> > (And yes, I'm fairly certain the method is still needed. While the
> > problem may have been fixed in recent kernels, there are many older
> > Linux kernels out there.)
>
> You're on the right track, however the inheritance structure that the C
> code is trying to mimic is:
>
> i386LinuxInferior IS-A LinuxInferior IS-A PtraceInferior
>
> Ah but that's not how the Linux-interfaces work (unless we drop
> support for multi-threading). LinuxInferior needs platform-dependent
> functionality that PtraceInferior doesn't (and shouldn't) provide.
That is due to limitations in the current implementation, and not due to
issues with the Linux threading model (why you choose to blame GDB's
design flaws on the Linux threading model I don't know). The LWP layer
needs to always be active, and with that done the juggling you refer to
is eliminated.
However, attempting that is clearly a follow-on (and one that Daniel
wizely avoided), hence my suggestion to add a function as the interum.
Andrew
> with the i386LinuxInferior.resume method overriding LinuxInferior.resume
> (which overrid PtraceInferior.resume); and not:
>
> But having i386LinuxInferior override LinuxInferior.resume really
> sucks because then it too has to do this insane dance of fiddling with
> LWPs because of the braindamaged Linux threading model.
>
> LinuxInferior IS-A i386LinuxInferior IS-A PtraceInferior
>
> This reflects reality better, although it might even be:
>
> i386LinuxInferior IS-A LinuxInferior IS-A i386LinuxPtraceInferior
> IS-A PtraceInferior
>
> But that breaks some OO rules of course.
>
> That the current inferior code doesn't facilitate this is a recognized
> problem, but not one that we should get hung-up over. Hence my
> suggestion of deprecated_set_super_linux_resume as a workaround until
> that is fixed.
>
> It's not a problem with the current inferior code. There may be some
> issues with the inferior code (like the ptrace_ops_hack), but this is
> a fundamental problem with the Linux threads debugging interface.
> Perhaps there simply shouldn't be a LinuxInferior:
>
> i386LinuxInferior IS-A PtraceInferior
>
> where we'de have some Linux-specific helper functions that can be used
> to implement i386LinuxInferior.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-13 22:57 ` Andrew Cagney
@ 2004-12-14 2:06 ` Mark Kettenis
2004-12-14 15:41 ` Andrew Cagney
0 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-14 2:06 UTC (permalink / raw)
To: cagney; +Cc: drow, gdb-patches
Date: Mon, 13 Dec 2004 17:27:15 -0500
From: Andrew Cagney <cagney@gnu.org>
Mark Kettenis wrote:
> Date: Mon, 13 Dec 2004 15:41:56 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> Mark Kettenis wrote:
>
> > Can you rename saved_xfer_partial to super_xfer_partial_hack and add a
> > FIXME. It should be calling super.xfer_partial but that's not available :-(
> >
> > Can you explain what you're hinting at here Andrew? What makes this
> > specific saved_xfer_partial so different from the other saved_xxx
> > instances that the patch introduces?
>
> Nothing? Changing those to be consistent with this would be a logical
> next step.
>
> I suspect I don't see the big picture like you do, and I don't see why
> you'd want a super.xfer_partial_hack. This construction isn't a hack
> at all; it explicitly shows how the method is inherited. However,
> super_xfer_partial is perhaps a better name than saved_xfer_partial.
What big picture? You're starting to make this sound like a conspiracy
;-) If we had an O-O language we could call t.super.xfer_partial; we
don't so we hack around it using the global variable
super_xfer_partial_hack.
As I noted later, we should fix things so that the global variable hack
isn't needed. But hey, in the mean time, lets fix it's name and move on.
I don't agree it's a hack. It's the natural way to implement it in C.
> > No it isn't. At a very low level, all Linux ports are slightly
> > different. Most ports will need to adjust the generic ptrace target
> > before it can be inherited by the generic Linux target. In fact I
> > think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
> > out, you'll see that *all* Linux ports will need to do this trick of
> > adjusting the ptrace target before passing it to linux_target().
> >
> > (And yes, I'm fairly certain the method is still needed. While the
> > problem may have been fixed in recent kernels, there are many older
> > Linux kernels out there.)
>
> You're on the right track, however the inheritance structure that the C
> code is trying to mimic is:
>
> i386LinuxInferior IS-A LinuxInferior IS-A PtraceInferior
>
> Ah but that's not how the Linux-interfaces work (unless we drop
> support for multi-threading). LinuxInferior needs platform-dependent
> functionality that PtraceInferior doesn't (and shouldn't) provide.
That is due to limitations in the current implementation, and not due to
issues with the Linux threading model (why you choose to blame GDB's
design flaws on the Linux threading model I don't know). The LWP layer
needs to always be active, and with that done the juggling you refer to
is eliminated.
This has nothing to do with it. The problem is that
PtraceInferior.resume doesn't work correctly due to kernel bugs. We
need to fix that in GDB, and the best place to fix that is between
LinuxInferior and PtraceInferior. It's almost impossible to fix it in
something derived from LinuxInferior, since the implementation needs
access to linux-nat.c's internal state.
I simply think the way Daniel solved this, is the best way to do it.
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-14 2:06 ` Mark Kettenis
@ 2004-12-14 15:41 ` Andrew Cagney
2004-12-15 0:07 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Andrew Cagney @ 2004-12-14 15:41 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
Mark Kettenis wrote:
> What big picture? You're starting to make this sound like a conspiracy
> ;-) If we had an O-O language we could call t.super.xfer_partial; we
> don't so we hack around it using the global variable
> super_xfer_partial_hack.
>
> As I noted later, we should fix things so that the global variable hack
> isn't needed. But hey, in the mean time, lets fix it's name and move on.
>
> I don't agree it's a hack. It's the natural way to implement it in C.
Using C to solve an O-O problem is a hack, but what ever.
> > > No it isn't. At a very low level, all Linux ports are slightly
> > > different. Most ports will need to adjust the generic ptrace target
> > > before it can be inherited by the generic Linux target. In fact I
> > > think that when the FETCH_INFERIOR_REGISTERS issue above is sorted
> > > out, you'll see that *all* Linux ports will need to do this trick of
> > > adjusting the ptrace target before passing it to linux_target().
> > >
> > > (And yes, I'm fairly certain the method is still needed. While the
> > > problem may have been fixed in recent kernels, there are many older
> > > Linux kernels out there.)
> >
> > You're on the right track, however the inheritance structure that the C
> > code is trying to mimic is:
> >
> > i386LinuxInferior IS-A LinuxInferior IS-A PtraceInferior
> >
> > Ah but that's not how the Linux-interfaces work (unless we drop
> > support for multi-threading). LinuxInferior needs platform-dependent
> > functionality that PtraceInferior doesn't (and shouldn't) provide.
>
> That is due to limitations in the current implementation, and not due to
> issues with the Linux threading model (why you choose to blame GDB's
> design flaws on the Linux threading model I don't know). The LWP layer
> needs to always be active, and with that done the juggling you refer to
> is eliminated.
>
> This has nothing to do with it. The problem is that
> PtraceInferior.resume doesn't work correctly due to kernel bugs. We
> need to fix that in GDB, and the best place to fix that is between
> LinuxInferior and PtraceInferior. It's almost impossible to fix it in
> something derived from LinuxInferior, since the implementation needs
> access to linux-nat.c's internal state.
Er, that is what a virtual function (to use C++ terminology) lets you do.
FYI, this is the bug:
/* Returning from a signal trampoline is done by calling a
special system call (sigreturn or rt_sigreturn, see
i386-linux-tdep.c for more information). This system call
restores the registers that were saved when the signal was
raised, including %eflags. That means that single-stepping
won't work. Instead, we'll have to modify the signal context
that's about to be restored, and set the trace flag there. */
it turns out that to make this (and sig*.exp) work ment pushing through
kernel changes - been there, done that. That code is now redundant (I
tested my local GDB and that worked without it) and removing it would
make things faster.
Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] Use target vector inheritance for GNU/Linux
2004-12-14 15:41 ` Andrew Cagney
@ 2004-12-15 0:07 ` Mark Kettenis
0 siblings, 0 replies; 12+ messages in thread
From: Mark Kettenis @ 2004-12-15 0:07 UTC (permalink / raw)
To: cagney; +Cc: drow, gdb-patches
Date: Mon, 13 Dec 2004 21:03:34 -0500
From: Andrew Cagney <cagney@gnu.org>
> That is due to limitations in the current implementation, and not due to
> issues with the Linux threading model (why you choose to blame GDB's
> design flaws on the Linux threading model I don't know). The LWP layer
> needs to always be active, and with that done the juggling you refer to
> is eliminated.
>
> This has nothing to do with it. The problem is that
> PtraceInferior.resume doesn't work correctly due to kernel bugs. We
> need to fix that in GDB, and the best place to fix that is between
> LinuxInferior and PtraceInferior. It's almost impossible to fix it in
> something derived from LinuxInferior, since the implementation needs
> access to linux-nat.c's internal state.
Er, that is what a virtual function (to use C++ terminology) lets you do.
Yup.
FYI, this is the bug:
/* Returning from a signal trampoline is done by calling a
special system call (sigreturn or rt_sigreturn, see
i386-linux-tdep.c for more information). This system call
restores the registers that were saved when the signal was
raised, including %eflags. That means that single-stepping
won't work. Instead, we'll have to modify the signal context
that's about to be restored, and set the trace flag there. */
it turns out that to make this (and sig*.exp) work ment pushing through
kernel changes - been there, done that. That code is now redundant (I
tested my local GDB and that worked without it) and removing it would
make things faster.
I'm all for removing that hack when it's no longer necessary.
However, before we decide that it isn't, we should make sure that we
won't hurt existing users by doing so. IIRC you fixed this a couple
of months ago. So there are probably still many people using kernels
that aren't fixed. Was your bugfix backported and accepted in the
Linux 2.4 kernel? Anyway, We once claimed that we support Linux 2.0
and up. This probably doesn't make sense anymore, but there are
probably still many Linux 2.2 systems out there that people would like
to use the latest GDB on. So I suspect it is still too early to
remove this code.
Meanwhile, it'd be great if you could add something to the comment
that states the problem has been fixed. Please add the version(s) of
the official Linux kernel where this was fixed, and when they were
released. That will make it easier for us to decide when to remove
this code.
But even then, this is just one case of where platform-dependent
"fixes" for the generic ptrace code are necessary. I think GDB should
still allow for such bits of code in the future.
Thanks,
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-12-14 22:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-05 18:48 [RFC] Use target vector inheritance for GNU/Linux Daniel Jacobowitz
2004-12-06 14:41 ` Mark Kettenis
2004-12-06 14:43 ` Daniel Jacobowitz
2004-12-12 17:53 ` Andrew Cagney
2004-12-12 17:59 ` Andrew Cagney
2004-12-12 21:45 ` Mark Kettenis
2004-12-13 20:45 ` Andrew Cagney
2004-12-13 22:29 ` Mark Kettenis
2004-12-13 22:57 ` Andrew Cagney
2004-12-14 2:06 ` Mark Kettenis
2004-12-14 15:41 ` Andrew Cagney
2004-12-15 0:07 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox