From patchwork Tue Nov 29 15:38:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 18044 Received: (qmail 125224 invoked by alias); 29 Nov 2016 15:38:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 125211 invoked by uid 89); 29 Nov 2016 15:38:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=remotec, remote.c, UD:remote.c, gdb_stdlog X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Nov 2016 15:38:27 +0000 Received: by mail-pf0-f195.google.com with SMTP id i88so8543310pfk.2 for ; Tue, 29 Nov 2016 07:38:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=g27OxK2aSdkiE2Rhehk+v9x+oXqeLNK76G+Yicxxstw=; b=BKA84aZbgsxlwkQsVtNicPY9ckuZOCRcob0Vwm1MFfDD6lP0orZO0irBwGaqsOed+f gpaLQnhUXSgfCP1R2uqxnsP1YCSQ3tP7F1jbowvXyVWEzAG/qU7+Jy1P6UM2hh3HWT/Z AajW3fzTKaA751hQQ8W0MrdRRUhdFXnbra+76jyx3AJSg/R6vIIB53dpWqxMUe4QXkFV YnCorEm306ck0WIXxzyMI+F24ge9pQ2Tr7Rdcmmw+B9ZTd2wNt8CSOlqL0h4wi7rwxuy sezPYdBMHoYZnb5HvODAONBOvYyXhQnXmyQqxHBaZvy84nzHU1bMzfMTUxBzGTkgvXQL PiVQ== X-Gm-Message-State: AKaTC025e0nsJu2712SqkIrVk+2Wm1Z5q6mmJzV0tpBpfiUKgTzCW5y9nnLHN5b+ibRpXg== X-Received: by 10.84.204.133 with SMTP id b5mr62896716ple.49.1480433905461; Tue, 29 Nov 2016 07:38:25 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (power8-aix.osuosl.org. [140.211.9.96]) by smtp.gmail.com with ESMTPSA id n17sm96046161pfg.80.2016.11.29.07.38.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 07:38:25 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Don't print too much if remote_debug is on Date: Tue, 29 Nov 2016 15:38:18 +0000 Message-Id: <1480433898-19584-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes 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 * 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. */