Пример #1
0
        private void OnResult(string cmd, string token)
        {
            uint id = token != null?uint.Parse(token, CultureInfo.InvariantCulture) : 0;

            _lastResult = cmd;
            Results results = MIResults.ParseCommandOutput(cmd);

            if (results.ResultClass == ResultClass.done)
            {
                if (EvaluationEvent != null)
                {
                    EvaluationEvent(this, new ResultEventArgs(results, id));
                }
            }
            else if (results.ResultClass == ResultClass.error)
            {
                if (ErrorEvent != null)
                {
                    ErrorEvent(this, new ResultEventArgs(results, id));
                }
            }
            else
            {
                OnStateChanged(cmd, "");
            }
        }
Пример #2
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;
                }
            }
        }