From: Nick Gasson Date: Sat, 22 Feb 2025 10:27:42 +0000 (+0000) Subject: Also show bug report message from fatal_trace X-Git-Url: https://git.nickg.me.uk/nvc.git/commitdiff_plain Also show bug report message from fatal_trace --- diff --git a/src/diag.c b/src/diag.c index 644927553..d39aafaa6 100644 --- a/src/diag.c +++ b/src/diag.c @@ -90,7 +90,6 @@ struct _diag { bool color; bool source; bool suppress; - bool stacktrace; bool prefix; }; @@ -1049,9 +1048,6 @@ void diag_femit(diag_t *d, FILE *f) diag_format_compact(d, f); else diag_format_full(d, f); - - if (d->stacktrace) - show_stacktrace(); } const unsigned count = relaxed_add(&n_diags[d->level], 1); @@ -1088,11 +1084,6 @@ void diag_suppress(diag_t *d, bool suppress) d->suppress = suppress; } -void diag_stacktrace(diag_t *d, bool stacktrace) -{ - d->stacktrace = stacktrace; -} - void diag_set_consumer(diag_consumer_t fn, void *context) { consumer_fn = fn; diff --git a/src/diag.h b/src/diag.h index 1b97c8d31..4b5aa5bdd 100644 --- a/src/diag.h +++ b/src/diag.h @@ -104,7 +104,6 @@ void diag_show_source(diag_t *d, bool show); void diag_emit(diag_t *d); void diag_femit(diag_t *d, FILE *f); void diag_suppress(diag_t *d, bool suppress); -void diag_stacktrace(diag_t *d, bool stacktrace); void diag_clear(diag_t *d); unsigned diag_count(diag_level_t level); diff --git a/src/util.c b/src/util.c index e0673698f..a6b8e25a5 100644 --- a/src/util.c +++ b/src/util.c @@ -126,6 +126,7 @@ typedef void (*print_fn_t)(const char *fmt, ...); static char *ansi_vasprintf(const char *fmt, va_list ap, bool force_plain); +static void show_bug_report(void); typedef struct _fault_handler fault_handler_t; typedef struct _pool_page pool_page_t; @@ -597,9 +598,11 @@ void fatal(const char *fmt, ...) void fatal_trace(const char *fmt, ...) { + struct cpu_state cpu; + capture_registers(&cpu); + diag_t *d = diag_new(DIAG_FATAL, NULL); diag_suppress(d, false); - diag_stacktrace(d, true); va_list ap; va_start(ap, fmt); @@ -608,6 +611,10 @@ void fatal_trace(const char *fmt, ...) diag_set_consumer(NULL, NULL); diag_emit(d); + + show_stacktrace(); + show_bug_report(); + fatal_exit(EXIT_FAILURE); } @@ -720,14 +727,18 @@ void show_stacktrace(void) "installing the libdw-dev package and reconfiguring$$\n"); #endif + fflush(stderr); +} + +static void show_bug_report(void) +{ #ifndef DEBUG extern const char version_string[]; color_fprintf(stderr, "\n$!red$%s ["TARGET_SYSTEM"]\n\n" "Please report this bug at "PACKAGE_BUGREPORT"$$\n\n", version_string); -#endif - fflush(stderr); +#endif } #ifdef __MINGW32__ @@ -895,6 +906,7 @@ static void signal_handler(int sig, siginfo_t *info, void *context) print_fatal_signal(sig, info, &cpu); show_stacktrace(); + show_bug_report(); if (sig != SIGUSR1) _exit(2); diff --git a/src/vcode.c b/src/vcode.c index 0a060060a..e0da6b39f 100644 --- a/src/vcode.c +++ b/src/vcode.c @@ -6216,7 +6216,6 @@ static void shape_mismatch(vcode_unit_t vu, vcode_unit_t shape, diag_t *d = diag_new(DIAG_FATAL, NULL); diag_printf(d, "instance %s does not match shape %s", istr(vu->name), istr(shape->name)); - diag_stacktrace(d, true); diag_vhint(d, NULL, fmt, ap); diag_emit(d);