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/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index 46a53c7..2528651 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -29,44 +29,31 @@
PlatformSP
-PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter,
- const char *platform_name,
- bool select,
- Error& error)
+PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool select, Error& error)
{
- if (platform_name && platform_name[0])
+ PlatformSP platform_sp;
+ if (!platform_name.empty())
{
- if (platform_sp)
- {
- error.SetErrorString ("platform can't be set more than once in a command");
- return PlatformSP();
- }
-
- platform_sp = Platform::Create (platform_name, error);
+ platform_sp = Platform::Create (platform_name.c_str(), error);
if (platform_sp)
{
- interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select);
- if (os_version_major != UINT32_MAX)
- {
- platform_sp->SetOSVersion (os_version_major,
- os_version_minor,
- os_version_update);
- }
+ interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select);
+ if (os_version_major != UINT32_MAX)
+ {
+ platform_sp->SetOSVersion (os_version_major,
+ os_version_minor,
+ os_version_update);
+ }
}
}
- else
- {
- error.SetErrorString ("invalid platform name");
- platform_sp.reset();
- }
return platform_sp;
}
void
PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
{
- platform_sp.reset();
+ platform_name.clear();
os_version_major = UINT32_MAX;
os_version_minor = UINT32_MAX;
os_version_update = UINT32_MAX;
@@ -75,7 +62,7 @@
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypeNone, "Specify name of the platform to use for this target, creating the platform if necessary."},
+ { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."},
{ LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }
};
@@ -112,19 +99,12 @@
switch (short_option)
{
case 'p':
- CreatePlatformWithOptions (interpreter, option_arg, true, error);
+ platform_name.assign (option_arg);
break;
case 'v':
if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg)
- {
error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
- }
- else
- {
- if (platform_sp)
- platform_sp->SetOSVersion (os_version_major, os_version_minor, os_version_update);
- }
break;
default:
@@ -149,7 +129,7 @@
m_option_group (interpreter),
m_platform_options (false) // Don't include the "--platform" option by passing false
{
- m_option_group.Append (&m_platform_options);
+ m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, 1);
m_option_group.Finalize();
}
@@ -161,16 +141,31 @@
virtual bool
Execute (Args& args, CommandReturnObject &result)
{
- Error error;
if (args.GetArgumentCount() == 1)
{
- const bool select = true;
- PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter,
- args.GetArgumentAtIndex (0),
- select,
- error));
- if (platform_sp)
- platform_sp->GetStatus (result.GetOutputStream());
+ const char *platform_name = args.GetArgumentAtIndex (0);
+ if (platform_name && platform_name[0])
+ {
+ const bool select = true;
+ m_platform_options.platform_name.assign (platform_name);
+ Error error;
+ PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, select, error));
+ if (platform_sp)
+ {
+ platform_sp->GetStatus (result.GetOutputStream());
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendError(error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ result.AppendError ("invalid platform name");
+ result.SetStatus (eReturnStatusFailed);
+ }
}
else
{