Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openocd not honouring watchpoint hit time (before/after) in mcontrol6 #1155

Open
RaamyPi opened this issue Oct 27, 2024 · 1 comment
Open

Comments

@RaamyPi
Copy link

RaamyPi commented Oct 27, 2024

When using mcontrol6, spike breaks after the watchpoint is hit. But openocd only checks if the watchpoint is hit and not the other bit also which indicates when the said watchpoint was hit. Subsequently, openocd assumes that the watchpoint is always hit before and sets the step bit in dcsr which ultimately results in control being returned after one more instruction.

@en-sc
Copy link
Collaborator

en-sc commented Oct 28, 2024

... and not the other bit also which indicates when the said watchpoint was hit.

OpenOCD checks the whole mcontrol6.hit field:

case CSR_TDATA1_TYPE_MCONTROL6:
hit_mask = CSR_MCONTROL6_HIT0 | CSR_MCONTROL6_HIT1;
break;

if (tdata1 & hit_mask) {
LOG_TARGET_DEBUG(target, "Trigger %u (unique_id=%" PRIi64 ") has hit bit set.",
i, r->trigger_unique_id[i]);
if (riscv_reg_set(target, GDB_REGNO_TDATA1, tdata1 & ~hit_mask) != ERROR_OK)
return ERROR_FAIL;
*unique_id = r->trigger_unique_id[i];
break;
}

Subsequently, openocd assumes that the watchpoint is always hit before and sets the step bit in dcsr which ultimately results in control being returned after one more instruction.

Yes, OpenOCD always steps from a breakpoint or a watchpoint. There is #1144 aiming to address this issue.

Moreover, I'm not checking hit field to skip the step worth it. The thing is, hit field is optional. Therefore, making sure OpenOCD does step from a trigger when the trigger was hit with a timing before requires a lot of communication with the target and maybe always stepping is simpler and faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants