mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 17:12:15 +00:00
Add "debug" diagnotic printing, and use it.
Debug diagnostics are silent for verbosity levels less than 1.
This commit is contained in:
parent
a37bdd9fb5
commit
834417b8c8
3 changed files with 34 additions and 5 deletions
|
@ -48,6 +48,8 @@ struct expr_s *warning (struct expr_s *e, const char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 2, 3)));
|
__attribute__ ((format (printf, 2, 3)));
|
||||||
struct expr_s *notice (struct expr_s *e, const char *fmt, ...)
|
struct expr_s *notice (struct expr_s *e, const char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 2, 3)));
|
__attribute__ ((format (printf, 2, 3)));
|
||||||
|
void debug (struct expr_s *e, const char *mft, ...)
|
||||||
|
__attribute__ ((format (printf, 2, 3)));
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,33 @@ _warning (expr_t *e, const char *fmt, va_list args)
|
||||||
fputs ("\n", stderr);
|
fputs ("\n", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
debug (expr_t *e, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (options.verbosity < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
if (options.notices.promote) {
|
||||||
|
_warning (e, fmt, args);
|
||||||
|
} else {
|
||||||
|
string_t file = pr.source_file;
|
||||||
|
int line = pr.source_line;
|
||||||
|
|
||||||
|
report_function (e);
|
||||||
|
if (e) {
|
||||||
|
file = e->file;
|
||||||
|
line = e->line;
|
||||||
|
}
|
||||||
|
fprintf (stderr, "%s:%d: debug: ", GETSTR (file), line);
|
||||||
|
vfprintf (stderr, fmt, args);
|
||||||
|
fputs ("\n", stderr);
|
||||||
|
}
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
expr_t *
|
expr_t *
|
||||||
notice (expr_t *e, const char *fmt, ...)
|
notice (expr_t *e, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -735,9 +735,9 @@ statement_expr (sblock_t *sblock, expr_t *e)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (e->e.expr.op < 256)
|
if (e->e.expr.op < 256)
|
||||||
notice (e, "e %c", e->e.expr.op);
|
debug (e, "e %c", e->e.expr.op);
|
||||||
else
|
else
|
||||||
notice (e, "e %d", e->e.expr.op);
|
debug (e, "e %d", e->e.expr.op);
|
||||||
if (options.warnings.executable)
|
if (options.warnings.executable)
|
||||||
warning (e, "Non-executable statement;"
|
warning (e, "Non-executable statement;"
|
||||||
" executing programmer instead.");
|
" executing programmer instead.");
|
||||||
|
@ -753,7 +753,7 @@ statement_uexpr (sblock_t *sblock, expr_t *e)
|
||||||
|
|
||||||
switch (e->e.expr.op) {
|
switch (e->e.expr.op) {
|
||||||
case 'r':
|
case 'r':
|
||||||
notice (e, "RETURN");
|
debug (e, "RETURN");
|
||||||
opcode = "<RETURN>";
|
opcode = "<RETURN>";
|
||||||
if (!e->e.expr.e1 && !options.traditional)
|
if (!e->e.expr.e1 && !options.traditional)
|
||||||
opcode = "<RETURN_V>";
|
opcode = "<RETURN_V>";
|
||||||
|
@ -768,7 +768,7 @@ statement_uexpr (sblock_t *sblock, expr_t *e)
|
||||||
sblock = statement_branch (sblock, e);
|
sblock = statement_branch (sblock, e);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
notice (e, "e ue %d", e->e.expr.op);
|
debug (e, "e ue %d", e->e.expr.op);
|
||||||
if (options.warnings.executable)
|
if (options.warnings.executable)
|
||||||
warning (e, "Non-executable statement;"
|
warning (e, "Non-executable statement;"
|
||||||
" executing programmer instead.");
|
" executing programmer instead.");
|
||||||
|
@ -862,7 +862,7 @@ remove_dead_blocks (sblock_t *blocks)
|
||||||
statement_t *s;
|
statement_t *s;
|
||||||
ex_label_t *label = 0;
|
ex_label_t *label = 0;
|
||||||
|
|
||||||
notice (0, "removing dead block %p", sb);
|
debug (0, "removing dead block %p", sb);
|
||||||
|
|
||||||
sblock->next = sb->next;
|
sblock->next = sb->next;
|
||||||
free_sblock (sb);
|
free_sblock (sb);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue