]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: standard: add a new debug macro : fddebug()
authorWilly Tarreau <w@1wt.eu>
Sat, 12 May 2012 22:21:17 +0000 (00:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 May 2012 22:21:17 +0000 (00:21 +0200)
This macro is usable like printf but sends messages to fd #-1, which has no
visible effect but is easy to spot in strace. This is very useful to put
tracers at many points during debugging sessions.

include/common/standard.h

index 83b1fc042a4a493399588829c10da90c17c7106f..e7c5ebd9a88978bbd1d750e7e2e68c12534a9169 100644 (file)
@@ -705,4 +705,10 @@ char *gmt2str_log(char *dst, struct tm *tm, size_t size);
 char *memprintf(char **out, const char *format, ...)
        __attribute__ ((format(printf, 2, 3)));
 
+
+/* debugging macro to emit messages using write() on fd #-1 so that strace sees
+ * them.
+ */
+#define fddebug(msg...) do { char *_m = NULL; memprintf(&_m, ##msg); if (_m) write(-1, _m, strlen(_m)); free(_m); } while (0)
+
 #endif /* _COMMON_STANDARD_H */