Author: Jonas Devlieghere Date: 2025-01-30T09:53:57-08:00 New Revision: a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9
URL: https://github.com/llvm/llvm-project/commit/a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9 DIFF: https://github.com/llvm/llvm-project/commit/a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9.diff LOG: [lldb] Fix CommandInterpreter.{h,cpp} formatting (NFC) Fix CommandInterpreter.{h,cpp} formatting in preparation for #125006. Added: Modified: lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/source/Interpreter/CommandInterpreter.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 2bafc30cc8e23a..910c1d84303354 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -100,8 +100,7 @@ class CommandInterpreterRunOptions { LazyBool stop_on_error, LazyBool stop_on_crash, LazyBool echo_commands, LazyBool echo_comments, LazyBool print_results, LazyBool print_errors, - LazyBool add_to_history, - LazyBool handle_repeats) + LazyBool add_to_history, LazyBool handle_repeats) : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), m_echo_comment_commands(echo_comments), m_print_results(print_results), @@ -248,13 +247,13 @@ class CommandInterpreter : public Broadcaster, enum CommandTypes { eCommandTypesBuiltin = 0x0001, //< native commands such as "frame" eCommandTypesUserDef = 0x0002, //< scripted commands - eCommandTypesUserMW = 0x0004, //< multiword commands (command containers) + eCommandTypesUserMW = 0x0004, //< multiword commands (command containers) eCommandTypesAliases = 0x0008, //< aliases such as "po" - eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore + eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore eCommandTypesAllThem = 0xFFFF //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -334,9 +333,8 @@ class CommandInterpreter : public Broadcaster, /// dummy "contains everything MWC, so we return null here, but /// in this case error.Success is true. - CommandObjectMultiword *VerifyUserMultiwordCmdPath(Args &path, - bool leaf_is_command, - Status &result); + CommandObjectMultiword * + VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command, Status &result); CommandAlias *AddAlias(llvm::StringRef alias_name, lldb::CommandObjectSP &command_obj_sp, @@ -596,7 +594,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 764dcfd1903b19..04226af1a1eb8e 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -113,7 +113,6 @@ const char *CommandInterpreter::g_no_argument = "<no-argument>"; const char *CommandInterpreter::g_need_argument = "<need-argument>"; const char *CommandInterpreter::g_argument = "<argument>"; - #define LLDB_PROPERTIES_interpreter #include "InterpreterProperties.inc" @@ -447,16 +446,17 @@ void CommandInterpreter::Initialize() { CommandAlias *parray_alias = AddAlias("parray", cmd_obj_sp, "--element-count %1 --"); if (parray_alias) { - parray_alias->SetHelp - ("parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION " - "to get a typed-pointer-to-an-array in memory, and will display " - "COUNT elements of that type from the array."); - parray_alias->SetHelpLong(""); - } - CommandAlias *poarray_alias = AddAlias("poarray", cmd_obj_sp, - "--object-description --element-count %1 --"); + parray_alias->SetHelp( + "parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION " + "to get a typed-pointer-to-an-array in memory, and will display " + "COUNT elements of that type from the array."); + parray_alias->SetHelpLong(""); + } + CommandAlias *poarray_alias = AddAlias( + "poarray", cmd_obj_sp, "--object-description --element-count %1 --"); if (poarray_alias) { - poarray_alias->SetHelp("poarray <COUNT> <EXPRESSION> -- lldb will " + poarray_alias->SetHelp( + "poarray <COUNT> <EXPRESSION> -- lldb will " "evaluate EXPRESSION to get the address of an array of COUNT " "objects in memory, and will call po on them."); poarray_alias->SetHelpLong(""); @@ -536,9 +536,7 @@ void CommandInterpreter::Initialize() { } } -void CommandInterpreter::Clear() { - m_command_io_handler_sp.reset(); -} +void CommandInterpreter::Clear() { m_command_io_handler_sp.reset(); } const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) { // This function has not yet been implemented. @@ -851,9 +849,12 @@ void CommandInterpreter::LoadCommandDictionary() { // now "bt 3" is the preferred form, in line with gdb. if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$", "thread backtrace -c %1") && - bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$", "thread backtrace %1") && - bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") && - bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) { + bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$", + "thread backtrace %1") && + bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", + "thread backtrace all") && + bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", + "thread backtrace")) { CommandObjectSP command_sp(bt_regex_cmd_up.release()); m_command_dict[std::string(command_sp->GetCommandName())] = command_sp; } @@ -954,13 +955,14 @@ int CommandInterpreter::GetCommandNamesMatchingPartialString( return matches.GetSize(); } -CommandObjectMultiword *CommandInterpreter::VerifyUserMultiwordCmdPath( - Args &path, bool leaf_is_command, Status &result) { +CommandObjectMultiword * +CommandInterpreter::VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command, + Status &result) { result.Clear(); auto get_multi_or_report_error = [&result](CommandObjectSP cmd_sp, - const char *name) -> CommandObjectMultiword * { + const char *name) -> CommandObjectMultiword * { if (!cmd_sp) { result = Status::FromErrorStringWithFormat( "Path component: '%s' not found", name); @@ -1265,8 +1267,8 @@ CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str, // Try to find a match among commands and aliases. Allowing inexact matches, // but perferring exact matches. return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false, - matches, descriptions) - .get(); + matches, descriptions) + .get(); } CommandObject *CommandInterpreter::GetUserCommandObject( @@ -1299,8 +1301,8 @@ CommandObject *CommandInterpreter::GetUserCommandObject( StringList tmp_list; StringList *matches_ptr = matches ? matches : &tmp_list; AddNamesMatchingPartialString(GetUserCommands(), cmd_str, *matches_ptr); - AddNamesMatchingPartialString(GetUserMultiwordCommands(), - cmd_str, *matches_ptr); + AddNamesMatchingPartialString(GetUserMultiwordCommands(), cmd_str, + *matches_ptr); return {}; } @@ -1798,8 +1800,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) { return error; } -Status -CommandInterpreter::PreprocessToken(std::string &expr_str) { +Status CommandInterpreter::PreprocessToken(std::string &expr_str) { Status error; ExecutionContext exe_ctx(GetExecutionContext()); @@ -1819,9 +1820,8 @@ CommandInterpreter::PreprocessToken(std::string &expr_str) { options.SetTryAllThreads(true); options.SetTimeout(std::nullopt); - ExpressionResults expr_result = - target.EvaluateExpression(expr_str.c_str(), exe_ctx.GetFramePtr(), - expr_result_valobj_sp, options); + ExpressionResults expr_result = target.EvaluateExpression( + expr_str.c_str(), exe_ctx.GetFramePtr(), expr_result_valobj_sp, options); if (expr_result == eExpressionCompleted) { Scalar scalar; @@ -1890,7 +1890,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line, Log *log = GetLog(LLDBLog::Commands); llvm::PrettyStackTraceFormat stack_trace("HandleCommand(command = \"%s\")", - command_line); + command_line); LLDB_LOGF(log, "Processing command: %s", command_line); LLDB_SCOPED_TIMERF("Processing command: %s.", command_line); @@ -2011,7 +2011,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line, // has the command expanded to the full name. For example, if the input was // "br s -n main", command_string is now "breakpoint set -n main". if (log) { - llvm::StringRef command_name = cmd_obj ? cmd_obj->GetCommandName() : "<not found>"; + llvm::StringRef command_name = + cmd_obj ? cmd_obj->GetCommandName() : "<not found>"; LLDB_LOGF(log, "HandleCommand, cmd_obj : '%s'", command_name.str().c_str()); LLDB_LOGF(log, "HandleCommand, (revised) command_string: '%s'", command_string.c_str()); @@ -2216,11 +2217,15 @@ CommandInterpreter::GetAlias(llvm::StringRef alias_name) const { return nullptr; } -bool CommandInterpreter::HasCommands() const { return (!m_command_dict.empty()); } +bool CommandInterpreter::HasCommands() const { + return (!m_command_dict.empty()); +} bool CommandInterpreter::HasAliases() const { return (!m_alias_dict.empty()); } -bool CommandInterpreter::HasUserCommands() const { return (!m_user_dict.empty()); } +bool CommandInterpreter::HasUserCommands() const { + return (!m_user_dict.empty()); +} bool CommandInterpreter::HasUserMultiwordCommands() const { return (!m_user_mw_dict.empty()); @@ -2578,20 +2583,18 @@ bool CommandInterpreter::DidProcessStopAbnormally() const { return false; } -void -CommandInterpreter::HandleCommands(const StringList &commands, - const ExecutionContext &override_context, - const CommandInterpreterRunOptions &options, - CommandReturnObject &result) { +void CommandInterpreter::HandleCommands( + const StringList &commands, const ExecutionContext &override_context, + const CommandInterpreterRunOptions &options, CommandReturnObject &result) { OverrideExecutionContext(override_context); HandleCommands(commands, options, result); RestoreExecutionContext(); } -void CommandInterpreter::HandleCommands(const StringList &commands, - const CommandInterpreterRunOptions &options, - CommandReturnObject &result) { +void CommandInterpreter::HandleCommands( + const StringList &commands, const CommandInterpreterRunOptions &options, + CommandReturnObject &result) { size_t num_lines = commands.GetSize(); // If we are going to continue past a "continue" then we need to run the @@ -2728,8 +2731,9 @@ void CommandInterpreter::HandleCommandsFromFile( RestoreExecutionContext(); } -void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file, - const CommandInterpreterRunOptions &options, CommandReturnObject &result) { +void CommandInterpreter::HandleCommandsFromFile( + FileSpec &cmd_file, const CommandInterpreterRunOptions &options, + CommandReturnObject &result) { if (!FileSystem::Instance().Exists(cmd_file)) { result.AppendErrorWithFormat( "Error reading commands from file %s - file not found.\n", @@ -3134,9 +3138,9 @@ bool CommandInterpreter::EchoCommandNonInteractive( void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, std::string &line) { - // If we were interrupted, bail out... - if (WasInterrupted()) - return; + // If we were interrupted, bail out... + if (WasInterrupted()) + return; const bool is_interactive = io_handler.GetIsInteractive(); const bool allow_repeats = _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits