Fix misreporting of omitted bytes for large remote packets
authorSimon Marchi <simon.marchi@ericsson.com>
Fri, 9 Mar 2018 00:00:03 +0000 (19:00 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 9 Mar 2018 00:00:59 +0000 (19:00 -0500)
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/ChangeLog
gdb/remote.c

index fc5738bccc2b743662cf54156a9ca124fcbd126f..114f4515c3872fe2c7ae851640901dd197712ef8 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-08  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * remote.c (putpkt_binary): Fix omitted bytes reporting.
+       (getpkt_or_notif_sane_1): Likewise.
+
 2018-03-08  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * build-id.c (build_id_to_debug_bfd): Use std::string.
index 134a97eed98ff597ea5834b08861a9fd02eb8d6f..7f409fdb1d27ad01275e23edf3c556299bd0233e 100644 (file)
@@ -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");
            }