devcmd: "step N" now checks for breakpoints after each step.

This commit is contained in:
Daniel Beer 2016-01-09 11:51:59 +13:00
parent 561118dd21
commit a643a2e833
1 changed files with 35 additions and 1 deletions

View File

@ -234,6 +234,27 @@ int cmd_erase(char **arg)
return 0; return 0;
} }
static int bp_poll(void)
{
address_t regs[DEVICE_NUM_REGS];
int i;
if (device_getregs(regs) < 0)
return -1;
for (i = 0; i < device_default->max_breakpoints; i++) {
const struct device_breakpoint *bp =
&device_default->breakpoints[i];
if ((bp->flags & DEVICE_BP_ENABLED) &&
(bp->type == DEVICE_BPTYPE_BREAK) &&
(bp->addr == regs[MSP430_REG_PC]))
return 1;
}
return 0;
}
int cmd_step(char **arg) int cmd_step(char **arg)
{ {
char *count_text = get_arg(arg); char *count_text = get_arg(arg);
@ -247,10 +268,23 @@ int cmd_step(char **arg)
} }
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
int r;
if (device_ctl(DEVICE_CTL_STEP) < 0) if (device_ctl(DEVICE_CTL_STEP) < 0)
return -1; return -1;
r = bp_poll();
if (r < 0)
return -1;
if (r) {
printc("Breakpoint hit after %d steps\n", i + 1);
break;
}
}
reader_set_repeat("step"); reader_set_repeat("step");
return cmd_regs(NULL); return cmd_regs(NULL);
} }