]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/common/gdb_assert.h
Remove unnecessary block from execute_fn_to_ui_file
[thirdparty/binutils-gdb.git] / gdb / common / gdb_assert.h
1 /* GDB-friendly replacement for <assert.h>.
2 Copyright (C) 2000-2019 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef COMMON_GDB_ASSERT_H
20 #define COMMON_GDB_ASSERT_H
21
22 /* A static assertion. This will cause a compile-time error if EXPR,
23 which must be a compile-time constant, is false. */
24
25 #define gdb_static_assert(expr) static_assert (expr, "")
26
27 /* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
28 than upper case) macro since that provides the closest fit to the
29 existing lower case macro <assert.h>:assert() that it is
30 replacing. */
31
32 #define gdb_assert(expr) \
33 ((void) ((expr) ? 0 : \
34 (gdb_assert_fail (#expr, __FILE__, __LINE__, FUNCTION_NAME), 0)))
35
36 /* This prints an "Assertion failed" message, asking the user if they
37 want to continue, dump core, or just exit. */
38 #if defined (FUNCTION_NAME)
39 #define gdb_assert_fail(assertion, file, line, function) \
40 internal_error (file, line, _("%s: Assertion `%s' failed."), \
41 function, assertion)
42 #else
43 #define gdb_assert_fail(assertion, file, line, function) \
44 internal_error (file, line, _("Assertion `%s' failed."), \
45 assertion)
46 #endif
47
48 /* The canonical form of gdb_assert (0).
49 MESSAGE is a string to include in the error message. */
50
51 #if defined (FUNCTION_NAME)
52 #define gdb_assert_not_reached(message) \
53 internal_error (__FILE__, __LINE__, "%s: %s", FUNCTION_NAME, _(message))
54 #else
55 #define gdb_assert_not_reached(message) \
56 internal_error (__FILE__, __LINE__, _(message))
57 #endif
58
59 #endif /* COMMON_GDB_ASSERT_H */