From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19573 invoked by alias); 1 Sep 2013 22:10:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 19563 invoked by uid 89); 1 Sep 2013 22:10:11 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.214) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Sep 2013 22:10:11 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id 8BF2D1A0D44 for ; Mon, 2 Sep 2013 00:10:03 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id 7C1FE1A0D3C for ; Mon, 2 Sep 2013 00:10:03 +0200 (CEST) Received: from md14.u-strasbg.fr (md14.u-strasbg.fr [130.79.200.249]) by mr4.u-strasbg.fr (Postfix) with ESMTP id 6BBAC1A0D44 for ; Mon, 2 Sep 2013 00:10:02 +0200 (CEST) Received: from ms16.u-strasbg.fr (ms16.u-strasbg.fr [130.79.204.116]) by md14.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r81MA2kV014458 for ; Mon, 2 Sep 2013 00:10:02 +0200 Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (Authenticated sender: mullerp) by ms16.u-strasbg.fr (Postfix) with ESMTPSA id DF7FE1FD8E for ; Mon, 2 Sep 2013 00:10:01 +0200 (CEST) From: "Pierre Muller" To: Subject: [RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY in windows_xfer_memory function Date: Sun, 01 Sep 2013 22:10:00 -0000 Message-ID: <000601cea760$00ff8d90$02fea8b0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00001.txt.bz2 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 * 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