Added auto completion for architecture names and for platforms.
Modified the OptionGroupOptions to be able to specify only some of the options
that should be appended by using the usage_mask in the group defintions and
also provided a way to remap them to a new usage mask after the copy. This
allows options to be re-used and also targetted for specific option groups.
Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration.
Taught the option parser to be able to automatically use the appropriate
auto completion for a given options if nothing is explicitly specified
in the option definition. So you don't have to specify it in the option
definition tables.
Renamed the default host platform name to "host", and the default platform
hostname to be "localhost".
Modified the "file" and "platform select" commands to make sure all options
and args are good prior to creating a new platform. Also defer the computation
of the architecture in the file command until all options are parsed and the
platform has either not been specified or reset to a new value to avoid
computing the arch more than once.
Switch the PluginManager code over to using llvm::StringRef for string
comparisons and got rid of all the AccessorXXX functions in lieu of the newer
mutex + collection singleton accessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129483 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index baf4fcb..76cee5a 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -650,7 +650,7 @@
{ eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "A valid address in the target program's execution space." },
{ eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, NULL, "The name of an abbreviation (alias) for a debugger command." },
{ eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" },
- { eArgTypeArchitecture, "arch", CommandCompletions::eNoCompletion, NULL, "The architecture name, e.g. i386 or x86_64." },
+ { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, NULL, "The architecture name, e.g. i386 or x86_64." },
{ eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" },
{ eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL },
{ eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL },
@@ -707,6 +707,7 @@
{ eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "A value could be anything, depending on where and how it is used." },
{ eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." },
{ eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "No help available for this." },
+ { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, NULL, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }
};
const CommandObject::ArgumentTableEntry*
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index 8f1e10a..d6b30ed 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -11,8 +11,9 @@
// C Includes
// C++ Includes
-#include <bitset>
#include <algorithm>
+#include <bitset>
+#include <set>
// Other libraries and framework includes
// Project includes
@@ -853,7 +854,19 @@
// for that shared library.
// FIXME: Do we want to also have an "OptionType" so we don't have to match string names?
- uint32_t completion_mask = opt_defs[opt_defs_index].completionType;
+ uint32_t completion_mask = opt_defs[opt_defs_index].completion_type;
+
+ if (completion_mask == 0)
+ {
+ lldb::CommandArgumentType option_arg_type = opt_defs[opt_defs_index].argument_type;
+ if (option_arg_type != eArgTypeNone)
+ {
+ CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type);
+ if (arg_entry)
+ completion_mask = arg_entry->completion_type;
+ }
+ }
+
if (completion_mask & CommandCompletions::eSourceFileCompletion
|| completion_mask & CommandCompletions::eSymbolCompletion)
{
@@ -893,28 +906,21 @@
}
-
-
void
-OptionGroupOptions::Append (OptionGroup* group)
+OptionGroupOptions::Append (OptionGroup* group,
+ uint32_t src_mask,
+ uint32_t dst_mask)
{
- m_option_groups.push_back (group);
- const OptionDefinition* group_option_defs = group->GetDefinitions ();
- const uint32_t group_option_count = group->GetNumDefinitions();
- for (uint32_t i=0; i<group_option_count; ++i)
- m_option_defs.push_back (group_option_defs[i]);
-}
-
-void
-OptionGroupOptions::Append (OptionGroup* group, uint32_t usage_mask)
-{
- m_option_groups.push_back (group);
const OptionDefinition* group_option_defs = group->GetDefinitions ();
const uint32_t group_option_count = group->GetNumDefinitions();
for (uint32_t i=0; i<group_option_count; ++i)
{
- m_option_defs.push_back (group_option_defs[i]);
- m_option_defs.back().usage_mask = usage_mask;
+ if (group_option_defs[i].usage_mask & src_mask)
+ {
+ m_option_infos.push_back (OptionInfo (group, i));
+ m_option_defs.push_back (group_option_defs[i]);
+ m_option_defs.back().usage_mask = dst_mask;
+ }
}
}
@@ -933,38 +939,53 @@
// After calling OptionGroupOptions::Append(...), you must finalize the groups
// by calling OptionGroupOptions::Finlize()
assert (m_did_finalize);
-
- uint32_t curr_idx = 0;
- OptionGroupsType::iterator pos, end = m_option_groups.end();
- for (pos = m_option_groups.begin(); pos != end; ++pos)
- {
- const uint32_t num_group_definitions = (*pos)->GetNumDefinitions();
- if (option_idx < curr_idx + num_group_definitions)
- return (*pos)->SetOptionValue (m_interpreter, option_idx - curr_idx, option_value);
- curr_idx += num_group_definitions;
- }
+ assert (m_option_infos.size() + 1 == m_option_defs.size());
Error error;
- error.SetErrorString ("invalid option index"); // Shouldn't happen...
+ if (option_idx < m_option_infos.size())
+ {
+ error = m_option_infos[option_idx].option_group->SetOptionValue (m_interpreter,
+ m_option_infos[option_idx].option_index,
+ option_value);
+
+ }
+ else
+ {
+ error.SetErrorString ("invalid option index"); // Shouldn't happen...
+ }
return error;
}
void
OptionGroupOptions::OptionParsingStarting ()
{
- OptionGroupsType::iterator pos, end = m_option_groups.end();
- for (pos = m_option_groups.begin(); pos != end; ++pos)
- (*pos)->OptionParsingStarting (m_interpreter);
+ std::set<OptionGroup*> group_set;
+ OptionInfos::iterator pos, end = m_option_infos.end();
+ for (pos = m_option_infos.begin(); pos != end; ++pos)
+ {
+ OptionGroup* group = pos->option_group;
+ if (group_set.find(group) == group_set.end())
+ {
+ group->OptionParsingStarting (m_interpreter);
+ group_set.insert(group);
+ }
+ }
}
Error
OptionGroupOptions::OptionParsingFinished ()
{
+ std::set<OptionGroup*> group_set;
Error error;
- OptionGroupsType::iterator pos, end = m_option_groups.end();
- for (pos = m_option_groups.begin(); pos != end; ++pos)
+ OptionInfos::iterator pos, end = m_option_infos.end();
+ for (pos = m_option_infos.begin(); pos != end; ++pos)
{
- error = (*pos)->OptionParsingFinished (m_interpreter);
- if (error.Fail())
- return error;
+ OptionGroup* group = pos->option_group;
+ if (group_set.find(group) == group_set.end())
+ {
+ error = group->OptionParsingFinished (m_interpreter);
+ group_set.insert(group);
+ if (error.Fail())
+ return error;
+ }
}
return error;
}