+2014-08-19 Tom Tromey <tromey@redhat.com>
+ Gary Benson <gbenson@redhat.com>
+
+ * common/errors.h: New file.
+ * common/errors.c: Likewise.
+ * Makefile.in (SFILES): Add common/errors.c.
+ (HFILES_NO_SRCDIR): Add common/errors.h.
+ (COMMON_OBS): Add errors.o.
+ (errors.o): New rule.
+ * common/common-defs.h: Include errors.h.
+ * utils.h (perror_with_name, error, verror, warning, vwarning):
+ Don't declare.
+ * common/common-utils.h: (malloc_failure, internal_error):
+ Likewise.
+
2014-08-19 Gary Benson <gbenson@redhat.com>
* utils.c (internal_vproblem): Always print the message.
common/gdb_vecs.c common/common-utils.c common/xml-utils.c \
common/ptid.c common/buffer.c gdb-dlfcn.c common/agent.c \
common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
- target/waitstatus.c common/print-utils.c common/rsp-low.c
+ target/waitstatus.c common/print-utils.c common/rsp-low.c \
+ common/errors.c
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
ctf.h nat/i386-cpuid.h nat/i386-gcc-cpuid.h target/resume.h \
target/wait.h target/waitstatus.h nat/linux-nat.h nat/linux-waitpid.h \
common/print-utils.h common/rsp-low.h nat/i386-dregs.h x86-linux-nat.h \
-i386-linux-nat.h common/common-defs.h
+i386-linux-nat.h common/common-defs.h common/errors.h
# Header files that already have srcdir in them, or which are in objdir.
gdb_vecs.o jit.o progspace.o skip.o probe.o \
common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \
format.o registry.o btrace.o record-btrace.o waitstatus.o \
- print-utils.o rsp-low.o
+ print-utils.o rsp-low.o errors.o
TSOBS = inflow.o
$(COMPILE) $(srcdir)/common/rsp-low.c
$(POSTCOMPILE)
+errors.o: ${srcdir}/common/errors.c
+ $(COMPILE) $(srcdir)/common/errors.c
+ $(POSTCOMPILE)
+
#
# gdb/target/ dependencies
#
#include "ptid.h"
#include "common-utils.h"
#include "gdb_assert.h"
+#include "errors.h"
#endif /* COMMON_DEFS_H */
#endif
#endif
-extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
-extern void internal_error (const char *file, int line, const char *, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
-
/* xmalloc(), xrealloc() and xcalloc() have already been declared in
"libiberty.h". */
--- /dev/null
+/* Error reporting facilities.
+
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef GDBSERVER
+#include "server.h"
+#else
+#include "defs.h"
+#endif
+#include "errors.h"
+
+/* See common/errors.h. */
+
+void
+warning (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ vwarning (fmt, ap);
+ va_end (ap);
+}
+
+/* See common/errors.h. */
+
+void
+error (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ verror (fmt, ap);
+ va_end (ap);
+}
+
+/* See common/errors.h. */
+
+void
+internal_error (const char *file, int line, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ internal_verror (file, line, fmt, ap);
+ va_end (ap);
+}
--- /dev/null
+/* Declarations for error-reporting facilities.
+
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef COMMON_ERRORS_H
+#define COMMON_ERRORS_H
+
+/* A problem was detected, but the requested operation can still
+ proceed. A warning message is constructed using a printf- or
+ vprintf-style argument list. The function "vwarning" must be
+ provided by the client. */
+
+extern void warning (const char *fmt, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
+extern void vwarning (const char *fmt, va_list args)
+ ATTRIBUTE_PRINTF (1, 0);
+
+/* A non-predictable, non-fatal error was detected. The requested
+ operation cannot proceed. An error message is constructed using
+ a printf- or vprintf-style argument list. These functions do not
+ return. The function "verror" must be provided by the client. */
+
+extern void error (const char *fmt, ...)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+
+extern void verror (const char *fmt, va_list args)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
+
+/* An internal error was detected. Internal errors indicate
+ programming errors such as assertion failures, as opposed to
+ more general errors beyond the application's control. These
+ functions do not return. An error message is constructed using
+ a printf- or vprintf-style argument list. FILE and LINE
+ indicate the file and line number where the programming error
+ was detected. The function "internal_verror" must be provided
+ by the client. */
+
+extern void internal_error (const char *file, int line,
+ const char *fmt, ...)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
+
+extern void internal_verror (const char *file, int line,
+ const char *fmt, va_list args)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
+\f
+
+/* Like "error", but the error message is constructed by combining
+ STRING with the system error message for errno. This function does
+ not return. This function must be provided by the client. */
+
+extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
+
+/* Call this function to handle memory allocation failures. This
+ function does not return. This function must be provided by the
+ client. */
+
+extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
+
+#endif /* COMMON_ERRORS_H */
+2014-08-19 Tom Tromey <tromey@redhat.com>
+ Gary Benson <gbenson@redhat.com>
+
+ * Makefile.in (SFILES): Add common/errors.c.
+ (OBS): Add errors.o.
+ (IPA_OBS): Add errors-ipa.o.
+ (errors.o): New rule.
+ (errors-ipa.o): Likewise.
+ * utils.h (perror_with_name, error, warning): Don't declare.
+ * utils.c (warning): Renamed and rewritten as...
+ (vwarning): New function.
+ (error): Renamed and rewritten as...
+ (verror): New function.
+ (internal_error): Renamed and rewritten as...
+ (internal_verror): New function.
+
2014-08-07 Gary Benson <gbenson@redhat.com>
* configure.ac (AC_CHECK_HEADERS): Remove errno.h.
$(srcdir)/common/buffer.c $(srcdir)/nat/linux-btrace.c \
$(srcdir)/common/filestuff.c $(srcdir)/target/waitstatus.c \
$(srcdir)/nat/mips-linux-watch.c $(srcdir)/common/print-utils.c \
- $(srcdir)/common/rsp-low.c
+ $(srcdir)/common/rsp-low.c $(srcdir)/common/errors.c
DEPFILES = @GDBSERVER_DEPFILES@
target.o waitstatus.o utils.o debug.o version.o vec.o gdb_vecs.o \
mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
- tdesc.o print-utils.o rsp-low.o $(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
+ tdesc.o print-utils.o rsp-low.o errors.o $(XML_BUILTIN) $(DEPFILES) \
+ $(LIBOBJS)
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
XM_CLIBS = @LIBS@
${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
$(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
-IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o print-utils-ipa.o rsp-low-ipa.o ${IPA_DEPFILES}
+IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o \
+ regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o \
+ tdesc-ipa.o print-utils-ipa.o rsp-low-ipa.o errors-ipa.o \
+ ${IPA_DEPFILES}
IPA_LIB=libinproctrace.so
rsp-low-ipa.o: ../common/rsp-low.c
$(IPAGENT_COMPILE) $<
$(POSTCOMPILE)
+errors-ipa.o: ../common/errors.c
+ $(IPAGENT_COMPILE) $<
+ $(POSTCOMPILE)
ax.o: ax.c
$(COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
agent.o: ../common/agent.c
$(COMPILE) $<
$(POSTCOMPILE)
+errors.o: ../common/errors.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
waitstatus.o: ../target/waitstatus.c
$(COMPILE) $<
$(POSTCOMPILE)
error ("%s.", combined);
}
-/* Print an error message and return to command level.
- STRING is the error message, used as a fprintf string,
- and ARG is passed as an argument to it. */
+/* Print an error message and return to top level. */
void
-error (const char *string,...)
+verror (const char *string, va_list args)
{
#ifndef IN_PROCESS_AGENT
extern jmp_buf toplevel;
#endif
- va_list args;
- va_start (args, string);
+
fflush (stdout);
vfprintf (stderr, string, args);
fprintf (stderr, "\n");
exit (1);
}
-/* VARARGS */
+/* Print a warning message. */
+
void
-warning (const char *string,...)
+vwarning (const char *string, va_list args)
{
- va_list args;
- va_start (args, string);
fprintf (stderr, PREFIX);
vfprintf (stderr, string, args);
fprintf (stderr, "\n");
- va_end (args);
}
/* Report a problem internal to GDBserver, and exit. */
void
-internal_error (const char *file, int line, const char *fmt, ...)
+internal_verror (const char *file, int line, const char *fmt, va_list args)
{
- va_list args;
- va_start (args, fmt);
-
fprintf (stderr, "\
%s:%d: A problem internal to " TOOLNAME " has been detected.\n", file, line);
vfprintf (stderr, fmt, args);
fprintf (stderr, "\n");
- va_end (args);
exit (1);
}
#include "print-utils.h"
-void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
-void error (const char *string,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
void fatal (const char *string,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
-void warning (const char *string,...) ATTRIBUTE_PRINTF (1, 2);
char *paddress (CORE_ADDR addr);
char *pfildes (gdb_fildes_t fd);
}
}
-/* 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)
{
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
};
extern void throw_perror_with_name (enum errors errcode, const char *string)
ATTRIBUTE_NORETURN;
-extern void perror_with_name (const char *) ATTRIBUTE_NORETURN;
extern void perror_warning_with_name (const char *string);
extern char *warning_pre_print;
-extern void verror (const char *fmt, va_list ap)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
-
-extern void error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
-
extern void error_stream (struct ui_file *) ATTRIBUTE_NORETURN;
-extern void internal_verror (const char *file, int line, const char *,
- va_list ap)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
-
extern void internal_vwarning (const char *file, int line,
const char *, va_list ap)
ATTRIBUTE_PRINTF (3, 0);
extern void internal_warning (const char *file, int line,
const char *, ...) ATTRIBUTE_PRINTF (3, 4);
-extern void warning (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-
-extern void vwarning (const char *, va_list args) ATTRIBUTE_PRINTF (1, 0);
-
extern void demangler_vwarning (const char *file, int line,
const char *, va_list ap)
ATTRIBUTE_PRINTF (3, 0);