Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <alarson@ddci.com>, <gdb-patches@sourceware.org>
Subject: Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
Date: Thu, 08 Mar 2018 23:34:00 -0000	[thread overview]
Message-ID: <b7f74d40-1cd2-4376-3ae9-990a8a352c97@ericsson.com> (raw)
In-Reply-To: <OF7B034DAF.5A6D3B6A-ON06258244.005E4499-06258244.005EBCC4@ddci.com>

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




  reply	other threads:[~2018-03-08 23:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02 17:14 alarson
2018-03-08 23:34 ` Simon Marchi [this message]
2018-03-08 23:51   ` alarson
2018-03-09  0:01     ` Simon Marchi

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=b7f74d40-1cd2-4376-3ae9-990a8a352c97@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=alarson@ddci.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