diff options
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 */ |