crash vm trace

This commit is contained in:
2026-02-20 23:14:43 -06:00
parent 34cb19c357
commit 5ea0de9fbb
5 changed files with 91 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ static int run_test_suite(size_t heap_size);
cell_rt *root_cell = NULL;
static char *shop_path = NULL;
volatile JSContext *g_crash_ctx = NULL;
static char *core_path = NULL;
static int native_mode = 0;
static int warn_mode = 1;
@@ -408,6 +409,13 @@ static void signal_handler(int sig)
#endif
if (!str) return;
/* Reset handler to default so a double-fault terminates immediately */
signal(sig, SIG_DFL);
/* Try to print the JS stack (best-effort, signal-safe) */
if (g_crash_ctx)
JS_CrashPrintStack((JSContext *)g_crash_ctx);
exit_handler();
}
@@ -689,7 +697,9 @@ int cell_init(int argc, char **argv)
JS_DeleteGCRef(ctx, &args_ref);
JSValue hidden_env = JS_Stone(ctx, env_ref.val);
g_crash_ctx = ctx;
JSValue result = JS_RunMachBin(ctx, (const uint8_t *)bin_data, bin_size, hidden_env);
g_crash_ctx = NULL;
JS_DeleteGCRef(ctx, &env_ref);
free(bin_data);