Beispiel #1
0
        void ReceiveEvents(int timeout = -1)
        {
            string[] response = DebuggerClient.Receive(timeout);

            if (response == null)
            {
                throw new DebuggerNotResponses();
            }

            foreach (string line in response)
            {
                Logger.LogLine("< " + line);
            }

            MIOutput output = MIParser.ParseOutput(response);

            if (output.ResultRecord != null)
            {
                // this output must hasn't result record
                throw new MIParserException();
            }

            foreach (var record in output.OutOfBandRecords)
            {
                EventQueue.Enqueue(record);
            }
        }
Beispiel #2
0
        public MIResultRecord Request(string command, int timeout = -1)
        {
            MIResultRecord resultRecord = null;

            Logger.LogLine("> " + command);

            if (!DebuggerClient.Send(command))
            {
                throw new DebuggerNotResponses();
            }

            while (true)
            {
                string[] response = DebuggerClient.Receive(timeout);

                if (response == null)
                {
                    throw new DebuggerNotResponses();
                }

                foreach (string line in response)
                {
                    Logger.LogLine("< " + line);
                }

                // we could get async record, in this case we could have two "(gdb)" prompts one by one
                // NOTE in this case we have only one line response, that contain prompt only
                if (MIParser.IsEnd(response[0]))
                {
                    continue;
                }

                MIOutput output = MIParser.ParseOutput(response);

                foreach (var record in output.OutOfBandRecords)
                {
                    EventQueue.Enqueue(record);
                }

                if (output.ResultRecord != null)
                {
                    resultRecord = output.ResultRecord;
                    break;
                }
            }

            return(resultRecord);
        }
Beispiel #3
0
        public VSCodeResult Request(Request command, int timeout = -1)
        {
            command.seq = RequestSeq++;
            string stringJSON = JsonConvert.SerializeObject(command,
                                                            Formatting.None,
                                                            new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            Logger.LogLine("-> (C) " + stringJSON);

            if (!DebuggerClient.Send(stringJSON))
            {
                throw new DebuggerNotResponses();
            }

            while (true)
            {
                string[] response = DebuggerClient.Receive(timeout);
                if (response == null)
                {
                    throw new DebuggerNotResponses();
                }
                string line = response[0];

                if (isResponseContainProperty(line, "type", "response"))
                {
                    Logger.LogLine("<- (R) " + line);
                    if ((Int64)GetResponsePropertyValue(line, "request_seq") == command.seq)
                    {
                        return(new VSCodeResult((bool)GetResponsePropertyValue(line, "success"), line));
                    }
                    else
                    {
                        throw new WrongResponseSequence();
                    }
                }
                else
                {
                    Logger.LogLine("<- (E) " + line);
                    EventQueue.Enqueue(line);
                }
            }
        }
Beispiel #4
0
        void ReceiveEvents(int timeout = -1)
        {
            while (true)
            {
                string[] response = DebuggerClient.Receive(timeout);
                if (response == null)
                {
                    throw new DebuggerNotResponses();
                }
                string line = response[0];

                Logger.LogLine("<- (E) " + line);
                EventQueue.Enqueue(line);

                foreach (var Event in StopEvents)
                {
                    if (isResponseContainProperty(line, "event", Event))
                    {
                        return;
                    }
                }
            }
        }