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