From 52333d5b04a20c2ea7857413937d6e8e571311c7 Mon Sep 17 00:00:00 2001 From: matejcik Date: Sun, 30 Jun 2024 10:37:08 +0200 Subject: [PATCH] debug(core): make C impl of __fatal_error print to stderr Previously, any C assertion or other case of __fatal_error would only show the RSOD, but not print to emulator output. That is (a) mildly annoying, and (b) would not work in the weird case in Rust unit tests where graphics are not available. --- core/embed/lib/error_handling.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/embed/lib/error_handling.c b/core/embed/lib/error_handling.c index 6d9361e475..f93636c058 100644 --- a/core/embed/lib/error_handling.c +++ b/core/embed/lib/error_handling.c @@ -18,6 +18,9 @@ */ #include +#ifdef TREZOR_EMULATOR +#include +#endif #include "common.h" #include "display.h" @@ -65,6 +68,13 @@ void __attribute__((noreturn)) error_shutdown(const char *message) { void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line) { +#ifdef TREZOR_EMULATOR + fprintf(stderr, "FATAL ERROR: %s\n", msg); + if (file) { + fprintf(stderr, "file: %s:%d\n", file, line); + } + fflush(stderr); +#endif #ifdef FANCY_FATAL_ERROR if (msg == NULL) { char buf[128] = {0};