Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Don't print too much if remote_debug is on
@ 2016-11-29 15:38 Yao Qi
  2016-11-29 15:46 ` Luis Machado
  2016-12-06 14:22 ` [PATCH V2] " Yao Qi
  0 siblings, 2 replies; 8+ messages in thread
From: Yao Qi @ 2016-11-29 15:38 UTC (permalink / raw)
  To: gdb-patches

If we turn "remote debug" on and GDB does some vFile operations,
a lot of things will be printed in the screen, which makes
"remote debug" useless.

This patch changes the code that we don't print messages if
messages are too long, greater than 512.  Instead, print
"Sending packet: $vFile:pread:5,3fff,e0d12#c4...Packet received: [16384 bytes omitted]".

gdb:

2016-11-29  Yao Qi  <yao.qi@linaro.org>

	* remote.c (REMOTE_DEBUG_MAX_CHAR): New macro.
	(putpkt_binary): Print if content length is less than
	REMOTE_DEBUG_MAX_CHAR.
	(getpkt_or_notif_sane_1): Likewise.
---
 gdb/remote.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index ef6c54e..7b4c168 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -283,6 +283,11 @@ typedef unsigned char threadref[OPAQUETHREADBYTES];
 
 #define MAXTHREADLISTRESULTS 32
 
+/* The max number of chars in debug output.  Output more than this number
+   of chars is omitted.  */
+
+#define REMOTE_DEBUG_MAX_CHAR 512
+
 /* Data for the vFile:pread readahead cache.  */
 
 struct readahead_cache
@@ -8749,9 +8754,16 @@ putpkt_binary (const char *buf, int cnt)
 	{
 	  *p = '\0';
 
-	  std::string str = escape_buffer (buf2, p - buf2);
+	  fprintf_unfiltered (gdb_stdlog, "Sending packet: ");
+	  ptrdiff_t len = p - buf2;
+	  if (len <= REMOTE_DEBUG_MAX_CHAR)
+	    {
+	      std::string str = escape_buffer (buf2, len);
 
-	  fprintf_unfiltered (gdb_stdlog, "Sending packet: %s...", str.c_str ());
+	      fprintf_unfiltered (gdb_stdlog, "%s...", str.c_str ());
+	    }
+	  else
+	    fprintf_unfiltered (gdb_stdlog, "[%td bytes omitted]...", len);
 	  gdb_flush (gdb_stdlog);
 	}
       remote_serial_write (buf2, p - buf2);
@@ -9179,9 +9191,15 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
 	{
 	  if (remote_debug)
 	    {
-	      std::string str = escape_buffer (*buf, val);
+	      fprintf_unfiltered (gdb_stdlog, "Packet received: ");
+	      if (val <= REMOTE_DEBUG_MAX_CHAR)
+		{
+		  std::string str = escape_buffer (*buf, val);
 
-	      fprintf_unfiltered (gdb_stdlog, "Packet received: %s\n", str.c_str ());
+		  fprintf_unfiltered (gdb_stdlog, "%s\n", str.c_str ());
+		}
+	      else
+		fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]\n", val);
 	    }
 
 	  /* Skip the ack char if we're in no-ack mode.  */
-- 
1.9.1


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

end of thread, other threads:[~2017-01-13 15:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 15:38 [PATCH] Don't print too much if remote_debug is on Yao Qi
2016-11-29 15:46 ` Luis Machado
2016-11-30 12:54   ` Yao Qi
2016-11-30 14:01     ` Luis Machado
2016-12-01 20:05       ` Gary Benson
2016-11-30 19:28     ` Pedro Alves
2016-12-06 14:22 ` [PATCH V2] " Yao Qi
2017-01-13 15:46   ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox