diff --git a/simulators/bochs/cpu/cpu.cc b/simulators/bochs/cpu/cpu.cc index 857dd9b9..c47358fc 100644 --- a/simulators/bochs/cpu/cpu.cc +++ b/simulators/bochs/cpu/cpu.cc @@ -241,9 +241,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat(bxInstruction_c *i, BxExecutePtr_tR } if (RCX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -263,9 +260,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat(bxInstruction_c *i, BxExecutePtr_tR } if (ECX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -284,9 +278,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat(bxInstruction_c *i, BxExecutePtr_tR } if (CX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -333,9 +324,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (! get_ZF() || RCX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -355,9 +343,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (! get_ZF() || ECX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -376,9 +361,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (! get_ZF() || CX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -399,9 +381,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (get_ZF() || RCX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -421,9 +400,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (get_ZF() || ECX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif @@ -442,9 +418,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::repeat_ZF(bxInstruction_c *i, BxExecutePtr } if (get_ZF() || CX == 0) return; - // DanceOS - defineCPULoopJoinPoint(BX_CPU_THIS, i); - #if BX_DEBUGGER == 0 if (BX_CPU_THIS_PTR async_event) #endif diff --git a/src/core/sal/bochs/BreakRepeatInstr.ah b/src/core/sal/bochs/BreakRepeatInstr.ah new file mode 100644 index 00000000..fd11e19b --- /dev/null +++ b/src/core/sal/bochs/BreakRepeatInstr.ah @@ -0,0 +1,46 @@ +#ifndef __BREAK_REPEAT_INSTR_AH__ + #define __BREAK_REPEAT_INSTR_AH__ + +#include "config/VariantConfig.hpp" +#include "config/FailConfig.hpp" + +#if defined(BUILD_BOCHS) && defined(CONFIG_EVENT_BREAKPOINTS) + +#include + +#include "cpu/cpu.h" + +#include "BochsHelpers.hpp" +#include "../SALInst.hpp" + +/* + * This aspect ensures that all conditions like + * ... if (BX_CPU_THIS_PTR async_event) ... + * (in "break_condition_methods") are always true. + * + * This is required by the Breakpoint-Events (aspect) in case + * of (any) rep-instructions because they need to be triggered + * after *each* repetition of the corresponding instruction. + */ +aspect BreakRepeatInstr { + pointcut break_condition_methods() = + "% ...::bx_cpu_c::repeat(...)" || // cpu/cpu.cc + "% ...::bx_cpu_c::repeat_ZF(...)"; // dito + + advice execution (break_condition_methods()) : around () + { + // We cannot restore the previous state because the methods + // itself may change the value of "async_event". We need to + // be aware of introducing a potential bug in the Bochs' + // internal logic this way if "1" represents an internally + // used value. + //Bit32u old_async_ev = getCPU(tjp->that())->async_event; + getCPU(tjp->that())->async_event |= 1; + tjp->proceed(); + //getCPU(tjp->that())->async_event = old_async_ev; + } +}; + +#endif // CONFIG_EVENT_BREAKPOINTS + +#endif // __BREAK_REPEAT_INSTR_AH__