summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-10-13 02:07:45 +0000
committerGreg Clayton <gclayton@apple.com>2012-10-13 02:07:45 +0000
commit998255bfe841a4191d458a56aae0267f673b1a72 (patch)
treeada5b24a203f1a24e041f9cce2188283d037de98 /lldb/source/Interpreter
parent88db3171dd5dcc54e3890b6f823c60831fc520a5 (diff)
downloadbcm5719-llvm-998255bfe841a4191d458a56aae0267f673b1a72.tar.gz
bcm5719-llvm-998255bfe841a4191d458a56aae0267f673b1a72.zip
<rdar://problem/12491387>
I added the ability for a process plug-in to implement custom commands. All the lldb_private::Process plug-in has to do is override: virtual CommandObject * GetPluginCommandObject(); This object returned should be a multi-word command that vends LLDB commands. There is a sample implementation in ProcessGDBRemote that is hollowed out. It is intended to be used for sending a custom packet, though the body of the command execute function has yet to be implemented! llvm-svn: 165861
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp42
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp16
2 files changed, 13 insertions, 45 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 56a9d1bcad3..453004d860e 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -763,8 +763,7 @@ CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliase
{
if (cmd_obj_sp->IsMultiwordObject())
{
- cmd_obj_sp = ((CommandObjectMultiword *) cmd_obj_sp.get())->GetSubcommandSP
- (cmd_words.GetArgumentAtIndex (j));
+ cmd_obj_sp = cmd_obj_sp->GetSubcommandSP (cmd_words.GetArgumentAtIndex (j));
if (cmd_obj_sp.get() == NULL)
// The sub-command name was invalid. Fail and return the empty 'ret_val'.
return ret_val;
@@ -1049,8 +1048,7 @@ CommandInterpreter::GetCommandObjectForCommand (std::string &command_string)
else if (cmd_obj->IsMultiwordObject ())
{
// Our current object is a multi-word object; see if the cmd_word is a valid sub-command for our object.
- CommandObject *sub_cmd_obj =
- ((CommandObjectMultiword *) cmd_obj)->GetSubcommandObject (cmd_word.c_str());
+ CommandObject *sub_cmd_obj = cmd_obj->GetSubcommandObject (cmd_word.c_str());
if (sub_cmd_obj)
cmd_obj = sub_cmd_obj;
else // cmd_word was not a valid sub-command word, so we are donee
@@ -1547,7 +1545,7 @@ CommandInterpreter::HandleCommand (const char *command_line,
{
if (cmd_obj->IsMultiwordObject ())
{
- CommandObject *sub_cmd_obj = ((CommandObjectMultiword *) cmd_obj)->GetSubcommandObject (next_word.c_str());
+ CommandObject *sub_cmd_obj = cmd_obj->GetSubcommandObject (next_word.c_str());
if (sub_cmd_obj)
{
actual_cmd_name_len += next_word.length() + 1;
@@ -2722,35 +2720,6 @@ CommandInterpreter::OutputHelpText (Stream &strm,
}
void
-CommandInterpreter::AproposAllSubCommands (CommandObject *cmd_obj, const char *prefix, const char *search_word,
- StringList &commands_found, StringList &commands_help)
-{
- CommandObject::CommandMap::const_iterator pos;
- CommandObject::CommandMap sub_cmd_dict = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict;
- CommandObject *sub_cmd_obj;
-
- for (pos = sub_cmd_dict.begin(); pos != sub_cmd_dict.end(); ++pos)
- {
- const char * command_name = pos->first.c_str();
- sub_cmd_obj = pos->second.get();
- StreamString complete_command_name;
-
- complete_command_name.Printf ("%s %s", prefix, command_name);
-
- if (sub_cmd_obj->HelpTextContainsWord (search_word))
- {
- commands_found.AppendString (complete_command_name.GetData());
- commands_help.AppendString (sub_cmd_obj->GetHelp());
- }
-
- if (sub_cmd_obj->IsMultiwordObject())
- AproposAllSubCommands (sub_cmd_obj, complete_command_name.GetData(), search_word, commands_found,
- commands_help);
- }
-
-}
-
-void
CommandInterpreter::FindCommandsForApropos (const char *search_word, StringList &commands_found,
StringList &commands_help)
{
@@ -2768,7 +2737,10 @@ CommandInterpreter::FindCommandsForApropos (const char *search_word, StringList
}
if (cmd_obj->IsMultiwordObject())
- AproposAllSubCommands (cmd_obj, command_name, search_word, commands_found, commands_help);
+ cmd_obj->AproposAllSubCommands (command_name,
+ search_word,
+ commands_found,
+ commands_help);
}
}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 11e90f243df..8d8520d8085 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -377,23 +377,19 @@ CommandObject::HandleCompletion
bool
CommandObject::HelpTextContainsWord (const char *search_word)
{
- const char *short_help;
- const char *long_help;
- const char *syntax_help;
std::string options_usage_help;
-
bool found_word = false;
- short_help = GetHelp();
- long_help = GetHelpLong();
- syntax_help = GetSyntax();
+ const char *short_help = GetHelp();
+ const char *long_help = GetHelpLong();
+ const char *syntax_help = GetSyntax();
- if (strcasestr (short_help, search_word))
+ if (short_help && strcasestr (short_help, search_word))
found_word = true;
- else if (strcasestr (long_help, search_word))
+ else if (long_help && strcasestr (long_help, search_word))
found_word = true;
- else if (strcasestr (syntax_help, search_word))
+ else if (syntax_help && strcasestr (syntax_help, search_word))
found_word = true;
if (!found_word
OpenPOWER on IntegriCloud