Exemple #1
0
        public bool SetBreakpoint(WabbitcodeBreakpoint newBreakpoint)
        {
            if (_debugger == null || newBreakpoint == null)
            {
                return(false);
            }

            CalcLocation location = _symbolService.ListTable.GetCalcLocation(newBreakpoint.File, newBreakpoint.LineNumber + 1);

            if (location == null)
            {
                // move the breakpoint to the nearest location
                FilePath     fileName   = newBreakpoint.File;
                int          lineNumber = newBreakpoint.LineNumber;
                CalcLocation value      = _symbolService.ListTable.GetNextNearestCalcLocation(fileName, lineNumber + 1);
                if (value == null)
                {
                    return(false);
                }

                DocumentLocation newLocation = _symbolService.ListTable.GetFileLocation(value.Page, value.Address, value.IsRam);
                WabbitcodeBreakpointManager.RemoveBreakpoint(fileName, lineNumber);
                WabbitcodeBreakpointManager.AddBreakpoint(newLocation.FileName, newLocation.LineNumber - 1);
                return(true);
            }

            newBreakpoint.Page    = location.Page;
            newBreakpoint.Address = location.Address;
            newBreakpoint.IsRam   = location.IsRam;
            byte page = location.IsRam ? location.Page : (byte)(_appPage - newBreakpoint.Page);

            newBreakpoint.WabbitemuBreakpoint = _debugger.SetBreakpoint(newBreakpoint.IsRam,
                                                                        page, newBreakpoint.Address);
            return(false);
        }
Exemple #2
0
 public void ClearBreakpoint(WabbitcodeBreakpoint newBreakpoint)
 {
     if (_debugger != null && newBreakpoint != null && newBreakpoint.WabbitemuBreakpoint != null)
     {
         _debugger.ClearBreakpoint(newBreakpoint.WabbitemuBreakpoint);
     }
 }
        public override bool Equals(object obj)
        {
            if (!(obj is WabbitcodeBreakpoint))
            {
                return(false);
            }

            WabbitcodeBreakpoint break2 = obj as WabbitcodeBreakpoint;

            return((Address == break2.Address && Page == break2.Page && IsRam == break2.IsRam) ||
                   (string.Equals(File, break2.File, StringComparison.OrdinalIgnoreCase) && LineNumber == break2.LineNumber));
        }
Exemple #4
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;
            }
        }