aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-01-28 15:43:31 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2025-01-30 09:53:57 -0800
commita7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9 (patch)
tree579af898e3f4c49df098c075da548182728d5588 /lldb/source/Interpreter/CommandInterpreter.cpp
parent845cc968e987492bda6a62c9a87cd96cfc631d5b (diff)
downloadllvm-a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9.zip
llvm-a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9.tar.gz
llvm-a7e8bfe5ad9a1c1e3f0bba886474f381ebc403a9.tar.bz2
[lldb] Fix CommandInterpreter.{h,cpp} formatting (NFC)
Fix CommandInterpreter.{h,cpp} formatting in preparation for #125006.
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp94
1 files changed, 49 insertions, 45 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 764dcfd..04226af 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 =