summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp33
-rw-r--r--lldb/source/Commands/CommandObjectFile.cpp83
-rw-r--r--lldb/source/Commands/CommandObjectFile.h60
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp37
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp81
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.h15
6 files changed, 177 insertions, 132 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index fcfc29b4e88..e57a8b41685 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -20,6 +20,7 @@
// Project includes
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/FileSpecList.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -38,6 +39,8 @@ CommandCompletions::g_common_completions[] =
{eSymbolCompletion, CommandCompletions::Symbols},
{eModuleCompletion, CommandCompletions::Modules},
{eSettingsNameCompletion, CommandCompletions::SettingsNames},
+ {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
+ {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
{eNoCompletion, NULL} // This one has to be last in the list.
};
@@ -413,6 +416,36 @@ CommandCompletions::SettingsNames (CommandInterpreter &interpreter,
//return matches.GetSize();
}
+
+int
+CommandCompletions::PlatformPluginNames (CommandInterpreter &interpreter,
+ const char *partial_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ lldb_private::StringList &matches)
+{
+ const uint32_t num_matches = PluginManager::AutoCompletePlatformName(partial_name, matches);
+ word_complete = num_matches == 1;
+ return num_matches;
+}
+
+int
+CommandCompletions::ArchitectureNames (CommandInterpreter &interpreter,
+ const char *partial_name,
+ int match_start_point,
+ int max_return_elements,
+ SearchFilter *searcher,
+ bool &word_complete,
+ lldb_private::StringList &matches)
+{
+ const uint32_t num_matches = ArchSpec::AutoComplete (partial_name, matches);
+ word_complete = num_matches == 1;
+ return num_matches;
+}
+
+
CommandCompletions::Completer::Completer
(
CommandInterpreter &interpreter,
diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp
index 372baf9e822..563cbe298dc 100644
--- a/lldb/source/Commands/CommandObjectFile.cpp
+++ b/lldb/source/Commands/CommandObjectFile.cpp
@@ -26,7 +26,6 @@ using namespace lldb;
using namespace lldb_private;
FileOptionGroup::FileOptionGroup() :
- m_arch (),
m_arch_str ()
{
}
@@ -53,6 +52,17 @@ FileOptionGroup::GetDefinitions ()
return g_file_option_table;
}
+bool
+FileOptionGroup::GetArchitecture (Platform *platform, ArchSpec &arch)
+{
+ if (m_arch_str.empty())
+ arch.Clear();
+ else
+ arch.SetTriple(m_arch_str.c_str(), platform);
+ return arch.IsValid();
+}
+
+
Error
FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
uint32_t option_idx,
@@ -64,17 +74,7 @@ FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
switch (short_option)
{
case 'a':
- {
- // Save the arch value in case we specify a platform after specifying the arch
- m_arch_str.assign (option_arg);
- // Check to see if we already have a platform?
- m_arch_platform_sp = interpreter.GetPlatform (false);
- ArchSpec option_arch (option_arg, m_arch_platform_sp.get());
- if (option_arch.IsValid())
- m_arch = option_arch;
- else
- error.SetErrorStringWithFormat ("Invalid arch string '%s'.\n", option_arg);
- }
+ m_arch_str.assign (option_arg);
break;
default:
@@ -88,26 +88,7 @@ FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
void
FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
{
- m_arch.Clear();
-}
-
-Error
-FileOptionGroup::OptionParsingFinished (CommandInterpreter &interpreter)
-{
- Error error;
- if (m_arch.IsValid())
- {
- PlatformSP curr_platform_sp (interpreter.GetPlatform (false));
- if (curr_platform_sp.get() != m_arch_platform_sp.get())
- {
- ArchSpec option_arch (m_arch_str.c_str(), curr_platform_sp.get());
- if (option_arch.IsValid())
- m_arch = option_arch;
- else
- error.SetErrorStringWithFormat ("invalid arch '%s' for platform '%s'", m_arch_str.c_str(), curr_platform_sp->GetName());
- }
- }
- return error;
+ m_arch_str.clear();
}
//-------------------------------------------------------------------------
@@ -136,8 +117,8 @@ CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) :
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg);
- m_option_group.Append (&m_file_options);
- m_option_group.Append (&m_platform_options);
+ m_option_group.Append (&m_file_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
@@ -164,18 +145,46 @@ CommandObjectFile::Execute
if (argc == 1)
{
FileSpec file_spec (file_path, true);
+
+ bool select = true;
+ PlatformSP platform_sp;
+
+ Error error;
+
+ if (!m_platform_options.platform_name.empty())
+ {
+ platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error);
+ if (!platform_sp)
+ {
+ result.AppendError(error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ ArchSpec file_arch;
+
+ if (!m_file_options.m_arch_str.empty())
+ {
+ if (!platform_sp)
+ platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ if (!m_file_options.GetArchitecture(platform_sp.get(), file_arch))
+ {
+ result.AppendErrorWithFormat("invalid architecture '%s'", m_file_options.m_arch_str.c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation())
{
result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path);
result.SetStatus (eReturnStatusFailed);
- return result.Succeeded();
+ return false;
}
TargetSP target_sp;
-
Debugger &debugger = m_interpreter.GetDebugger();
- Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_file_options.m_arch, true, target_sp);
+ error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp);
if (target_sp)
{
diff --git a/lldb/source/Commands/CommandObjectFile.h b/lldb/source/Commands/CommandObjectFile.h
index 1af88964f52..f3ef2d94a15 100644
--- a/lldb/source/Commands/CommandObjectFile.h
+++ b/lldb/source/Commands/CommandObjectFile.h
@@ -26,37 +26,35 @@ namespace lldb_private {
// CommandObjectFile
//-------------------------------------------------------------------------
- class FileOptionGroup : public OptionGroup
- {
- public:
-
- FileOptionGroup ();
-
- virtual
- ~FileOptionGroup ();
-
-
- virtual uint32_t
- GetNumDefinitions ();
-
- virtual const OptionDefinition*
- GetDefinitions ();
-
- virtual Error
- SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_value);
-
- virtual void
- OptionParsingStarting (CommandInterpreter &interpreter);
-
- virtual Error
- OptionParsingFinished (CommandInterpreter &interpreter);
-
- ArchSpec m_arch;
- lldb::PlatformSP m_arch_platform_sp; // The platform that was used to resolve m_arch
- std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
- };
+class FileOptionGroup : public OptionGroup
+{
+public:
+
+ FileOptionGroup ();
+
+ virtual
+ ~FileOptionGroup ();
+
+
+ virtual uint32_t
+ GetNumDefinitions ();
+
+ virtual const OptionDefinition*
+ GetDefinitions ();
+
+ virtual Error
+ SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_value);
+
+ virtual void
+ OptionParsingStarting (CommandInterpreter &interpreter);
+
+ bool
+ GetArchitecture (Platform *platform, ArchSpec &arch);
+
+ std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
+};
class CommandObjectFile : public CommandObject
{
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index e38b618bdb3..7dcfabc6617 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -42,16 +42,6 @@ using namespace lldb;
using namespace lldb_private;
-static LogChannelSP
-GetLogChannelPluginForChannel (const char *channel)
-{
- std::string log_channel_plugin_name(channel);
- log_channel_plugin_name += LogChannel::GetPluginSuffix();
- LogChannelSP log_channel_sp (LogChannel::FindPlugin (log_channel_plugin_name.c_str()));
- return log_channel_sp;
-}
-
-
class CommandObjectLogEnable : public CommandObject
{
public:
@@ -99,6 +89,27 @@ public:
return &m_options;
}
+// int
+// HandleArgumentCompletion (Args &input,
+// int &cursor_index,
+// int &cursor_char_position,
+// OptionElementVector &opt_element_vector,
+// int match_start_point,
+// int max_return_elements,
+// bool &word_complete,
+// StringList &matches)
+// {
+// std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+// completion_str.erase (cursor_char_position);
+//
+// if (cursor_index == 1)
+// {
+// //
+// Log::AutoCompleteChannelName (completion_str.c_str(), matches);
+// }
+// return matches.GetSize();
+// }
+//
virtual bool
Execute (Args& args,
CommandReturnObject &result)
@@ -141,7 +152,7 @@ public:
}
else
{
- LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+ LogChannelSP log_channel_sp (LogChannel::FindPlugin (channel.c_str()));
if (log_channel_sp)
{
if (log_channel_sp->Enable (log_stream_sp, log_options, &result.GetErrorStream(), args))
@@ -314,7 +325,7 @@ public:
}
else
{
- LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+ LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
if (log_channel_sp)
{
log_channel_sp->Disable(args, &result.GetErrorStream());
@@ -388,7 +399,7 @@ public:
}
else
{
- LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+ LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
if (log_channel_sp)
{
log_channel_sp->ListCategories(&result.GetOutputStream());
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 46a53c7139e..252865162a0 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -29,44 +29,31 @@ using namespace lldb_private;
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 @@ PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
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 @@ PlatformOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
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 @@ public:
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 @@ public:
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
{
diff --git a/lldb/source/Commands/CommandObjectPlatform.h b/lldb/source/Commands/CommandObjectPlatform.h
index 255fc3bb911..00199158666 100644
--- a/lldb/source/Commands/CommandObjectPlatform.h
+++ b/lldb/source/Commands/CommandObjectPlatform.h
@@ -49,11 +49,11 @@ class PlatformOptionGroup : public OptionGroup
public:
PlatformOptionGroup (bool include_platform_option) :
- m_include_platform_option (include_platform_option),
- platform_sp (),
+ platform_name (),
os_version_major (UINT32_MAX),
os_version_minor (UINT32_MAX),
- os_version_update (UINT32_MAX)
+ os_version_update (UINT32_MAX),
+ m_include_platform_option (include_platform_option)
{
}
@@ -74,17 +74,16 @@ public:
const char *option_value);
lldb::PlatformSP
- CreatePlatformWithOptions (CommandInterpreter &interpreter,
- const char *platform_name,
- bool select,
- Error& error);
+ CreatePlatformWithOptions (CommandInterpreter &interpreter,
+ bool select,
+ Error &error);
virtual void
OptionParsingStarting (CommandInterpreter &interpreter);
// Instance variables to hold the values for command options.
- lldb::PlatformSP platform_sp;
+ std::string platform_name;
uint32_t os_version_major;
uint32_t os_version_minor;
uint32_t os_version_update;
OpenPOWER on IntegriCloud