diff options
author | Gary Benson <gbenson@redhat.com> | 2014-07-30 14:09:07 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2014-08-19 10:07:18 +0100 |
commit | ef87c8bbe7d1c4a987578626655f4a15555c7f4a (patch) | |
tree | afeee8eea42eec0227665caf43eda9cdc495b00f /gdb/common | |
parent | 196a707b15ab32c29ba021b4f5b9ea202c109fe1 (diff) | |
download | fsf-binutils-gdb-ef87c8bbe7d1c4a987578626655f4a15555c7f4a.zip fsf-binutils-gdb-ef87c8bbe7d1c4a987578626655f4a15555c7f4a.tar.gz fsf-binutils-gdb-ef87c8bbe7d1c4a987578626655f4a15555c7f4a.tar.bz2 |
Introduce common/errors.h
This introduces common/errors.h. This holds some error- and warning-
related declarations that can be used by the code in common, nat and
target. Some of the declared functions must be provided by the client
as documented by the header file comments.
gdb/ChangeLog:
* 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.
gdb/gdbserver/ChangeLog:
* 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.
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/common-defs.h | 1 | ||||
-rw-r--r-- | gdb/common/common-utils.h | 4 | ||||
-rw-r--r-- | gdb/common/errors.c | 61 | ||||
-rw-r--r-- | gdb/common/errors.h | 75 |
4 files changed, 137 insertions, 4 deletions
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index 82290dc..a15423c 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -41,5 +41,6 @@ #include "ptid.h" #include "common-utils.h" #include "gdb_assert.h" +#include "errors.h" #endif /* COMMON_DEFS_H */ diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h index 9038bc2..67615ba 100644 --- a/gdb/common/common-utils.h +++ b/gdb/common/common-utils.h @@ -38,10 +38,6 @@ #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". */ diff --git a/gdb/common/errors.c b/gdb/common/errors.c new file mode 100644 index 0000000..7d0bb6e --- /dev/null +++ b/gdb/common/errors.c @@ -0,0 +1,61 @@ +/* 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); +} diff --git a/gdb/common/errors.h b/gdb/common/errors.h new file mode 100644 index 0000000..4e6c2b3 --- /dev/null +++ b/gdb/common/errors.h @@ -0,0 +1,75 @@ +/* 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); + + +/* 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 */ |