From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72929 invoked by alias); 2 Nov 2017 23:05:31 -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 72919 invoked by uid 89); 2 Nov 2017 23:05:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_50,FORGED_MUA_MOZILLA,GIT_PATCH_2,GIT_PATCH_3,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,URIBL_RED autolearn=ham version=3.3.2 spammy=H*x:WebService, H*x:Mozilla, H*x:Gecko, H*UA:WebService X-HELO: sonic307-18.consmr.mail.bf2.yahoo.com Received: from sonic307-18.consmr.mail.bf2.yahoo.com (HELO sonic307-18.consmr.mail.bf2.yahoo.com) (74.6.134.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 23:05:29 +0000 Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.bf2.yahoo.com with HTTP; Thu, 2 Nov 2017 23:05:27 +0000 Date: Thu, 02 Nov 2017 23:05:00 -0000 From: "pcarroll@codesourcery.com" To: "gdb-patches@sourceware.org" Message-ID: <1155839491.1748621.1509663923992@mail.yahoo.com> Subject: [PATCH] Assertion 'xfered>0' in target.c for remote connection MIME-Version: 1.0 References: <1155839491.1748621.1509663923992.ref@mail.yahoo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2017-11/txt/msg00054.txt.bz2 We have a customer who is using a Corelis gdb server to connect to gdb. Occasionally, the gdb server will send a 0-byte block of memory for a read. When this happens, gdb gives an assertion from target.c: internal-error: target_xfer_partial: Assertion `*xfered_len > 0' failed. This problem is almost identical to that fixed in https://sourceware.org/ml= /gdb-patches/2014-02/msg00636.html In this case, remote.c needs to be modified to return TARGET_XFER_EOF inste= ad of TARGET_XFER_OK or TARGET_XFER_UNAVAILABLE when 0 bytes are transferre= d.=20 The proposed fix would be: diff -rup fsf/gdb/ChangeLog fix/gdb/ChangeLog --- fsf/gdb/ChangeLog=C2=A0=C2=A0 2017-11-02 16:13:19.188615000 -0500 +++ fix/gdb/ChangeLog=C2=A0=C2=A0 2017-11-02 16:13:21.626754500 -0500 @@ -1,3 +1,10 @@ +2017-11-02=C2=A0 Paul Carroll=C2=A0 + +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PR gdb/22388 +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * remote.c (remote_write_bytes_aux, r= emote_read_bytes_1, +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 remote_read_bytes, remote_write_qxfer= , remote_xfer_partial): +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Return TARGET_XFER_EOF if size of ret= urned data is 0. + 2017-11-02=C2=A0 Yao Qi=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * frame.c (do_frame_register_rea= d): Remove aspace. diff -rup fsf/gdb/remote.c fix/gdb/remote.c --- fsf/gdb/remote.c=C2=A0=C2=A0=C2=A0 2017-11-02 16:06:15.979408800 -0500 +++ fix/gdb/remote.c=C2=A0=C2=A0=C2=A0 2017-11-02 15:24:35.536391700 -0500 @@ -8264,7 +8264,7 @@ remote_write_bytes_aux (const char *head =C2=A0=C2=A0 /* Return UNITS_WRITTEN, not TODO_UNITS, in case escape chars = caused us to =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 send fewer units than we'd planned.=C2=A0 */ =C2=A0=C2=A0 *xfered_len_units =3D (ULONGEST) units_written; -=C2=A0 return TARGET_XFER_OK; +=C2=A0 return (*xfered_len_units !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EO= F; } /* Write memory data directly to the remote machine. @@ -8358,7 +8358,7 @@ remote_read_bytes_1 (CORE_ADDR memaddr, =C2=A0=C2=A0 decoded_bytes =3D hex2bin (p, myaddr, todo_units * unit_size); =C2=A0=C2=A0 /* Return what we have.=C2=A0 Let higher layers handle partial= reads.=C2=A0 */ =C2=A0=C2=A0 *xfered_len_units =3D (ULONGEST) (decoded_bytes / unit_size); -=C2=A0 return TARGET_XFER_OK; +=C2=A0 return (*xfered_len_units !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EO= F; } /* Using the set of read-only target sections of remote, read live @@ -8455,13 +8455,14 @@ remote_read_bytes (struct target_ops *op =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 res =3D remote_xfer_live_readonly_partial (ops, myaddr, memaddr, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 len, unit_size, xfered_len); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (res =3D=3D TARGET_XFER_OK) -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 return TARGET_XFER_OK; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 return (*xfered_len !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 else =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 /* No use trying further, we know some memory s= tarting =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at MEMADDR isn't available.= =C2=A0 */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 *xfered_len =3D len; -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 return TARGET_XFER_UNAVAILABLE; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 return (*xfered_len !=3D 0) ? +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TARGET_XFER_UNAVAILABLE : TARGET_XFER_= EOF; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } @@ -10386,7 +10387,7 @@ remote_write_qxfer (struct target_ops *o =C2=A0=C2=A0 unpack_varlen_hex (rs->buf, &n); =C2=A0=C2=A0 *xfered_len =3D n; -=C2=A0 return TARGET_XFER_OK; +=C2=A0 return (*xfered_len !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; } /* Read OBJECT_NAME/ANNEX from the remote target using a qXfer packet. @@ -10687,7 +10688,7 @@ remote_xfer_partial (struct target_ops * =C2=A0=C2=A0 strcpy ((char *) readbuf, rs->buf); =C2=A0=C2=A0 *xfered_len =3D strlen ((char *) readbuf); -=C2=A0 return TARGET_XFER_OK; +=C2=A0 return (*xfered_len !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; } /* Implementation of to_get_memory_xfer_limit.=C2=A0 */