Esempio n. 1
0
        public async Task Breakpoint(Breakpoint breakpoint)
        {
            // We do not need old breakpoints because GDB will set them again
            _target.ClearBreakpoints();

            await SendGlobal(GDBSession.FormatResponse(GDBSession.StandartAnswers.Breakpoint));
        }
 void BreakpointOccured(object sender, EventArgs e)
 {
     lock (_SporadicLock)
     {
         SendGlobal(GDBSession.FormatResponse(GDBSession.StandartAnswers.Breakpoint, false));
     }
 }
Esempio n. 3
0
        private async Task ProcessGdbClient(TcpClient tcpClient)
        {
            NetworkStream clientStream = tcpClient.GetStream();
            GDBSession    session      = new GDBSession(_target);

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

            _target.DoStop();

            while (true)
            {
                try
                {
                    bytesRead = await clientStream.ReadAsync(message, 0, 4096);
                }
                catch (IOException iex)
                {
                    var sex = iex.InnerException as SocketException;
                    if (sex == null || sex.SocketErrorCode != SocketError.Interrupted)
                    {
                        _target.LogException?.Invoke(sex);
                    }
                    break;
                }
                catch (SocketException sex)
                {
                    if (sex.SocketErrorCode != SocketError.Interrupted)
                    {
                        _target.LogException?.Invoke(sex);
                    }
                    break;
                }
                catch (Exception ex)
                {
                    _target.LogException?.Invoke(ex);
                    break;
                }

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

                if (bytesRead > 0)
                {
                    GDBPacket packet = new GDBPacket(message, bytesRead);
                    _target.Log?.Invoke($"--> {packet}");

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

            tcpClient.Client.Shutdown(SocketShutdown.Both);
        }