From b95440f5d613e18920b93a99c9b604c05362555f Mon Sep 17 00:00:00 2001 From: Lazula <26179473+Lazula@users.noreply.github.com> Date: Tue, 21 Dec 2021 12:00:05 -0600 Subject: [PATCH] Add EPRINT macros for debug printing with variable name --- libr/include/r_types.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libr/include/r_types.h b/libr/include/r_types.h index 040eb25b79..a74a1374e4 100644 --- a/libr/include/r_types.h +++ b/libr/include/r_types.h @@ -401,8 +401,21 @@ static inline void *r_new_copy(int size, void *data) { #endif #ifndef HAVE_EPRINTF -#define eprintf(...) fprintf(stderr,__VA_ARGS__) +#define eprintf(...) fprintf (stderr, __VA_ARGS__) #define HAVE_EPRINTF 1 + +#define EPRINT_STR(x) eprintf (#x ": %s", x) +#define EPRINT_CHAR(x) eprintf (#x ": %c", x) +#define EPRINT_INT(x) eprintf (#x ": %d (%x)", x, x) +#define EPRINT_BOOL(x) eprintf (#x ": %s", x? "true": "false") +#define EPRINT_UT64(x) eprintf (#x ": %" PFMT64u " (%" PFMT64x ")", x, x) +#define EPRINT_ST64(x) eprintf (#x ": %" PFMT64d " (%" PFMT64x ")", x, x) +#define EPRINT_UT32(x) eprintf (#x ": %" PFMT32u " (%" PFMT32x ")", x, x) +#define EPRINT_ST32(x) eprintf (#x ": %" PFMT32d " (%" PFMT32x ")", x, x) +#define EPRINT_UT16(x) eprintf (#x ": %hu (%hx)", x, x) +#define EPRINT_ST16(x) eprintf (#x ": %hd (%hx)", x, x) +#define EPRINT_UT8(x) eprintf (#x ": %hhu (%hhx)", x, x) +#define EPRINT_ST8(x) eprintf (#x ": %hhd (%hhx)", x, x) #endif #ifndef typeof