diff options
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandInterpreter.h | 4 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectApropos.cpp | 62 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 53 |
3 files changed, 88 insertions, 31 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 15911b4d6ba..a2155882e27 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -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; } diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index 2eeec78e4b0..02dc7269775 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -68,29 +68,59 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result) // 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 < 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); } - - 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); } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 7860edaaa6f..a57db4860b9 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2804,27 +2804,52 @@ CommandInterpreter::OutputHelpText (Stream &strm, 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); + + } } } |