From 89e6174b9fc196e86f3777ee2f53a4f38ff9f1d8 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Fri, 11 Dec 2015 08:38:42 +1300 Subject: [PATCH] Show triggered breakpoints (and watchpoints in sim). The "regs" command indicates when the PC is sitting on an enabled breakpoint. The simulator emits debug output when a watchpoint is triggered by a simulated instruction. --- drivers/sim.c | 2 ++ ui/devcmd.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/sim.c b/drivers/sim.c index 5415257..ed45629 100644 --- a/drivers/sim.c +++ b/drivers/sim.c @@ -68,6 +68,8 @@ static void watchpoint_check(struct sim_device *dev, uint16_t addr, ((bp->type == DEVICE_BPTYPE_WATCH || (bp->type == DEVICE_BPTYPE_READ && !is_write) || (bp->type == DEVICE_BPTYPE_WRITE && is_write)))) { + printc_dbg("Watchpoint %d triggered (0x%04x, %s)\n", + i, addr, is_write ? "WRITE" : "READ"); dev->watchpoint_hit = 1; return; } diff --git a/ui/devcmd.c b/ui/devcmd.c index 945ba6b..5b16fdb 100644 --- a/ui/devcmd.c +++ b/ui/devcmd.c @@ -38,11 +38,25 @@ int cmd_regs(char **arg) address_t regs[DEVICE_NUM_REGS]; uint8_t code[16]; int len = sizeof(code); + int i; (void)arg; if (device_getregs(regs) < 0) return -1; + + /* Check for breakpoints */ + 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])) + printc("Breakpoint %d triggered (0x%04x)\n", + i, bp->addr); + } + show_regs(regs); /* Try to disassemble the instruction at PC */