1 //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
10 #define LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
11 
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"
19 
20 namespace lldb_private {
21 
22 class CommandObjectExpression : public CommandObjectRaw,
23                                 public IOHandlerDelegate {
24 public:
25   class CommandOptions : public OptionGroup {
26   public:
27     CommandOptions();
28 
29     ~CommandOptions() override;
30 
31     llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
32 
33     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
34                           ExecutionContext *execution_context) override;
35 
36     void OptionParsingStarting(ExecutionContext *execution_context) override;
37 
38     bool top_level;
39     bool unwind_on_error;
40     bool ignore_breakpoints;
41     bool allow_jit;
42     bool show_types;
43     bool show_summary;
44     bool debug;
45     uint32_t timeout;
46     bool try_all_threads;
47     lldb::LanguageType language;
48     LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
49     LazyBool auto_apply_fixits;
50   };
51 
52   CommandObjectExpression(CommandInterpreter &interpreter);
53 
54   ~CommandObjectExpression() override;
55 
56   Options *GetOptions() override;
57 
58   void HandleCompletion(CompletionRequest &request) override;
59 
60 protected:
61   // IOHandler::Delegate functions
62   void IOHandlerInputComplete(IOHandler &io_handler,
63                               std::string &line) override;
64 
65   bool IOHandlerIsInputComplete(IOHandler &io_handler,
66                                 StringList &lines) override;
67 
68   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
69 
70   /// Return the appropriate expression options used for evaluating the
71   /// expression in the given target.
72   EvaluateExpressionOptions GetEvalOptions(const Target &target);
73 
74   bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream,
75                           Stream &error_stream, CommandReturnObject &result);
76 
77   void GetMultilineExpression();
78 
79   OptionGroupOptions m_option_group;
80   OptionGroupFormat m_format_options;
81   OptionGroupValueObjectDisplay m_varobj_options;
82   OptionGroupBoolean m_repl_option;
83   CommandOptions m_command_options;
84   uint32_t m_expr_line_count;
85   std::string m_expr_lines;       // Multi-line expression support
86   std::string m_fixed_expression; // Holds the current expression's fixed text.
87 };
88 
89 } // namespace lldb_private
90 
91 #endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
92