[Lldb-commits] [lldb] r178597 - Allow partial matching for alias commands as well as regular commands.
Jim Ingham
jingham at apple.com
Tue Apr 2 17:25:49 PDT 2013
Author: jingham
Date: Tue Apr 2 19:25:49 2013
New Revision: 178597
URL: http://llvm.org/viewvc/llvm-project?rev=178597&view=rev
Log:
Allow partial matching for alias commands as well as regular commands.
<rdar://problem/13552724>
Modified:
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
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=178597&r1=178596&r2=178597&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Apr 2 19:25:49 2013
@@ -114,6 +114,9 @@ public:
bool
RemoveAlias (const char *alias_name);
+
+ bool
+ GetAliasFullName (const char *cmd, std::string &full_name);
bool
RemoveUser (const char *alias_name);
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=178597&r1=178596&r2=178597&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Apr 2 19:25:49 2013
@@ -331,11 +331,7 @@ CommandInterpreter::Initialize ()
{
alias_arguments_vector_sp.reset (new OptionArgVector);
ProcessAliasOptionsArgs (cmd_obj_sp, "--func-regex %1", alias_arguments_vector_sp);
- AddAlias ("rb", cmd_obj_sp);
- AddAlias ("rbr", cmd_obj_sp);
AddAlias ("rbreak", cmd_obj_sp);
- AddOrReplaceAliasOptions("rb", alias_arguments_vector_sp);
- AddOrReplaceAliasOptions("rbr", alias_arguments_vector_sp);
AddOrReplaceAliasOptions("rbreak", alias_arguments_vector_sp);
}
}
@@ -923,6 +919,40 @@ CommandInterpreter::ProcessAliasOptionsA
}
bool
+CommandInterpreter::GetAliasFullName (const char *cmd, std::string &full_name)
+{
+ bool exact_match = (m_alias_dict.find(cmd) != m_alias_dict.end());
+ if (exact_match)
+ {
+ full_name.assign(cmd);
+ return exact_match;
+ }
+ else
+ {
+ StringList matches;
+ size_t num_alias_matches;
+ num_alias_matches = CommandObject::AddNamesMatchingPartialString (m_alias_dict, cmd, matches);
+ if (num_alias_matches == 1)
+ {
+ // Make sure this isn't shadowing a command in the regular command space:
+ StringList regular_matches;
+ const bool include_aliases = false;
+ const bool exact = false;
+ CommandObjectSP cmd_obj_sp(GetCommandSP (cmd, include_aliases, exact, ®ular_matches));
+ if (cmd_obj_sp || regular_matches.GetSize() > 0)
+ return false;
+ else
+ {
+ full_name.assign (matches.GetStringAtIndex(0));
+ return true;
+ }
+ }
+ else
+ return false;
+ }
+}
+
+bool
CommandInterpreter::AliasExists (const char *cmd)
{
return m_alias_dict.find(cmd) != m_alias_dict.end();
@@ -1574,10 +1604,11 @@ CommandInterpreter::HandleCommand (const
ExtractCommand (command_string, next_word, suffix, quote_char);
if (cmd_obj == NULL)
{
- if (AliasExists (next_word.c_str()))
+ std::string full_name;
+ if (GetAliasFullName(next_word.c_str(), full_name))
{
std::string alias_result;
- cmd_obj = BuildAliasResult (next_word.c_str(), command_string, alias_result, result);
+ cmd_obj = BuildAliasResult (full_name.c_str(), command_string, alias_result, result);
revised_command_line.Printf ("%s", alias_result.c_str());
if (cmd_obj)
{
More information about the lldb-commits
mailing list