[qfcc] Add a function to print the source line

It's not used anywhere, but it saves me a lot of grief when debugging.
This commit is contained in:
Bill Currie 2023-02-05 20:19:52 +09:00
parent 35f4f2e692
commit 02432311c5
2 changed files with 17 additions and 0 deletions

View file

@ -71,6 +71,8 @@ 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)
void print_srcline (int rep, const struct expr_s *e);
///@}
#endif//__diagnostic_h

View file

@ -77,6 +77,21 @@ report_function (const expr_t *e)
last_func = current_func;
}
void
print_srcline (int rep, const expr_t *e)
{
pr_string_t file = pr.source_file;
int line = pr.source_line;
if (e) {
file = e->file;
line = e->line;
}
if (rep) {
report_function (e);
}
printf ("%s:%d\n", GETSTR (file), line);
}
static __attribute__((format(PRINTF, 4, 0))) void
format_message (dstring_t *message, const char *msg_type, const expr_t *e,
const char *fmt, va_list args)