[Lldb-commits] [lldb] r182068 - Apropos should search user commands as well as built-in commands.
Jim Ingham
jingham at apple.com
Thu May 16 18:30:38 PDT 2013
Author: jingham
Date: Thu May 16 20:30:37 2013
New Revision: 182068
URL: http://llvm.org/viewvc/llvm-project?rev=182068&view=rev
Log:
Apropos should search user commands as well as built-in commands.
rdar://problem/13916722
Modified:
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/source/Commands/CommandObjectApropos.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=182068&r1=182067&r2=182068&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Thu May 16 20:30:37 2013
@@ -396,7 +396,9 @@ public:
void
FindCommandsForApropos (const char *word,
StringList &commands_found,
- StringList &commands_help);
+ StringList &commands_help,
+ bool search_builtin_commands,
+ bool search_user_commands);
bool
GetBatchCommandMode () { return m_batch_command_mode; }
Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=182068&r1=182067&r2=182068&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Thu May 16 20:30:37 2013
@@ -68,29 +68,59 @@ CommandObjectApropos::DoExecute (Args& a
// is private.
StringList commands_found;
StringList commands_help;
- m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help);
- if (commands_found.GetSize() == 0)
+ StringList user_commands_found;
+ StringList user_commands_help;
+
+ m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, false);
+ m_interpreter.FindCommandsForApropos (search_word, user_commands_found, user_commands_help, false, true);
+
+ if (commands_found.GetSize() == 0 && user_commands_found.GetSize() == 0)
{
result.AppendMessageWithFormat ("No commands found pertaining to '%s'. Try 'help' to see a complete list of debugger commands.\n", search_word);
}
else
{
- result.AppendMessageWithFormat ("The following commands may relate to '%s':\n", search_word);
- size_t max_len = 0;
-
- for (size_t i = 0; i < commands_found.GetSize(); ++i)
+ if (commands_found.GetSize() > 0)
{
- size_t len = strlen (commands_found.GetStringAtIndex (i));
- if (len > max_len)
- max_len = len;
+ result.AppendMessageWithFormat ("The following built-in commands may relate to '%s':\n", search_word);
+ size_t max_len = 0;
+
+ for (size_t i = 0; i < commands_found.GetSize(); ++i)
+ {
+ size_t len = strlen (commands_found.GetStringAtIndex (i));
+ if (len > max_len)
+ max_len = len;
+ }
+
+ for (size_t i = 0; i < commands_found.GetSize(); ++i)
+ m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
+ commands_found.GetStringAtIndex(i),
+ "--",
+ commands_help.GetStringAtIndex(i),
+ max_len);
+ if (user_commands_found.GetSize() > 0)
+ result.AppendMessage("");
}
+
+ if (user_commands_found.GetSize() > 0)
+ {
+ result.AppendMessageWithFormat ("The following user commands may relate to '%s':\n", search_word);
+ size_t max_len = 0;
- for (size_t i = 0; i < commands_found.GetSize(); ++i)
- m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
- commands_found.GetStringAtIndex(i),
- "--",
- commands_help.GetStringAtIndex(i),
- max_len);
+ for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
+ {
+ size_t len = strlen (user_commands_found.GetStringAtIndex (i));
+ if (len > max_len)
+ max_len = len;
+ }
+
+ for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
+ m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
+ user_commands_found.GetStringAtIndex(i),
+ "--",
+ user_commands_help.GetStringAtIndex(i),
+ max_len);
+ }
}
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=182068&r1=182067&r2=182068&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu May 16 20:30:37 2013
@@ -2804,27 +2804,52 @@ CommandInterpreter::OutputHelpText (Stre
void
CommandInterpreter::FindCommandsForApropos (const char *search_word, StringList &commands_found,
- StringList &commands_help)
+ StringList &commands_help, bool search_builtin_commands, bool search_user_commands)
{
CommandObject::CommandMap::const_iterator pos;
- for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos)
+ if (search_builtin_commands)
{
- const char *command_name = pos->first.c_str();
- CommandObject *cmd_obj = pos->second.get();
-
- if (cmd_obj->HelpTextContainsWord (search_word))
+ for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos)
{
- commands_found.AppendString (command_name);
- commands_help.AppendString (cmd_obj->GetHelp());
+ const char *command_name = pos->first.c_str();
+ CommandObject *cmd_obj = pos->second.get();
+
+ if (cmd_obj->HelpTextContainsWord (search_word))
+ {
+ commands_found.AppendString (command_name);
+ commands_help.AppendString (cmd_obj->GetHelp());
+ }
+
+ if (cmd_obj->IsMultiwordObject())
+ cmd_obj->AproposAllSubCommands (command_name,
+ search_word,
+ commands_found,
+ commands_help);
+
}
+ }
+
+ if (search_user_commands)
+ {
+ for (pos = m_user_dict.begin(); pos != m_user_dict.end(); ++pos)
+ {
+ const char *command_name = pos->first.c_str();
+ CommandObject *cmd_obj = pos->second.get();
- if (cmd_obj->IsMultiwordObject())
- cmd_obj->AproposAllSubCommands (command_name,
- search_word,
- commands_found,
- commands_help);
-
+ if (cmd_obj->HelpTextContainsWord (search_word))
+ {
+ commands_found.AppendString (command_name);
+ commands_help.AppendString (cmd_obj->GetHelp());
+ }
+
+ if (cmd_obj->IsMultiwordObject())
+ cmd_obj->AproposAllSubCommands (command_name,
+ search_word,
+ commands_found,
+ commands_help);
+
+ }
}
}
More information about the lldb-commits
mailing list