130fdc8d8SChris Lattner //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===// 230fdc8d8SChris Lattner // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 630fdc8d8SChris Lattner // 730fdc8d8SChris Lattner //===----------------------------------------------------------------------===// 830fdc8d8SChris Lattner 9cdc514e4SJonas Devlieghere #ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H 10cdc514e4SJonas Devlieghere #define LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H 1130fdc8d8SChris Lattner 1244d93782SGreg Clayton #include "lldb/Core/IOHandler.h" 1330fdc8d8SChris Lattner #include "lldb/Interpreter/CommandObject.h" 14f2bd5c3eSSean Callanan #include "lldb/Interpreter/OptionGroupBoolean.h" 151deb7962SGreg Clayton #include "lldb/Interpreter/OptionGroupFormat.h" 16b576bba2SEnrico Granata #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" 178f7c911bSRaphael Isemann #include "lldb/Target/Target.h" 18b9c1b51eSKate Stone #include "lldb/lldb-private-enumerations.h" 198f7c911bSRaphael Isemann 2030fdc8d8SChris Lattner namespace lldb_private { 2130fdc8d8SChris Lattner 22b9c1b51eSKate Stone class CommandObjectExpression : public CommandObjectRaw, 23b9c1b51eSKate Stone public IOHandlerDelegate { 2430fdc8d8SChris Lattner public: 25b9c1b51eSKate Stone class CommandOptions : public OptionGroup { 2630fdc8d8SChris Lattner public: 271deb7962SGreg Clayton CommandOptions(); 2830fdc8d8SChris Lattner 291fb7e202SPavel Labath ~CommandOptions() override; 3030fdc8d8SChris Lattner 311f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> GetDefinitions() override; 3230fdc8d8SChris Lattner 3397206d57SZachary Turner Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, 34e1cfbc79STodd Fiala ExecutionContext *execution_context) override; 351deb7962SGreg Clayton 36b9c1b51eSKate Stone void OptionParsingStarting(ExecutionContext *execution_context) override; 371deb7962SGreg Clayton 38863fab69SSean Callanan bool top_level; 39399f1cafSJim Ingham bool unwind_on_error; 40184e9811SJim Ingham bool ignore_breakpoints; 413fe71581SMarianne Mailhot-Sarrasin bool allow_jit; 4230fdc8d8SChris Lattner bool show_types; 4330fdc8d8SChris Lattner bool show_summary; 4462afb9f6SGreg Clayton bool debug; 4535e1bda6SJim Ingham uint32_t timeout; 4635e1bda6SJim Ingham bool try_all_threads; 4715663c53SDawn Perchik lldb::LanguageType language; 484d93b8cdSEnrico Granata LanguageRuntimeDescriptionDisplayVerbosity m_verbosity; 49a1e541bfSJim Ingham LazyBool auto_apply_fixits; 5030fdc8d8SChris Lattner }; 5130fdc8d8SChris Lattner 52a7015092SGreg Clayton CommandObjectExpression(CommandInterpreter &interpreter); 5330fdc8d8SChris Lattner 541fb7e202SPavel Labath ~CommandObjectExpression() override; 5530fdc8d8SChris Lattner 56b9c1b51eSKate Stone Options *GetOptions() override; 5730fdc8d8SChris Lattner 58ae34ed2cSRaphael Isemann void HandleCompletion(CompletionRequest &request) override; 5974829734SRaphael Isemann 6030fdc8d8SChris Lattner protected: 6144d93782SGreg Clayton // IOHandler::Delegate functions 62b9c1b51eSKate Stone void IOHandlerInputComplete(IOHandler &io_handler, 631fb7e202SPavel Labath std::string &line) override; 6444d93782SGreg Clayton 65b9c1b51eSKate Stone bool IOHandlerIsInputComplete(IOHandler &io_handler, 66f52c40c5SSean Callanan StringList &lines) override; 67f52c40c5SSean Callanan 684d51a902SRaphael Isemann bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override; 6930fdc8d8SChris Lattner 708f7c911bSRaphael Isemann /// Return the appropriate expression options used for evaluating the 718f7c911bSRaphael Isemann /// expression in the given target. 728f7c911bSRaphael Isemann EvaluateExpressionOptions GetEvalOptions(const Target &target); 738f7c911bSRaphael Isemann 74*6a4905aeSRaphael Isemann /// Evaluates the given expression. 75*6a4905aeSRaphael Isemann /// \param output_stream The stream to which the evaluation result will be 76*6a4905aeSRaphael Isemann /// printed. 77*6a4905aeSRaphael Isemann /// \param error_stream Contains error messages that should be displayed to 78*6a4905aeSRaphael Isemann /// the user in case the evaluation fails. 79*6a4905aeSRaphael Isemann /// \param result A CommandReturnObject which status will be set to the 80*6a4905aeSRaphael Isemann /// appropriate value depending on evaluation success and 81*6a4905aeSRaphael Isemann /// whether the expression produced any result. 82*6a4905aeSRaphael Isemann /// \return Returns true iff the expression was successfully evaluated, 83*6a4905aeSRaphael Isemann /// executed and the result could be printed to the output stream. 847c6e52acSRaphael Isemann bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream, 857c6e52acSRaphael Isemann Stream &error_stream, CommandReturnObject &result); 86cf28a8b7SGreg Clayton 87b9c1b51eSKate Stone void GetMultilineExpression(); 8830fdc8d8SChris Lattner 891deb7962SGreg Clayton OptionGroupOptions m_option_group; 901deb7962SGreg Clayton OptionGroupFormat m_format_options; 91b576bba2SEnrico Granata OptionGroupValueObjectDisplay m_varobj_options; 92f2bd5c3eSSean Callanan OptionGroupBoolean m_repl_option; 931deb7962SGreg Clayton CommandOptions m_command_options; 9430fdc8d8SChris Lattner uint32_t m_expr_line_count; 9530fdc8d8SChris Lattner std::string m_expr_lines; // Multi-line expression support 96e5ee6f04SJim Ingham std::string m_fixed_expression; // Holds the current expression's fixed text. 9730fdc8d8SChris Lattner }; 9830fdc8d8SChris Lattner 9930fdc8d8SChris Lattner } // namespace lldb_private 10030fdc8d8SChris Lattner 101cdc514e4SJonas Devlieghere #endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H 102