mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Promote bugs to internal errors
Mostly so I can catch them in test cases
This commit is contained in:
parent
39df9c0c87
commit
91f5023681
3 changed files with 65 additions and 12 deletions
|
@ -70,6 +70,11 @@ typedef struct {
|
|||
qboolean silent; // don't even bother (overrides promote)
|
||||
} notice_options_t;
|
||||
|
||||
typedef struct {
|
||||
qboolean promote; // Promote bugs to internal errors
|
||||
qboolean silent; // don't even bother (overrides promote)
|
||||
} bug_options_t;
|
||||
|
||||
typedef struct {
|
||||
qboolean initial;
|
||||
qboolean thread;
|
||||
|
@ -88,6 +93,7 @@ typedef struct {
|
|||
code_options_t code; // Code generation options
|
||||
warn_options_t warnings; // Warning options
|
||||
notice_options_t notices; // Notice options
|
||||
bug_options_t bug; // Bug options
|
||||
blockdot_options_t block_dot; // Statement block flow diagrams
|
||||
|
||||
int verbosity; // 0=silent, goes up to 2 currently
|
||||
|
|
|
@ -141,17 +141,39 @@ _debug (expr_t *e, const char *file, int line, const char *fmt, ...)
|
|||
va_end (args);
|
||||
}
|
||||
|
||||
static __attribute__((noreturn, format(printf, 4, 0))) void
|
||||
__internal_error (expr_t *e, const char *file, int line,
|
||||
const char *fmt, va_list args)
|
||||
{
|
||||
dstring_t *message = dstring_new ();
|
||||
|
||||
report_function (e);
|
||||
|
||||
format_message (message, "internal error", e, fmt, args);
|
||||
dasprintf (message, " (%s:%d)", file, line);
|
||||
fprintf (stderr, "%s\n", message->str);
|
||||
dstring_delete (message);
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
_bug (expr_t *e, const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
report_function (e);
|
||||
if (options.bug.silent)
|
||||
return;
|
||||
|
||||
va_start (args, fmt);
|
||||
if (options.bug.promote) {
|
||||
__internal_error (e, file, line, fmt, args);
|
||||
}
|
||||
|
||||
{
|
||||
dstring_t *message = dstring_new ();
|
||||
|
||||
report_function (e);
|
||||
|
||||
format_message (message, "BUG", e, fmt, args);
|
||||
dasprintf (message, " (%s:%d)", file, line);
|
||||
if (bug_hook) {
|
||||
|
@ -211,19 +233,9 @@ _internal_error (expr_t *e, const char *file, int line, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
report_function (e);
|
||||
|
||||
va_start (args, fmt);
|
||||
{
|
||||
dstring_t *message = dstring_new ();
|
||||
|
||||
format_message (message, "internal error", e, fmt, args);
|
||||
dasprintf (message, " (%s:%d)", file, line);
|
||||
fprintf (stderr, "%s\n", message->str);
|
||||
dstring_delete (message);
|
||||
}
|
||||
__internal_error (e, file, line, fmt, args);
|
||||
va_end (args);
|
||||
abort ();
|
||||
}
|
||||
|
||||
expr_t *
|
||||
|
|
|
@ -69,11 +69,13 @@ enum {
|
|||
OPT_PROGDEFS,
|
||||
OPT_QCCX_ESCAPES,
|
||||
OPT_TRADITIONAL,
|
||||
OPT_BUG,
|
||||
};
|
||||
|
||||
static struct option const long_options[] = {
|
||||
{"advanced", no_argument, 0, OPT_ADVANCED},
|
||||
{"block-dot", optional_argument, 0, OPT_BLOCK_DOT},
|
||||
{"bug", required_argument, 0, OPT_BUG},
|
||||
{"code", required_argument, 0, 'C'},
|
||||
{"cpp", required_argument, 0, OPT_CPP},
|
||||
{"define", required_argument, 0, 'D'},
|
||||
|
@ -139,6 +141,7 @@ usage (int status)
|
|||
"Options:\n"
|
||||
" --advanced Advanced Ruamoko mode\n"
|
||||
" default for separate compilation mode\n"
|
||||
" --bug OPTION,... Set bug options\n"
|
||||
" -C, --code OPTION,... Set code generation options\n"
|
||||
" -c Only compile, don't link\n"
|
||||
" --cpp CPPSPEC cpp execution command line\n"
|
||||
|
@ -264,6 +267,21 @@ notice_usage (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
static void
|
||||
bug_usage (void)
|
||||
{
|
||||
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
||||
printf ("Bug options\n");
|
||||
printf (
|
||||
" help Display his text.\n"
|
||||
" none Turn off all bugs (don't we wish: messages).\n"
|
||||
" die Change bugs to internal errors.\n"
|
||||
"\n"
|
||||
"This is a developer feature and thus not in the manual page\n"
|
||||
);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static void
|
||||
add_file (const char *file)
|
||||
{
|
||||
|
@ -590,6 +608,23 @@ DecodeArgs (int argc, char **argv)
|
|||
free (opts);
|
||||
}
|
||||
break;
|
||||
case OPT_BUG:{
|
||||
char *opts = strdup (optarg);
|
||||
char *temp = strtok (opts, ",");
|
||||
|
||||
while (temp) {
|
||||
if (!strcasecmp (temp, "help")) {
|
||||
bug_usage ();
|
||||
} else if (!(strcasecmp (temp, "none"))) {
|
||||
options.bug.silent = true;
|
||||
} else if (!(strcasecmp (temp, "die"))) {
|
||||
options.bug.promote = true;
|
||||
}
|
||||
temp = strtok (NULL, ",");
|
||||
}
|
||||
free (opts);
|
||||
}
|
||||
break;
|
||||
case OPT_CPP: // --cpp=
|
||||
cpp_name = save_string (optarg);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue