This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY in windows_xfer_memory function
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Mon, 2 Sep 2013 00:10:00 +0200
- Subject: [RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY in windows_xfer_memory function
- Authentication-results: sourceware.org; auth=none
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