Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] not trigger pagination with dprintf
@ 2013-04-19  3:22 Hui Zhu
  2013-04-20  8:20 ` Tom Tromey
  0 siblings, 1 reply; 16+ messages in thread
From: Hui Zhu @ 2013-04-19  3:22 UTC (permalink / raw)
  To: gdb-patches ml

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

Hi,

This is the patch for http://sourceware.org/bugzilla/show_bug.cgi?id=15182
I agree with what Marc said in the bug report.

So this patch make dprintf not trigger pagination.

Please help me review it.

Thanks,
Hui

2013-04-18  Hui Zhu  <hui@codesourcery.com>

	PR gdb/15182

	* printcmd.c (printf_c_string): Add argument filter and handle it.
	(printf_wide_c_string): Ditto.
	(printf_decfloat): Ditto.
	(printf_pointer): Ditto.
	(ui_printf): Ditto.
	(printf_command): Update argument of ui_printf.
	(eval_command): Ditto.

[-- Attachment #2: dprintf-unfiltered.txt --]
[-- Type: text/plain, Size: 7834 bytes --]

--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2001,7 +2001,7 @@ print_variable_and_value (const char *na
 
 static void
 printf_c_string (struct ui_file *stream, const char *format,
-		 struct value *value)
+		 struct value *value, int filter)
 {
   gdb_byte *str;
   CORE_ADDR tem;
@@ -2026,7 +2026,10 @@ printf_c_string (struct ui_file *stream,
     read_memory (tem, str, j);
   str[j] = 0;
 
-  fprintf_filtered (stream, format, (char *) str);
+  if (filter)
+    fprintf_filtered (stream, format, (char *) str);
+  else
+    fprintf_unfiltered (stream, format, (char *) str);
 }
 
 /* Subroutine of ui_printf to simplify it.
@@ -2035,7 +2038,7 @@ printf_c_string (struct ui_file *stream,
 
 static void
 printf_wide_c_string (struct ui_file *stream, const char *format,
-		      struct value *value)
+		      struct value *value, int filter)
 {
   gdb_byte *str;
   CORE_ADDR tem;
@@ -2075,7 +2078,10 @@ printf_wide_c_string (struct ui_file *st
 			     &output, translit_char);
   obstack_grow_str0 (&output, "");
 
-  fprintf_filtered (stream, format, obstack_base (&output));
+  if (filter)
+    fprintf_filtered (stream, format, obstack_base (&output));
+  else
+    fprintf_unfiltered (stream, format, obstack_base (&output));
   do_cleanups (inner_cleanup);
 }
 
@@ -2084,14 +2090,17 @@ printf_wide_c_string (struct ui_file *st
 
 static void
 printf_decfloat (struct ui_file *stream, const char *format,
-		 struct value *value)
+		 struct value *value, int filter)
 {
   const gdb_byte *param_ptr = value_contents (value);
 
 #if defined (PRINTF_HAS_DECFLOAT)
   /* If we have native support for Decimal floating
      printing, handle it here.  */
-  fprintf_filtered (stream, format, param_ptr);
+  if (filter)
+    fprintf_filtered (stream, format, param_ptr);
+  else
+    fprintf_unfiltered (stream, format, param_ptr);
 #else
   /* As a workaround until vasprintf has native support for DFP
      we convert the DFP values to string and print them using
@@ -2160,7 +2169,10 @@ printf_decfloat (struct ui_file *stream,
   decimal_to_string (dfp_ptr, dfp_len, byte_order, decstr);
 
   /* Print the DFP value.  */
-  fprintf_filtered (stream, "%s", decstr);
+  if (filter)
+    fprintf_filtered (stream, "%s", decstr);
+  else
+    fprintf_unfiltered (stream, "%s", decstr);
 #endif
 }
 
@@ -2169,7 +2181,7 @@ printf_decfloat (struct ui_file *stream,
 
 static void
 printf_pointer (struct ui_file *stream, const char *format,
-		struct value *value)
+		struct value *value, int filter)
 {
   /* We avoid the host's %p because pointers are too
      likely to be the wrong size.  The only interesting
@@ -2219,20 +2231,26 @@ printf_pointer (struct ui_file *stream,
       *fmt_p++ = 'l';
       *fmt_p++ = 'x';
       *fmt_p++ = '\0';
-      fprintf_filtered (stream, fmt, val);
+      if (filter)
+	fprintf_filtered (stream, fmt, val);
+      else
+	fprintf_unfiltered (stream, fmt, val);
     }
   else
     {
       *fmt_p++ = 's';
       *fmt_p++ = '\0';
-      fprintf_filtered (stream, fmt, "(nil)");
+      if (filter)
+	fprintf_filtered (stream, fmt, "(nil)");
+      else
+	fprintf_unfiltered (stream, fmt, "(nil)");
     }
 }
 
 /* printf "printf format string" ARG to STREAM.  */
 
 static void
-ui_printf (const char *arg, struct ui_file *stream)
+ui_printf (const char *arg, struct ui_file *stream, int filter)
 {
   struct format_piece *fpieces;
   const char *s = arg;
@@ -2310,10 +2328,12 @@ ui_printf (const char *arg, struct ui_fi
 	switch (fpieces[fr].argclass)
 	  {
 	  case string_arg:
-	    printf_c_string (stream, current_substring, val_args[i]);
+	    printf_c_string (stream, current_substring, val_args[i],
+			     filter);
 	    break;
 	  case wide_string_arg:
-	    printf_wide_c_string (stream, current_substring, val_args[i]);
+	    printf_wide_c_string (stream, current_substring, val_args[i],
+				  filter);
 	    break;
 	  case wide_char_arg:
 	    {
@@ -2343,8 +2363,12 @@ ui_printf (const char *arg, struct ui_fi
 					 &output, translit_char);
 	      obstack_grow_str0 (&output, "");
 
-	      fprintf_filtered (stream, current_substring,
-                                obstack_base (&output));
+	      if (filter)
+	        fprintf_filtered (stream, current_substring,
+				  obstack_base (&output));
+	      else
+	        fprintf_unfiltered (stream, current_substring,
+				    obstack_base (&output));
 	      do_cleanups (inner_cleanup);
 	    }
 	    break;
@@ -2361,7 +2385,10 @@ ui_printf (const char *arg, struct ui_fi
 	      if (inv)
 		error (_("Invalid floating value found in program."));
 
-              fprintf_filtered (stream, current_substring, (double) val);
+	      if (filter)
+                fprintf_filtered (stream, current_substring, (double) val);
+	      else
+		fprintf_unfiltered (stream, current_substring, (double) val);
 	      break;
 	    }
 	  case long_double_arg:
@@ -2378,8 +2405,12 @@ ui_printf (const char *arg, struct ui_fi
 	      if (inv)
 		error (_("Invalid floating value found in program."));
 
-	      fprintf_filtered (stream, current_substring,
-                                (long double) val);
+	      if (filter)
+	        fprintf_filtered (stream, current_substring,
+				  (long double) val);
+	      else
+	        fprintf_unfiltered (stream, current_substring,
+				    (long double) val);
 	      break;
 	    }
 #else
@@ -2390,7 +2421,10 @@ ui_printf (const char *arg, struct ui_fi
 	    {
 	      long long val = value_as_long (val_args[i]);
 
-              fprintf_filtered (stream, current_substring, val);
+	      if (filter)
+		fprintf_filtered (stream, current_substring, val);
+	      else
+		fprintf_unfiltered (stream, current_substring, val);
 	      break;
 	    }
 #else
@@ -2400,22 +2434,28 @@ ui_printf (const char *arg, struct ui_fi
 	    {
 	      int val = value_as_long (val_args[i]);
 
-              fprintf_filtered (stream, current_substring, val);
+	      if (filter)
+		fprintf_filtered (stream, current_substring, val);
+	      else
+		fprintf_unfiltered (stream, current_substring, val);
 	      break;
 	    }
 	  case long_arg:
 	    {
 	      long val = value_as_long (val_args[i]);
 
-              fprintf_filtered (stream, current_substring, val);
+	      if (filter)
+		fprintf_filtered (stream, current_substring, val);
+	      else
+		fprintf_unfiltered (stream, current_substring, val);
 	      break;
 	    }
 	  /* Handles decimal floating values.  */
 	  case decfloat_arg:
-	    printf_decfloat (stream, current_substring, val_args[i]);
+	    printf_decfloat (stream, current_substring, val_args[i], filter);
 	    break;
 	  case ptr_arg:
-	    printf_pointer (stream, current_substring, val_args[i]);
+	    printf_pointer (stream, current_substring, val_args[i], filter);
 	    break;
 	  case literal_piece:
 	    /* Print a portion of the format string that has no
@@ -2426,7 +2466,10 @@ ui_printf (const char *arg, struct ui_fi
 	       have modified GCC to include -Wformat-security by
 	       default, which will warn here if there is no
 	       argument.  */
-	    fprintf_filtered (stream, current_substring, 0);
+	    if (filter)
+	      fprintf_filtered (stream, current_substring, 0);
+	    else
+	      fprintf_unfiltered (stream, current_substring, 0);
 	    break;
 	  default:
 	    internal_error (__FILE__, __LINE__,
@@ -2445,7 +2488,7 @@ ui_printf (const char *arg, struct ui_fi
 static void
 printf_command (char *arg, int from_tty)
 {
-  ui_printf (arg, gdb_stdout);
+  ui_printf (arg, gdb_stdout, from_tty);
 }
 
 /* Implement the "eval" command.  */
@@ -2457,7 +2500,7 @@ eval_command (char *arg, int from_tty)
   struct cleanup *cleanups = make_cleanup_ui_file_delete (ui_out);
   char *expanded;
 
-  ui_printf (arg, ui_out);
+  ui_printf (arg, ui_out, 1);
 
   expanded = ui_file_xstrdup (ui_out, NULL);
   make_cleanup (xfree, expanded);

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

end of thread, other threads:[~2013-05-10 11:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-19  3:22 [PATCH] not trigger pagination with dprintf Hui Zhu
2013-04-20  8:20 ` Tom Tromey
2013-04-22  9:21   ` Hui Zhu
2013-04-25  8:02     ` Tom Tromey
2013-04-26 13:55       ` Hui Zhu
2013-04-26 14:14         ` Yao Qi
2013-04-27 11:40         ` Tom Tromey
2013-04-30 11:12           ` Hui Zhu
2013-05-04  4:41             ` Doug Evans
2013-05-07  2:30               ` Hui Zhu
2013-05-07 16:39                 ` Eli Zaretskii
2013-05-07 17:01                   ` Doug Evans
2013-05-07 18:08                     ` Tom Tromey
2013-05-07 18:10                       ` Doug Evans
2013-05-07 18:28                         ` Eli Zaretskii
2013-05-10 11:21                           ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox