From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2205 invoked by alias); 2 Sep 2013 14:25:22 -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 2195 invoked by uid 89); 2 Sep 2013 14:25:21 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Sep 2013 14:25:21 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,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 0DF95C0865; Mon, 2 Sep 2013 16:25:18 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id F33E8C0862; Mon, 2 Sep 2013 16:25:17 +0200 (CEST) Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mr3.u-strasbg.fr (Postfix) with ESMTP id D0BD0C0865; Mon, 2 Sep 2013 16:25:15 +0200 (CEST) Received: from ms18.u-strasbg.fr (ms18.u-strasbg.fr [130.79.204.118]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r82EPFfX011158 ; Mon, 2 Sep 2013 16:25:15 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (Authenticated sender: mullerp) by ms18.u-strasbg.fr (Postfix) with ESMTPSA id 3663D1FD88; Mon, 2 Sep 2013 16:25:14 +0200 (CEST) From: "Pierre Muller" To: "'Pedro Alves'" Cc: References: <5223bb46.c6c0420a.5a41.008dSMTPIN_ADDED_BROKEN@mx.google.com> <52248978.90500@redhat.com> <000301cea7dd$17bc4af0$4734e0d0$@muller@ics-cnrs.unistra.fr> <52249053.6050103@redhat.com> <522494dc.297a420a.6ab0.6047SMTPIN_ADDED_BROKEN@mx.google.com> <522497AF.8080800@redhat.com> <52249a22.42bd420a.28f1.722cSMTPIN_ADDED_BROKEN@mx.google.com> <52249C06.1020100@redhat.com> <52249e27.e8a4420a.4293.ffff89a0SMTPIN_ADDED_BROKEN@mx.google.com> <52249E7A.8010300@redhat.com> In-Reply-To: <52249E7A.8010300@redhat.com> Subject: [RFA-v2] gdbserver/win32-low.c: Check Read/WriteProcessMemory return value (followup to [RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY in windows_xfer_memory function) Date: Mon, 02 Sep 2013 14:25:00 -0000 Message-ID: <000301cea7e8$3bd48dc0$b37da940$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-09/txt/msg00030.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Pedro Alves > Envoy=E9=A0: lundi 2 septembre 2013 16:20 > =C0=A0: Pierre Muller > Cc=A0: 'Pedro Alves'; gdb-patches@sourceware.org > Objet=A0: Re: [RFA] gdbserver/win32-low.c: Check Read/WriteProcessMemory > return value (followup to [RFA] windows-nat.c: Handle ERROR_PARTIAL_COPY in > windows_xfer_memory function) >=20 > On 09/02/2013 03:18 PM, Pierre Muller wrote: >=20 > > The problem is that TARGET_XFER_E_IO > > is only defined in gdb/target.h... > > > > Should I just replace TARGET_XFER_E_IO by -1 and keep the gdb version > > otherwise? >=20 > Yep. Here is an update patch, is this OK? 2013-09-02 Pierre Muller * win32-low.c (child_xfer_memory): Check if ReadProcessMemory or WriteProcessMemory complete successfully and handle ERROR_PARTIAL_COPY error. Index: gdbserver/win32-low.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.66 diff -u -p -r1.66 win32-low.c --- gdbserver/win32-low.c 2 Jul 2013 11:59:24 -0000 1.66 +++ gdbserver/win32-low.c 2 Sep 2013 14:23:35 -0000 @@ -278,21 +278,30 @@ static int child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write, struct target_ops *target) { - SIZE_T done; + BOOL success; + SIZE_T done =3D 0; + DWORD lasterror =3D 0; uintptr_t addr =3D (uintptr_t) memaddr; =20 if (write) { - WriteProcessMemory (current_process_handle, (LPVOID) addr, - (LPCVOID) our, len, &done); + success =3D WriteProcessMemory (current_process_handle, (LPVOID) add= r, + (LPCVOID) our, len, &done); + if (!success) + lasterror =3D GetLastError (); FlushInstructionCache (current_process_handle, (LPCVOID) addr, len); } else { - ReadProcessMemory (current_process_handle, (LPCVOID) addr, (LPVOID) our, - len, &done); + success =3D ReadProcessMemory (current_process_handle, (LPCVOID) add= r, + (LPVOID) our, len, &done); + if (!success) + lasterror =3D GetLastError (); } - return done; + if (!success && lasterror =3D=3D ERROR_PARTIAL_COPY && done > 0) + return done; + else + return success ? done : -1; } =20 /* Clear out any old thread list and reinitialize it to a pristine