From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112642 invoked by alias); 3 Nov 2017 20:36:43 -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 112609 invoked by uid 89); 3 Nov 2017 20:36:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=safer X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 20:36:40 +0000 Received: from svr-orw-mbx-02.mgc.mentorg.com ([147.34.90.202]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1eAihi-0006W2-82 from Paul_Carroll@mentor.com ; Fri, 03 Nov 2017 13:36:38 -0700 Received: from svr-orw-mbx-04.mgc.mentorg.com (147.34.90.204) by svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 3 Nov 2017 13:36:36 -0700 Received: from svr-orw-mbx-04.mgc.mentorg.com ([fe80::4967:8f7f:4a15:68a4]) by SVR-ORW-MBX-04.mgc.mentorg.com ([fe80::4967:8f7f:4a15:68a4%22]) with mapi id 15.00.1320.000; Fri, 3 Nov 2017 13:36:36 -0700 From: "Carroll, Paul" To: Sergio Durigan Junior CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH] Assertion 'xfered>0' in target.c for remote connection Date: Fri, 03 Nov 2017 20:36:00 -0000 Message-ID: x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2017-11/txt/msg00089.txt.bz2 Thanks for your comments, Sergio. Sadly, I had to manually put the tabs into my patch here, but it looks corr= ect now. I also removed the TARGET_XFER_OK/TARGET_XFER_EOF test in remote_read_bytes= , for the reasons you noted. The TARGET_XFER_UNAVAILABLE/TARGET_XFER_EOF test is still necessary in case= 0 bytes is returned by remote_read_bytes_1. Some of the added tests are for writing blocks, rather than reading blocks. It is possible that these returns are not needed, but it seems safer to jus= t cover all of the returns. diff -rup fsf/gdb/ChangeLog fix/gdb/ChangeLog --- fsf/gdb/ChangeLog 2017-11-02 16:13:19.188615000 -0500 +++ fix/gdb/ChangeLog 2017-11-02 16:13:21.626754500 -0500 @@ -1,3 +1,10 @@ +2017-11-02 Paul Carroll + + PR gdb/22388 + * remote.c (remote_write_bytes_aux, remote_read_bytes_1, + remote_read_bytes, remote_write_qxfer, remote_xfer_partial): + Return TARGET_XFER_EOF if size of returned data is 0. + 2017-11-02 Yao Qi * frame.c (do_frame_register_read): Remove aspace. diff -rup fsf/gdb/remote.c fix/gdb/remote.c --- fsf/gdb/remote.c 2017-11-02 16:06:15.979408800 -0500 +++ fix/gdb/remote.c 2017-11-03 13:01:04.953135100 -0500 @@ -8264,7 +8264,7 @@ remote_write_bytes_aux (const char *head /* Return UNITS_WRITTEN, not TODO_UNITS, in case escape chars caused us = to send fewer units than we'd planned. */ *xfered_len_units =3D (ULONGEST) units_written; - return TARGET_XFER_OK; + return (*xfered_len_units !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; } /* Write memory data directly to the remote machine. @@ -8358,7 +8358,7 @@ remote_read_bytes_1 (CORE_ADDR memaddr, decoded_bytes =3D hex2bin (p, myaddr, todo_units * unit_size); /* Return what we have. Let higher layers handle partial reads. */ *xfered_len_units =3D (ULONGEST) (decoded_bytes / unit_size); - return TARGET_XFER_OK; + return (*xfered_len_units !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; } /* Using the set of read-only target sections of remote, read live @@ -8461,7 +8461,8 @@ remote_read_bytes (struct target_ops *op /* No use trying further, we know some memory starting at MEMADDR isn't available. */ *xfered_len =3D len; - return TARGET_XFER_UNAVAILABLE; + return (*xfered_len !=3D 0) ? + TARGET_XFER_UNAVAILABLE : TARGET_XFER_EOF; } } @@ -10386,7 +10387,7 @@ remote_write_qxfer (struct target_ops *o unpack_varlen_hex (rs->buf, &n); *xfered_len =3D n; - return TARGET_XFER_OK; + 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 * strcpy ((char *) readbuf, rs->buf); *xfered_len =3D strlen ((char *) readbuf); - return TARGET_XFER_OK; + return (*xfered_len !=3D 0) ? TARGET_XFER_OK : TARGET_XFER_EOF; } /* Implementation of to_get_memory_xfer_limit. */