riscv-collab / riscv-openocd

Fork of OpenOCD that has RISC-V support
Other
452 stars 328 forks source link

There are cases when WPs disabled by `disable_triggers()` can not be re-enabled by `enable_triggers()`. #1108

Open en-sc opened 3 months ago

en-sc commented 3 months ago

Currently, disable_triggers() just goes through all the WPs and disables them one-by-one (the case when r->manual_hwbp_set is false): https://github.com/riscv-collab/riscv-openocd/blob/5afed58fcdb67ff87842dad9c3ab7f73ca0c8cd8/src/target/riscv/riscv.c#L2487-L2499 enable_triggers() works accordingly: https://github.com/riscv-collab/riscv-openocd/blob/5afed58fcdb67ff87842dad9c3ab7f73ca0c8cd8/src/target/riscv/riscv.c#L2526-L2536

Now consider the following situation:

en-sc commented 3 months ago

Moreover, seems like the state array is redundant here -- all watchpoints are enabled/disabled at once.

JanMatCodasip commented 2 months ago

It sounds like a reasonable fix would be to: