Ejemplo n.º 1
0
        public override void ReadBytes(IntPtr addr, uint size, byte[] readBuff)
        {
            string reply = SendCommand($"m{addr.ToString("X")},{size:x}");

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply.Length == 3 && reply.StartsWith("E"))
            {
                GDBException.ThrowFromReply(reply);
            }

            int readLen = reply.Length / 2;

            if (readLen < size)
            {
                throw new IncompleteReadException();
            }

            for (int i = 0; i < readLen; ++i)
            {
                readBuff[i] = Convert.ToByte(reply.Substring(i * 2, 2), 16);
            }
        }
Ejemplo n.º 2
0
        public uint SearchMemory(IntPtr startAddr, byte[] pattern)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("qSearch:memory:{0:x};{1:x};", startAddr, pattern.Length);

            for (int i = 0; i < pattern.Length; ++i)
            {
                sb.AppendFormat("{0:x2}", pattern[i]);
            }
            string reply = SendCommand(sb.ToString());

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply.StartsWith("E"))
            {
                GDBException.ThrowFromReply(reply);
            }

            if (reply == "0")
            {
                return(0);
            }

            return(Convert.ToUInt32(reply.Substring(2), 16));
        }
Ejemplo n.º 3
0
        public void SetNonStop(bool enable = true)
        {
            string reply = SendCommand(enable ? "QNonStop:1" : "QNonStop:0");

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply != "OK")
            {
                GDBException.ThrowFromReply(reply);
            }
        }
Ejemplo n.º 4
0
        public uint CRCMemory(IntPtr addr, uint size)
        {
            string reply = SendCommand("qCRC:{addr:x},{size:x}");

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply.StartsWith("E"))
            {
                GDBException.ThrowFromReply(reply);
            }
            return(Convert.ToUInt32(reply.Substring(2, 4)));
        }
Ejemplo n.º 5
0
        public override void WriteBytes(byte[] srcBuff, IntPtr dstAddr, uint size)
        {
            var sb = new StringBuilder();

            sb.AppendFormat($"M{0:x},{1:x}:", dstAddr, size);

            for (int i = 0; i < size; ++i)
            {
                sb.AppendFormat("{0:x2}", srcBuff[i]);
            }
            string reply = SendCommand(sb.ToString());

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply != "OK")
            {
                GDBException.ThrowFromReply(reply);
            }
        }
Ejemplo n.º 6
0
        public StopPacket?AttachToProcess(int pid)
        {
            if (!vSane)
            {
                throw new InvalidOperationException();
            }
            string reply = SendCommand($"vAttach;{pid:x}");

            if (reply == "")
            {
                throw new UnsupportedCommandException();
            }
            if (reply.StartsWith("E"))
            {
                GDBException.ThrowFromReply(reply);
            }

            if (reply == "OK")
            {
                return(null);
            }

            return(ParseStopPacket(reply));
        }