Add a breakpoint flag to opcodes

The progs execution code will call a breakpoint handler just before
executing an instruction with the flag set. This means there's no need
for the breakpoint handler to mess with execution state or even the
instruction in order to continue past the breakpoint.

The flag being set in a progs file is invalid.
This commit is contained in:
Bill Currie 2020-02-26 13:40:26 +09:00
parent d60291a73e
commit aa02069dd1
3 changed files with 12 additions and 1 deletions

View file

@ -396,6 +396,7 @@ typedef enum {
OP_MOD_F,
OP_MOD_D,
} pr_opcode_e;
#define OP_BREAK 0x8000
typedef struct opcode_s {
const char *name;

View file

@ -1776,6 +1776,7 @@ struct progs_s {
/// \name debugging
///@{
struct prdeb_resources_s *pr_debug_resources;
void (*breakpoint_handler) (progs_t *pr);
pr_type_t *watch;
int wp_conditional;
pr_type_t wp_val;

View file

@ -440,7 +440,16 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
if (pr->pr_trace)
PR_PrintStatement (pr, st, 1);
switch (st->op) {
if (st->op & OP_BREAK) {
if (pr->breakpoint_handler) {
pr->breakpoint_handler (pr);
} else {
PR_RunError (pr, "breakpoint hit");
}
}
pr_opcode_e op = st->op & ~OP_BREAK;
switch (op) {
case OP_ADD_D:
OPC_double_var = OPA_double_var + OPB_double_var;
break;