Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY  in windows_xfer_memory function
Date: Sun, 01 Sep 2013 22:10:00 -0000	[thread overview]
Message-ID: <000601cea760$00ff8d90$02fea8b0$@muller@ics-cnrs.unistra.fr> (raw)

This is the patch that Pedro suggested I send
after his commit to remove deprecated_xfer_memory
in windows-nat.c.

  Pedro suggested that I submit this patch separately
(which I do here)... and with a gdbserver counterpart,
which I don't...

  I tried, but finally realized that given the
read_memory / write_memory functions type defined
in target.h target_ops structure,
there is no way of passing information of partial 
copy and of the length of this partial copy.
Indeed, the comments state that the return value is either 0 for success
or errno...

This is not compatible with returning information that only part of the
request length
was read/written.
  Changing this semantics is too much work with high risks of breaking
things elsewhere...

  

Pierre Muller
GDB pascal language maintainer

PS: the use of plongest function is because I got an warning about %d
used for 'long long integer' type.


2013-09-01  Pierre Muller  <muller@sourceware.org>

	* windows-nat.c (windows_xfer_memory): Fix compilation failure
	by use of plongest function.
	Handle ERROR_PARTIAL_COPY error code.


Index: src/gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.258
diff -u -p -r1.258 windows-nat.c
--- src/gdb/windows-nat.c	27 Aug 2013 11:36:09 -0000	1.258
+++ src/gdb/windows-nat.c	1 Sep 2013 21:20:51 -0000
@@ -2324,26 +2324,34 @@ windows_xfer_memory (gdb_byte *readbuf, 
 {
   SIZE_T done = 0;
   BOOL success;
+  DWORD lasterror = 0;
 
   if (writebuf != NULL)
     {
-      DEBUG_MEM (("gdb: write target memory, %d bytes at %s\n",
-		  len, core_addr_to_string (memaddr)));
+      DEBUG_MEM (("gdb: write target memory, %s bytes at %s\n",
+		  plongest (len), core_addr_to_string (memaddr)));
       success = WriteProcessMemory (current_process_handle,
 				    (LPVOID) (uintptr_t) memaddr, writebuf,
 				    len, &done);
+      if (!success)
+       lasterror = GetLastError ();
       FlushInstructionCache (current_process_handle,
 			     (LPCVOID) (uintptr_t) memaddr, len);
     }
   else
     {
-      DEBUG_MEM (("gdb: read target memory, %d bytes at %s\n",
-		  len, core_addr_to_string (memaddr)));
+      DEBUG_MEM (("gdb: read target memory, %s bytes at %s\n",
+		  plongest (len), core_addr_to_string (memaddr)));
       success = ReadProcessMemory (current_process_handle,
 				   (LPCVOID) (uintptr_t) memaddr, readbuf,
 				   len, &done);
+      if (!success)
+       lasterror = GetLastError ();
     }
-  return success ? done : TARGET_XFER_E_IO;
+  if (!success && lasterror == ERROR_PARTIAL_COPY && done > 0)
+    return done;
+  else
+    return success ? done : TARGET_XFER_E_IO;
 }
 
 static void


             reply	other threads:[~2013-09-01 22:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-01 22:10 Pierre Muller [this message]
     [not found] <5223bb46.c6c0420a.5a41.008dSMTPIN_ADDED_BROKEN@mx.google.com>
2013-09-02 12:34 ` Pedro Alves
2013-09-02 12:48   ` Pierre Muller
2013-09-02 12:50 ` Pedro Alves
2013-09-02 13:05   ` Pierre Muller
2013-09-02 13:19     ` 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='000601cea760$00ff8d90$02fea8b0$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --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