]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdbsupport/errors.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdbsupport / errors.h
CommitLineData
ef87c8bb
GB
1/* Declarations for error-reporting facilities.
2
213516ef 3 Copyright (C) 1986-2023 Free Software Foundation, Inc.
ef87c8bb
GB
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef COMMON_ERRORS_H
21#define COMMON_ERRORS_H
22
23/* A problem was detected, but the requested operation can still
24 proceed. A warning message is constructed using a printf- or
25 vprintf-style argument list. The function "vwarning" must be
26 provided by the client. */
27
28extern void warning (const char *fmt, ...)
29 ATTRIBUTE_PRINTF (1, 2);
30
31extern void vwarning (const char *fmt, va_list args)
32 ATTRIBUTE_PRINTF (1, 0);
33
34/* A non-predictable, non-fatal error was detected. The requested
35 operation cannot proceed. An error message is constructed using
36 a printf- or vprintf-style argument list. These functions do not
37 return. The function "verror" must be provided by the client. */
38
39extern void error (const char *fmt, ...)
40 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
41
42extern void verror (const char *fmt, va_list args)
43 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
44
45/* An internal error was detected. Internal errors indicate
46 programming errors such as assertion failures, as opposed to
47 more general errors beyond the application's control. These
48 functions do not return. An error message is constructed using
49 a printf- or vprintf-style argument list. FILE and LINE
50 indicate the file and line number where the programming error
f34652de
PA
51 was detected. Most client code should call the internal_error
52 wrapper macro instead, which expands the source location
53 automatically. The function "internal_verror" must be provided
ef87c8bb
GB
54 by the client. */
55
f34652de
PA
56extern void internal_error_loc (const char *file, int line,
57 const char *fmt, ...)
ef87c8bb
GB
58 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
59
f34652de
PA
60#define internal_error(fmt, ...) \
61 internal_error_loc (__FILE__, __LINE__, fmt, ##__VA_ARGS__)
62
ef87c8bb
GB
63extern void internal_verror (const char *file, int line,
64 const char *fmt, va_list args)
65 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
e3d6ba5d
GB
66
67/* An internal problem was detected, but the requested operation can
68 still proceed. Internal warnings indicate programming errors as
69 opposed to more general issues beyond the application's control.
70 A warning message is constructed using a printf- or vprintf-style
71 argument list. The function "internal_vwarning" must be provided
72 by the client. */
73
f34652de
PA
74extern void internal_warning_loc (const char *file, int line,
75 const char *fmt, ...)
e3d6ba5d
GB
76 ATTRIBUTE_PRINTF (3, 4);
77
f34652de
PA
78#define internal_warning(fmt, ...) \
79 internal_warning_loc (__FILE__, __LINE__, fmt, ##__VA_ARGS__)
80
e3d6ba5d
GB
81extern void internal_vwarning (const char *file, int line,
82 const char *fmt, va_list args)
83 ATTRIBUTE_PRINTF (3, 0);
ef87c8bb
GB
84\f
85
86/* Like "error", but the error message is constructed by combining
87 STRING with the system error message for errno. This function does
88 not return. This function must be provided by the client. */
89
90extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
91
92/* Call this function to handle memory allocation failures. This
93 function does not return. This function must be provided by the
94 client. */
95
96extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
97
c1cd3163
TT
98/* Flush stdout and stderr. Must be provided by the client. */
99
100extern void flush_streams ();
101
a83c64f5 102#if defined(USE_WIN32API) || defined(__CYGWIN__)
02d04eac
TT
103
104/* Map the Windows error number in ERROR to a locale-dependent error
105 message string and return a pointer to it. Typically, the values
106 for ERROR come from GetLastError.
107
108 The string pointed to shall not be modified by the application,
109 but may be overwritten by a subsequent call to strwinerror
110
111 The strwinerror function does not change the current setting
112 of GetLastError. */
113
114extern const char *strwinerror (ULONGEST error);
115
116#endif /* USE_WIN32API */
117
ef87c8bb 118#endif /* COMMON_ERRORS_H */