From: "pcarroll@codesourcery.com" <pcarroll@codesourcery.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] Assertion 'xfered>0' in target.c for remote connection
Date: Thu, 02 Nov 2017 23:05:00 -0000 [thread overview]
Message-ID: <1155839491.1748621.1509663923992@mail.yahoo.com> (raw)
In-Reply-To: <1155839491.1748621.1509663923992.ref@mail.yahoo.com>
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 instead of TARGET_XFER_OK or TARGET_XFER_UNAVAILABLE when 0 bytes are transferred.
The proposed fix would be:
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 <pcarroll@codesourcery.com>
+
+ 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 <yao.qi@linaro.org>
* 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-02 15:24:35.536391700 -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 = (ULONGEST) units_written;
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 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 = hex2bin (p, myaddr, todo_units * unit_size);
/* Return what we have. Let higher layers handle partial reads. */
*xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Using the set of read-only target sections of remote, read live
@@ -8455,13 +8455,14 @@ remote_read_bytes (struct target_ops *op
res = remote_xfer_live_readonly_partial (ops, myaddr, memaddr,
len, unit_size, xfered_len);
if (res == TARGET_XFER_OK)
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
else
{
/* No use trying further, we know some memory starting
at MEMADDR isn't available. */
*xfered_len = len;
- return TARGET_XFER_UNAVAILABLE;
+ return (*xfered_len != 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 = n;
- return TARGET_XFER_OK;
+ return (*xfered_len != 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 = strlen ((char *) readbuf);
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Implementation of to_get_memory_xfer_limit. */
next parent reply other threads:[~2017-11-02 23:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1155839491.1748621.1509663923992.ref@mail.yahoo.com>
2017-11-02 23:05 ` pcarroll [this message]
2017-11-03 3:11 ` Sergio Durigan Junior
[not found] ` <b62b6cfa-ede8-b7bc-0254-e2eaf0effb98@codesourcery.com>
2017-11-14 21:38 ` Simon Marchi
2017-11-14 22:08 ` Yao Qi
2017-11-14 22:30 ` Paul Carroll
2017-11-14 22:41 ` Simon Marchi
2017-11-03 20:36 Carroll, Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1155839491.1748621.1509663923992@mail.yahoo.com \
--to=pcarroll@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox