mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-11 05:36:09 +00:00
fix(core): emulator: coverage data atexit handler
Partially reverts 5fc3c6e617
.
[no changelog]
This commit is contained in:
parent
ca1c5c4e33
commit
a05ed10f1a
@ -22,6 +22,9 @@ uint8_t *FIRMWARE_START = 0;
|
||||
|
||||
void set_core_clock(int) {}
|
||||
|
||||
// used in fw emulator to raise python exception on exit
|
||||
void __attribute__((noreturn)) main_clean_exit() { exit(3); }
|
||||
|
||||
int bootloader_main(void);
|
||||
|
||||
// assuming storage is single subarea
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "display.h"
|
||||
#include "memzero.h"
|
||||
|
||||
void __attribute__((noreturn)) main_clean_exit();
|
||||
|
||||
void __attribute__((noreturn)) trezor_shutdown(void) {
|
||||
printf("SHUTDOWN\n");
|
||||
|
||||
@ -49,7 +51,7 @@ uint32_t hal_ticks_ms() {
|
||||
static int SDLCALL emulator_event_filter(void *userdata, SDL_Event *event) {
|
||||
switch (event->type) {
|
||||
case SDL_QUIT:
|
||||
exit(3);
|
||||
main_clean_exit();
|
||||
return 0;
|
||||
case SDL_KEYUP:
|
||||
if (event->key.repeat) {
|
||||
@ -57,7 +59,7 @@ static int SDLCALL emulator_event_filter(void *userdata, SDL_Event *event) {
|
||||
}
|
||||
switch (event->key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
exit(3);
|
||||
main_clean_exit();
|
||||
return 0;
|
||||
case SDLK_p:
|
||||
display_save("emu");
|
||||
|
@ -408,6 +408,19 @@ STATIC void set_sys_argv(char *argv[], int argc, int start_arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// Inject SystemExit exception. This is primarily needed by prof.py to run the
|
||||
// atexit() handler.
|
||||
void __attribute__((noreturn)) main_clean_exit() {
|
||||
const int status = 3;
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
// sys.exit is disabled, so raise a SystemExit exception directly
|
||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_SystemExit,
|
||||
MP_OBJ_NEW_SMALL_INT(status)));
|
||||
// the above shouldn't return, but make sure we exit just in case
|
||||
exit(status);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PATHLIST_SEP_CHAR ';'
|
||||
#else
|
||||
@ -682,7 +695,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
#if !MICROPY_VFS
|
||||
|
||||
#ifdef TREZOR_EMULATOR_FROZEN
|
||||
mp_import_stat_t mp_import_stat(const char *path) { return MP_IMPORT_STAT_NO_EXIST; }
|
||||
mp_import_stat_t mp_import_stat(const char *path) {
|
||||
return MP_IMPORT_STAT_NO_EXIST;
|
||||
}
|
||||
#else
|
||||
mp_import_stat_t mp_import_stat(const char *path) {
|
||||
struct stat st;
|
||||
|
Loading…
Reference in New Issue
Block a user