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"
17 #include "lldb/Target/Target.h"
19 
20 namespace lldb_private {
21 
23  public IOHandlerDelegate {
24 public:
25  class CommandOptions : public OptionGroup {
26  public:
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;
41  bool allow_jit;
42  bool show_types;
44  bool debug;
50  };
51 
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.
73 
74  /// Evaluates the given expression.
75  /// \param output_stream The stream to which the evaluation result will be
76  /// printed.
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);
86 
88 
95  std::string m_expr_lines; // Multi-line expression support
96  std::string m_fixed_expression; // Holds the current expression's fixed text.
97 };
98 
99 } // namespace lldb_private
100 
101 #endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
lldb_private::CommandObjectExpression::CommandOptions::show_summary
bool show_summary
Definition: CommandObjectExpression.h:43
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
OptionGroupFormat.h
lldb_private::CommandObjectExpression::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectExpression.cpp:166
lldb_private::LanguageRuntimeDescriptionDisplayVerbosity
LanguageRuntimeDescriptionDisplayVerbosity
Definition: lldb-private-enumerations.h:160
lldb_private::CommandObjectExpression::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectExpression.cpp:190
IOHandler.h
lldb_private::CommandObjectExpression::IOHandlerIsInputComplete
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
Definition: CommandObjectExpression.cpp:485
lldb_private::CommandObjectExpression::CommandOptions::unwind_on_error
bool unwind_on_error
Definition: CommandObjectExpression.h:39
lldb_private::OptionGroupOptions
Definition: Options.h:255
lldb_private::CommandObjectExpression::CommandOptions::auto_apply_fixits
LazyBool auto_apply_fixits
Definition: CommandObjectExpression.h:49
lldb_private::OptionGroup
Definition: Options.h:233
lldb_private::EvaluateExpressionOptions
Definition: Target.h:253
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::CommandObjectExpression::CommandOptions::ignore_breakpoints
bool ignore_breakpoints
Definition: CommandObjectExpression.h:40
lldb_private::CommandObjectExpression::CommandOptions
Definition: CommandObjectExpression.h:25
lldb_private::Stream
Definition: Stream.h:28
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
lldb_private::CommandObjectExpression::CommandOptions::allow_jit
bool allow_jit
Definition: CommandObjectExpression.h:41
lldb-private-enumerations.h
lldb_private::Target
Definition: Target.h:445
lldb_private::CommandObjectExpression::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectExpression.h:89
lldb_private::CommandObjectExpression
Definition: CommandObjectExpression.h:22
lldb_private::CommandObjectExpression::m_fixed_expression
std::string m_fixed_expression
Definition: CommandObjectExpression.h:96
lldb_private::CommandObjectExpression::GetEvalOptions
EvaluateExpressionOptions GetEvalOptions(const Target &target)
Return the appropriate expression options used for evaluating the expression in the given target.
Definition: CommandObjectExpression.cpp:335
Target.h
OptionGroupValueObjectDisplay.h
lldb_private::Options
Definition: Options.h:57
lldb_private::CommandObjectExpression::DoExecute
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
Definition: CommandObjectExpression.cpp:546
lldb_private::CommandObjectExpression::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectExpression.cpp:27
lldb_private::CommandObjectExpression::GetMultilineExpression
void GetMultilineExpression()
Definition: CommandObjectExpression.cpp:498
lldb_private::OptionGroupFormat
Definition: OptionGroupFormat.h:21
lldb_private::StringList
Definition: StringList.h:25
lldb_private::CommandObjectExpression::HandleCompletion
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
Definition: CommandObjectExpression.cpp:265
lldb_private::IOHandler
Definition: IOHandler.h:46
lldb_private::CommandObjectExpression::EvaluateExpression
bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream, Stream &error_stream, CommandReturnObject &result)
Evaluates the given expression.
Definition: CommandObjectExpression.cpp:375
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:221
lldb_private::CommandObjectExpression::m_expr_lines
std::string m_expr_lines
Definition: CommandObjectExpression.h:95
lldb_private::CommandObjectExpression::m_format_options
OptionGroupFormat m_format_options
Definition: CommandObjectExpression.h:90
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::OptionGroupValueObjectDisplay
Definition: OptionGroupValueObjectDisplay.h:19
lldb_private::CommandObjectExpression::~CommandObjectExpression
~CommandObjectExpression() override
lldb_private::CommandObjectExpression::CommandOptions::~CommandOptions
~CommandOptions() override
lldb_private::CommandObjectExpression::CommandOptions::try_all_threads
bool try_all_threads
Definition: CommandObjectExpression.h:46
lldb_private::CommandObjectRaw
Definition: CommandObject.h:395
lldb_private::CommandObjectExpression::m_command_options
CommandOptions m_command_options
Definition: CommandObjectExpression.h:93
lldb_private::CommandObjectExpression::CommandOptions::debug
bool debug
Definition: CommandObjectExpression.h:44
lldb_private::CommandObjectExpression::m_repl_option
OptionGroupBoolean m_repl_option
Definition: CommandObjectExpression.h:92
lldb_private::CommandObjectExpression::GetOptions
Options * GetOptions() override
Definition: CommandObjectExpression.cpp:263
lldb_private::CommandObjectExpression::CommandOptions::m_verbosity
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity
Definition: CommandObjectExpression.h:48
lldb_private::CommandObjectExpression::m_varobj_options
OptionGroupValueObjectDisplay m_varobj_options
Definition: CommandObjectExpression.h:91
lldb_private::OptionGroupBoolean
Definition: OptionGroupBoolean.h:18
lldb_private::Status
Definition: Status.h:44
lldb_private::CommandObjectExpression::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectExpression.cpp:51
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
lldb_private::CommandObjectExpression::IOHandlerInputComplete
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
Definition: CommandObjectExpression.cpp:467
uint32_t
CommandObject.h
lldb_private::CommandObjectExpression::m_expr_line_count
uint32_t m_expr_line_count
Definition: CommandObjectExpression.h:94
lldb_private::CommandObjectExpression::CommandOptions::language
lldb::LanguageType language
Definition: CommandObjectExpression.h:47
lldb_private::IOHandlerDelegate
A delegate class for use with IOHandler subclasses.
Definition: IOHandler.h:195
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::CommandObjectExpression::CommandObjectExpression
CommandObjectExpression(CommandInterpreter &interpreter)
Definition: CommandObjectExpression.cpp:194
lldb_private::CommandObjectExpression::CommandOptions::top_level
bool top_level
Definition: CommandObjectExpression.h:38
lldb_private::CommandObjectExpression::CommandOptions::timeout
uint32_t timeout
Definition: CommandObjectExpression.h:45
OptionGroupBoolean.h
lldb_private::CommandObjectExpression::CommandOptions::show_types
bool show_types
Definition: CommandObjectExpression.h:42
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100