From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28501 invoked by alias); 6 Dec 2016 14:22:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 28052 invoked by uid 89); 6 Dec 2016 14:22:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=0008, Sending, 016, 037 X-HELO: mail-pg0-f68.google.com Received: from mail-pg0-f68.google.com (HELO mail-pg0-f68.google.com) (74.125.83.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Dec 2016 14:22:12 +0000 Received: by mail-pg0-f68.google.com with SMTP id e9so19982345pgc.1 for ; Tue, 06 Dec 2016 06:22:12 -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:in-reply-to :references; bh=hctuDf2CU1sx8/ZqXP538kf75TTZ0Rwkc/j1hWjp0uw=; b=PpWf8a7PRxWDIUDM7rt553IQDOCDsh0FqqSl/X64T82A9k8EMp4a8QMkdcq4ixVDh/ VhlAQeBz1DV3lhe+8aB9LynxG2EqixPxjhVJikSi/alHeA7ZvkzekvjS3reMYm4oxCsh 5KSQLmqfSVeX3CQMQlQAsY/wrUgtF13pA3YL8FbtnF6+KSV6OY/ygDXMsczqDe5T/cg5 j9jMtDarhTcj9y/X7AC8AqZ2zQ1O6CTOfy0Lua32KLC+v7sVhgPsO0rhrmUr7Kb8zNgP wxhis4X5OL2m11lL654PRNHb1cnKuORWjHpZ15fFGCNfSetytpj2+hQ78V7m2d6l8kcm K1BQ== X-Gm-Message-State: AKaTC02f/luoEpm3F20U2pIW+dWpf1wytRLQhzLWLC15+shflHFEdbSX+ZphA1W17VfaBw== X-Received: by 10.98.198.85 with SMTP id m82mr63436540pfg.69.1481034130493; Tue, 06 Dec 2016 06:22:10 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id q145sm35393128pfq.22.2016.12.06.06.22.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Dec 2016 06:22:09 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH V2] Don't print too much if remote_debug is on Date: Tue, 06 Dec 2016 14:22:00 -0000 Message-Id: <1481034118-17745-1-git-send-email-yao.qi@linaro.org> In-Reply-To: <1480433898-19584-1-git-send-email-yao.qi@linaro.org> References: <1480433898-19584-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00161.txt.bz2 v2: Only print the first REMOTE_DEBUG_MAX_CHAR chars in debug output. 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\n\n\n\n\n\n\n i386:x86-64\n GNU/Linux\n \n * 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. --- gdb/remote.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index ef6c54e..6833038 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. */ -- 1.9.1