#include <sys/param.h>
#include <pwd.h>
#endif
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
#include <varargs.h>
+#endif
#include <ctype.h>
#include <string.h>
#endif /* NO_MMALLOC, etc */
static void
-fatal_dump_core (); /* Can't prototype with <varargs.h> usage... */
+fatal_dump_core PARAMS((char *, ...));
static void
prompt_for_continue PARAMS ((void));
}
\f
-/* Provide a hook for modules wishing to print their own warning messages
- to set up the terminal state in a compatible way, without them having
- to import all the target_<...> macros. */
+/* Print a warning message. Way to use this is to call warning_begin,
+ output the warning message (use unfiltered output to gdb_stderr),
+ ending in a newline. There is not currently a warning_end that you
+ call afterwards, but such a thing might be added if it is useful
+ for a GUI to separate warning messages from other output.
+
+ FIXME: Why do warnings use unfiltered output and errors filtered?
+ Is this anything other than a historical accident? */
void
-warning_setup ()
+warning_begin ()
{
target_terminal_ours ();
wrap_here(""); /* Force out any buffered output */
gdb_flush (gdb_stdout);
+ if (warning_pre_print)
+ fprintf_unfiltered (gdb_stderr, warning_pre_print);
}
/* 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. */
+ does not force the return to command level. */
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+warning (char *string, ...)
+#else
warning (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, string);
+#else
char *string;
va_start (args);
- target_terminal_ours ();
- wrap_here(""); /* Force out any buffered output */
- gdb_flush (gdb_stdout);
- if (warning_pre_print)
- fprintf_unfiltered (gdb_stderr, warning_pre_print);
string = va_arg (args, char *);
+#endif
+ warning_begin ();
vfprintf_unfiltered (gdb_stderr, string, args);
fprintf_unfiltered (gdb_stderr, "\n");
va_end (args);
}
/* Start the printing of an error message. Way to use this is to call
- this, output the error message (use filtered output), and then call
- return_to_top_level (RETURN_ERROR). error() provides a convenient way to
- do this for the special case that the error message can be formatted with
- a single printf call, but this is more general. */
+ this, output the error message (use filtered output to gdb_stderr
+ (FIXME: Some callers, like memory_error, use gdb_stdout)), ending
+ in a newline, and then call return_to_top_level (RETURN_ERROR).
+ error() provides a convenient way to do this for the special case
+ that the error message can be formatted with a single printf call,
+ but this is more general. */
void
error_begin ()
{
The first argument STRING is the error message, used as a fprintf string,
and the remaining args are passed as arguments to it. */
-/* VARARGS */
+#ifdef ANSI_PROTOTYPES
NORETURN void
+error (char *string, ...)
+#else
error (va_alist)
va_dcl
+#endif
{
+#ifdef ANSI_PROTOTYPES
va_list args;
- char *string;
-
+ va_start (args, string);
+#else
va_start (args);
-
+#endif
if (error_hook)
- error_hook (args); /* Never returns */
-
- error_begin ();
- string = va_arg (args, char *);
- vfprintf_filtered (gdb_stderr, string, args);
- fprintf_filtered (gdb_stderr, "\n");
- va_end (args);
- return_to_top_level (RETURN_ERROR);
+ error_hook();
+ else
+ {
+ char *string1;
+ error_begin ();
+#ifdef ANSI_PROTOTYPES
+ vfprintf_filtered (gdb_stderr, string, args);
+#else
+ string1 = va_arg (args, char *);
+ vfprintf_filtered (gdb_stderr, string1, args);
+#endif
+ fprintf_filtered (gdb_stderr, "\n");
+ va_end (args);
+ return_to_top_level (RETURN_ERROR);
+ }
}
+
/* Print an error message and exit reporting failure.
This is for a error that we cannot continue from.
The arguments are printed a la printf.
/* VARARGS */
NORETURN void
+#ifdef ANSI_PROTOTYPES
+fatal (char *string, ...)
+#else
fatal (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, string);
+#else
char *string;
-
va_start (args);
string = va_arg (args, char *);
+#endif
fprintf_unfiltered (gdb_stderr, "\ngdb: ");
vfprintf_unfiltered (gdb_stderr, string, args);
fprintf_unfiltered (gdb_stderr, "\n");
/* VARARGS */
static void
+#ifdef ANSI_PROTOTYPES
+fatal_dump_core (char *string, ...)
+#else
fatal_dump_core (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, string);
+#else
char *string;
va_start (args);
string = va_arg (args, char *);
+#endif
/* "internal error" is always correct, since GDB should never dump
core, no matter what the input. */
fprintf_unfiltered (gdb_stderr, "\ngdb internal error: ");
/* VARARGS */
int
+#ifdef ANSI_PROTOTYPES
+query (char *ctlstr, ...)
+#else
query (va_alist)
va_dcl
+#endif
{
va_list args;
- char *ctlstr;
register int answer;
register int ans2;
int retval;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, ctlstr);
+#else
+ char *ctlstr;
+ va_start (args);
+ ctlstr = va_arg (args, char *);
+#endif
+
if (query_hook)
{
- va_start (args);
- return query_hook (args);
+ return query_hook (ctlstr, args);
}
/* Automatically answer "yes" if input is not from a terminal. */
if (annotation_level > 1)
printf_filtered ("\n\032\032pre-query\n");
- va_start (args);
- ctlstr = va_arg (args, char *);
vfprintf_filtered (gdb_stdout, ctlstr, args);
- va_end (args);
printf_filtered ("(y or n) ");
if (annotation_level > 1)
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+fprintf_filtered (FILE *stream, char *format, ...)
+#else
fprintf_filtered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
FILE *stream;
char *format;
va_start (args);
stream = va_arg (args, FILE *);
format = va_arg (args, char *);
-
+#endif
vfprintf_filtered (stream, format, args);
va_end (args);
}
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+fprintf_unfiltered (FILE *stream, char *format, ...)
+#else
fprintf_unfiltered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
FILE *stream;
char *format;
va_start (args);
stream = va_arg (args, FILE *);
format = va_arg (args, char *);
-
+#endif
vfprintf_unfiltered (stream, format, args);
va_end (args);
}
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+fprintfi_filtered (int spaces, FILE *stream, char *format, ...)
+#else
fprintfi_filtered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
int spaces;
FILE *stream;
char *format;
spaces = va_arg (args, int);
stream = va_arg (args, FILE *);
format = va_arg (args, char *);
+#endif
print_spaces_filtered (spaces, stream);
vfprintf_filtered (stream, format, args);
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+printf_filtered (char *format, ...)
+#else
printf_filtered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
char *format;
va_start (args);
format = va_arg (args, char *);
-
+#endif
vfprintf_filtered (gdb_stdout, format, args);
va_end (args);
}
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+printf_unfiltered (char *format, ...)
+#else
printf_unfiltered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
char *format;
va_start (args);
format = va_arg (args, char *);
-
+#endif
vfprintf_unfiltered (gdb_stdout, format, args);
va_end (args);
}
/* VARARGS */
void
+#ifdef ANSI_PROTOTYPES
+printfi_filtered (int spaces, char *format, ...)
+#else
printfi_filtered (va_alist)
va_dcl
+#endif
{
va_list args;
+#ifdef ANSI_PROTOTYPES
+ va_start (args, format);
+#else
int spaces;
char *format;
va_start (args);
spaces = va_arg (args, int);
format = va_arg (args, char *);
+#endif
print_spaces_filtered (spaces, gdb_stdout);
vfprintf_filtered (gdb_stdout, format, args);
va_end (args);