diff --git a/tools/qfcc/include/diagnostic.h b/tools/qfcc/include/diagnostic.h index 1c0ee51bc..99a542762 100644 --- a/tools/qfcc/include/diagnostic.h +++ b/tools/qfcc/include/diagnostic.h @@ -55,10 +55,13 @@ struct expr_s *warning (struct expr_s *e, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); struct expr_s *notice (struct expr_s *e, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -void debug (struct expr_s *e, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -void bug (struct expr_s *e, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +void _debug (struct expr_s *e, const char *file, int line, + const char *fmt, ...) + __attribute__ ((format (printf, 4, 5))); +#define debug(e, fmt...) _debug(e, __FILE__, __LINE__, fmt) +void _bug (struct expr_s *e, const char *file, int line, const char *fmt, ...) + __attribute__ ((format (printf, 4, 5))); +#define bug(e, fmt...) _bug(e, __FILE__, __LINE__, fmt) //@} diff --git a/tools/qfcc/source/diagnostic.c b/tools/qfcc/source/diagnostic.c index dbf71142c..67a6644e0 100644 --- a/tools/qfcc/source/diagnostic.c +++ b/tools/qfcc/source/diagnostic.c @@ -118,7 +118,7 @@ _warning (expr_t *e, const char *fmt, va_list args) } void -debug (expr_t *e, const char *fmt, ...) +_debug (expr_t *e, const char *file, int line, const char *fmt, ...) { va_list args; @@ -131,6 +131,7 @@ debug (expr_t *e, const char *fmt, ...) dstring_t *message = dstring_new (); format_message (message, "debug", e, fmt, args); + dasprintf (message, " (%s:%d)", file, line); fprintf (stderr, "%s\n", message->str); dstring_delete (message); } @@ -138,7 +139,7 @@ debug (expr_t *e, const char *fmt, ...) } void -bug (expr_t *e, const char *fmt, ...) +_bug (expr_t *e, const char *file, int line, const char *fmt, ...) { va_list args; @@ -149,6 +150,7 @@ bug (expr_t *e, const char *fmt, ...) dstring_t *message = dstring_new (); format_message (message, "BUG", e, fmt, args); + dasprintf (message, " (%s:%d)", file, line); if (bug_hook) { bug_hook (message->str); } else {