[Simh] Bug in dealing with breakpoints of different kinds

Leo Broukhis leob at mailcom.com
Wed Nov 4 22:46:08 EST 2009


Dear colleagues,

I think there might be a bug in handling different kinds of
breakpoints at once. Consider setting a watchpoint (br -w) on address
W when a breakpoint (br -e) on some address B is set. Suppose the
watchpoint has triggered at PC = X != B. They both belong to space 0,
being on the same processor and within the same address space.
The watchpoint condition is checked by the VM as it has to compute the
effective address of the instruction,
whereas the breakpoint condition is checked by SIMH.
Attempting to perform a step will cause a check of the execution
breakpoint to be done first, resetting the 'pending' flag, then the
watchpoint will trigger again at the same PC.

The fix is to make sim_brk_pend[] an array of uint32 istead of t_bool
and to deal with each breakpoint type separately:

@@ -372,7 +372,7 @@
 int32 sim_brk_ent = 0;
 int32 sim_brk_lnt = 0;
 int32 sim_brk_ins = 0;
-t_bool sim_brk_pend[SIM_BKPT_N_SPC] = { FALSE };
+int32 sim_brk_pend[SIM_BKPT_N_SPC] = { 0 };
 t_addr sim_brk_ploc[SIM_BKPT_N_SPC] = { 0 };
 int32 sim_quiet = 0;
 int32 sim_step = 0;
@@ -4619,11 +4619,11 @@
         return 0;
     bp->cnt = 0;                                        /* reset count */
     sim_brk_ploc[spc] = loc;                            /* save location */
-    sim_brk_pend[spc] = TRUE;                           /* don't do twice */
+    sim_brk_pend[spc] |= btyp;                           /* don't do twice */
     sim_brk_act = bp->act;                              /* set up actions */
     return (btyp & bp->typ);
     }
-sim_brk_pend[spc] = FALSE;
+sim_brk_pend[spc] &= ~btyp;
 return 0;
 }

@@ -4669,7 +4669,7 @@
 if ((cnt == 0) || (cnt > SIM_BKPT_N_SPC))
     cnt = SIM_BKPT_N_SPC;
 for (i = 0; i < cnt; i++) {
-    sim_brk_pend[i] = FALSE;
+    sim_brk_pend[i] = 0;
     sim_brk_ploc[i] = 0;
     }
 return;
@@ -4680,7 +4680,7 @@
 void sim_brk_clrspc (uint32 spc)
 {
 if (spc < SIM_BKPT_N_SPC) {
-    sim_brk_pend[spc] = FALSE;
+    sim_brk_pend[spc] = 0;
     sim_brk_ploc[spc] = 0;
     }
 return;

Regards,
Leo



More information about the Simh mailing list