diff --git a/src/makeint.h b/src/makeint.h index f9de63d0..e345011b 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -658,8 +658,12 @@ int unload_file (const char *name); #ifdef MAKE_MAINTAINER_MODE # define SPIN(_s) spin (_s) void spin (const char* suffix); +# define DBG(_f) dbg _f +void dbg (const char *fmt, ...); #else # define SPIN(_s) +/* Never put this code into Git or a release. */ +# define DBG(_f) compile-error #endif /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION, diff --git a/src/misc.c b/src/misc.c index 18728f35..4f52e78c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -530,6 +530,22 @@ spin (const char* type) } } +void +dbg (const char *fmt, ...) +{ + FILE *fp = fopen ("/tmp/gmkdebug.log", "a+"); + va_list args; + char buf[4096]; + + va_start (args, fmt); + vsprintf (buf, fmt, args); + va_end (args); + + fprintf(fp, "%u: %s\n", (unsigned) make_pid (), buf); + fflush (fp); + fclose (fp); +} + #endif