#include "defs.h"
#include "dyn-string.h"
-#include "gdb_assert.h"
#include <ctype.h>
-#include <string.h>
#include "gdb_wait.h"
#include "event-top.h"
-#include "exceptions.h"
#include "gdbthread.h"
#include "fnmatch.h"
#include "gdb_bfd.h"
(*deprecated_warning_hook) (string, args);
else
{
- target_terminal_ours ();
- wrap_here (""); /* Force out any buffered output. */
+ if (target_supports_terminal_ours ())
+ target_terminal_ours ();
+ if (filtered_printing_initialized ())
+ wrap_here (""); /* Force out any buffered output. */
gdb_flush (gdb_stdout);
if (warning_pre_print)
fputs_unfiltered (warning_pre_print, gdb_stderr);
}
}
-/* Print a warning message.
- The first argument STRING is the warning message, used as a fprintf string,
- and the remaining args are passed as arguments to it.
- The primary difference between warnings and errors is that a warning
- does not force the return to command level. */
-
-void
-warning (const char *string, ...)
-{
- va_list args;
-
- va_start (args, string);
- vwarning (string, args);
- va_end (args);
-}
-
/* Print an error message and return to command level.
The first argument STRING is the error message, used as a fprintf string,
and the remaining args are passed as arguments to it. */
throw_verror (GENERIC_ERROR, string, args);
}
-void
-error (const char *string, ...)
-{
- va_list args;
-
- va_start (args, string);
- throw_verror (GENERIC_ERROR, string, args);
- va_end (args);
-}
-
void
error_stream (struct ui_file *stream)
{
error (("%s"), message);
}
+/* Emit a message and abort. */
+
+static void ATTRIBUTE_NORETURN
+abort_with_message (const char *msg)
+{
+ if (gdb_stderr == NULL)
+ fputs (msg, stderr);
+ else
+ fputs_unfiltered (msg, gdb_stderr);
+
+ abort (); /* NOTE: GDB has only three calls to abort(). */
+}
+
/* Dump core trying to increase the core soft limit to hard limit first. */
void
break;
case 1:
dejavu = 2;
- fputs_unfiltered (msg, gdb_stderr);
- abort (); /* NOTE: GDB has only three calls to abort(). */
+ abort_with_message (msg);
default:
dejavu = 3;
/* Newer GLIBC versions put the warn_unused_result attribute
}
}
- /* Try to get the message out and at the start of a new line. */
- target_terminal_ours ();
- begin_line ();
-
/* Create a string containing the full error/warning message. Need
to call query with this full string, as otherwize the reason
(error/warning) and question become separated. Format using a
make_cleanup (xfree, reason);
}
+ /* Fall back to abort_with_message if gdb_stderr is not set up. */
+ if (gdb_stderr == NULL)
+ {
+ fputs (reason, stderr);
+ abort_with_message ("\n");
+ }
+
+ /* Try to get the message out and at the start of a new line. */
+ if (target_supports_terminal_ours ())
+ target_terminal_ours ();
+ if (filtered_printing_initialized ())
+ begin_line ();
+
+ /* Emit the message unless query will emit it below. */
+ if (problem->should_quit != internal_problem_ask
+ || !confirm
+ || !filtered_printing_initialized ())
+ fprintf_unfiltered (gdb_stderr, "%s\n", reason);
+
if (problem->should_quit == internal_problem_ask)
{
/* Default (yes/batch case) is to quit GDB. When in batch mode
this lessens the likelihood of GDB going into an infinite
loop. */
- if (!confirm)
- {
- /* Emit the message and quit. */
- fputs_unfiltered (reason, gdb_stderr);
- fputs_unfiltered ("\n", gdb_stderr);
- quit_p = 1;
- }
+ if (!confirm || !filtered_printing_initialized ())
+ quit_p = 1;
else
quit_p = query (_("%s\nQuit this debugging session? "), reason);
}
{
if (!can_dump_core_warn (LIMIT_MAX, reason))
dump_core_p = 0;
+ else if (!filtered_printing_initialized ())
+ dump_core_p = 1;
else
{
/* Default (yes/batch case) is to dump core. This leaves a GDB
throw_quit (_("Command aborted."));
}
-void
-internal_error (const char *file, int line, const char *string, ...)
-{
- va_list ap;
-
- va_start (ap, string);
- internal_verror (file, line, string, ap);
- va_end (ap);
-}
-
static struct internal_problem internal_warning_problem = {
"internal-warning", 1, internal_problem_ask, 1, internal_problem_ask
};
internal_vproblem (&internal_warning_problem, file, line, fmt, ap);
}
-void
-internal_warning (const char *file, int line, const char *string, ...)
-{
- va_list ap;
-
- va_start (ap, string);
- internal_vwarning (file, line, string, ap);
- va_end (ap);
-}
-
static struct internal_problem demangler_warning_problem = {
"demangler-warning", 1, internal_problem_ask, 0, internal_problem_no
};
set_width ();
}
+/* Return nonzero if filtered printing is initialized. */
+int
+filtered_printing_initialized (void)
+{
+ return wrap_buffer != NULL;
+}
+
/* Helper for make_cleanup_restore_page_info. */
static void