Esempio n. 1
0
        private void StepOutBreakpointEvent(object sender, BreakpointEventArgs breakpointEventArgs)
        {
            if (_debugger == null)
            {
                return;
            }

            _debugger.ClearBreakpoint(_stepOutBreakpoint);
            int page             = GetRelativePageNum(_stepOutBreakpoint.Address.Address);
            DocumentLocation key = _symbolService.ListTable.GetFileLocation(page,
                                                                            _stepOutBreakpoint.Address.Address,
                                                                            !_stepOutBreakpoint.Address.Page.IsFlash);

            UpdateStack();
            _debugger.OnBreakpoint -= StepOutBreakpointEvent;

            Task.Factory.StartNew(() =>
            {
                if (DebuggerStep != null)
                {
                    DebuggerStep(this, new DebuggerStepEventArgs(key));
                }
            });

            _isStepping = false;
        }
Esempio n. 2
0
        private void BreakpointHit(object sender, BreakpointEventArgs e)
        {
            IBreakpoint breakEvent = e.Breakpoint;

            Debug.WriteLine("Hit breakpoint " + breakEvent.Address.Address);
            if ((breakEvent.Address == _jforceBreakpoint.Address && breakEvent.Address.Page == _jforceBreakpoint.Address.Page) ||
                (breakEvent.Address == _ramClearBreakpoint.Address && breakEvent.Address.Page == _ramClearBreakpoint.Address.Page))
            {
                DebuggerOnClose(null, EventArgs.Empty);
                return;
            }

            if (breakEvent.Address == _insertMemBreakpoint.Address && breakEvent.Address.Page == _insertMemBreakpoint.Address.Page)
            {
                _memoryAllocations.Add(new KeyValuePair <ushort, ushort>(_debugger.CPU.DE, _debugger.CPU.HL));
                _debugger.Step();
                _debugger.Running = true;
                return;
            }

            if (breakEvent.Address == _delMemBreakpoint.Address && breakEvent.Address.Page == _delMemBreakpoint.Address.Page)
            {
                _memoryAllocations.RemoveAll(kvp => kvp.Key == _debugger.CPU.HL && kvp.Value == _debugger.CPU.DE);
                _debugger.Step();
                _debugger.Running = true;
                return;
            }

            ushort address                  = breakEvent.Address.Address;
            int    relativePage             = GetRelativePageNum(address);
            WabbitcodeBreakpoint breakpoint = WabbitcodeBreakpointManager.Breakpoints.FirstOrDefault(
                b => b.Address == address && b.Page == (byte)relativePage && b.IsRam == address >= 0x8000);

            if (breakpoint == null)
            {
                return;
            }

            breakpoint.NumberOfTimesHit++;
            bool conditionsTrue = breakpoint.Enabled;

            switch (breakpoint.HitCountCondition)
            {
            case HitCountEnum.BreakEqualTo:
                if (breakpoint.NumberOfTimesHit != breakpoint.HitCountConditionNumber)
                {
                    conditionsTrue = false;
                }
                break;

            case HitCountEnum.BreakGreaterThanEqualTo:
                if (breakpoint.NumberOfTimesHit < breakpoint.HitCountConditionNumber)
                {
                    conditionsTrue = false;
                }
                break;

            case HitCountEnum.BreakMultipleOf:
                if (breakpoint.NumberOfTimesHit % breakpoint.HitCountConditionNumber != 0)
                {
                    conditionsTrue = false;
                }
                break;
            }

            if (conditionsTrue && breakpoint.EvalulateAllConditions(_debugger.CPU))
            {
                DocumentLocation key = _symbolService.ListTable.GetFileLocation(relativePage, address, !breakEvent.Address.Page.IsFlash);
                if (key == null)
                {
                    throw new InvalidOperationException("Unable to find breakpoint");
                }

                UpdateStack();

                if (DebuggerRunningChanged != null)
                {
                    DebuggerRunningChanged(this, new DebuggerRunningEventArgs(key, false));
                }
            }
            else
            {
                _debugger.Running = true;
            }
        }