From patchwork Mon Nov 25 15:30:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36187 Received: (qmail 22878 invoked by alias); 25 Nov 2019 15:30:38 -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 22773 invoked by uid 89); 25 Nov 2019 15:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Nov 2019 15:30:15 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 11D8D20249; Mon, 25 Nov 2019 10:30:10 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 3AB76202D0; Mon, 25 Nov 2019 10:30:09 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id F129F20AF6; Mon, 25 Nov 2019 10:30:08 -0500 (EST) X-Gerrit-PatchSet: 7 Date: Mon, 25 Nov 2019 10:30:08 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Luis Machado , Pedro Alves , Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] [Debugging output] Make remote packet truncation length adjustable X-Gerrit-Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c X-Gerrit-Change-Number: 691 X-Gerrit-ChangeURL: X-Gerrit-Commit: 6cc8564b9a2f3aa133ceaf9ab6e71ed68129a8f8 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, palves@redhat.com, luis.machado@linaro.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191125153008.F129F20AF6@gnutoolchain-gerrit.osci.io> The original change was created by Luis Machado. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... [Debugging output] Make remote packet truncation length adjustable While debugging, i felt the need to adjust the truncation length of remote packets so i could see more or less data as needed. The default is currently set to 512 bytes. This patch makes this option adjustable through the new "set debug remote-packet-max-chars" command. It can be set to unlimited if we want to completely disable truncation. Update on v5: - Adjusted function and variable documentation, NEWS entry and GDB manual. gdb/ChangeLog: 2019-11-25 Luis Machado * NEWS (New Commands): Mention "set debug remote-packet-max-chars". * remote.c (REMOTE_DEBUG_MAX_CHAR): Remove. (remote_packet_max_chars): New static global. (show_remote_packet_max_chars): New function. (remote_target::putpkt_binary): Adjust to use new remote_packet_max_chars option. (remote_target::getpkt_or_notif_sane_1): Likewise. (_initialize_remote): Register new remote-packet-max-chars option. gdb/doc/ChangeLog: 2019-11-25 Luis Machado * gdb.texinfo (Debugging Output): Document set debug remote-packet-max-chars. Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c --- M gdb/ChangeLog M gdb/NEWS M gdb/doc/ChangeLog M gdb/doc/gdb.texinfo M gdb/remote.c 5 files changed, 79 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3b656f4..45ff42a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2019-11-25 Luis Machado + + * NEWS (New Commands): Mention "set debug remote-packet-max-chars". + * remote.c (REMOTE_DEBUG_MAX_CHAR): Remove. + (remote_packet_max_chars): New static global. + (show_remote_packet_max_chars): New function. + (remote_target::putpkt_binary): Adjust to use new + remote_packet_max_chars option. + (remote_target::getpkt_or_notif_sane_1): Likewise. + (_initialize_remote): Register new remote-packet-max-chars option. + 2019-11-24 Simon Marchi * m68k-linux-nat.c: Include gdbarch.h. diff --git a/gdb/NEWS b/gdb/NEWS index b0f5447..01b38cf 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -186,6 +186,12 @@ TYPE_REGEXP matches against the variable type, and REGEXP matches against the variable name. +set debug remote-packet-max-chars +show debug remote-packet-max-chars + Controls the number of characters to output in a remote packet when using + "set debug remote". + The default is 512 bytes. + * Changed commands help diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 2571839..c6fa5f5 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2019-11-25 Luis Machado + + * gdb.texinfo (Debugging Output): Document set debug + remote-packet-max-chars. + 2019-11-14 Tom de Vries * gdb.texinfo: Fix typos. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c66a39c..18bb18b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26274,6 +26274,19 @@ @item show debug remote Displays the state of display of remote packets. +@item set debug remote-packet-max-chars +Sets the maximum number of characters to display for each remote packet when +@code{set debug remote} is on. This is useful to prevent @value{GDBN} from +displaying lengthy remote packets and polluting the console. + +The default value is @code{512}, which means @value{GDBN} will truncate each +remote packet after 512 bytes. + +Setting this option to @code{unlimited} will disable truncation and will output +the full length of the remote packets. +@item show debug remote-packet-max-chars +Displays the number of bytes to output for remote packet debugging. + @item set debug separate-debug-file Turns on or off display of debug output about separate debug file search. @item show debug separate-debug-file diff --git a/gdb/remote.c b/gdb/remote.c index 1ac9013..3fc9a26 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1041,11 +1041,6 @@ static bool use_range_stepping = true; -/* The max number of chars in debug output. The rest of chars are - omitted. */ - -#define REMOTE_DEBUG_MAX_CHAR 512 - /* Private data that we'll store in (struct thread_info)->priv. */ struct remote_thread_info : public private_thread_info { @@ -1712,6 +1707,23 @@ "breakpoints is %s.\n"), value); } +/* Controls the maximum number of characters to display in the debug output + for each remote packet. The remaining characters are omitted. */ + +static int remote_packet_max_chars = 512; + +/* Show the maximum number of characters to display for each remote packet + when remote debugging is enabled. */ + +static void +show_remote_packet_max_chars (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Number of remote packet characters to " + "display is %s.\n"), value); +} + long remote_target::get_memory_write_packet_size () { @@ -9119,15 +9131,21 @@ *p = '\0'; int len = (int) (p - buf2); + int max_chars; + + if (remote_packet_max_chars < 0) + max_chars = len; + else + max_chars = remote_packet_max_chars; std::string str - = escape_buffer (buf2, std::min (len, REMOTE_DEBUG_MAX_CHAR)); + = escape_buffer (buf2, std::min (len, max_chars)); fprintf_unfiltered (gdb_stdlog, "Sending packet: %s", str.c_str ()); - if (len > REMOTE_DEBUG_MAX_CHAR) + if (len > max_chars) fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]", - len - REMOTE_DEBUG_MAX_CHAR); + len - max_chars); fprintf_unfiltered (gdb_stdlog, "..."); @@ -9563,16 +9581,23 @@ { if (remote_debug) { + int max_chars; + + if (remote_packet_max_chars < 0) + max_chars = val; + else + max_chars = remote_packet_max_chars; + std::string str = escape_buffer (buf->data (), - std::min (val, REMOTE_DEBUG_MAX_CHAR)); + std::min (val, max_chars)); fprintf_unfiltered (gdb_stdlog, "Packet received: %s", str.c_str ()); - if (val > REMOTE_DEBUG_MAX_CHAR) + if (val > max_chars) fprintf_unfiltered (gdb_stdlog, "[%d bytes omitted]", - val - REMOTE_DEBUG_MAX_CHAR); + val - max_chars); fprintf_unfiltered (gdb_stdlog, "\n"); } @@ -14723,6 +14748,14 @@ show_watchdog, &setlist, &showlist); + add_setshow_zuinteger_unlimited_cmd ("remote-packet-max-chars", no_class, + &remote_packet_max_chars, _("\ +Set the maximum number of characters to display for each remote packet."), _("\ +Show the maximum number of characters to display for each remote packet."), _("\ +Specify \"unlimited\" to display all the characters."), + NULL, show_remote_packet_max_chars, + &setdebuglist, &showdebuglist); + /* Eventually initialize fileio. See fileio.c */ initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); }