forked from OSchip/llvm-project
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. llvm-svn: 129483
This commit is contained in:
parent
a7773f719e
commit
ab65b34fdc
|
@ -142,6 +142,10 @@ public:
|
|||
const ArchSpec&
|
||||
operator= (const ArchSpec& rhs);
|
||||
|
||||
static uint32_t
|
||||
AutoComplete (const char *name,
|
||||
StringList &matches);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Returns a static string representing the current architecture.
|
||||
///
|
||||
|
|
|
@ -106,6 +106,13 @@ public:
|
|||
static void
|
||||
Terminate ();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Auto completion
|
||||
//------------------------------------------------------------------
|
||||
static void
|
||||
AutoCompleteChannelName (const char *channel_name,
|
||||
StringList &matches);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Member functions
|
||||
//------------------------------------------------------------------
|
||||
|
@ -193,9 +200,6 @@ public:
|
|||
virtual
|
||||
~LogChannel ();
|
||||
|
||||
static const char *
|
||||
GetPluginSuffix ();
|
||||
|
||||
static lldb::LogChannelSP
|
||||
FindPlugin (const char *plugin_name);
|
||||
|
||||
|
|
|
@ -192,6 +192,9 @@ public:
|
|||
static const char *
|
||||
GetPlatformPluginDescriptionAtIndex (uint32_t idx);
|
||||
|
||||
static uint32_t
|
||||
AutoCompletePlatformName (const char *partial_name,
|
||||
StringList &matches);
|
||||
//------------------------------------------------------------------
|
||||
// Process
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -38,16 +38,19 @@ public:
|
|||
lldb_private::StringList &matches); // The array of matches we return.
|
||||
typedef enum
|
||||
{
|
||||
eNoCompletion = 0,
|
||||
eSourceFileCompletion = (1 << 0),
|
||||
eDiskFileCompletion = (1 << 1),
|
||||
eDiskDirectoryCompletion = (1 << 2),
|
||||
eSymbolCompletion = (1 << 3),
|
||||
eModuleCompletion = (1 << 4),
|
||||
eSettingsNameCompletion = (1 << 5),
|
||||
eCustomCompletion = (1 << 6) // This item serves two purposes. It is the last element in the enum,
|
||||
// so you can add custom enums starting from here in your Option class.
|
||||
// Also if you & in this bit the base code will not process the option.
|
||||
eNoCompletion = 0u,
|
||||
eSourceFileCompletion = (1u << 0),
|
||||
eDiskFileCompletion = (1u << 1),
|
||||
eDiskDirectoryCompletion = (1u << 2),
|
||||
eSymbolCompletion = (1u << 3),
|
||||
eModuleCompletion = (1u << 4),
|
||||
eSettingsNameCompletion = (1u << 5),
|
||||
ePlatformPluginCompletion = (1u << 6),
|
||||
eArchitectureCompletion = (1u << 7),
|
||||
// This item serves two purposes. It is the last element in the enum,
|
||||
// so you can add custom enums starting from here in your Option class.
|
||||
// Also if you & in this bit the base code will not process the option.
|
||||
eCustomCompletion = (1u << 8)
|
||||
|
||||
} CommonCompletionTypes;
|
||||
|
||||
|
@ -122,6 +125,25 @@ public:
|
|||
bool &word_complete,
|
||||
lldb_private::StringList &matches);
|
||||
|
||||
static int
|
||||
PlatformPluginNames (CommandInterpreter &interpreter,
|
||||
const char *partial_file_name,
|
||||
int match_start_point,
|
||||
int max_return_elements,
|
||||
SearchFilter *searcher,
|
||||
bool &word_complete,
|
||||
lldb_private::StringList &matches);
|
||||
|
||||
|
||||
static int
|
||||
ArchitectureNames (CommandInterpreter &interpreter,
|
||||
const char *partial_file_name,
|
||||
int match_start_point,
|
||||
int max_return_elements,
|
||||
SearchFilter *searcher,
|
||||
bool &word_complete,
|
||||
lldb_private::StringList &matches);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// The Completer class is a convenient base class for building searchers
|
||||
// that go along with the SearchFilter passed to the standard Completer
|
||||
|
|
|
@ -382,7 +382,7 @@ protected:
|
|||
OptionGroupOptions (CommandInterpreter &interpreter) :
|
||||
Options (interpreter),
|
||||
m_option_defs (),
|
||||
m_option_groups (),
|
||||
m_option_infos (),
|
||||
m_did_finalize (false)
|
||||
{
|
||||
}
|
||||
|
@ -392,11 +392,32 @@ protected:
|
|||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/// Append options from a OptionGroup class.
|
||||
///
|
||||
/// Append options from \a group that have a usage mask that has any bits
|
||||
/// in "src_mask" set. After the option definition is copied into the
|
||||
/// options definitions in this class, set the usage_mask to "dst_mask".
|
||||
///
|
||||
/// @param[in] group
|
||||
/// A group of options to take option values from and copy their
|
||||
/// definitions into this class.
|
||||
///
|
||||
/// @param[in] src_mask
|
||||
/// When copying options from \a group, you might only want some of
|
||||
/// the options to be appended to this group. This mask allows you
|
||||
/// to control which options from \a group get added. It also allows
|
||||
/// you to specify the same options from \a group multiple times
|
||||
/// for different option sets.
|
||||
///
|
||||
/// @param[in] dst_mask
|
||||
/// Set the usage mask for any copied options to \a dst_mask after
|
||||
/// copying the option definition.
|
||||
//----------------------------------------------------------------------
|
||||
void
|
||||
Append (OptionGroup* group);
|
||||
|
||||
void
|
||||
Append (OptionGroup* group, uint32_t usage_mask);
|
||||
Append (OptionGroup* group,
|
||||
uint32_t src_mask,
|
||||
uint32_t dst_mask);
|
||||
|
||||
void
|
||||
Finalize ();
|
||||
|
@ -417,10 +438,20 @@ protected:
|
|||
assert (m_did_finalize);
|
||||
return &m_option_defs[0];
|
||||
}
|
||||
typedef std::vector<OptionGroup*> OptionGroupsType;
|
||||
struct OptionInfo
|
||||
{
|
||||
OptionInfo (OptionGroup* g, uint32_t i) :
|
||||
option_group (g),
|
||||
option_index (i)
|
||||
{
|
||||
}
|
||||
OptionGroup* option_group; // The group that this option came from
|
||||
uint32_t option_index; // The original option index from the OptionGroup
|
||||
};
|
||||
typedef std::vector<OptionInfo> OptionInfos;
|
||||
|
||||
std::vector<OptionDefinition> m_option_defs;
|
||||
OptionGroupsType m_option_groups;
|
||||
OptionInfos m_option_infos;
|
||||
bool m_did_finalize;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@ namespace lldb_private {
|
|||
static lldb::PlatformSP
|
||||
GetDefaultPlatform ();
|
||||
|
||||
static const char *
|
||||
GetHostPlatformName ();
|
||||
|
||||
static void
|
||||
SetDefaultPlatform (const lldb::PlatformSP &platform_sp);
|
||||
|
||||
|
|
|
@ -387,6 +387,7 @@ namespace lldb {
|
|||
eArgTypeValue,
|
||||
eArgTypeWidth,
|
||||
eArgTypeNone,
|
||||
eArgTypePlatform,
|
||||
eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!!
|
||||
} CommandArgumentType;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace lldb_private
|
|||
char short_option; // Single character for this option.
|
||||
int option_has_arg; // no_argument, required_argument or optional_argument
|
||||
OptionEnumValueElement *enum_values; // If non-NULL an array of enum values.
|
||||
uint32_t completionType; // Cookie the option class can use to do define the argument completion.
|
||||
uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
|
||||
lldb::CommandArgumentType argument_type; // Type of argument this option takes
|
||||
const char * usage_text; // Full text explaining what this options does and what (if any) argument to
|
||||
// pass it.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -165,17 +146,45 @@ CommandObjectFile::Execute
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -26,37 +26,35 @@ namespace lldb_private {
|
|||
// CommandObjectFile
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class FileOptionGroup : public OptionGroup
|
||||
{
|
||||
public:
|
||||
class FileOptionGroup : public OptionGroup
|
||||
{
|
||||
public:
|
||||
|
||||
FileOptionGroup ();
|
||||
FileOptionGroup ();
|
||||
|
||||
virtual
|
||||
~FileOptionGroup ();
|
||||
virtual
|
||||
~FileOptionGroup ();
|
||||
|
||||
|
||||
virtual uint32_t
|
||||
GetNumDefinitions ();
|
||||
virtual uint32_t
|
||||
GetNumDefinitions ();
|
||||
|
||||
virtual const OptionDefinition*
|
||||
GetDefinitions ();
|
||||
virtual const OptionDefinition*
|
||||
GetDefinitions ();
|
||||
|
||||
virtual Error
|
||||
SetOptionValue (CommandInterpreter &interpreter,
|
||||
uint32_t option_idx,
|
||||
const char *option_value);
|
||||
virtual Error
|
||||
SetOptionValue (CommandInterpreter &interpreter,
|
||||
uint32_t option_idx,
|
||||
const char *option_value);
|
||||
|
||||
virtual void
|
||||
OptionParsingStarting (CommandInterpreter &interpreter);
|
||||
virtual void
|
||||
OptionParsingStarting (CommandInterpreter &interpreter);
|
||||
|
||||
virtual Error
|
||||
OptionParsingFinished (CommandInterpreter &interpreter);
|
||||
bool
|
||||
GetArchitecture (Platform *platform, ArchSpec &arch);
|
||||
|
||||
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
|
||||
};
|
||||
std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
|
||||
};
|
||||
|
||||
class CommandObjectFile : public CommandObject
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -75,16 +75,15 @@ public:
|
|||
|
||||
lldb::PlatformSP
|
||||
CreatePlatformWithOptions (CommandInterpreter &interpreter,
|
||||
const char *platform_name,
|
||||
bool select,
|
||||
Error& error);
|
||||
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;
|
||||
|
|
|
@ -79,11 +79,11 @@ static const CoreDefinition g_core_definitions[ArchSpec::kNumCores] =
|
|||
{ eByteOrderLittle, 4, 4, 4, llvm::Triple::sparc , ArchSpec::eCore_sparc_generic , "sparc" },
|
||||
{ eByteOrderLittle, 8, 4, 4, llvm::Triple::sparcv9, ArchSpec::eCore_sparc9_generic , "sparcv9" },
|
||||
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" },
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" },
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" },
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" },
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" },
|
||||
{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" },
|
||||
|
||||
{ eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" }
|
||||
{ eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" }
|
||||
};
|
||||
|
||||
struct ArchDefinitionEntry
|
||||
|
@ -104,6 +104,28 @@ struct ArchDefinition
|
|||
};
|
||||
|
||||
|
||||
uint32_t
|
||||
ArchSpec::AutoComplete (const char *name, StringList &matches)
|
||||
{
|
||||
uint32_t i;
|
||||
if (name && name[0])
|
||||
{
|
||||
for (i = 0; i < ArchSpec::kNumCores; ++i)
|
||||
{
|
||||
if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
|
||||
matches.AppendString (g_core_definitions[i].name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < ArchSpec::kNumCores; ++i)
|
||||
matches.AppendString (g_core_definitions[i].name);
|
||||
}
|
||||
return matches.GetSize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CPU_ANY (UINT32_MAX)
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -381,6 +381,27 @@ Log::EnableAllLogChannels
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
Log::AutoCompleteChannelName (const char *channel_name, StringList &matches)
|
||||
{
|
||||
LogChannelMap &map = GetChannelMap ();
|
||||
LogChannelMapIter pos, end = map.end();
|
||||
for (pos = map.begin(); pos != end; ++pos)
|
||||
{
|
||||
const char *pos_channel_name = pos->first.GetCString();
|
||||
if (channel_name && channel_name[0])
|
||||
{
|
||||
if (NameMatches (channel_name, eNameMatchStartsWith, pos_channel_name))
|
||||
{
|
||||
matches.AppendString(pos_channel_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
matches.AppendString(pos_channel_name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Log::DisableAllLogChannels (Stream *feedback_strm)
|
||||
{
|
||||
|
@ -499,10 +520,4 @@ LogChannel::~LogChannel ()
|
|||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
LogChannel::GetPluginSuffix ()
|
||||
{
|
||||
return ".log-channel";
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -650,7 +650,7 @@ CommandObject::g_arguments_data[] =
|
|||
{ 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 @@ CommandObject::g_arguments_data[] =
|
|||
{ 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*
|
||||
|
|
|
@ -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 @@ Options::HandleOptionArgumentCompletion
|
|||
// 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 @@ Options::HandleOptionArgumentCompletion
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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 @@ OptionGroupOptions::SetOptionValue (uint32_t option_idx,
|
|||
// 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;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ const char *
|
|||
PlatformMacOSX::GetShortPluginNameStatic (bool is_host)
|
||||
{
|
||||
if (is_host)
|
||||
return "local-macosx";
|
||||
return Platform::GetHostPlatformName ();
|
||||
else
|
||||
return "remote-macosx";
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info)
|
|||
break;
|
||||
}
|
||||
}
|
||||
const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (3000); // TODO: lower this to 5 seconds prior to checkin!!!
|
||||
const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5);
|
||||
int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv);
|
||||
m_gdb_client.SetPacketTimeout (old_packet_timeout);
|
||||
if (arg_packet_err == 0)
|
||||
|
|
|
@ -54,16 +54,9 @@ LogChannelDWARF::CreateInstance ()
|
|||
const char *
|
||||
LogChannelDWARF::GetPluginNameStatic()
|
||||
{
|
||||
static std::string g_plugin_name;
|
||||
if (g_plugin_name.empty())
|
||||
{
|
||||
g_plugin_name = SymbolFileDWARF::GetPluginNameStatic();
|
||||
g_plugin_name += LogChannel::GetPluginSuffix ();
|
||||
}
|
||||
return g_plugin_name.c_str();
|
||||
return SymbolFileDWARF::GetPluginNameStatic();
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
LogChannelDWARF::GetPluginDescriptionStatic()
|
||||
{
|
||||
|
|
|
@ -46,6 +46,13 @@ GetConnectedPlatformList ()
|
|||
return g_remote_connected_platforms;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
Platform::GetHostPlatformName ()
|
||||
{
|
||||
return "host";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Get the native host platform plug-in.
|
||||
///
|
||||
|
@ -319,11 +326,8 @@ Platform::GetName ()
|
|||
const char *
|
||||
Platform::GetHostname ()
|
||||
{
|
||||
if (IsHost() && m_name.empty())
|
||||
{
|
||||
if (!Host::GetHostname(m_name))
|
||||
return "localhost";
|
||||
}
|
||||
if (IsHost())
|
||||
return "localhost";
|
||||
|
||||
if (m_name.empty())
|
||||
return NULL;
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef struct
|
|||
const char * long_option; // Full name for this option.
|
||||
char short_option; // Single character for this option.
|
||||
int option_has_arg; // no_argument, required_argument or optional_argument
|
||||
uint32_t completionType; // Cookie the option class can use to do define the argument completion.
|
||||
uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
|
||||
lldb::CommandArgumentType argument_type; // Type of argument this option takes
|
||||
const char * usage_text; // Full text explaining what this options does and what (if any) argument to
|
||||
// pass it.
|
||||
|
|
Loading…
Reference in New Issue