]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
utils: Introduce expr_print_debug()
authorPhil Sutter <phil@nwl.cc>
Wed, 22 Oct 2025 13:26:36 +0000 (15:26 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 27 Jan 2026 22:01:54 +0000 (23:01 +0100)
A simple function to call in random places when debugging
expression-related code.

Signed-off-by: Phil Sutter <phil@nwl.cc>
include/utils.h

index 6a0e494607c93addcc3ead69430c0c8ab22ac220..1c227f6849a22697bc5518af7d848420b1508d28 100644 (file)
 #define pr_gmp_debug(fmt, arg...) ({ if (false) {}; 0; })
 #endif
 
+#define expr_print_debug(expr)                                 \
+{                                                              \
+       struct output_ctx octx = { .output_fp = stdout };       \
+       printf("%s:%d: ", __FILE__, __LINE__);                  \
+       printf("'" #expr "' type %s: ", expr_name(expr));       \
+       expr_print((expr), &octx);                              \
+       printf("\n");                                           \
+}
+
 #define __fmtstring(x, y)      __attribute__((format(printf, x, y)))
 
 #define __must_check           __attribute__((warn_unused_result))