Beispiel #1
0
        /**
         * Used to stop CPU execution and enable single stepping through opcodes via the interactive
         * debugger (only when Debug = true).
         */
        public void Break()
        {
            if (!Debug)
            {
                return;
            }

            _singleStepping = true;

            if (OnBreakpointHitEvent != null)
            {
                _isWaitingForInteractiveDebugger = true;
                OnBreakpointHitEvent.Invoke();
            }
        }
Beispiel #2
0
        /**
         * Used to reverse step backwards a single step, effectively reverting the CPU to the state
         * prior to the last opcode executing. This requires Debug=true and ReverseStepEnabled=true.
         */
        public void ReverseStep()
        {
            if (!Debug && !ReverseStepEnabled)
            {
                throw new Exception("Debug feature: reverse stepping is not enabled.");
            }

            var state = _executionHistory[_executionHistory.Count - 1];

            _executionHistory.RemoveAt(_executionHistory.Count - 1);

            // The first time we step backwards in the debugger, the most recent saved execution state
            // will be the same as the current state. In that case, pop again to get the last state.
            if (state.Registers.PC == _cpu.Registers.PC && _executionHistory.Count > 0)
            {
                state = _executionHistory[_executionHistory.Count - 1];
                _executionHistory.RemoveAt(_executionHistory.Count - 1);
            }

            LoadState(state);
            _cyclesSinceLastInterrupt -= state.LastCyclesExecuted.Value;
            OnBreakpointHitEvent.Invoke();
        }