public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] [Debugging output] Make remote packet truncation length adjustable
@ 2019-11-20 15:26 Luis Machado (Code Review)
  2019-11-20 15:27 ` Luis Machado (Code Review)
                   ` (16 more replies)
  0 siblings, 17 replies; 22+ messages in thread
From: Luis Machado (Code Review) @ 2019-11-20 15:26 UTC (permalink / raw)
  To: gdb-patches

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(-)



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);
 }

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2e871b37bfcaa6376537c3fe3db8f016dd806a7c
Gerrit-Change-Number: 691
Gerrit-PatchSet: 1
Gerrit-Owner: Luis Machado <luis.machado@linaro.org>
Gerrit-MessageType: newchange

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-11-25 15:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 15:26 [review] [Debugging output] Make remote packet truncation length adjustable Luis Machado (Code Review)
2019-11-20 15:27 ` Luis Machado (Code Review)
2019-11-20 18:12 ` Tom Tromey (Code Review)
2019-11-20 18:42 ` Luis Machado (Code Review)
2019-11-20 20:35 ` [review v2] " Luis Machado (Code Review)
2019-11-21 15:05   ` Eli Zaretskii
2019-11-21 14:41 ` Tom Tromey (Code Review)
2019-11-21 15:17 ` [review v3] " Luis Machado (Code Review)
2019-11-21 15:25   ` Eli Zaretskii
2019-11-21 16:31 ` Pedro Alves (Code Review)
2019-11-21 17:15 ` [review v4] " Luis Machado (Code Review)
2019-11-21 18:55 ` Pedro Alves (Code Review)
2019-11-21 21:49 ` Luis Machado (Code Review)
2019-11-21 21:49 ` Luis Machado (Code Review)
2019-11-21 22:03 ` [review v5] " Luis Machado (Code Review)
2019-11-22  7:34   ` Eli Zaretskii
2019-11-22 15:22 ` Pedro Alves (Code Review)
2019-11-25 13:31 ` [review v6] " Luis Machado (Code Review)
2019-11-25 15:34   ` Eli Zaretskii
2019-11-25 13:33 ` Luis Machado (Code Review)
2019-11-25 15:30 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-25 15:30 ` Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).