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); }
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); } } }