devcmd: "step N" now checks for breakpoints after each step.
This commit is contained in:
parent
561118dd21
commit
a643a2e833
36
ui/devcmd.c
36
ui/devcmd.c
|
@ -234,6 +234,27 @@ int cmd_erase(char **arg)
|
|||
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)
|
||||
{
|
||||
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)
|
||||
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");
|
||||
return cmd_regs(NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue