2 * This file contains error printing functions.
3 * These functions can be used by various binaries included in the strace
4 * package. Variable 'program_invocation_name' and function 'die()'
5 * have to be defined globally.
7 * Copyright (c) 2001-2018 The strace developers.
10 * SPDX-License-Identifier: LGPL-2.1-or-later
13 #ifndef STRACE_ERROR_PRINTS_H
14 # define STRACE_ERROR_PRINTS_H
18 # include "gcc_compat.h"
20 extern bool debug_flag;
22 void die(void) ATTRIBUTE_NORETURN;
24 void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
25 void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
26 void perror_msg_and_die(const char *fmt, ...)
27 ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
28 void error_msg_and_help(const char *fmt, ...)
29 ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
30 void error_msg_and_die(const char *fmt, ...)
31 ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
33 /* Wrappers for if (debug_flag) error_msg(...) */
34 # define debug_msg(...) \
37 error_msg(__VA_ARGS__); \
39 # define debug_perror_msg(...) \
42 perror_msg(__VA_ARGS__); \
45 /* Simple wrappers for providing function name in error messages */
46 # define error_func_msg(fmt_, ...) \
47 error_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
48 # define perror_func_msg(fmt_, ...) \
49 perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
50 # define debug_func_msg(fmt_, ...) \
51 debug_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
52 # define debug_func_perror_msg(fmt_, ...) \
53 debug_perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
54 # define error_func_msg_and_die(fmt_, ...) \
55 error_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
56 # define perror_func_msg_and_die(fmt_, ...) \
57 perror_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
59 #endif /* !STRACE_ERROR_PRINTS_H */