xref: /openbsd-src/gnu/llvm/lldb/source/Commands/CommandObjectExpression.h (revision dda2819751e49c83612958492e38917049128b41)
1061da546Spatrick //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9*dda28197Spatrick #ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
10*dda28197Spatrick #define LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
11061da546Spatrick 
12061da546Spatrick #include "lldb/Core/IOHandler.h"
13061da546Spatrick #include "lldb/Interpreter/CommandObject.h"
14061da546Spatrick #include "lldb/Interpreter/OptionGroupBoolean.h"
15061da546Spatrick #include "lldb/Interpreter/OptionGroupFormat.h"
16061da546Spatrick #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
17*dda28197Spatrick #include "lldb/Target/Target.h"
18061da546Spatrick #include "lldb/lldb-private-enumerations.h"
19*dda28197Spatrick 
20061da546Spatrick namespace lldb_private {
21061da546Spatrick 
22061da546Spatrick class CommandObjectExpression : public CommandObjectRaw,
23061da546Spatrick                                 public IOHandlerDelegate {
24061da546Spatrick public:
25061da546Spatrick   class CommandOptions : public OptionGroup {
26061da546Spatrick   public:
27061da546Spatrick     CommandOptions();
28061da546Spatrick 
29061da546Spatrick     ~CommandOptions() override;
30061da546Spatrick 
31061da546Spatrick     llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
32061da546Spatrick 
33061da546Spatrick     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
34061da546Spatrick                           ExecutionContext *execution_context) override;
35061da546Spatrick 
36061da546Spatrick     void OptionParsingStarting(ExecutionContext *execution_context) override;
37061da546Spatrick 
38061da546Spatrick     bool top_level;
39061da546Spatrick     bool unwind_on_error;
40061da546Spatrick     bool ignore_breakpoints;
41061da546Spatrick     bool allow_jit;
42061da546Spatrick     bool show_types;
43061da546Spatrick     bool show_summary;
44061da546Spatrick     bool debug;
45061da546Spatrick     uint32_t timeout;
46061da546Spatrick     bool try_all_threads;
47061da546Spatrick     lldb::LanguageType language;
48061da546Spatrick     LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
49061da546Spatrick     LazyBool auto_apply_fixits;
50061da546Spatrick   };
51061da546Spatrick 
52061da546Spatrick   CommandObjectExpression(CommandInterpreter &interpreter);
53061da546Spatrick 
54061da546Spatrick   ~CommandObjectExpression() override;
55061da546Spatrick 
56061da546Spatrick   Options *GetOptions() override;
57061da546Spatrick 
58061da546Spatrick   void HandleCompletion(CompletionRequest &request) override;
59061da546Spatrick 
60061da546Spatrick protected:
61061da546Spatrick   // IOHandler::Delegate functions
62061da546Spatrick   void IOHandlerInputComplete(IOHandler &io_handler,
63061da546Spatrick                               std::string &line) override;
64061da546Spatrick 
65061da546Spatrick   bool IOHandlerIsInputComplete(IOHandler &io_handler,
66061da546Spatrick                                 StringList &lines) override;
67061da546Spatrick 
68061da546Spatrick   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
69061da546Spatrick 
70*dda28197Spatrick   /// Return the appropriate expression options used for evaluating the
71*dda28197Spatrick   /// expression in the given target.
72*dda28197Spatrick   EvaluateExpressionOptions GetEvalOptions(const Target &target);
73*dda28197Spatrick 
74*dda28197Spatrick   /// Evaluates the given expression.
75*dda28197Spatrick   /// \param output_stream The stream to which the evaluation result will be
76*dda28197Spatrick   ///                      printed.
77*dda28197Spatrick   /// \param error_stream Contains error messages that should be displayed to
78*dda28197Spatrick   ///                     the user in case the evaluation fails.
79*dda28197Spatrick   /// \param result A CommandReturnObject which status will be set to the
80*dda28197Spatrick   ///               appropriate value depending on evaluation success and
81*dda28197Spatrick   ///               whether the expression produced any result.
82*dda28197Spatrick   /// \return Returns true iff the expression was successfully evaluated,
83*dda28197Spatrick   ///         executed and the result could be printed to the output stream.
84*dda28197Spatrick   bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream,
85*dda28197Spatrick                           Stream &error_stream, CommandReturnObject &result);
86061da546Spatrick 
87061da546Spatrick   void GetMultilineExpression();
88061da546Spatrick 
89061da546Spatrick   OptionGroupOptions m_option_group;
90061da546Spatrick   OptionGroupFormat m_format_options;
91061da546Spatrick   OptionGroupValueObjectDisplay m_varobj_options;
92061da546Spatrick   OptionGroupBoolean m_repl_option;
93061da546Spatrick   CommandOptions m_command_options;
94061da546Spatrick   uint32_t m_expr_line_count;
95061da546Spatrick   std::string m_expr_lines;       // Multi-line expression support
96061da546Spatrick   std::string m_fixed_expression; // Holds the current expression's fixed text.
97061da546Spatrick };
98061da546Spatrick 
99061da546Spatrick } // namespace lldb_private
100061da546Spatrick 
101*dda28197Spatrick #endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
102