More diagnostic improvements.

This commit is contained in:
Bill Currie 2018-10-12 16:01:11 +09:00
parent 71b3d30aa1
commit 668896aa82
2 changed files with 11 additions and 6 deletions

View file

@ -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)
//@}

View file

@ -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 {