fix using old mach
This commit is contained in:
@@ -1804,7 +1804,7 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code,
|
||||
}
|
||||
|
||||
default:
|
||||
result = JS_ThrowInternalError(ctx, "unknown register VM opcode %d", op);
|
||||
result = JS_ThrowInternalError(ctx, "unknown register VM opcode %d: %s", op, mach_opcode_names[op]);
|
||||
goto done;
|
||||
}
|
||||
continue;
|
||||
@@ -1827,12 +1827,38 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code,
|
||||
break;
|
||||
}
|
||||
if (JS_IsNull(frame->caller)) {
|
||||
if (!JS_HasException(ctx)) {
|
||||
/* Bare disrupt with no error message — provide location */
|
||||
const char *fn_name = code->name_cstr ? code->name_cstr : "<anonymous>";
|
||||
fprintf(stderr, "unhandled disruption in %s\n", fn_name);
|
||||
} else {
|
||||
fprintf(stderr, "unhandled disruption\n");
|
||||
const char *fn_name = code->name_cstr ? code->name_cstr : "<anonymous>";
|
||||
const char *file = code->filename_cstr ? code->filename_cstr : "<unknown>";
|
||||
uint16_t line = 0, col = 0;
|
||||
if (code->line_table && frame_pc > 0 && frame_pc - 1 < code->instr_count) {
|
||||
line = code->line_table[frame_pc - 1].line;
|
||||
col = code->line_table[frame_pc - 1].col;
|
||||
}
|
||||
fprintf(stderr, "unhandled disruption in %s (%s:%u:%u)\n", fn_name, file, line, col);
|
||||
/* Walk and print the frame chain as a stack trace */
|
||||
{
|
||||
JSFrameRegister *trace_frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
|
||||
int first = 1;
|
||||
while (trace_frame) {
|
||||
if (!JS_IsFunction(trace_frame->function)) break;
|
||||
JSFunction *trace_fn = JS_VALUE_GET_FUNCTION(trace_frame->function);
|
||||
if (trace_fn->kind == JS_FUNC_KIND_REGISTER && trace_fn->u.reg.code) {
|
||||
JSCodeRegister *tc = trace_fn->u.reg.code;
|
||||
uint32_t tpc = first ? (frame_pc > 0 ? frame_pc - 1 : 0)
|
||||
: (uint32_t)(JS_VALUE_GET_INT(trace_frame->address) >> 16);
|
||||
uint16_t tl = 0, tcol = 0;
|
||||
if (tc->line_table && tpc < tc->instr_count) {
|
||||
tl = tc->line_table[tpc].line;
|
||||
tcol = tc->line_table[tpc].col;
|
||||
}
|
||||
fprintf(stderr, " at %s (%s:%u:%u)\n",
|
||||
tc->name_cstr ? tc->name_cstr : "<anonymous>",
|
||||
tc->filename_cstr ? tc->filename_cstr : "<unknown>", tl, tcol);
|
||||
}
|
||||
if (JS_IsNull(trace_frame->caller)) break;
|
||||
trace_frame = (JSFrameRegister *)JS_VALUE_GET_PTR(trace_frame->caller);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
result = JS_Throw(ctx, JS_NULL);
|
||||
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
|
||||
|
||||
Reference in New Issue
Block a user