Message ID | gerrit.1574263562000.I2e871b37bfcaa6376537c3fe3db8f016dd806a7c@gnutoolchain-gerrit.osci.io |
---|---|
State | New, archived |
Headers |
Received: (qmail 10201 invoked by alias); 20 Nov 2019 15:26:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10191 invoked by uid 89); 20 Nov 2019 15:26:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=adjustable, sk:add_set 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; Wed, 20 Nov 2019 15:26:10 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 9ADFD2041E; Wed, 20 Nov 2019 10:26:08 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 9415920250 for <gdb-patches@sourceware.org>; Wed, 20 Nov 2019 10:26:03 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 0D06D2816F for <gdb-patches@sourceware.org>; Wed, 20 Nov 2019 10:26:03 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Wed, 20 Nov 2019 10:26:03 -0500 From: "Luis Machado (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io> To: gdb-patches@sourceware.org Message-ID: <gerrit.1574263562000.I2e871b37bfcaa6376537c3fe3db8f016dd806a7c@gnutoolchain-gerrit.osci.io> Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] [Debugging output] Make remote packet truncation length adjustable X-Gerrit-Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c X-Gerrit-Change-Number: 691 X-Gerrit-ChangeURL: <https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691> X-Gerrit-Commit: 44ea60143f96567d5183cf80145961fc0e25a343 References: <gerrit.1574263562000.I2e871b37bfcaa6376537c3fe3db8f016dd806a7c@gnutoolchain-gerrit.osci.io> Reply-To: luis.machado@linaro.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 |
Commit Message
Simon Marchi (Code Review)
Nov. 20, 2019, 3:26 p.m. UTC
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 remote
packet-length-limit" command. It can be set to unlimited if we want to
completely disable truncation.
gdb/ChangeLog:
2019-11-20 Luis Machado <luis.machado@linaro.org>
* remote.c (REMOTE_DEBUG_MAX_CHAR): Remove.
(remote_packet_length_limit): New static global.
(show_packet_length_limit): New function.
(remote_target::putpkt_binary): Adjust to use new
adjustable option.
(remote_target::getpkt_or_notif_sane_1): Likewise.
(_initialize_remote): Register remote packet-length-limit option.
Signed-off-by: Luis Machado <luis.machado@linaro.org>
Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c
---
M gdb/remote.c
1 file changed, 42 insertions(+), 8 deletions(-)
Comments
Luis Machado has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 1: I'm not too sure packet-length-limit is good. Suggestions are welcome.
Tom Tromey has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 1: > Patch Set 1: > > I'm not too sure packet-length-limit is good. Suggestions are welcome. I tend to think something in the "set debug" namespace would be better, since it's a setting related to "set debug remote". How about "set debug remote-log-length"? This patch also needs a documentation change and a NEWS entry.
Luis Machado has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 1: > Patch Set 1: > > > Patch Set 1: > > > > I'm not too sure packet-length-limit is good. Suggestions are welcome. > > I tend to think something in the "set debug" namespace would be better, > since it's a setting related to "set debug remote". I contemplated that, but upon looking at what sorts of options were available via "set debug", they were related to producing debugging output only, not adjusting how the debugging output was produced. So i went for more locality by putting it into "set remote". To be honest, i don't think it fits in any of those two. But i'm okay with going for "set debug remote-log-length" based on feedback. > > How about "set debug remote-log-length"? > > This patch also needs a documentation change and a NEWS entry. I'll put something together.
Tom Tromey has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 2: Code-Review+1 (1 comment) Thank you. I have a small suggestion for the docs, but otherwise everything looks good. I'm marking this +1 since Eli should review the doc changes. | --- gdb/doc/gdb.texinfo | +++ gdb/doc/gdb.texinfo | @@ -26273,7 +26273,20 @@ the serial line to the remote machine. The info is printed on the | @value{GDBN} standard output stream. The default is off. | @item show debug remote | Displays the state of display of remote packets. | | +@item set debug remote-log-length | +Sets the number of characters to display for each remote packet when | +@code{set debug remote} is on. This is useful to prevent GDB from | +displaying lengthy remote packets and polluting the console. | + | +The default value is @code{512}, which means @value{GDBN} will truncate the | +remote packet output after 512 bytes. PS2, Line 26283: I think maybe this should say something like "will truncate each remote packet after 512 bytes" ... the current text makes it sound a bit like the entirety of the output will be truncated. | + | +Setting this option to @code{unlimited} will disable truncation and will output | +the full length of the remote packets. | +@item show debug remote-log-length | +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
Pedro Alves has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 3: > > > I'm not too sure packet-length-limit is good. Suggestions are welcome. I agree "set remote packet-length-limit" isn't good, since I'd expect a setting by that name to control the actual max size of gdb's packet buffer. > > > > I tend to think something in the "set debug" namespace would be better, > > since it's a setting related to "set debug remote". > > I contemplated that, but upon looking at what sorts of options were available via "set debug", they were related to producing debugging output only, not adjusting how the debugging output was produced. So i went for more locality by putting it into "set remote". > > To be honest, i don't think it fits in any of those two. But i'm okay with going for "set debug remote-log-length" based on feedback. > > > > > How about "set debug remote-log-length"? > > > > This patch also needs a documentation change and a NEWS entry. > > I'll put something together. I'm not thrilled with "remote-log-length" because "length" alone doesn't convey "max", or "limit". Your original "packet-length-limit" did, but it was under the wrong namespace. Including "log" in the setting name seems redundant, since "set debug" settings all control logging in some form. "packet-length-limit" wasn't 100% correct, since it's not really the size of the packet that counts, it's how much you'd display, including escaping, but that seems like a minor issue. Let's look at how the option is described: "Sets the number of characters to display for each remote packet" Note that it doesn't talk about "log" and doesn't say "length". If you start from that description, then the obvious setting name would be around: set debug remote-max-chars set debug remote-packet-max-characters set debug remote-packet-max-chars set debug remote-max-packet-chars I think my preferred one would be "remote-packet-max-chars", since the limit only applies to packet logging. Which is not unlike the existing macro name: /* The max number of chars in debug output. The rest of chars are omitted. */ #define REMOTE_DEBUG_MAX_CHAR 512
Pedro Alves has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 4: (5 comments) Thanks. A few comments more. | --- /dev/null | +++ /COMMIT_MSG | @@ -1,0 +19,19 @@ gdb/ChangeLog: | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * 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. PS4, Line 28: remote_packet_max_chars -> remote-packet-max-chars | + | +gdb/doc/ChangeLog: | + | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * gdb.texinfo (Debugging Output): Document set debug | + remote-packet-max-chars. | + | +Signed-off-by: Luis Machado <luis.machado@linaro.org> | --- gdb/NEWS | +++ gdb/NEWS | @@ -183,14 +183,19 @@ info module variables [-q] [-m MODULE_REGEXP] [-t TYPE_REGEXP] [REGEXP] | Return a list of variables within all modules, grouped by module. | The list of variables can be restricted with the optional regular | expressions. MODULE_REGEXP matches against the module name, | 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 amount of characters to output when using "set debug remote". | + The default is 512 bytes. PS4, Line 192: Should mention "packet" somewhere in this description. Maybe just "amount of packet characters". | + | * Changed commands | | help | The "help" command uses the title style to enhance the | readibility of its output by styling the classes and | command names. | | apropos [-v] REGEXP | --- gdb/remote.c | +++ gdb/remote.c | @@ -1037,19 +1037,17 @@ /* For "set remote" and "show remote". */ | static struct cmd_list_element *remote_set_cmdlist; | static struct cmd_list_element *remote_show_cmdlist; | | /* Controls whether GDB is willing to use range stepping. */ | | static bool use_range_stepping = true; | | /* The max number of chars in debug output. The rest of chars are | omitted. */ | PS4, Line 1046: This comment above... | -#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 | { | std::string extra; | std::string name; | int core = -1; | ... | @@ -1706,16 +1704,30 @@ /* Show the number of hardware breakpoints that can be used. */ | static void | show_hardware_breakpoint_limit (struct ui_file *file, int from_tty, | struct cmd_list_element *c, | const char *value) | { | fprintf_filtered (file, _("The maximum number of target hardware " | "breakpoints is %s.\n"), value); | } | | +static int remote_packet_max_chars = 512; PS4, Line 1713: ... should be moved here. | + | +/* Show the maximum number of characters to display for a 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, _("Remote packet output will be truncated at %s " | + "characters.\n"), value); PS4, Line 1724: Pedantically, this string doesn't work well with singular / 1 character. Come to think of it, nor with "unlimited"? Does it say: "Remote packet output will be truncated at unlimited characters." Better rephrase that as: "something something something is %s.\n", value | +} | + | long | remote_target::get_memory_write_packet_size () | { | return get_memory_packet_size (&memory_write_packet_config); | } | | static struct memory_packet_config memory_read_packet_config =
Luis Machado has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 4: (4 comments) | --- /dev/null | +++ /COMMIT_MSG | @@ -1,0 +19,19 @@ gdb/ChangeLog: | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * 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. PS4, Line 28: This was actually supposed to refer to the variable itself. Though thinking again, it may be better to refer to the debug option itself. | + | +gdb/doc/ChangeLog: | + | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * gdb.texinfo (Debugging Output): Document set debug | + remote-packet-max-chars. | + | +Signed-off-by: Luis Machado <luis.machado@linaro.org> | --- gdb/NEWS | +++ gdb/NEWS | @@ -183,14 +183,19 @@ info module variables [-q] [-m MODULE_REGEXP] [-t TYPE_REGEXP] [REGEXP] | Return a list of variables within all modules, grouped by module. | The list of variables can be restricted with the optional regular | expressions. MODULE_REGEXP matches against the module name, | 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 amount of characters to output when using "set debug remote". | + The default is 512 bytes. PS4, Line 192: Indeed. I'll fix this. | + | * Changed commands | | help | The "help" command uses the title style to enhance the | readibility of its output by styling the classes and | command names. | | apropos [-v] REGEXP | --- gdb/remote.c | +++ gdb/remote.c | @@ -1706,16 +1704,30 @@ /* Show the number of hardware breakpoints that can be used. */ | static void | show_hardware_breakpoint_limit (struct ui_file *file, int from_tty, | struct cmd_list_element *c, | const char *value) | { | fprintf_filtered (file, _("The maximum number of target hardware " | "breakpoints is %s.\n"), value); | } | | +static int remote_packet_max_chars = 512; PS4, Line 1713: ... and moved it here then. Thanks for spotting this. | + | +/* Show the maximum number of characters to display for a 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, _("Remote packet output will be truncated at %s " | + "characters.\n"), value); PS4, Line 1724: "Number of remote packet characters to display is %s.\n"? | +} | + | long | remote_target::get_memory_write_packet_size () | { | return get_memory_packet_size (&memory_write_packet_config); | } | | static struct memory_packet_config memory_read_packet_config =
Luis Machado has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 4: (1 comment) | --- gdb/remote.c | +++ gdb/remote.c | @@ -1037,19 +1037,17 @@ /* For "set remote" and "show remote". */ | static struct cmd_list_element *remote_set_cmdlist; | static struct cmd_list_element *remote_show_cmdlist; | | /* Controls whether GDB is willing to use range stepping. */ | | static bool use_range_stepping = true; | | /* The max number of chars in debug output. The rest of chars are | omitted. */ | PS4, Line 1046: I took the liberty to make this comment a bit more grammatically correct... | -#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 | { | std::string extra; | std::string name; | int core = -1; |
Pedro Alves has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 5: Code-Review+2 (2 comments) Thanks. This looks good. | --- /dev/null | +++ /COMMIT_MSG | @@ -1,0 +23,19 @@ gdb/ChangeLog: | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * 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. PS5, Line 32: > (_initialize_remote): Register new remote_packet_max_chars option. I guess you mean to use hyphens here as well. This is actually the case that I was referring to earlier. | + | +gdb/doc/ChangeLog: | + | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * gdb.texinfo (Debugging Output): Document set debug | + remote-packet-max-chars. | + | +Signed-off-by: Luis Machado <luis.machado@linaro.org> | --- gdb/remote.c | +++ gdb/remote.c | @@ -1715,7 +1715,19 @@ static int remote_packet_max_chars = 512; | +/* Show the maximum number of characters to display for a 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, _("Remote packet output will be truncated at %s " | + "characters.\n"), value); PS4, Line 1724: > "Number of remote packet characters to display is %s.\n"? That looks good. | +} | + | long | remote_target::get_memory_write_packet_size () | { | return get_memory_packet_size (&memory_write_packet_config); | } | | static struct memory_packet_config memory_read_packet_config =
Luis Machado has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/691 ...................................................................... Patch Set 6: (1 comment) Thanks for the review. I'll push this later today. | --- /dev/null | +++ /COMMIT_MSG | @@ -1,0 +23,19 @@ gdb/ChangeLog: | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * 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. PS5, Line 32: Ah, got it. Sorry, i missed this in e-mail form for some reason. | + | +gdb/doc/ChangeLog: | + | +2019-11-21 Luis Machado <luis.machado@linaro.org> | + | + * gdb.texinfo (Debugging Output): Document set debug | + remote-packet-max-chars. | + | +Signed-off-by: Luis Machado <luis.machado@linaro.org>
diff --git a/gdb/remote.c b/gdb/remote.c index 1ac9013..80457ad 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1044,8 +1044,6 @@ /* 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 +1710,20 @@ "breakpoints is %s.\n"), value); } +static int remote_packet_length_limit = 512; + +/* Show the maximum number of characters to display for a remote packet when + remote debugging is enabled. */ + +static void +show_packet_length_limit (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("Remote packet output will be truncated at %s " + "characters.\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_length_limit < 0) + max_chars = len; + else + max_chars = remote_packet_length_limit; 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_length_limit < 0) + max_chars = val; + else + max_chars = remote_packet_length_limit; + 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,15 @@ show_watchdog, &setlist, &showlist); + add_setshow_zuinteger_unlimited_cmd ("packet-length-limit", no_class, + &remote_packet_length_limit, _("\ +Set the maximum number of characters to display for remote packet debugging."), _("\ +Show the maximum number of characters to display for remote packet debugging."), _("\ +Specify \"unlimited\" to display all the characters."), + NULL, show_packet_length_limit, + &remote_set_cmdlist, + &remote_show_cmdlist); + /* Eventually initialize fileio. See fileio.c */ initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); }