diff options
author | Eugene Syromiatnikov <esyr@redhat.com> | 2017-08-04 08:03:03 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-12-13 00:35:31 +0000 |
commit | 859bc3444ca932c04c2715194beda6b0b6af55dc (patch) | |
tree | 799f8ffeb6d42793e4cfbd3fa72ee89c71a519fd | |
parent | 4f47c43ce73abf0398eb7f080a35fd3c5c1ff401 (diff) | |
download | strace-859bc3444ca932c04c2715194beda6b0b6af55dc.tar.gz |
error_prints.h: add debug print macros
* defs.h (debug_flag): Move the declaration...
* error_prints.h (debug_flag): ... here.
(debug_msg, debug_perror_msg): New macro definitions.
Include <stdbool.h> for the debug_flag declaration.
-rw-r--r-- | defs.h | 1 | ||||
-rw-r--r-- | error_prints.h | 16 |
2 files changed, 16 insertions, 1 deletions
@@ -355,7 +355,6 @@ typedef enum { CFLAG_BOTH } cflag_t; extern cflag_t cflag; -extern bool debug_flag; extern bool Tflag; extern bool iflag; extern bool count_wallclock; diff --git a/error_prints.h b/error_prints.h index 7ddcb50be..19ecb8f78 100644 --- a/error_prints.h +++ b/error_prints.h @@ -33,8 +33,12 @@ #ifndef STRACE_ERROR_PRINTS_H #define STRACE_ERROR_PRINTS_H +#include <stdbool.h> + #include "gcc_compat.h" +extern bool debug_flag; + void die(void) ATTRIBUTE_NORETURN; void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2)); @@ -46,4 +50,16 @@ void error_msg_and_help(const char *fmt, ...) void error_msg_and_die(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN; +/* Wrappers for if (debug_flag) error_msg(...) */ +#define debug_msg(...) \ + do { \ + if (debug_flag) \ + error_msg(__VA_ARGS__); \ + } while (0) +#define debug_perror_msg(...) \ + do { \ + if (debug_flag) \ + perror_msg(__VA_ARGS__); \ + } while (0) + #endif /* !STRACE_ERROR_PRINTS_H */ |