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] windows-nat.c: Don't install a deprecated_xfer_memory method.
Date: Fri, 23 Aug 2013 18:12:00 -0000	[thread overview]
Message-ID: <20130823181245.4023.25651.stgit@brno.lan> (raw)

This stops another target from installing a
target_ops->deprecated_xfer_memory method.

I'm not setup for proper Cygwin/Windows testing, but I managed to
cross build gdb from GNU/Linux, and copy the resulting binary to a
Windows box.  Running that gdb on itself worked well enough to run to
main, so I can't imagine any regression from this.  Does anyone want
(and is willing) to run this through the testsuite?

gdb/
2013-08-23  Pedro Alves  <palves@redhat.com>

	* windows-nat.c (windows_xfer_memory): Adjust prototype to follow
	xfer_partial's interface.  Return TARGET_XFER_E_IO on error.
	(windows_xfer_partial): Defer TARGET_OBJECT_MEMORY handling to
	windows_xfer_memory directly.
	(init_windows_ops): Don't install a deprecated_xfer_memory method.
---
 gdb/windows-nat.c |   36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 9a0241b..a4e7107 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2315,20 +2315,20 @@ windows_stop (ptid_t ptid)
   registers_changed ();		/* refresh register state */
 }
 
-static int
-windows_xfer_memory (CORE_ADDR memaddr, gdb_byte *our, int len,
-		   int write, struct mem_attrib *mem,
-		   struct target_ops *target)
+static LONGEST
+windows_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+		     ULONGEST memaddr, LONGEST len)
 {
   SIZE_T done = 0;
-  if (write)
+  BOOL success;
+
+  if (writebuf != NULL)
     {
       DEBUG_MEM (("gdb: write target memory, %d bytes at %s\n",
 		  len, core_addr_to_string (memaddr)));
-      if (!WriteProcessMemory (current_process_handle,
-			       (LPVOID) (uintptr_t) memaddr, our,
-			       len, &done))
-	done = 0;
+      success = WriteProcessMemory (current_process_handle,
+				    (LPVOID) (uintptr_t) memaddr, writebuf,
+				    len, &done);
       FlushInstructionCache (current_process_handle,
 			     (LPCVOID) (uintptr_t) memaddr, len);
     }
@@ -2336,12 +2336,11 @@ windows_xfer_memory (CORE_ADDR memaddr, gdb_byte *our, int len,
     {
       DEBUG_MEM (("gdb: read target memory, %d bytes at %s\n",
 		  len, core_addr_to_string (memaddr)));
-      if (!ReadProcessMemory (current_process_handle,
-			      (LPCVOID) (uintptr_t) memaddr, our,
-			      len, &done))
-	done = 0;
+      success = ReadProcessMemory (current_process_handle,
+				   (LPCVOID) (uintptr_t) memaddr, readbuf,
+				   len, &done);
     }
-  return done;
+  return success ? done : TARGET_XFER_E_IO;
 }
 
 static void
@@ -2442,13 +2441,7 @@ windows_xfer_partial (struct target_ops *ops, enum target_object object,
   switch (object)
     {
     case TARGET_OBJECT_MEMORY:
-      if (readbuf)
-	return (*ops->deprecated_xfer_memory) (offset, readbuf,
-					       len, 0/*read*/, NULL, ops);
-      if (writebuf)
-	return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
-					       len, 1/*write*/, NULL, ops);
-      return -1;
+      return windows_xfer_memory (readbuf, writebuf, offset, len);
 
     case TARGET_OBJECT_LIBRARIES:
       return windows_xfer_shared_libraries (ops, object, annex, readbuf,
@@ -2502,7 +2495,6 @@ init_windows_ops (void)
   windows_ops.to_fetch_registers = windows_fetch_inferior_registers;
   windows_ops.to_store_registers = windows_store_inferior_registers;
   windows_ops.to_prepare_to_store = windows_prepare_to_store;
-  windows_ops.deprecated_xfer_memory = windows_xfer_memory;
   windows_ops.to_xfer_partial = windows_xfer_partial;
   windows_ops.to_files_info = windows_files_info;
   windows_ops.to_insert_breakpoint = memory_insert_breakpoint;


             reply	other threads:[~2013-08-23 18:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23 18:12 Pedro Alves [this message]
2013-08-23 20:08 ` Joel Brobecker
2013-08-27 11:38   ` Pedro Alves
2013-08-23 21:37 ` Pierre Muller
2013-08-26 16:52   ` Pedro Alves
2013-08-26 16:54     ` Pedro Alves
2013-08-27  0:50 ` Yao Qi
2013-08-27 11:37   ` 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=20130823181245.4023.25651.stgit@brno.lan \
    --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