This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Don't print too much if remote_debug is on


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6f8976bfd6d7848268849b88e95917217ee31d3e

commit 6f8976bfd6d7848268849b88e95917217ee31d3e
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Jan 13 15:45:33 2017 +0000

    Don't print too much if remote_debug is on
    
    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 only print 512 chars in max in
    debugging messages, like this,
    
    Sending packet: $qXfer:features:read:target.xml:0,fff#7d...Packet received: l<?xml version="1.0"?>\n<!-- Copyright (C) 2010-2016 Free Software Foundation, Inc.\n\n     Copying and distribution of this file, with or without modification,\n     are permitted in any medium without royalty provided the copyright\n     notice and this notice are preserved.  -->\n\n<!-- AMD64 with AVX - Includes Linux-only special "register".  -->\n\n<!DOCTYPE target SYSTEM "gdb-target.dtd">\n<target>\n  <architecture>i386:x86-64</architecture>\n  <osabi>GNU/Linux</osabi>\n  <xi:include href="64bit-core.xml"/>\n  <xi:[14 bytes omitted]
    
    Sending packet: $qXfer:auxv:read::0,1000#6b...Packet received: l!\000\000\000\000\000\000\000\000d\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000@\000@\000\000\000\000\000\004\000\000\000\000\000\000\0008\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\t\000\000\000\000\000\000\000\a\000\000\000\000\000\000\000\177\000\000\b\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\t\000\000\000\000\000\000\000\000\004@\000\000\000\000\000\013\000\000\000\000\000\000\003\000\000\000\000\000\000\f\000\000\000\000\000\000\003\000\000\000\000\000\000\r\000\000\000\000\000\000\003\000\000\000\000\000\000\016\000\000\000\000\000\000\003\000\000\000\000\000\000\027\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\000\000\000\000\000\177\000\000\037\000\000\000\000\000\000\000\000\017\000\000\000\000\000\000\00\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000[582 bytes omitted]
    
    gdb:
    
    2017-01-13  Yao Qi  <yao.qi@linaro.org>
    
    	* remote.c (REMOTE_DEBUG_MAX_CHAR): New macro.
    	(putpkt_binary): Print only REMOTE_DEBUG_MAX_CHAR chars in debug
    	output.
    	(getpkt_or_notif_sane_1): Likewise.

Diff:
---
 gdb/ChangeLog |  7 +++++++
 gdb/remote.c  | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dde53bd..39d66b8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2017-01-13  Yao Qi  <yao.qi@linaro.org>
 
+	* remote.c (REMOTE_DEBUG_MAX_CHAR): New macro.
+	(putpkt_binary): Print only REMOTE_DEBUG_MAX_CHAR chars in debug
+	output.
+	(getpkt_or_notif_sane_1): Likewise.
+
+2017-01-13  Yao Qi  <yao.qi@linaro.org>
+
 	* Makefile.in (checker-headers): Use CXX and CXX_DIALET instead
 	of CC.  Pass "-x c++-header" instead of "-x c".
 
diff --git a/gdb/remote.c b/gdb/remote.c
index c73c30a..2f7954a 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.  The rest of chars are
+   omitted.  */
+
+#define REMOTE_DEBUG_MAX_CHAR 512
+
 /* Data for the vFile:pread readahead cache.  */
 
 struct readahead_cache
@@ -8749,9 +8754,21 @@ putpkt_binary (const char *buf, int cnt)
 	{
 	  *p = '\0';
 
-	  std::string str = escape_buffer (buf2, p - buf2);
+	  int len = (int) (p - buf2);
+
+	  std::string str
+	    = escape_buffer (buf2, std::min (len, REMOTE_DEBUG_MAX_CHAR));
+
+	  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);
+	    }
+
+	  fprintf_unfiltered (gdb_stdlog, "...");
 
-	  fprintf_unfiltered (gdb_stdlog, "Sending packet: %s...", str.c_str ());
 	  gdb_flush (gdb_stdlog);
 	}
       remote_serial_write (buf2, p - buf2);
@@ -9179,9 +9196,20 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
 	{
 	  if (remote_debug)
 	    {
-	      std::string str = escape_buffer (*buf, val);
+	      std::string str
+		= escape_buffer (*buf,
+				 std::min (val, REMOTE_DEBUG_MAX_CHAR));
+
+	      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);
+		}
 
-	      fprintf_unfiltered (gdb_stdlog, "Packet received: %s\n", str.c_str ());
+	      fprintf_unfiltered (gdb_stdlog, "\n");
 	    }
 
 	  /* Skip the ack char if we're in no-ack mode.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]