This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <alarson at ddci dot com>, <gdb-patches at sourceware dot org>
- Date: Thu, 8 Mar 2018 18:34:17 -0500
- Subject: Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <OF7B034DAF.5A6D3B6A-ON06258244.005E4499-06258244.005EBCC4@ddci.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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