Esempio n. 1
0
        private void OnReplyPacketReceived(byte[] packetBytes)
        {
            ReplyPacketParser packet = new ReplyPacketParser(packetBytes, _IDSizes);
            uint id = packet.Id;

            WaitingOperationDescriptor waitingOperation = null;

            lock (_waitingOperations)
            {
                if (_waitingOperations.TryGetValue(id, out waitingOperation))
                {
                    _waitingOperations.Remove(id);
                }
            }
            if (waitingOperation != null)
            {
                try
                {
                    waitingOperation.OnComplete(packet);
                }
                catch (JdwpException e)
                {
                    waitingOperation.OnJdwpException(e);
                }
            }
            else
            {
                Debug.Fail("How did we get a reply packet that we don't have a waiting operation for?");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Send a command packet to the VM
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Task SendCommandAsync(JdwpCommand command)
        {
            var waitingOperation = new WaitingOperationDescriptor(command);

            lock (_waitingOperations)
            {
                _waitingOperations.Add(command.PacketId, waitingOperation);
            }

            SendToTransport(command);

            return(waitingOperation.Task);
        }
Esempio n. 3
0
        /// <summary>
        /// Send a command packet to the VM
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Task SendCommandAsync(JdwpCommand command)
        {
            var waitingOperation = new WaitingOperationDescriptor(command);

            lock (_waitingOperations)
            {
                _waitingOperations.Add(command.PacketId, waitingOperation);
            }

            SendToTransport(command);

            return waitingOperation.Task;
        }
Esempio n. 4
0
        private Task <Results> CmdAsyncInternal(string command, ResultClass expectedResultClass)
        {
            var  waitingOperation = new WaitingOperationDescriptor(command, expectedResultClass);
            uint id;

            lock (_waitingOperations)
            {
                if (_isClosed)
                {
                    throw new ObjectDisposedException("Debugger");
                }

                id = ++_lastCommandId;
                _waitingOperations.Add(id, waitingOperation);
            }

            SendToTransport(id.ToString(CultureInfo.InvariantCulture) + command);

            return(waitingOperation.Task);
        }
Esempio n. 5
0
        public void ProcessStdOutLine(string line)
        {
            if (line.Length == 0)
            {
                return;
            }
            else if (line == "(gdb)")
            {
                if (_consoleDebuggerInitializeCompletionSource != null)
                {
                    lock (_waitingOperations)
                    {
                        if (_consoleDebuggerInitializeCompletionSource != null)
                        {
                            _consoleDebuggerInitializeCompletionSource.TrySetResult(null);
                        }
                    }
                }
            }
            else
            {
                string token    = ParseToken(ref line);
                char   c        = line[0];
                string noprefix = line.Substring(1).Trim();

                if (token != null)
                {
                    // Look for event handlers registered on a specific Result id
                    if (c == '^')
                    {
                        uint id = uint.Parse(token, CultureInfo.InvariantCulture);
                        WaitingOperationDescriptor waitingOperation = null;
                        lock (_waitingOperations)
                        {
                            if (_waitingOperations.TryGetValue(id, out waitingOperation))
                            {
                                _waitingOperations.Remove(id);
                            }
                        }
                        if (waitingOperation != null)
                        {
                            Results results = MIResults.ParseCommandOutput(noprefix);
                            Logger.WriteLine(id + ": elapsed time " + (int)(DateTime.Now - waitingOperation.StartTime).TotalMilliseconds);
                            waitingOperation.OnComplete(results, this.MICommandFactory);
                            return;
                        }
                    }
                    // Check to see if we are just getting the echo of the command we sent
                    else if (c == '-')
                    {
                        uint id = uint.Parse(token, CultureInfo.InvariantCulture);
                        lock (_waitingOperations)
                        {
                            WaitingOperationDescriptor waitingOperation;
                            if (_waitingOperations.TryGetValue(id, out waitingOperation) &&
                                !waitingOperation.EchoReceived &&
                                line == waitingOperation.Command)
                            {
                                // This is just the echo. Ignore.
                                waitingOperation.EchoReceived = true;
                                return;
                            }
                        }
                    }
                }

                switch (c)
                {
                case '~':
                    OnDebuggeeOutput(noprefix);             // Console stream
                    break;

                case '^':
                    OnResult(noprefix, token);
                    break;

                case '*':
                    OnOutOfBand(noprefix);
                    break;

                case '&':
                    OnLogStreamOutput(noprefix);
                    break;

                case '=':
                    OnNotificationOutput(noprefix);
                    break;

                default:
                    OnDebuggeeOutput(line + '\n');
                    break;
                }
            }
        }
Esempio n. 6
0
        private Task<Results> CmdAsyncInternal(string command, ResultClass expectedResultClass)
        {
            var waitingOperation = new WaitingOperationDescriptor(command, expectedResultClass);
            uint id;

            lock (_waitingOperations)
            {
                if (_isClosed)
                {
                    throw new ObjectDisposedException("Debugger");
                }

                id = ++_lastCommandId;
                _waitingOperations.Add(id, waitingOperation);
                _lastCommandText = command;
            }

            SendToTransport(id.ToString(CultureInfo.InvariantCulture) + command);

            return waitingOperation.Task;
        }