public void ExecuteOneCommand(string command, bool displayDiagnosticInformation = false) { InitParserIfNecessary(); string[] parts = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; if (parts[0] == "#") return; // Lines starting with # are comments ICommand commandToExecute; if (IsInDbgEngNativeMode && parts[0] != "q") { commandToExecute = new DbgEngCommand() { Command = command }; } else { var parseResult = _commandParser.Parse(_allCommandTypes, command); if (!parseResult.Success) { WriteError(parseResult.Error); return; } if (parseResult.Value == null) return; commandToExecute = (ICommand)parseResult.Value; } using (new TimeAndMemory(displayDiagnosticInformation, Printer)) { try { if (!IsCommandIsSupportedForThisTarget(commandToExecute.GetType())) { WriteError("This command is not supported for the current target type: '{0}'", TargetType); } else { commandToExecute.Execute(this); } } catch (Exception ex) { // Commands can throw exceptions occasionally. It's dangerous to continue // after an arbitrary exception, but some of them are perfectly benign. We are // taking the risk because there is no critical state that could become corrupted // as a result of continuing. WriteError("Exception during command execution -- {0}: '{1}'", ex.GetType().Name, ex.Message); WriteError("\n" + ex.StackTrace); WriteError("Proceed at your own risk, or restart the debugging session."); } } if (HyperlinkOutput && _temporaryAliases.Count > WarnThresholdCountOfTemporaryAliases) { WriteWarning("Hyperlinks are enabled. You currently have {0} temporary aliases. " + "Use .clearalias --temporary to clear them.", _temporaryAliases.Count); } Printer.CommandEnded(); }
public void ExecuteOneCommand(string command) { InitParserIfNecessary(); string[] parts = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) { return; } if (parts[0] == "#") { return; // Lines starting with # are comments } ICommand commandToExecute; if (IsInDbgEngNativeMode && parts[0] != "q") { commandToExecute = new DbgEngCommand() { Command = command }; } else { var parseResult = _commandParser.Parse(_allCommandTypes, command); if (!parseResult.Success) { WriteErrorLine(parseResult.Error); return; } if (parseResult.Value == null) { return; } commandToExecute = (ICommand)parseResult.Value; } using (new TimeAndMemory(DisplayDiagnosticInformation, Printer)) { try { if (!IsCommandIsSupportedForThisTarget(commandToExecute.GetType())) { WriteErrorLine("This command is not supported for the current target type: '{0}'", TargetType); } else { commandToExecute.Execute(this); } } catch (Exception ex) { // Commands can throw exceptions occasionally. It's dangerous to continue // after an arbitrary exception, but some of them are perfectly benign. We are // taking the risk because there is no critical state that could become corrupted // as a result of continuing. WriteErrorLine("Exception during command execution -- {0}: '{1}'", ex.GetType().Name, ex.Message); WriteErrorLine("\n" + ex.StackTrace); WriteErrorLine("Proceed at your own risk, or restart the debugging session."); } } if (HyperlinkOutput && _temporaryAliases.Count > WarnThresholdCountOfTemporaryAliases) { WriteWarningLine("Hyperlinks are enabled. You currently have {0} temporary aliases. " + "Use .clearalias --temporary to clear them.", _temporaryAliases.Count); } Printer.CommandEnded(); }