1 //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
10 #define LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
12 #include "lldb/Core/IOHandler.h"
13 #include "lldb/Interpreter/CommandObject.h"
14 #include "lldb/Interpreter/OptionGroupBoolean.h"
15 #include "lldb/Interpreter/OptionGroupFormat.h"
16 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
17 #include "lldb/Target/Target.h"
18 #include "lldb/lldb-private-enumerations.h"
20 namespace lldb_private {
22 class CommandObjectExpression : public CommandObjectRaw,
23 public IOHandlerDelegate {
25 class CommandOptions : public OptionGroup {
29 ~CommandOptions() override;
31 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
33 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
34 ExecutionContext *execution_context) override;
36 void OptionParsingStarting(ExecutionContext *execution_context) override;
40 bool ignore_breakpoints;
47 lldb::LanguageType language;
48 LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
49 LazyBool auto_apply_fixits;
52 CommandObjectExpression(CommandInterpreter &interpreter);
54 ~CommandObjectExpression() override;
56 Options *GetOptions() override;
58 void HandleCompletion(CompletionRequest &request) override;
61 // IOHandler::Delegate functions
62 void IOHandlerInputComplete(IOHandler &io_handler,
63 std::string &line) override;
65 bool IOHandlerIsInputComplete(IOHandler &io_handler,
66 StringList &lines) override;
68 bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
70 /// Return the appropriate expression options used for evaluating the
71 /// expression in the given target.
72 EvaluateExpressionOptions GetEvalOptions(const Target &target);
74 /// Evaluates the given expression.
75 /// \param output_stream The stream to which the evaluation result will be
77 /// \param error_stream Contains error messages that should be displayed to
78 /// the user in case the evaluation fails.
79 /// \param result A CommandReturnObject which status will be set to the
80 /// appropriate value depending on evaluation success and
81 /// whether the expression produced any result.
82 /// \return Returns true iff the expression was successfully evaluated,
83 /// executed and the result could be printed to the output stream.
84 bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream,
85 Stream &error_stream, CommandReturnObject &result);
87 void GetMultilineExpression();
89 OptionGroupOptions m_option_group;
90 OptionGroupFormat m_format_options;
91 OptionGroupValueObjectDisplay m_varobj_options;
92 OptionGroupBoolean m_repl_option;
93 CommandOptions m_command_options;
94 uint32_t m_expr_line_count;
95 std::string m_expr_lines; // Multi-line expression support
96 std::string m_fixed_expression; // Holds the current expression's fixed text.
99 } // namespace lldb_private
101 #endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H