예제 #1
0
 public BreakpointAdlers(BreakpointInfo info)
 {
     Label = info.breakpointString;
     Check = checkInfo;
     Address = null;
     Info = info;
 }
예제 #2
0
        public void AddExtBreakpoint(List<string> newBreakpointDesc)
        {
            if (_breakpointsExt == null)
                _breakpointsExt = new DictionarySafe<byte, BreakpointAdlers>();

            BreakpointInfo breakpointInfo = new BreakpointInfo();

            //1.LEFT condition
            bool leftIsMemoryReference = false;

            string left = newBreakpointDesc[1];
            if (DebuggerManager.isMemoryReference(left))
            {
                breakpointInfo.leftCondition = left.ToUpper();

                // it can be memory reference by registry value, e.g.: (PC), (DE), ...
                if (DebuggerManager.isRegistryMemoryReference(left))
                    breakpointInfo.leftValue = DebuggerManager.getRegistryValueByName(m_spectrum.CPU.regs, DebuggerManager.getRegistryFromReference(left));
                else
                    breakpointInfo.leftValue = DebuggerManager.getReferencedMemoryPointer(left);

                leftIsMemoryReference = true;
            }
            else
            {
                //must be a registry
                if (!DebuggerManager.isRegistry(left))
                    throw new Exception("incorrect breakpoint(left condition)");

                breakpointInfo.leftCondition = left.ToUpper();
            }

            //2.CONDITION type
            breakpointInfo.conditionTypeSign = newBreakpointDesc[2]; // ==, !=, <, >, ...

            //3.RIGHT condition
            byte rightType = 0xFF; // 0 - memory reference, 1 - registry value, 2 - common value

            string right = newBreakpointDesc[3];
            if (DebuggerManager.isMemoryReference(right))
            {
                breakpointInfo.rightCondition = right.ToUpper(); // because of breakpoint panel
                breakpointInfo.rightValue = m_spectrum.ReadMemory(DebuggerManager.getReferencedMemoryPointer(right));

                rightType = 0;
            }
            else
            {
                if (DebuggerManager.isRegistry(right))
                {
                    breakpointInfo.rightCondition = right;

                    rightType = 1;
                }
                else
                {
                    //it has to be a common value, e.g.: #4000, %111010101, ...
                    breakpointInfo.rightCondition = right.ToUpper(); // because of breakpoint panel
                    breakpointInfo.rightValue = DebuggerManager.convertNumberWithPrefix(right); // last chance

                    rightType = 2;
                }
            }

            if (rightType == 0xFF)
                throw new Exception("incorrect right condition");

            //4. finish
            if (leftIsMemoryReference)
            {
                if (DebuggerManager.isRegistryMemoryReference(breakpointInfo.leftCondition)) // left condition is e.g.: (PC), (HL), (DE), ...
                {
                    if (rightType == 2) // right is number
                        breakpointInfo.accessType = BreakPointConditionType.registryMemoryReferenceVsValue;
                }
            }
            else
            {
                if (rightType == 2)
                    breakpointInfo.accessType = BreakPointConditionType.registryVsValue;
            }

            breakpointInfo.isOn = true; // activate the breakpoint

            //save breakpoint command line string
            breakpointInfo.breakpointString = String.Empty;
            for (byte counter = 0; counter < newBreakpointDesc.Count; counter++)
            {
                breakpointInfo.breakpointString += newBreakpointDesc[counter];
                if (counter + 1 < newBreakpointDesc.Count)
                    breakpointInfo.breakpointString += " ";
            }

            // ADD breakpoint into list
            // Here will be the breakpoint key assigned by searching keys starting with key 0
            // Maximum 255 breakpoints is allowed
            if (_breakpointsExt.Count < 255)
            {
                var bp = new BreakpointAdlers(breakpointInfo);
                _breakpointsExt.Add((byte)_breakpointsExt.Count, bp);
                m_spectrum.AddBreakpoint(bp);
            }
            else
                throw new Exception("Maximum breakpoints count(255) exceeded...");
        }