Пример #1
0
        public void Breakpoint(Breakpoint breakpoint)
        {
            // emulator.IsRunning= false;

            // We do not need old breakpoints because GDB will set them again
            _emulator.ClearBreakpoints();
            _jtagDevice.ClearBreakpoints();

            SendGlobal(GDBSession.FormatResponse(GDBSession.StandartAnswers.Breakpoint));
        }
Пример #2
0
        private void GDBClientConnected(object client)
        {
            TcpClient     tcpClient    = (TcpClient)client;
            NetworkStream clientStream = tcpClient.GetStream();
            GDBSession    session      = new GDBSession(_emulator, _jtagDevice);

            byte[] message = new byte[0x1000];
            int    bytesRead;

            // log = new StreamWriter("c:\\temp\\log.txt");
            // log.AutoFlush = true;

            _emulator.DoStop();

            while (true)
            {
                bytesRead = 0;

                try
                {
                    bytesRead = clientStream.Read(message, 0, 4096);
                }
                catch (IOException iex)
                {
                    var sex = iex.InnerException as SocketException;
                    if (sex == null || sex.ErrorCode != 10004)
                    {
                        Logger.Error(sex);
                    }
                    break;
                }
                catch (SocketException sex)
                {
                    if (sex.ErrorCode != 10004)
                    {
                        Logger.Error(sex);
                    }
                    break;
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    break;
                }

                if (bytesRead == 0)
                {
                    //the client has disconnected from the server
                    break;
                }

                if (bytesRead > 0)
                {
                    GDBPacket packet = new GDBPacket(message, bytesRead);
                    if (_jtagDevice.Log)
                    {
                        Logger.Info("--> {0}", packet);
                    }

                    bool   isSignal;
                    string response = session.ParseRequest(packet, out isSignal);
                    if (response != null)
                    {
                        if (isSignal)
                        {
                            SendGlobal(response);
                        }
                        else
                        {
                            SendResponse(clientStream, response);
                        }
                    }
                }
            }
            tcpClient.Close();
        }