Skip to content

Commit a7e8bfe

Browse files
committed
[lldb] Fix CommandInterpreter.{h,cpp} formatting (NFC)
Fix CommandInterpreter.{h,cpp} formatting in preparation for #125006.
1 parent 845cc96 commit a7e8bfe

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

lldb/include/lldb/Interpreter/CommandInterpreter.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ class CommandInterpreterRunOptions {
100100
LazyBool stop_on_error, LazyBool stop_on_crash,
101101
LazyBool echo_commands, LazyBool echo_comments,
102102
LazyBool print_results, LazyBool print_errors,
103-
LazyBool add_to_history,
104-
LazyBool handle_repeats)
103+
LazyBool add_to_history, LazyBool handle_repeats)
105104
: m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
106105
m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
107106
m_echo_comment_commands(echo_comments), m_print_results(print_results),
@@ -248,13 +247,13 @@ class CommandInterpreter : public Broadcaster,
248247
enum CommandTypes {
249248
eCommandTypesBuiltin = 0x0001, //< native commands such as "frame"
250249
eCommandTypesUserDef = 0x0002, //< scripted commands
251-
eCommandTypesUserMW = 0x0004, //< multiword commands (command containers)
250+
eCommandTypesUserMW = 0x0004, //< multiword commands (command containers)
252251
eCommandTypesAliases = 0x0008, //< aliases such as "po"
253-
eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore
252+
eCommandTypesHidden = 0x0010, //< commands prefixed with an underscore
254253
eCommandTypesAllThem = 0xFFFF //< all commands
255254
};
256255

257-
// The CommandAlias and CommandInterpreter both have a hand in
256+
// The CommandAlias and CommandInterpreter both have a hand in
258257
// substituting for alias commands. They work by writing special tokens
259258
// in the template form of the Alias command, and then detecting them when the
260259
// command is executed. These are the special tokens:
@@ -334,9 +333,8 @@ class CommandInterpreter : public Broadcaster,
334333
/// dummy "contains everything MWC, so we return null here, but
335334
/// in this case error.Success is true.
336335

337-
CommandObjectMultiword *VerifyUserMultiwordCmdPath(Args &path,
338-
bool leaf_is_command,
339-
Status &result);
336+
CommandObjectMultiword *
337+
VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command, Status &result);
340338

341339
CommandAlias *AddAlias(llvm::StringRef alias_name,
342340
lldb::CommandObjectSP &command_obj_sp,
@@ -596,7 +594,7 @@ class CommandInterpreter : public Broadcaster,
596594
void SetEchoCommentCommands(bool enable);
597595

598596
bool GetRepeatPreviousCommand() const;
599-
597+
600598
bool GetRequireCommandOverwrite() const;
601599

602600
const CommandObject::CommandMap &GetUserCommands() const {

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ const char *CommandInterpreter::g_no_argument = "<no-argument>";
113113
const char *CommandInterpreter::g_need_argument = "<need-argument>";
114114
const char *CommandInterpreter::g_argument = "<argument>";
115115

116-
117116
#define LLDB_PROPERTIES_interpreter
118117
#include "InterpreterProperties.inc"
119118

@@ -447,16 +446,17 @@ void CommandInterpreter::Initialize() {
447446
CommandAlias *parray_alias =
448447
AddAlias("parray", cmd_obj_sp, "--element-count %1 --");
449448
if (parray_alias) {
450-
parray_alias->SetHelp
451-
("parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION "
452-
"to get a typed-pointer-to-an-array in memory, and will display "
453-
"COUNT elements of that type from the array.");
454-
parray_alias->SetHelpLong("");
455-
}
456-
CommandAlias *poarray_alias = AddAlias("poarray", cmd_obj_sp,
457-
"--object-description --element-count %1 --");
449+
parray_alias->SetHelp(
450+
"parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION "
451+
"to get a typed-pointer-to-an-array in memory, and will display "
452+
"COUNT elements of that type from the array.");
453+
parray_alias->SetHelpLong("");
454+
}
455+
CommandAlias *poarray_alias = AddAlias(
456+
"poarray", cmd_obj_sp, "--object-description --element-count %1 --");
458457
if (poarray_alias) {
459-
poarray_alias->SetHelp("poarray <COUNT> <EXPRESSION> -- lldb will "
458+
poarray_alias->SetHelp(
459+
"poarray <COUNT> <EXPRESSION> -- lldb will "
460460
"evaluate EXPRESSION to get the address of an array of COUNT "
461461
"objects in memory, and will call po on them.");
462462
poarray_alias->SetHelpLong("");
@@ -536,9 +536,7 @@ void CommandInterpreter::Initialize() {
536536
}
537537
}
538538

539-
void CommandInterpreter::Clear() {
540-
m_command_io_handler_sp.reset();
541-
}
539+
void CommandInterpreter::Clear() { m_command_io_handler_sp.reset(); }
542540

543541
const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {
544542
// This function has not yet been implemented.
@@ -851,9 +849,12 @@ void CommandInterpreter::LoadCommandDictionary() {
851849
// now "bt 3" is the preferred form, in line with gdb.
852850
if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$",
853851
"thread backtrace -c %1") &&
854-
bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$", "thread backtrace %1") &&
855-
bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
856-
bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
852+
bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$",
853+
"thread backtrace %1") &&
854+
bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$",
855+
"thread backtrace all") &&
856+
bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$",
857+
"thread backtrace")) {
857858
CommandObjectSP command_sp(bt_regex_cmd_up.release());
858859
m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
859860
}
@@ -954,13 +955,14 @@ int CommandInterpreter::GetCommandNamesMatchingPartialString(
954955
return matches.GetSize();
955956
}
956957

957-
CommandObjectMultiword *CommandInterpreter::VerifyUserMultiwordCmdPath(
958-
Args &path, bool leaf_is_command, Status &result) {
958+
CommandObjectMultiword *
959+
CommandInterpreter::VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command,
960+
Status &result) {
959961
result.Clear();
960962

961963
auto get_multi_or_report_error =
962964
[&result](CommandObjectSP cmd_sp,
963-
const char *name) -> CommandObjectMultiword * {
965+
const char *name) -> CommandObjectMultiword * {
964966
if (!cmd_sp) {
965967
result = Status::FromErrorStringWithFormat(
966968
"Path component: '%s' not found", name);
@@ -1265,8 +1267,8 @@ CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
12651267
// Try to find a match among commands and aliases. Allowing inexact matches,
12661268
// but perferring exact matches.
12671269
return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false,
1268-
matches, descriptions)
1269-
.get();
1270+
matches, descriptions)
1271+
.get();
12701272
}
12711273

12721274
CommandObject *CommandInterpreter::GetUserCommandObject(
@@ -1299,8 +1301,8 @@ CommandObject *CommandInterpreter::GetUserCommandObject(
12991301
StringList tmp_list;
13001302
StringList *matches_ptr = matches ? matches : &tmp_list;
13011303
AddNamesMatchingPartialString(GetUserCommands(), cmd_str, *matches_ptr);
1302-
AddNamesMatchingPartialString(GetUserMultiwordCommands(),
1303-
cmd_str, *matches_ptr);
1304+
AddNamesMatchingPartialString(GetUserMultiwordCommands(), cmd_str,
1305+
*matches_ptr);
13041306

13051307
return {};
13061308
}
@@ -1798,8 +1800,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
17981800
return error;
17991801
}
18001802

1801-
Status
1802-
CommandInterpreter::PreprocessToken(std::string &expr_str) {
1803+
Status CommandInterpreter::PreprocessToken(std::string &expr_str) {
18031804
Status error;
18041805
ExecutionContext exe_ctx(GetExecutionContext());
18051806

@@ -1819,9 +1820,8 @@ CommandInterpreter::PreprocessToken(std::string &expr_str) {
18191820
options.SetTryAllThreads(true);
18201821
options.SetTimeout(std::nullopt);
18211822

1822-
ExpressionResults expr_result =
1823-
target.EvaluateExpression(expr_str.c_str(), exe_ctx.GetFramePtr(),
1824-
expr_result_valobj_sp, options);
1823+
ExpressionResults expr_result = target.EvaluateExpression(
1824+
expr_str.c_str(), exe_ctx.GetFramePtr(), expr_result_valobj_sp, options);
18251825

18261826
if (expr_result == eExpressionCompleted) {
18271827
Scalar scalar;
@@ -1890,7 +1890,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
18901890

18911891
Log *log = GetLog(LLDBLog::Commands);
18921892
llvm::PrettyStackTraceFormat stack_trace("HandleCommand(command = \"%s\")",
1893-
command_line);
1893+
command_line);
18941894

18951895
LLDB_LOGF(log, "Processing command: %s", command_line);
18961896
LLDB_SCOPED_TIMERF("Processing command: %s.", command_line);
@@ -2011,7 +2011,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
20112011
// has the command expanded to the full name. For example, if the input was
20122012
// "br s -n main", command_string is now "breakpoint set -n main".
20132013
if (log) {
2014-
llvm::StringRef command_name = cmd_obj ? cmd_obj->GetCommandName() : "<not found>";
2014+
llvm::StringRef command_name =
2015+
cmd_obj ? cmd_obj->GetCommandName() : "<not found>";
20152016
LLDB_LOGF(log, "HandleCommand, cmd_obj : '%s'", command_name.str().c_str());
20162017
LLDB_LOGF(log, "HandleCommand, (revised) command_string: '%s'",
20172018
command_string.c_str());
@@ -2216,11 +2217,15 @@ CommandInterpreter::GetAlias(llvm::StringRef alias_name) const {
22162217
return nullptr;
22172218
}
22182219

2219-
bool CommandInterpreter::HasCommands() const { return (!m_command_dict.empty()); }
2220+
bool CommandInterpreter::HasCommands() const {
2221+
return (!m_command_dict.empty());
2222+
}
22202223

22212224
bool CommandInterpreter::HasAliases() const { return (!m_alias_dict.empty()); }
22222225

2223-
bool CommandInterpreter::HasUserCommands() const { return (!m_user_dict.empty()); }
2226+
bool CommandInterpreter::HasUserCommands() const {
2227+
return (!m_user_dict.empty());
2228+
}
22242229

22252230
bool CommandInterpreter::HasUserMultiwordCommands() const {
22262231
return (!m_user_mw_dict.empty());
@@ -2578,20 +2583,18 @@ bool CommandInterpreter::DidProcessStopAbnormally() const {
25782583
return false;
25792584
}
25802585

2581-
void
2582-
CommandInterpreter::HandleCommands(const StringList &commands,
2583-
const ExecutionContext &override_context,
2584-
const CommandInterpreterRunOptions &options,
2585-
CommandReturnObject &result) {
2586+
void CommandInterpreter::HandleCommands(
2587+
const StringList &commands, const ExecutionContext &override_context,
2588+
const CommandInterpreterRunOptions &options, CommandReturnObject &result) {
25862589

25872590
OverrideExecutionContext(override_context);
25882591
HandleCommands(commands, options, result);
25892592
RestoreExecutionContext();
25902593
}
25912594

2592-
void CommandInterpreter::HandleCommands(const StringList &commands,
2593-
const CommandInterpreterRunOptions &options,
2594-
CommandReturnObject &result) {
2595+
void CommandInterpreter::HandleCommands(
2596+
const StringList &commands, const CommandInterpreterRunOptions &options,
2597+
CommandReturnObject &result) {
25952598
size_t num_lines = commands.GetSize();
25962599

25972600
// If we are going to continue past a "continue" then we need to run the
@@ -2728,8 +2731,9 @@ void CommandInterpreter::HandleCommandsFromFile(
27282731
RestoreExecutionContext();
27292732
}
27302733

2731-
void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file,
2732-
const CommandInterpreterRunOptions &options, CommandReturnObject &result) {
2734+
void CommandInterpreter::HandleCommandsFromFile(
2735+
FileSpec &cmd_file, const CommandInterpreterRunOptions &options,
2736+
CommandReturnObject &result) {
27332737
if (!FileSystem::Instance().Exists(cmd_file)) {
27342738
result.AppendErrorWithFormat(
27352739
"Error reading commands from file %s - file not found.\n",
@@ -3134,9 +3138,9 @@ bool CommandInterpreter::EchoCommandNonInteractive(
31343138

31353139
void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
31363140
std::string &line) {
3137-
// If we were interrupted, bail out...
3138-
if (WasInterrupted())
3139-
return;
3141+
// If we were interrupted, bail out...
3142+
if (WasInterrupted())
3143+
return;
31403144

31413145
const bool is_interactive = io_handler.GetIsInteractive();
31423146
const bool allow_repeats =

0 commit comments

Comments
 (0)