/* General utility routines for GDB, the GNU debugger.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
else
fputs_unfiltered (msg, gdb_stderr);
- abort (); /* NOTE: GDB has only three calls to abort(). */
+ abort (); /* ARI: abort */
}
/* Dump core trying to increase the core soft limit to hard limit first. */
setrlimit (RLIMIT_CORE, &rlim);
#endif /* HAVE_SETRLIMIT */
- abort (); /* NOTE: GDB has only three calls to abort(). */
+ abort (); /* ARI: abort */
}
/* Check whether GDB will be able to dump core using the dump_core
does not fix this problem. This is the solution suggested
at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509. */
if (write (STDERR_FILENO, msg, sizeof (msg)) != sizeof (msg))
- abort (); /* NOTE: GDB has only three calls to abort(). */
+ abort (); /* ARI: abort */
exit (1);
}
}
}
/* If the output is not a terminal, don't paginate it. */
- if (!ui_file_isatty (gdb_stdout))
+ if (!gdb_stdout->isatty ())
lines_per_page = UINT_MAX;
#endif
}
if (stream == nullptr)
wrap_buffer.append (style.to_ansi ());
else
- fputs_unfiltered (style.to_ansi ().c_str (), stream);
+ stream->puts (style.to_ansi ().c_str ());
}
/* Set the current output style. This will affect future uses of the
{
if (stream == gdb_stdout && !wrap_buffer.empty ())
{
- fputs_unfiltered (wrap_buffer.c_str (), stream);
+ stream->puts (wrap_buffer.c_str ());
wrap_buffer.clear ();
}
}
+/* See utils.h. */
+
+void
+gdb_flush (struct ui_file *stream)
+{
+ flush_wrap_buffer (stream);
+ stream->flush ();
+}
+
/* Indicate that if the next sequence of characters overflows the line,
a newline should be inserted here rather than when it hits the end.
If INDENT is non-null, it is a string to be printed to indent the
|| top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ())
{
flush_wrap_buffer (stream);
- fputs_unfiltered (linebuffer, stream);
+ stream->puts (linebuffer);
return;
}
newline -- if chars_per_line is right, we
probably just overflowed anyway; if it's wrong,
let us keep going. */
- fputc_unfiltered ('\n', stream);
+ /* XXX: The ideal thing would be to call
+ 'stream->putc' here, but we can't because it
+ currently calls 'fputc_unfiltered', which ends up
+ calling us, which generates an infinite
+ recursion. */
+ stream->puts ("\n");
}
else
{
/* Now output indentation and wrapped string. */
if (wrap_column)
{
- fputs_unfiltered (wrap_indent, stream);
+ stream->puts (wrap_indent);
if (stream->can_emit_style_escape ())
emit_style_escape (save_style, stream);
/* FIXME, this strlen is what prevents wrap_indent from
wrap_here ((char *) 0); /* Spit out chars, cancel
further wraps. */
lines_printed++;
- fputc_unfiltered ('\n', stream);
+ /* XXX: The ideal thing would be to call
+ 'stream->putc' here, but we can't because it
+ currently calls 'fputc_unfiltered', which ends up
+ calling us, which generates an infinite
+ recursion. */
+ stream->puts ("\n");
lineptr++;
}
}
fputs_maybe_filtered (linebuffer, stream, 1);
}
+void
+fputs_unfiltered (const char *linebuffer, struct ui_file *stream)
+{
+ fputs_maybe_filtered (linebuffer, stream, 0);
+}
+
/* See utils.h. */
void
int
putchar_unfiltered (int c)
{
- char buf = c;
-
- ui_file_write (gdb_stdout, &buf, 1);
- return c;
+ return fputc_unfiltered (c, gdb_stdout);
}
/* Write character C to gdb_stdout using GDB's paging mechanism and return C.
int
fputc_unfiltered (int c, struct ui_file *stream)
{
- char buf = c;
+ char buf[2];
- ui_file_write (stream, &buf, 1);
+ buf[0] = c;
+ buf[1] = 0;
+ fputs_unfiltered (buf, stream);
return c;
}
}
}
+void _initialize_utils ();
void
-_initialize_utils (void)
+_initialize_utils ()
{
add_setshow_uinteger_cmd ("width", class_support, &chars_per_line, _("\
Set number of characters where GDB should wrap lines of its output."), _("\