Skip to content

Commit

Permalink
debug(core): make C impl of __fatal_error print to stderr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matejcik committed Jul 4, 2024
1 parent 730b934 commit bb70ccc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/embed/lib/error_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/

#include <stddef.h>
#ifdef TREZOR_EMULATOR
#include <stdio.h>
#endif

#include "common.h"
#include "display.h"
Expand Down Expand Up @@ -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};
Expand Down

0 comments on commit bb70ccc

Please sign in to comment.