[gamecode] Add VM enter/exit events

And rename prd_exit to prd_terminate (the idea is the host will
terminate the VM). This makes it possible for the debugger to pause the
VM before any code, even a builtin function, is executed. Breaks the
debugger source window, but only because it's not updating on file
change (I think).
This commit is contained in:
Bill Currie 2020-03-26 12:30:32 +09:00
parent 1bd8e2ee85
commit 2d5df34234
3 changed files with 11 additions and 2 deletions

View file

@ -1710,7 +1710,9 @@ typedef enum {
prd_trace,
prd_breakpoint,
prd_watchpoint,
prd_exit, // not sent by VM
prd_subenter,
prd_subexit, // current invocation of PR_ExecuteProgram finished
prd_terminate, // not sent by VM
prd_runerror,
prd_error, // lower level error thann prd_runerror
} prdebug_t;

View file

@ -458,6 +458,10 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
Sys_PushSignalHook (signal_hook, pr);
Sys_PushErrorHandler (error_handler, pr);
if (pr->debug_handler) {
pr->debug_handler (prd_subenter, &fnum, pr->debug_data);
}
if (!PR_CallFunction (pr, fnum)) {
// called a builtin instead of progs code
goto exit_program;
@ -1723,6 +1727,9 @@ op_call:
}
}
exit_program:
if (pr->debug_handler) {
pr->debug_handler (prd_subexit, 0, pr->debug_data);
}
pr->pr_argc = 0;
Sys_PopErrorHandler ();
Sys_PopSignalHook ();

View file

@ -233,7 +233,7 @@ run_progs (void *data)
PR_ExecuteProgram (thread->pr, thread->main_func);
PR_PopFrame (thread->pr);
if (thread->pr->debug_handler) {
thread->pr->debug_handler (prd_exit, 0, thread->pr->debug_data);
thread->pr->debug_handler (prd_terminate, 0, thread->pr->debug_data);
}
thread->return_code = R_INT (thread->pr);
return thread;