public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
@ 2018-03-02 17:14 alarson
  2018-03-08 23:34 ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: alarson @ 2018-03-02 17:14 UTC (permalink / raw)
  To: gdb-patches

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");

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
  2018-03-02 17:14 PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages alarson
@ 2018-03-08 23:34 ` Simon Marchi
  2018-03-08 23:51   ` alarson
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2018-03-08 23:34 UTC (permalink / raw)
  To: alarson, gdb-patches

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
  2018-03-08 23:34 ` Simon Marchi
@ 2018-03-08 23:51   ` alarson
  2018-03-09  0:01     ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: alarson @ 2018-03-08 23:51 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

"Simon Marchi" <simon.marchi@ericsson.com> wrote on 03/08/2018 05:34:17 
PM:

> From: "Simon Marchi" <simon.marchi@ericsson.com>
SM> Are you ok with me pushing the following patch on your behalf?

Absolutely fine.  And thank you very much.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages
  2018-03-08 23:51   ` alarson
@ 2018-03-09  0:01     ` Simon Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2018-03-09  0:01 UTC (permalink / raw)
  To: alarson; +Cc: Simon Marchi, gdb-patches

On 2018-03-08 18:51, alarson@ddci.com wrote:
> "Simon Marchi" <simon.marchi@ericsson.com> wrote on 03/08/2018 05:34:17
> PM:
> 
>> From: "Simon Marchi" <simon.marchi@ericsson.com>
> SM> Are you ok with me pushing the following patch on your behalf?
> 
> Absolutely fine.  And thank you very much.

Pushed, thanks.

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-09  0:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02 17:14 PATCH for minor buglet in remote.c misreporting REMOTE_DEBUG_MAX_CHAR messages alarson
2018-03-08 23:34 ` Simon Marchi
2018-03-08 23:51   ` alarson
2018-03-09  0:01     ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).