Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method
Date: Wed, 19 Feb 2014 20:29:00 -0000	[thread overview]
Message-ID: <1392841775-19126-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1392841775-19126-1-git-send-email-palves@redhat.com>

This removes yet another instance of a deprecated_xfer_memory user.

I have no way to test this.

gdb/
2014-02-19  Pedro Alves  <palves@redhat.com>

	* nto-procfs.c (procfs_xfer_memory): Adjust interface as a
	to_xfer_partial helper.  Rewrite.
	(procfs_xfer_partial): New function.
	(init_procfs_ops): Don't install a deprecated_xfer_memory hook.
	Install a to_xfer_partial hook.
---
 gdb/nto-procfs.c | 58 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 24 deletions(-)

diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index d0bdc90..bdda7ce 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -59,10 +59,6 @@ static void procfs_open (char *, int);
 
 static int procfs_can_run (struct target_ops *self);
 
-static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
-			       struct mem_attrib *attrib,
-			       struct target_ops *);
-
 static void init_procfs_ops (void);
 
 static ptid_t do_attach (ptid_t ptid);
@@ -849,30 +845,44 @@ procfs_fetch_registers (struct target_ops *ops,
     nto_supply_altregset (regcache, (char *) &reg.altreg);
 }
 
-/* Copy LEN bytes to/from inferior's memory starting at MEMADDR
-   from/to debugger memory starting at MYADDR.  Copy from inferior
-   if DOWRITE is zero or to inferior if DOWRITE is nonzero.
+/* Helper for procfs_xfer_partial that handles memory transfers.
+   Arguments are like target_xfer_partial.  */
 
-   Returns the length copied, which is either the LEN argument or
-   zero.  This xfer function does not do partial moves, since procfs_ops
-   doesn't allow memory operations to cross below us in the target stack
-   anyway.  */
-static int
-procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
-		    struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+		    ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
 {
-  int nbytes = 0;
+  int nbytes;
+
+  if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr)
+    return TARGET_XFER_E_IO;
+
+  if (writebuf != NULL)
+    nbytes = write (ctl_fd, writebuf, len);
+  else
+    nbytes = read (ctl_fd, readbuf, len);
+  if (nbytes <= 0)
+    return TARGET_XFER_E_IO;
+  *xfered_len = nbytes;
+  return TARGET_XFER_OK;
+}
+
+/* Target to_xfer_partial implementation.  */
 
-  if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
+static enum target_xfer_status
+procfs_xfer_partial (struct target_ops *ops, enum target_object object,
+		     const char *annex, gdb_byte *readbuf,
+		     const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+		     ULONGEST *xfered_len)
+{
+  switch (object)
     {
-      if (dowrite)
-	nbytes = write (ctl_fd, myaddr, len);
-      else
-	nbytes = read (ctl_fd, myaddr, len);
-      if (nbytes < 0)
-	nbytes = 0;
+    case TARGET_OBJECT_MEMORY:
+      return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+    default:
+      return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+					    readbuf, writebuf, offset, len);
     }
-  return (nbytes);
 }
 
 /* Take a program previously attached to and detaches it.
@@ -1397,7 +1407,7 @@ init_procfs_ops (void)
   procfs_ops.to_fetch_registers = procfs_fetch_registers;
   procfs_ops.to_store_registers = procfs_store_registers;
   procfs_ops.to_prepare_to_store = procfs_prepare_to_store;
-  procfs_ops.deprecated_xfer_memory = procfs_xfer_memory;
+  procfs_ops.to_xfer_partial = procfs_xfer_partial;
   procfs_ops.to_files_info = procfs_files_info;
   procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint;
   procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint;
-- 
1.7.11.7


  parent reply	other threads:[~2014-02-19 20:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method Pedro Alves
     [not found]   ` <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr>
2014-02-20 16:37     ` Pedro Alves
2014-02-19 20:29 ` [PATCH 2/7] remote-m32r-sdi.c: " Pedro Alves
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: " Pedro Alves
2014-02-20 15:48   ` Joel Brobecker
2014-02-20 15:56     ` Joel Brobecker
2014-02-20 16:38       ` Pedro Alves
2014-02-24 17:53         ` Joel Brobecker
2014-02-24 18:21           ` Pedro Alves
2014-02-24 18:37             ` Joel Brobecker
2014-02-19 20:29 ` Pedro Alves [this message]
2014-02-19 20:29 ` [PATCH 1/7] remote-mips.c: " Pedro Alves
2014-02-19 20:29 ` [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
2014-02-20 13:26   ` Mark Kettenis
2014-02-20 16:42     ` Pedro Alves
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
2014-02-26 14:50   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392841775-19126-5-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox