PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
Simon Marchi
simon.marchi@ericsson.com
Thu Mar 8 23:34:00 GMT 2018
On 2018-03-02 12:14 PM, alarson@ddci.com wrote:
> In remote.c, when the output of "set debug remote" is truncated, the
> number of characters reported is incorrect. What is reported is the
> number of characters added by the quoting, not the number of characters
> that were truncated. I'm not up to speed on the GDB patch process , but
> here are the necessary changes if someone is willing to be a proxy:
>
> --- gdb/remote.c 2017-09-07 08:28:11.000000000 -0600
> +++ ../../gdb-8.0.1/gdb/remote.c 2018-03-02 11:07:33.465414200
> -0600
> @@ -8768,10 +8768,10 @@
>
> fprintf_unfiltered (gdb_stdlog, "Sending packet: %s", str.c_str
> ());
>
> - if (str.length () > REMOTE_DEBUG_MAX_CHAR)
> + if (len > REMOTE_DEBUG_MAX_CHAR)
> {
> fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
> - str.length () - REMOTE_DEBUG_MAX_CHAR);
> + len - REMOTE_DEBUG_MAX_CHAR);
> }
>
> fprintf_unfiltered (gdb_stdlog, "...");
> @@ -9210,10 +9210,10 @@
> fprintf_unfiltered (gdb_stdlog, "Packet received: %s",
> str.c_str ());
>
> - if (str.length () > REMOTE_DEBUG_MAX_CHAR)
> + if (val > REMOTE_DEBUG_MAX_CHAR)
> {
> fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
> - str.length () -
> REMOTE_DEBUG_MAX_CHAR);
> + val - REMOTE_DEBUG_MAX_CHAR);
> }
>
> fprintf_unfiltered (gdb_stdlog, "\n");
>
Hi Aaron,
Thanks for the patch, it does indeed seem bogus to me.
Some tips for the next time you want to submit a patch:
- Use git-send-email if possible, it makes it much easier to apply the patch
(your patch has some lines wrapped, which makes it difficult to work with).
- Add a ChangeLog entry in your commit message.
You can find more details here: http://sourceware.org/gdb/wiki/ContributionChecklist
This patch was small enough that it was easy to re-do by hand, so don't worry
about it. I made some small changes:
- Remove unnecessary curly braces that were there previously, to comply with the
GNU coding style.
- Adjust the format string, since I had this compiler error:
/home/emaisin/src/binutils-gdb/gdb/remote.c:8725:32: error: format â%zuâ expects argument of type âsize_tâ, but argument 3 has type âintâ [-Werror=format=]
len - REMOTE_DEBUG_MAX_CHAR);
^
Other than that the patch is unchanged. Are you ok with me pushing the
following patch on your behalf?
(Note that I took the liberty to Google your name, since you had only
provided your email address :))
>From c8b93cd02bb22a7c62d5bacc4591ed69ac8785a1 Mon Sep 17 00:00:00 2001
From: Aaron Larson <alarson@ddci.com>
Date: Thu, 8 Mar 2018 18:22:29 -0500
Subject: [PATCH] Fix misreporting of omitted bytes for large remote packets
In remote.c, when the output of "set debug remote" is truncated, the
number of characters reported is incorrect. What is reported is the
number of characters added by the quoting, not the number of characters
that were truncated.
gdb/ChangeLog:
* remote.c (putpkt_binary): Fix omitted bytes reporting.
(getpkt_or_notif_sane_1): Likewise.
---
gdb/remote.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 134a97e..7f409fd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8720,11 +8720,9 @@ putpkt_binary (const char *buf, int cnt)
fprintf_unfiltered (gdb_stdlog, "Sending packet: %s", str.c_str ());
- if (str.length () > REMOTE_DEBUG_MAX_CHAR)
- {
- fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
- str.length () - REMOTE_DEBUG_MAX_CHAR);
- }
+ if (len > REMOTE_DEBUG_MAX_CHAR)
+ fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]",
+ len - REMOTE_DEBUG_MAX_CHAR);
fprintf_unfiltered (gdb_stdlog, "...");
@@ -9157,11 +9155,9 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
fprintf_unfiltered (gdb_stdlog, "Packet received: %s",
str.c_str ());
- if (str.length () > REMOTE_DEBUG_MAX_CHAR)
- {
- fprintf_unfiltered (gdb_stdlog, "[%zu bytes omitted]",
- str.length () - REMOTE_DEBUG_MAX_CHAR);
- }
+ if (val > REMOTE_DEBUG_MAX_CHAR)
+ fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]",
+ val - REMOTE_DEBUG_MAX_CHAR);
fprintf_unfiltered (gdb_stdlog, "\n");
}
--
2.7.4
More information about the Gdb-patches
mailing list