LLDB mainline
CommandObjectExpression.h
Go to the documentation of this file.
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"
18#include "lldb/Target/Target.h"
20
21namespace lldb_private {
22
24 public IOHandlerDelegate {
25public:
26 class CommandOptions : public OptionGroup {
27 public:
29
30 ~CommandOptions() override;
31
32 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
33
34 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
35 ExecutionContext *execution_context) override;
36
37 void OptionParsingStarting(ExecutionContext *execution_context) override;
38
39 /// Return the appropriate expression options used for evaluating the
40 /// expression in the given target.
42 const Target &target,
43 const OptionGroupValueObjectDisplay &display_opts);
44
46 const OptionGroupValueObjectDisplay &display_opts) const;
47
48 /// Appends the options that language plugins add to the commands that
49 /// evaluate expressions to \p group.
51
58 bool debug;
59 uint32_t timeout;
65
66 private:
67 std::vector<std::shared_ptr<OptionGroupLanguageExpression>>
69 };
70
72
74
75 Options *GetOptions() override;
76
77 void HandleCompletion(CompletionRequest &request) override;
78
79protected:
80 // IOHandler::Delegate functions
81 void IOHandlerInputComplete(IOHandler &io_handler,
82 std::string &line) override;
83
84 bool IOHandlerIsInputComplete(IOHandler &io_handler,
85 StringList &lines) override;
86
87 void DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
88
89 /// Evaluates the given expression.
90 /// \param output_stream The stream to which the evaluation result will be
91 /// printed.
92 /// \param error_stream Contains error messages that should be displayed to
93 /// the user in case the evaluation fails.
94 /// \param result A CommandReturnObject which status will be set to the
95 /// appropriate value depending on evaluation success and
96 /// whether the expression produced any result.
97 /// \return Returns true iff the expression was successfully evaluated,
98 /// executed and the result could be printed to the output stream.
99 bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream,
100 Stream &error_stream, CommandReturnObject &result);
101
103
110 std::string m_expr_lines; // Multi-line expression support
111 std::string m_fixed_expression; // Holds the current expression's fixed text.
112};
113
114} // namespace lldb_private
115
116#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
bool ShouldSuppressResult(const OptionGroupValueObjectDisplay &display_opts) const
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity
std::vector< std::shared_ptr< OptionGroupLanguageExpression > > m_language_options
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
void AppendLanguageOptions(OptionGroupOptions &group)
Appends the options that language plugins add to the commands that evaluate expressions to group.
EvaluateExpressionOptions GetEvaluateExpressionOptions(const Target &target, const OptionGroupValueObjectDisplay &display_opts)
Return the appropriate expression options used for evaluating the expression in the given target.
CommandObjectExpression(CommandInterpreter &interpreter)
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
OptionGroupValueObjectDisplay m_varobj_options
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream, Stream &error_stream, CommandReturnObject &result)
Evaluates the given expression.
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
"lldb/Utility/ArgCompletionRequest.h"
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
IOHandlerDelegate(Completion completion=Completion::None)
Definition IOHandler.h:188
A command line option parsing protocol class.
Definition Options.h:58
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
LanguageType
Programming language type.