This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/RFA] Target vectors for native Linux targets


Mark Kettenis wrote:

> Sorry, but you're not supposed to add anything to nm.h files anymore.
> Instead you should add things to the target vector.  Take a look at
> inf-ttrace.c on how to do this.
> 
> This may be hard to do at the moment, since the target vector stuff
> for native Linux targets is a bit of a mess.  That really needs to be
> fixed!

Some time ago I attempted to do this, but never got around to submitting
the patches.  This looks like a good opportunity to resurrect them ...

One problem with the conversion is that I wouldn't want to have to
convert all the various Linux subtargets at the same time.  It's a
lot of work, and I'm unable to test most of those platforms.  Thus
I've thought of a way to stage the conversion:

- First, linux-nat.c is changed to support either the old-style target
  (overriding deprecated_child_ops entries) or new-style targets
  implemented via a linux_target () routine.  The new style is selected
  by defining USE_LINUX_TARGET in the nm file.

  The patch in this mail implements this step.

- Then, Linux subtargets can be converted one by one to use the new style.
  I'd hope the various maintainers would take on their platforms.

  In a subsequent mail I'll send a patch implementing this step for s390.

- Once all targets have been converted, the remains of old-style support
  (and USE_LINUX_TARGET) are removed frome linux-nat.c.



The patch below implements the first step.  By itself, it shouldn't change
the behaviour at all.  The changes are relatively mechanical; in particular
the way the miscellaneous thread and process stratum target layers are
related to each other isn't changed at all -- the new style simply uses
a target generated by linux_target () instead of deprecated_child_ops
as process stratum.

To avoid calling child_xfer_memory I had to switch to using xfer_partial
instead.  This change also bubbled up to linux-thread-db.c.  (But seeing
as xfer_memory is deprecated, that's probably a good idea anyway.)

What do you think of this approach?

This patch was tested on s390x-ibm-linux without regressions.

Bye,
Ulrich


ChangeLog:

	* Makefile (linux-nat.o): Depend on $(inf_ptrace.h) and $(auxv_h).
	* linux-nat.c: Include "inf_prtrace.h" and "auxv.h".
	(linux_ops): New global variable.
	(child_follow_fork): Use it instead of deprecated_child_ops.
	(linux_nat_attach, linux_nat_detach): Likewise.
	(resume_callback, linux_nat_resume): Likewise.
	(linux_nat_create_inferior, linux_nat_mourn_inferior): Likewise.
	(linux_nat_wait): Use linux_ops->to_resume instead of child_resume.
	(child_wait): Do not depend on CHILD_WAIT.
	(linux_nat_xfer_memory): Remove, replace by ...
	(linux_nat_xfer_partial): ... this.  Use linux_ops->to_xfer_partial
	instead of child_xfer_memory.
	(linux_nat_fetch_registers, linux_nat_store_registers): New functions.
	(init_linux_nat_ops): Use them instead of fetch_inferior_register
	and store_inferior_registers.  Set to_xfer_partial instead of
	deprecated_xfer_memory.
	(linux_proc_xfer_memory): Remove, replace by ...
	(linux_proc_xfer_partial): ... this.  Make static.
	(inf_ptrace_xfer_partial): New global variable.
	(linux_xfer_partial): New function.
	(linux_target): New function.
	(_initialize_linux_nat): If USE_LINUX_TARGET, do not modify
	deprecated_child_ops.
	* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
	(struct mem_attrib, struct target_ops): Remove forward declarations.
	(linux_target): Add prototype.
	* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
	(thread_db_xfer_partial): ... this.
	(init_thread_db_ops): Set to_xfer_partial instead of
	deprecated_xfer_memory.
	* config/nm-linux.h (struct target_waitstatus, child_wait, CHILD_WAIT,
	CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT,
	CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT,
	CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK,
	DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV, #include "auxv.h"):
	Remove unless USE_LINUX_TARGET.


Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.742
diff -c -p -r1.742 Makefile.in
*** gdb/Makefile.in	8 Aug 2005 20:59:18 -0000	1.742
--- gdb/Makefile.in	18 Aug 2005 23:45:50 -0000
*************** linespec.o: linespec.c $(defs_h) $(symta
*** 2174,2181 ****
  	$(objc_lang_h) $(linespec_h) $(exceptions_h)
  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)
  linux-thread-db.o: linux-thread-db.c $(defs_h) $(gdb_assert_h) \
  	$(gdb_proc_service_h) $(gdb_thread_db_h) $(bfd_h) $(exceptions_h) \
  	$(gdbthread_h) $(inferior_h) $(symfile_h) $(objfiles_h) $(target_h) \
--- 2174,2181 ----
  	$(objc_lang_h) $(linespec_h) $(exceptions_h)
  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) $(inf_ptrace.h) $(auxv.h) $(elf_bfd_h) \
! 	$(gregset_h) $(gdbcore_h) $(gdbthread_h) $(gdb_stat_h)
  linux-thread-db.o: linux-thread-db.c $(defs_h) $(gdb_assert_h) \
  	$(gdb_proc_service_h) $(gdb_thread_db_h) $(bfd_h) $(exceptions_h) \
  	$(gdbthread_h) $(inferior_h) $(symfile_h) $(objfiles_h) $(target_h) \
Index: gdb/linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.31
diff -c -p -r1.31 linux-nat.c
*** gdb/linux-nat.c	9 Aug 2005 16:35:45 -0000	1.31
--- gdb/linux-nat.c	18 Aug 2005 23:45:50 -0000
***************
*** 34,39 ****
--- 34,41 ----
  #include "gdbthread.h"
  #include "gdbcmd.h"
  #include "regcache.h"
+ #include "inf-ptrace.h"
+ #include "auxv.h"
  #include <sys/param.h>		/* for MAXPATHLEN */
  #include <sys/procfs.h>		/* for elf_gregset etc. */
  #include "elf-bfd.h"		/* for elfcore_write_* */
***************
*** 81,86 ****
--- 83,96 ----
  #define __WALL          0x40000000 /* Wait for any child.  */
  #endif
  
+ /* FIXME: All USE_LINUX_TARGET ifdefs can be removed once all GNU/Linux
+    targets have been modified to use linux_target.  */
+ #ifndef USE_LINUX_TARGET
+ static struct target_ops *linux_ops = &deprecated_child_ops;
+ #else
+ static struct target_ops *linux_ops;
+ #endif
+ 
  static int debug_linux_nat;
  static void
  show_debug_linux_nat (struct ui_file *file, int from_tty,
*************** child_follow_fork (int follow_child)
*** 466,472 ****
  	target_detach (NULL, 0);
  
        inferior_ptid = pid_to_ptid (child_pid);
!       push_target (&deprecated_child_ops);
  
        /* Reset breakpoints in the child as appropriate.  */
        follow_inferior_reset_breakpoints ();
--- 476,482 ----
  	target_detach (NULL, 0);
  
        inferior_ptid = pid_to_ptid (child_pid);
!       push_target (linux_ops);
  
        /* Reset breakpoints in the child as appropriate.  */
        follow_inferior_reset_breakpoints ();
*************** linux_nat_attach (char *args, int from_t
*** 910,916 ****
  
    /* FIXME: We should probably accept a list of process id's, and
       attach all of them.  */
!   deprecated_child_ops.to_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)));
--- 920,926 ----
  
    /* FIXME: We should probably accept a list of process id's, and
       attach all of them.  */
!   linux_ops->to_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)));
*************** linux_nat_detach (char *args, int from_t
*** 1020,1026 ****
    sigemptyset (&blocked_mask);
  
    inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
!   deprecated_child_ops.to_detach (args, from_tty);
  }
  
  /* Resume LP.  */
--- 1030,1036 ----
    sigemptyset (&blocked_mask);
  
    inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
!   linux_ops->to_detach (args, from_tty);
  }
  
  /* Resume LP.  */
*************** resume_callback (struct lwp_info *lp, vo
*** 1032,1038 ****
      {
        struct thread_info *tp;
  
!       child_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",
--- 1042,1049 ----
      {
        struct thread_info *tp;
  
!       linux_ops->to_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",
*************** linux_nat_resume (ptid_t ptid, int step,
*** 1106,1112 ****
    if (resume_all)
      iterate_over_lwps (resume_callback, NULL);
  
!   child_resume (ptid, step, signo);
    if (debug_linux_nat)
      fprintf_unfiltered (gdb_stdlog,
  			"LLR: %s %s, %s (resume event thread)\n",
--- 1117,1123 ----
    if (resume_all)
      iterate_over_lwps (resume_callback, NULL);
  
!   linux_ops->to_resume (ptid, step, signo);
    if (debug_linux_nat)
      fprintf_unfiltered (gdb_stdlog,
  			"LLR: %s %s, %s (resume event thread)\n",
*************** resumed_callback (struct lwp_info *lp, v
*** 1680,1687 ****
    return lp->resumed;
  }
  
- #ifdef CHILD_WAIT
- 
  /* We need to override child_wait to support attaching to cloned
     processes, since a normal wait (as done by the default version)
     ignores those processes.  */
--- 1691,1696 ----
*************** child_wait (ptid_t ptid, struct target_w
*** 1786,1793 ****
    return pid_to_ptid (pid);
  }
  
- #endif
- 
  /* Stop an active thread, verify it still exists, then resume it.  */
  
  static int
--- 1795,1800 ----
*************** retry:
*** 1896,1903 ****
        /* Resume the thread.  It should halt immediately returning the
           pending SIGSTOP.  */
        registers_changed ();
!       child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
! 		    TARGET_SIGNAL_0);
        if (debug_linux_nat)
  	fprintf_unfiltered (gdb_stdlog,
  			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
--- 1903,1910 ----
        /* Resume the thread.  It should halt immediately returning the
           pending SIGSTOP.  */
        registers_changed ();
!       linux_ops->to_resume (pid_to_ptid (GET_LWP (lp->ptid)),
! 			    lp->step, TARGET_SIGNAL_0);
        if (debug_linux_nat)
  	fprintf_unfiltered (gdb_stdlog,
  			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
*************** retry:
*** 2098,2105 ****
  	      lp->signalled = 0;
  
  	      registers_changed ();
! 	      child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
! 			    TARGET_SIGNAL_0);
  	      if (debug_linux_nat)
  		fprintf_unfiltered (gdb_stdlog,
  				    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
--- 2105,2112 ----
  	      lp->signalled = 0;
  
  	      registers_changed ();
! 	      linux_ops->to_resume (pid_to_ptid (GET_LWP (lp->ptid)),
! 				    lp->step, TARGET_SIGNAL_0);
  	      if (debug_linux_nat)
  		fprintf_unfiltered (gdb_stdlog,
  				    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
*************** retry:
*** 2158,2164 ****
  	     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);
  	  if (debug_linux_nat)
  	    fprintf_unfiltered (gdb_stdlog,
  				"LLW: %s %s, %s (preempt 'handle')\n",
--- 2165,2172 ----
  	     newly attached threads may cause an unwanted delay in
  	     getting them running.  */
  	  registers_changed ();
! 	  linux_ops->to_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",
*************** static void
*** 2307,2313 ****
  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);
  }
  
  static void
--- 2315,2321 ----
  linux_nat_create_inferior (char *exec_file, char *allargs, char **env,
  			 int from_tty)
  {
!   linux_ops->to_create_inferior (exec_file, allargs, env, from_tty);
  }
  
  static void
*************** linux_nat_mourn_inferior (void)
*** 2322,2345 ****
    sigprocmask (SIG_SETMASK, &normal_mask, NULL);
    sigemptyset (&blocked_mask);
  
!   deprecated_child_ops.to_mourn_inferior ();
  }
  
! static int
! linux_nat_xfer_memory (CORE_ADDR memaddr, gdb_byte *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;
  }
--- 2330,2360 ----
    sigprocmask (SIG_SETMASK, &normal_mask, NULL);
    sigemptyset (&blocked_mask);
  
!   linux_ops->to_mourn_inferior ();
  }
  
! static LONGEST
! linux_proc_xfer_partial (struct target_ops *ops, enum target_object object,
! 			 const char *annex, gdb_byte *readbuf,
! 			 const gdb_byte *writebuf,
! 			 ULONGEST offset, LONGEST len);
! static LONGEST
! linux_nat_xfer_partial (struct target_ops *ops, enum target_object object,
! 			const char *annex, gdb_byte *readbuf,
! 			const gdb_byte *writebuf,
! 			ULONGEST offset, LONGEST len)
  {
    struct cleanup *old_chain = save_inferior_ptid ();
!   LONGEST xfer;
  
    if (is_lwp (inferior_ptid))
      inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
  
!   xfer = linux_proc_xfer_partial (ops, object, annex,
! 				  readbuf, writebuf, offset, len);
    if (xfer == 0)
!     xfer = linux_ops->to_xfer_partial (ops, object, annex,
! 				       readbuf, writebuf, offset, len);
    do_cleanups (old_chain);
    return xfer;
  }
*************** linux_nat_pid_to_str (ptid_t ptid)
*** 2377,2382 ****
--- 2392,2409 ----
  }
  
  static void
+ linux_nat_fetch_registers (int regnum)
+ {
+   linux_ops->to_fetch_registers (regnum);
+ }
+ 
+ static void
+ linux_nat_store_registers (int regnum)
+ {
+   linux_ops->to_store_registers (regnum);
+ }
+ 
+ static void
  init_linux_nat_ops (void)
  {
  #if 0
*************** init_linux_nat_ops (void)
*** 2389,2399 ****
    linux_nat_ops.to_detach = linux_nat_detach;
    linux_nat_ops.to_resume = linux_nat_resume;
    linux_nat_ops.to_wait = linux_nat_wait;
!   /* fetch_inferior_registers and store_inferior_registers will
!      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_kill = linux_nat_kill;
    linux_nat_ops.to_create_inferior = linux_nat_create_inferior;
    linux_nat_ops.to_mourn_inferior = linux_nat_mourn_inferior;
--- 2416,2424 ----
    linux_nat_ops.to_detach = linux_nat_detach;
    linux_nat_ops.to_resume = linux_nat_resume;
    linux_nat_ops.to_wait = linux_nat_wait;
!   linux_nat_ops.to_fetch_registers = linux_nat_fetch_registers;
!   linux_nat_ops.to_store_registers = linux_nat_store_registers;
!   linux_nat_ops.to_xfer_partial = linux_nat_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;
*************** linux_nat_info_proc_cmd (char *args, int
*** 2945,2958 ****
      }
  }
  
! int
! linux_proc_xfer_memory (CORE_ADDR addr, gdb_byte *myaddr, int len, int write,
! 			struct mem_attrib *attrib, struct target_ops *target)
  {
!   int fd, ret;
    char filename[64];
  
!   if (write)
      return 0;
  
    /* Don't bother for one word.  */
--- 2970,2986 ----
      }
  }
  
! static LONGEST
! linux_proc_xfer_partial (struct target_ops *ops, enum target_object object,
! 			 const char *annex, gdb_byte *readbuf,
! 			 const gdb_byte *writebuf,
! 			 ULONGEST offset, LONGEST len)
  {
!   LONGEST ret;
!   int fd;
    char filename[64];
  
!   if (object != TARGET_OBJECT_MEMORY || !readbuf)
      return 0;
  
    /* Don't bother for one word.  */
*************** linux_proc_xfer_memory (CORE_ADDR addr, 
*** 2971,2979 ****
       32-bit platforms (for instance, SPARC debugging a SPARC64
       application).  */
  #ifdef HAVE_PREAD64
!   if (pread64 (fd, myaddr, len, addr) != len)
  #else
!   if (lseek (fd, addr, SEEK_SET) == -1 || read (fd, myaddr, len) != len)
  #endif
      ret = 0;
    else
--- 2999,3007 ----
       32-bit platforms (for instance, SPARC debugging a SPARC64
       application).  */
  #ifdef HAVE_PREAD64
!   if (pread64 (fd, readbuf, len, offset) != len)
  #else
!   if (lseek (fd, offset, SEEK_SET) == -1 || read (fd, readbuf, len) != len)
  #endif
      ret = 0;
    else
*************** linux_proc_pending_signals (int pid, sig
*** 3064,3077 ****
--- 3092,3154 ----
    fclose (procfile);
  }
  
+ #ifdef USE_LINUX_TARGET
+ LONGEST (*inf_ptrace_xfer_partial) (struct target_ops *, enum target_object,
+                                     const char *, gdb_byte *, const gdb_byte *,
+                                     ULONGEST, LONGEST);
+ 
+ static LONGEST
+ linux_xfer_partial (struct target_ops *ops, enum target_object object,
+                     const char *annex, gdb_byte *readbuf,
+ 		    const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ {
+   if (object == TARGET_OBJECT_AUXV)
+     return procfs_xfer_auxv (ops, object, annex, readbuf, writebuf,
+                              offset, len);
+ 
+   return inf_ptrace_xfer_partial (ops, object, annex, readbuf, writebuf,
+                                   offset, len);
+ }
+ 
+ /* Create a prototype generic Linux target.  The client can override
+    it with local methods.  */
+ 
+ struct target_ops *
+ linux_target (void)
+ {
+   struct target_ops *t;
+ 
+   t = inf_ptrace_target ();
+   t->to_wait = child_wait;
+   t->to_kill = kill_inferior;
+   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_pid_to_exec_file = child_pid_to_exec_file;
+   t->to_post_startup_inferior = child_post_startup_inferior;
+   t->to_post_attach = child_post_attach;
+   t->to_follow_fork = child_follow_fork;
+   t->to_find_memory_regions = linux_nat_find_memory_regions;
+   t->to_make_corefile_notes = linux_nat_make_corefile_notes;
+ 
+   inf_ptrace_xfer_partial = t->to_xfer_partial;
+   t->to_xfer_partial = linux_xfer_partial;
+ 
+   linux_ops = t;
+   return t;
+ }
+ #endif /* USE_LINUX_TARGET */
+ 
  void
  _initialize_linux_nat (void)
  {
    struct sigaction action;
    extern void thread_db_init (struct target_ops *);
  
+ #ifndef USE_LINUX_TARGET
    deprecated_child_ops.to_find_memory_regions = linux_nat_find_memory_regions;
    deprecated_child_ops.to_make_corefile_notes = linux_nat_make_corefile_notes;
+ #endif
  
    add_info ("proc", linux_nat_info_proc_cmd, _("\
  Show /proc process information about any running process.\n\
Index: gdb/linux-nat.h
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.h,v
retrieving revision 1.7
diff -c -p -r1.7 linux-nat.h
*** gdb/linux-nat.h	9 Aug 2005 16:35:45 -0000	1.7
--- gdb/linux-nat.h	18 Aug 2005 23:45:50 -0000
*************** struct lwp_info
*** 63,76 ****
    struct lwp_info *next;
  };
  
- /* Read/write to target memory via the Linux kernel's "proc file
-    system".  */
- struct mem_attrib;
- struct target_ops;
- 
- extern int linux_proc_xfer_memory (CORE_ADDR addr, gdb_byte *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);
--- 63,68 ----
*************** extern void linux_child_post_startup_inf
*** 86,88 ****
--- 78,86 ----
  struct lwp_info *iterate_over_lwps (int (*callback) (struct lwp_info *, 
  						     void *), 
  				    void *data);
+ 
+ 
+ /* Create a prototype generic Linux target.  The client can override
+    it with local methods.  */
+ struct target_ops * linux_target (void);
+ 
Index: gdb/linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.9
diff -c -p -r1.9 linux-thread-db.c
*** gdb/linux-thread-db.c	28 May 2005 16:44:29 -0000	1.9
--- gdb/linux-thread-db.c	18 Aug 2005 23:45:50 -0000
*************** thread_db_wait (ptid_t ptid, struct targ
*** 961,972 ****
    return ptid;
  }
  
! static int
! thread_db_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
! 		       struct mem_attrib *attrib, struct target_ops *target)
  {
    struct cleanup *old_chain = save_inferior_ptid ();
!   int xfer;
  
    if (is_thread (inferior_ptid))
      {
--- 961,973 ----
    return ptid;
  }
  
! static LONGEST
! thread_db_xfer_partial (struct target_ops *ops, enum target_object object,
! 			const char *annex, gdb_byte *readbuf,
! 			const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
  {
    struct cleanup *old_chain = save_inferior_ptid ();
!   LONGEST xfer;
  
    if (is_thread (inferior_ptid))
      {
*************** thread_db_xfer_memory (CORE_ADDR memaddr
*** 978,986 ****
  	inferior_ptid = lwp_from_thread (inferior_ptid);
      }
  
!   xfer =
!     target_beneath->deprecated_xfer_memory (memaddr, myaddr, len, write,
! 					    attrib, target);
  
    do_cleanups (old_chain);
    return xfer;
--- 979,986 ----
  	inferior_ptid = lwp_from_thread (inferior_ptid);
      }
  
!   xfer = target_beneath->to_xfer_partial (ops, object, annex,
! 					  readbuf, writebuf, offset, len);
  
    do_cleanups (old_chain);
    return xfer;
*************** init_thread_db_ops (void)
*** 1298,1304 ****
    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_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;
--- 1298,1304 ----
    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.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: gdb/config/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-linux.h,v
retrieving revision 1.24
diff -c -p -r1.24 nm-linux.h
*** gdb/config/nm-linux.h	20 Sep 2004 16:39:34 -0000	1.24
--- gdb/config/nm-linux.h	18 Aug 2005 23:45:51 -0000
*************** struct target_ops;
*** 42,52 ****
  #endif
  
  
- /* Override child_wait in `inftarg.c'.  */
- struct target_waitstatus;
- extern ptid_t child_wait (ptid_t ptid, struct target_waitstatus *ourstatus);
- #define CHILD_WAIT
- 
  extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
  #define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
  
--- 42,47 ----
*************** extern void lin_thread_get_thread_signal
*** 59,64 ****
--- 54,70 ----
  #define GDB_GREGSET_T  elf_gregset_t
  #define GDB_FPREGSET_T elf_fpregset_t
  
+ 
+ /* FIXME: Everything below here can be deleted once all GNU/Linux
+    targets have been modified to use linux_target.  */
+ 
+ #ifndef USE_LINUX_TARGET
+ 
+ /* Override child_wait in `inftarg.c'.  */
+ struct target_waitstatus;
+ extern ptid_t child_wait (ptid_t ptid, struct target_waitstatus *ourstatus);
+ #define CHILD_WAIT
+ 
  /* Override child_pid_to_exec_file in 'inftarg.c'.  */
  #define CHILD_PID_TO_EXEC_FILE
  
*************** extern void lin_thread_get_thread_signal
*** 72,74 ****
--- 78,83 ----
  
  #define NATIVE_XFER_AUXV	procfs_xfer_auxv
  #include "auxv.h"		/* Declares it. */
+ 
+ #endif /* USE_LINUX_TARGET */
+ 

-- 
  Dr. Ulrich Weigand
  Linux on zSeries Development
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]