On 1/14/2026 1:46 AM, Nicholas Piggin wrote:
Remove TCG breakpoints/watchpoints when the CPU is reset.
Currently they get lost.

Signed-off-by: Nicholas Piggin <[email protected]>
---

Reviewed-by: Daniel Henrique Barboza <[email protected]>

  target/riscv/debug.c | 15 +++++++++++++--
  1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/target/riscv/debug.c b/target/riscv/debug.c
index 19c45fb13c..973de3b2e2 100644
--- a/target/riscv/debug.c
+++ b/target/riscv/debug.c
@@ -1131,6 +1131,19 @@ void riscv_trigger_reset_hold(CPURISCVState *env)
/* init to type 2 triggers */
      for (i = 0; i < RV_MAX_TRIGGERS; i++) {
+        int trigger_type = get_trigger_type(env, i);
+
+        switch (trigger_type) {
+        case TRIGGER_TYPE_AD_MATCH:
+            type2_breakpoint_remove(env, i);
+            break;
+        case TRIGGER_TYPE_AD_MATCH6:
+            type6_breakpoint_remove(env, i);
+            break;
+        default:
+            break;
+        }
+
          /*
           * type = TRIGGER_TYPE_AD_MATCH
           * dmode = 0 (both debug and M-mode can write tdata)
@@ -1147,8 +1160,6 @@ void riscv_trigger_reset_hold(CPURISCVState *env)
          env->tdata1[i] = tdata1;
          env->tdata2[i] = 0;
          env->tdata3[i] = 0;
-        env->cpu_breakpoint[i] = NULL;
-        env->cpu_watchpoint[i] = NULL;
          timer_del(env->itrigger_timer[i]);
      }


Reply via email to