Example #1
0
        private string WriteMemory(GDBPacket packet)
        {
            var parameters = packet.GetCommandParameters();

            if (parameters.Length < 3)
            {
                return(GetErrorAnswer(Errno.ENOENT));
            }
            var arg1 = Convert.ToUInt32(parameters[0], 16);
            var arg2 = Convert.ToUInt32(parameters[1], 16);

            if (arg1 > ushort.MaxValue || arg2 > ushort.MaxValue)
            {
                return(GetErrorAnswer(Errno.ENOENT));
            }
            var addr   = (ushort)arg1;
            var length = (ushort)arg2;

            for (var i = 0; i < length; i++)
            {
                var hex   = parameters[2].Substring(i * 2, 2);
                var value = Convert.ToByte(hex, 16);
                _emulator.CPU.WRMEM((ushort)(addr + i), value);
            }
            return(StandartAnswers.OK);
        }
Example #2
0
        private string ReadMemory(GDBPacket packet)
        {
            var parameters = packet.GetCommandParameters();

            if (parameters.Length < 2)
            {
                return(GetErrorAnswer(Errno.EPERM));
            }
            var arg1 = Convert.ToUInt32(parameters[0], 16);
            var arg2 = Convert.ToUInt32(parameters[1], 16);

            if (arg1 > ushort.MaxValue || arg2 > ushort.MaxValue)
            {
                return(GetErrorAnswer(Errno.EPERM));
            }
            var addr   = (ushort)arg1;
            var length = (ushort)arg2;
            var result = string.Empty;

            for (var i = 0; i < length; i++)
            {
                var hex = _emulator.CPU.RDMEM((ushort)(addr + i))
                          .ToLowEndianHexString();
                result += hex;
            }
            return(result);
        }
Example #3
0
        private string GeneralQueryResponse(GDBPacket packet)
        {
            string command = packet.GetCommandParameters()[0];

            if (command.StartsWith("Supported"))
            {
                return("PacketSize=4000");
            }
            if (command.StartsWith("C"))
            {
                return(StandartAnswers.Empty);
            }
            if (command.StartsWith("Attached"))
            {
                return("1");
            }
            if (command.StartsWith("TStatus"))
            {
                return(StandartAnswers.Empty);
            }
            if (command.StartsWith("Offset"))
            {
                return(StandartAnswers.Error);
            }
            return(StandartAnswers.OK);
        }
Example #4
0
        private string WriteRegisters(GDBPacket packet)
        {
            var regsData = packet.GetCommandParameters()[0];

            for (int i = 0, pos = 0; i < RegistersCount; i++)
            {
                int currentRegisterLength = GetRegisterSize(i) == RegisterSize.Word ? 4 : 2;
                SetRegister(i, regsData.Substring(pos, currentRegisterLength));
                pos += currentRegisterLength;
            }
            return(StandartAnswers.OK);
        }
Example #5
0
        private string ExecutionRequest(GDBPacket packet)
        {
            string command = packet.GetCommandParameters()[0];

            if (command.StartsWith("Cont?"))
            {
                return("");
            }
            if (command.StartsWith("Cont"))
            {
            }
            return(StandartAnswers.Empty);
        }
Example #6
0
        private string SetRegister(GDBPacket packet)
        {
            var parameters = packet.GetCommandParameters()[0].Split(new char[] { '=' });

            if (SetRegister(Convert.ToInt32(parameters[0], 16), parameters[1]))
            {
                return(StandartAnswers.OK);
            }
            else
            {
                return(StandartAnswers.Error);
            }
        }
Example #7
0
        private string RemoveBreakpoint(GDBPacket packet)
        {
            string[] parameters            = packet.GetCommandParameters();
            Breakpoint.BreakpointType type = Breakpoint.GetBreakpointType(int.Parse(parameters[0]));
            ushort addr = Convert.ToUInt16(parameters[1], 16);

            if (type == Breakpoint.BreakpointType.Execution)
            {
                _emulator.RemoveBreakpoint(new ZXMAK2.Engine.Entities.Breakpoint(addr));
            }
            else
            {
                _jtagDevice.RemoveBreakpoint(addr);
            }

            return(StandartAnswers.OK);
        }
Example #8
0
 private string GetRegister(GDBPacket packet)
 {
     return(GetRegisterAsHex(Convert.ToInt32(packet.GetCommandParameters()[0], 16)));
 }