LLDB mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
lldb_private::Args Class Reference

A command line argument class. More...

#include "lldb/Utility/Args.h"

Classes

struct  ArgEntry
 

Public Types

using const_iterator = std::vector< ArgEntry >::const_iterator
 

Public Member Functions

 Args (llvm::StringRef command=llvm::StringRef())
 Construct with an option command string.
 
 Args (const Args &rhs)
 
 Args (const StringList &list)
 
 Args (llvm::ArrayRef< llvm::StringRef > args)
 
Argsoperator= (const Args &rhs)
 
 ~Args ()
 Destructor.
 
 Args (const Environment &env)
 
 operator Environment () const
 
void Dump (Stream &s, const char *label_name="argv") const
 Dump all entries to the stream s using label label_name.
 
void SetCommandString (llvm::StringRef command)
 Sets the command string contained by this object.
 
bool GetCommandString (std::string &command) const
 
bool GetQuotedCommandString (std::string &command) const
 
size_t GetArgumentCount () const
 Gets the number of arguments left in this command object.
 
bool empty () const
 
const char * GetArgumentAtIndex (size_t idx) const
 Gets the NULL terminated C string argument pointer for the argument at index idx.
 
llvm::ArrayRef< ArgEntryentries () const
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
const ArgEntryoperator[] (size_t n) const
 
char ** GetArgumentVector ()
 Gets the argument vector.
 
const char ** GetConstArgumentVector () const
 Gets the argument vector.
 
llvm::ArrayRef< const char * > GetArgumentArrayRef () const
 Gets the argument as an ArrayRef.
 
void AppendArgument (llvm::StringRef arg_str, char quote_char='\0')
 Appends a new argument to the end of the list argument list.
 
void AppendArguments (const Args &rhs)
 
void AppendArguments (const char **argv)
 
void InsertArgumentAtIndex (size_t idx, llvm::StringRef arg_str, char quote_char='\0')
 Insert the argument value at index idx to arg_str.
 
void ReplaceArgumentAtIndex (size_t idx, llvm::StringRef arg_str, char quote_char='\0')
 Replaces the argument value at index idx to arg_str if idx is a valid argument index.
 
void DeleteArgumentAtIndex (size_t idx)
 Deletes the argument value at index if idx is a valid argument index.
 
void SetArguments (size_t argc, const char **argv)
 Sets the argument vector value, optionally copying all arguments into an internal buffer.
 
void SetArguments (const char **argv)
 
void Shift ()
 Shifts the first argument C string value of the array off the argument array.
 
void Unshift (llvm::StringRef arg_str, char quote_char='\0')
 Inserts a class owned copy of arg_str at the beginning of the argument vector.
 
void Clear ()
 Clear the arguments.
 

Static Public Member Functions

static lldb::Encoding StringToEncoding (llvm::StringRef s, lldb::Encoding fail_value=lldb::eEncodingInvalid)
 
static uint32_t StringToGenericRegister (llvm::StringRef s)
 
static std::string GetShellSafeArgument (const FileSpec &shell, llvm::StringRef unsafe_arg)
 
static void EncodeEscapeSequences (const char *src, std::string &dst)
 EncodeEscapeSequences will change the textual representation of common escape sequences like "\n" (two characters) into a single '
'.
 
static void ExpandEscapedCharacters (const char *src, std::string &dst)
 ExpandEscapeSequences will change a string of possibly non-printable characters and expand them into text.
 
static std::string EscapeLLDBCommandArgument (const std::string &arg, char quote_char)
 

Private Attributes

std::vector< ArgEntrym_entries
 
std::vector< char * > m_argv
 The arguments as C strings with a trailing nullptr element.
 

Detailed Description

A command line argument class.

The Args class is designed to be fed a command line. The command line is copied into an internal buffer and then split up into arguments. Arguments are space delimited if there are no quotes (single, double, or backtick quotes) surrounding the argument. Spaces can be escaped using a \ character to avoid having to surround an argument that contains a space with quotes.

Definition at line 33 of file Args.h.

Member Typedef Documentation

◆ const_iterator

using lldb_private::Args::const_iterator = std::vector<ArgEntry>::const_iterator

Definition at line 130 of file Args.h.

Constructor & Destructor Documentation

◆ Args() [1/5]

Args::Args ( llvm::StringRef  command = llvm::StringRef())

Construct with an option command string.

Parameters
[in]commandA NULL terminated command that will be copied and split up into arguments.
See also
Args::SetCommandString(llvm::StringRef)

Definition at line 168 of file Args.cpp.

References SetCommandString().

◆ Args() [2/5]

Args::Args ( const Args rhs)

Definition at line 170 of file Args.cpp.

◆ Args() [3/5]

Args::Args ( const StringList list)
explicit

Definition at line 172 of file Args.cpp.

References AppendArgument().

◆ Args() [4/5]

Args::Args ( llvm::ArrayRef< llvm::StringRef >  args)
explicit

Definition at line 177 of file Args.cpp.

References AppendArgument().

◆ ~Args()

Args::~Args ( )
default

Destructor.

◆ Args() [5/5]

lldb_private::Args::Args ( const Environment env)
inlineexplicit

Member Function Documentation

◆ AppendArgument()

void Args::AppendArgument ( llvm::StringRef  arg_str,
char  quote_char = '\0' 
)

Appends a new argument to the end of the list argument list.

Parameters
[in]arg_strThe new argument.
[in]quote_charIf the argument was originally quoted, put in the quote char here.

Definition at line 322 of file Args.cpp.

References GetArgumentCount(), and InsertArgumentAtIndex().

Referenced by lldb_private::CompletionRequest::AppendEmptyArgument(), Args(), lldb_private::CommandInterpreter::BuildAliasCommandArgs(), lldb::SBPlatform::ConnectRemote(), lldb_private::ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(), lldb_private::PlatformQemuUser::DebugProcess(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::DecodeProcessInfoResponse(), CommandObjectPlatformProcessLaunch::DoExecute(), CommandObjectProcessLaunch::DoExecute(), lldb_private::BreakpointIDList::FindAndReplaceIDRanges(), lldb_private::OptionValueArgs::GetArgs(), lldb_private::OptionValueArray::GetArgs(), lldb_private::OptionValueDictionary::GetArgs(), lldb_private::PlatformDarwin::GetExtraStartupCommands(), GetFreeBSDProcessArgs(), GetMacOSXProcessArgs(), GetNetBSDProcessArgs(), GetOpenBSDProcessArgs(), GetProcessArgs(), CommandObjectThreadBacktrace::GetRepeatCommand(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_A(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_vRun(), ReconstituteArgsAfterParsing(), CommandObjectProcessContinue::CommandOptions::SetOptionValue(), CommandObjectBreakpointSet::CommandOptions::SetOptionValue(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), and xcrun().

◆ AppendArguments() [1/2]

void Args::AppendArguments ( const Args rhs)

◆ AppendArguments() [2/2]

void Args::AppendArguments ( const char **  argv)

Definition at line 308 of file Args.cpp.

References ArgvToArgc(), m_argv, and m_entries.

◆ begin()

const_iterator lldb_private::Args::begin ( ) const
inline

Definition at line 132 of file Args.h.

References m_entries.

Referenced by FindOriginalIndex().

◆ Clear()

void Args::Clear ( )

◆ DeleteArgumentAtIndex()

void Args::DeleteArgumentAtIndex ( size_t  idx)

Deletes the argument value at index if idx is a valid argument index.

Parameters
[in]idxThe index of the argument that will have its value replaced.

Definition at line 349 of file Args.cpp.

References m_argv, and m_entries.

Referenced by lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(), and lldb_private::Options::ParseAlias().

◆ Dump()

void Args::Dump ( Stream s,
const char *  label_name = "argv" 
) const

Dump all entries to the stream s using label label_name.

If label_name is nullptr, the dump operation is skipped.

Parameters
[in]sThe stream to which to dump all arguments in the argument vector.
[in]label_nameThe label_name to use as the label printed for each entry of the args like so: {label_name}[{index}]={value}

Definition at line 198 of file Args.cpp.

References lldb_private::Stream::EOL(), lldb_private::Stream::Format(), lldb_private::Stream::Indent(), and m_entries.

Referenced by lldb_private::ProcessInfo::Dump().

◆ empty()

bool lldb_private::Args::empty ( ) const
inline

◆ EncodeEscapeSequences()

void Args::EncodeEscapeSequences ( const char *  src,
std::string &  dst 
)
static

EncodeEscapeSequences will change the textual representation of common escape sequences like "\n" (two characters) into a single '
'.

It does this for all of the supported escaped sequences and for the \0ooo (octal) and \xXX (hex). The resulting "dst" string will contain the character versions of all supported escape sequences. The common supported escape sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".

Definition at line 453 of file Args.cpp.

Referenced by lldb_private::OptionValueString::SetValueFromString().

◆ end()

const_iterator lldb_private::Args::end ( ) const
inline

Definition at line 133 of file Args.h.

References m_entries.

Referenced by CommandObjectSourceList::GetRepeatCommand(), and ReconstituteArgsAfterParsing().

◆ entries()

llvm::ArrayRef< ArgEntry > lldb_private::Args::entries ( ) const
inline

◆ EscapeLLDBCommandArgument()

std::string Args::EscapeLLDBCommandArgument ( const std::string &  arg,
char  quote_char 
)
static

◆ ExpandEscapedCharacters()

void Args::ExpandEscapedCharacters ( const char *  src,
std::string &  dst 
)
static

ExpandEscapeSequences will change a string of possibly non-printable characters and expand them into text.

So '
' will turn into two characters like "\n" which is suitable for human reading. When a character is not printable and isn't one of the common in escape sequences listed in the help for EncodeEscapeSequences, then it will be encoded as octal. Printable characters are left alone.

Definition at line 552 of file Args.cpp.

Referenced by lldb_private::OptionValueString::DumpValue().

◆ GetArgumentArrayRef()

llvm::ArrayRef< const char * > lldb_private::Args::GetArgumentArrayRef ( ) const
inline

Gets the argument as an ArrayRef.

Note that the return value does not have a nullptr const char * at the end, as the size of the list is embedded in the ArrayRef object.

Definition at line 169 of file Args.h.

References m_argv.

Referenced by CommandObjectLogEnable::DoExecute(), CommandObjectLogDisable::DoExecute(), get_arg_range(), and lldb_private::CommandObjectMultiwordBreakpoint::VerifyIDs().

◆ GetArgumentAtIndex()

const char * Args::GetArgumentAtIndex ( size_t  idx) const

Gets the NULL terminated C string argument pointer for the argument at index idx.

Returns
The NULL terminated C string argument pointer if idx is a valid argument index, NULL otherwise.

Definition at line 263 of file Args.cpp.

References m_argv.

Referenced by lldb_private::CommandInterpreter::BuildAliasCommandArgs(), lldb_private::CommandInterpreter::BuildAliasResult(), CommandObjectTypeFilterDelete::CommandObjectTypeFilterDelete(), CompleteEnableDisable(), lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(), lldb_private::platform_android::PlatformAndroid::ConnectRemote(), lldb_private::platform_android::PlatformAndroidRemoteGDBServer::ConnectRemote(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ConnectRemote(), lldb_private::PlatformAppleSimulator::ConnectRemote(), CommandObjectPlatformSelect::DoExecute(), CommandObjectPlatformInstall::DoExecute(), lldb_private::CommandObjectQuit::DoExecute(), CommandObjectTargetSelect::DoExecute(), CommandObjectTargetModulesLoad::DoExecute(), CommandObjectThreadPlanDiscard::DoExecute(), CommandObjectThreadPlanPrune::DoExecute(), CommandObjectCommandsContainerAdd::DoExecute(), CommandObjectCommandsContainerDelete::DoExecute(), CommandObjectFrameRecognizerDelete::DoExecute(), CommandObjectFrameRecognizerInfo::DoExecute(), CommandObjectProcessConnect::DoExecute(), CommandObjectProcessSignal::DoExecute(), CommandObjectProcessSaveCore::DoExecute(), CommandObjectSettingsClear::DoExecute(), CommandObjectTargetCreate::DoExecute(), CommandObjectTargetModulesSearchPathsAdd::DoExecute(), CommandObjectTargetModulesSearchPathsInsert::DoExecute(), CommandObjectTargetModulesSearchPathsQuery::DoExecute(), CommandObjectTargetModulesDumpObjfile::DoExecute(), CommandObjectTargetModulesDumpSymtab::DoExecute(), CommandObjectTargetModulesDumpSections::DoExecute(), CommandObjectTargetModulesDumpClangPCMInfo::DoExecute(), CommandObjectTargetModulesDumpSymfile::DoExecute(), CommandObjectTargetModulesDumpLineTable::DoExecute(), CommandObjectTargetModulesDumpSeparateDebugInfoFiles::DoExecute(), CommandObjectTargetModulesShowUnwind::DoExecute(), CommandObjectTargetModulesLookup::DoExecute(), CommandObjectTargetStopHookDelete::DoExecute(), CommandObjectTargetStopHookEnableDisable::DoExecute(), CommandObjectThreadStepWithTypeAndScope::DoExecute(), CommandObjectThreadUntil::DoExecute(), CommandObjectThreadSelect::DoExecute(), lldb_private::CommandObjectIterateOverThreads::DoExecute(), lldb_private::CommandObjectMultipleThreads::DoExecute(), CommandObjectTypeFormatterDelete::DoExecute(), CommandObjectTypeFormatterClear::DoExecute(), CommandObjectTypeFormatterList< FormatterType >::DoExecute(), CommandObjectObjC_ClassTable_Dump::DoExecute(), CommandObjectMultiwordObjC_TaggedPointer_Info::DoExecute(), CommandObjectProcessGDBRemotePacketXferSize::DoExecute(), CommandObjectProcessGDBRemotePacketSend::DoExecute(), CommandObjectSettingsRemove::DoExecute(), CommandObjectSettingsReplace::DoExecute(), CommandObjectSettingsInsertBefore::DoExecute(), CommandObjectSettingsInsertAfter::DoExecute(), CommandObjectSettingsAppend::DoExecute(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoLaunch(), lldb_private::ProcessInstanceInfo::Dump(), lldb_private::ProcessInstanceInfo::DumpAsTableRow(), lldb_private::CommandInterpreter::GetCommandSPExact(), lldb_private::CompletionRequest::GetCursorArgumentPrefix(), GetSingleThreadFromArgs(), lldb_private::CommandInterpreter::HandleCompletion(), lldb_private::CommandInterpreter::HandleCompletionMatches(), CommandObjectBreakpointRead::CommandOptions::HandleOptionArgumentCompletion(), lldb_private::Options::HandleOptionArgumentCompletion(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchProcess(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::LaunchProcess(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::LaunchProcess(), sddarwinlog_private::ParseAutoEnableOptions(), lldb_private::Target::PrintDummySignals(), CommandObjectProcessHandle::PrintSignalInformation(), lldb_private::OptionValueArray::SetArgs(), lldb_private::ProcessInfo::SetArguments(), lldb_private::OptionValueFileSpecList::SetValueFromString(), lldb_private::OptionValuePathMappings::SetValueFromString(), CoreSimulatorSupport::Device::Spawn(), lldb_private::UnwindLLDB::UnwindLLDB(), and lldb_private::CommandInterpreter::VerifyUserMultiwordCmdPath().

◆ GetArgumentCount()

size_t lldb_private::Args::GetArgumentCount ( ) const
inline

Gets the number of arguments left in this command object.

Returns
The number or arguments in this object.

Definition at line 116 of file Args.h.

References m_entries.

Referenced by AppendArgument(), lldb_private::CommandInterpreter::BuildAliasCommandArgs(), lldb_private::CommandInterpreter::BuildAliasResult(), lldb_private::Target::ClearDummySignals(), lldb_private::CommandCompletions::CompleteModifiableCmdPathArgs(), lldb_private::CompletionRequest::CompletionRequest(), lldb_private::ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(), lldb_private::platform_android::PlatformAndroidRemoteGDBServer::ConnectRemote(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ConnectRemote(), lldb_private::PlatformAppleSimulator::ConnectRemote(), CommandObjectLogEnable::DoExecute(), CommandObjectLogTimerEnable::DoExecute(), CommandObjectLogTimerIncrement::DoExecute(), CommandObjectPlatformSelect::DoExecute(), CommandObjectPlatformDisconnect::DoExecute(), CommandObjectPlatformProcessLaunch::DoExecute(), CommandObjectPlatformProcessInfo::DoExecute(), CommandObjectPlatformInstall::DoExecute(), lldb_private::CommandObjectQuit::DoExecute(), CommandObjectSettingsList::DoExecute(), CommandObjectTargetSelect::DoExecute(), CommandObjectTargetDelete::DoExecute(), CommandObjectTargetVariable::DoExecute(), CommandObjectTargetModulesAdd::DoExecute(), CommandObjectTargetModulesLoad::DoExecute(), CommandObjectTargetSymbolsAdd::DoExecute(), CommandObjectThreadPlanDiscard::DoExecute(), CommandObjectThreadPlanPrune::DoExecute(), lldb_private::CommandObjectApropos::DoExecute(), CommandObjectBreakpointNameConfigure::DoExecute(), CommandObjectCommandsSource::DoExecute(), CommandObjectCommandsScriptAdd::DoExecute(), CommandObjectCommandsScriptDelete::DoExecute(), CommandObjectCommandsContainerAdd::DoExecute(), CommandObjectCommandsContainerDelete::DoExecute(), CommandObjectFrameSelect::DoExecute(), CommandObjectFrameRecognizerDelete::DoExecute(), CommandObjectFrameRecognizerInfo::DoExecute(), lldb_private::CommandObjectHelp::DoExecute(), CommandObjectMemoryRead::DoExecute(), CommandObjectMemoryFind::DoExecute(), CommandObjectMemoryWrite::DoExecute(), CommandObjectMemoryHistory::DoExecute(), CommandObjectMemoryRegion::DoExecute(), CommandObjectMemoryTagRead::DoExecute(), CommandObjectMemoryTagWrite::DoExecute(), CommandObjectPluginLoad::DoExecute(), CommandObjectProcessContinue::DoExecute(), CommandObjectProcessConnect::DoExecute(), CommandObjectProcessSignal::DoExecute(), CommandObjectProcessSaveCore::DoExecute(), CommandObjectRegisterRead::DoExecute(), CommandObjectRegisterWrite::DoExecute(), CommandObjectRegisterInfo::DoExecute(), CommandObjectSettingsClear::DoExecute(), CommandObjectTargetCreate::DoExecute(), CommandObjectTargetModulesSearchPathsAdd::DoExecute(), CommandObjectTargetModulesSearchPathsInsert::DoExecute(), CommandObjectTargetModulesSearchPathsQuery::DoExecute(), CommandObjectTargetModulesDumpObjfile::DoExecute(), CommandObjectTargetModulesDumpSymtab::DoExecute(), CommandObjectTargetModulesDumpSections::DoExecute(), CommandObjectTargetModulesDumpClangPCMInfo::DoExecute(), CommandObjectTargetModulesDumpClangAST::DoExecute(), CommandObjectTargetModulesDumpSymfile::DoExecute(), CommandObjectTargetModulesDumpLineTable::DoExecute(), CommandObjectTargetModulesDumpSeparateDebugInfoFiles::DoExecute(), CommandObjectTargetModulesList::DoExecute(), CommandObjectTargetModulesShowUnwind::DoExecute(), CommandObjectTargetModulesLookup::DoExecute(), CommandObjectTargetStopHookDelete::DoExecute(), CommandObjectTargetStopHookEnableDisable::DoExecute(), CommandObjectThreadStepWithTypeAndScope::DoExecute(), CommandObjectThreadContinue::DoExecute(), CommandObjectThreadUntil::DoExecute(), CommandObjectThreadSelect::DoExecute(), CommandObjectThreadPlanList::DoExecute(), lldb_private::CommandObjectIterateOverThreads::DoExecute(), lldb_private::CommandObjectMultipleThreads::DoExecute(), CommandObjectTypeFormatterDelete::DoExecute(), CommandObjectTypeFormatterClear::DoExecute(), CommandObjectTypeFormatterList< FormatterType >::DoExecute(), CommandObjectWatchpointList::DoExecute(), CommandObjectWatchpointEnable::DoExecute(), CommandObjectWatchpointDisable::DoExecute(), CommandObjectWatchpointIgnore::DoExecute(), CommandObjectWatchpointModify::DoExecute(), CommandObjectWatchpointCommandDelete::DoExecute(), CommandObjectWatchpointCommandList::DoExecute(), CommandObjectObjC_ClassTable_Dump::DoExecute(), CommandObjectMultiwordObjC_TaggedPointer_Info::DoExecute(), CommandObjectProcessGDBRemoteSpeedTest::DoExecute(), CommandObjectProcessGDBRemotePacketXferSize::DoExecute(), CommandObjectProcessGDBRemotePacketSend::DoExecute(), CommandObjectProcessMinidumpDump::DoExecute(), CommandObjectProcessLaunch::DoExecute(), CommandObjectProcessHandle::DoExecute(), CommandObjectSettingsRemove::DoExecute(), CommandObjectSettingsInsertBefore::DoExecute(), CommandObjectSettingsInsertAfter::DoExecute(), CommandObjectSettingsAppend::DoExecute(), lldb_private::ProcessInstanceInfo::Dump(), lldb_private::ProcessInstanceInfo::DumpAsTableRow(), empty(), lldb_private::CommandObjectParsed::Execute(), lldb_private::CommandObjectMultiword::Execute(), CommandObjectTypeSummaryAdd::Execute_StringSummary(), lldb_private::OptionValueArgs::GetArgs(), lldb_private::OptionValueArray::GetArgs(), lldb_private::OptionValueDictionary::GetArgs(), lldb_private::CommandInterpreter::GetCommandSPExact(), CommandObjectTypeCategoryEnable::CommandOptions::GetDefinitions(), CommandObjectThreadBacktrace::GetRepeatCommand(), lldb_private::CommandObjectMultiword::GetRepeatCommand(), GetSingleThreadFromArgs(), lldb_private::CommandObjectMultiword::HandleCompletion(), lldb_private::CommandInterpreter::HandleCompletionMatches(), lldb::SBCommandInterpreter::HandleCompletionWithDescriptions(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::LaunchProcess(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchProcess(), CommandObjectTypeCategoryDisable::CommandOptions::OptionParsingStarting(), lldb_private::Options::ParseAlias(), sddarwinlog_private::ParseAutoEnableOptions(), lldb_private::Target::PrintDummySignals(), CommandObjectProcessHandle::PrintSignalInformation(), lldb_private::OptionValueArray::SetArgs(), lldb_private::OptionValueDictionary::SetArgs(), lldb_private::OptionValueFileSpecList::SetValueFromString(), lldb_private::OptionValuePathMappings::SetValueFromString(), size(), CoreSimulatorSupport::Device::Spawn(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), lldb_private::UnwindLLDB::UnwindLLDB(), lldb_private::CommandInterpreter::VerifyUserMultiwordCmdPath(), and lldb_private::CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs().

◆ GetArgumentVector()

char ** Args::GetArgumentVector ( )

Gets the argument vector.

The value returned by this function can be used by any function that takes and vector. The return value is just like argv in the standard C entry point function:

int main (int argc, const char **argv);
Returns
An array of NULL terminated C string argument pointers that also has a terminating NULL C string pointer

Definition at line 269 of file Args.cpp.

References m_argv.

Referenced by lldb_private::CommandPluginInterfaceImplementation::DoExecute().

◆ GetCommandString()

bool Args::GetCommandString ( std::string &  command) const

◆ GetConstArgumentVector()

const char ** Args::GetConstArgumentVector ( ) const

Gets the argument vector.

The value returned by this function can be used by any function that takes and vector. The return value is just like argv in the standard C entry point function:

int main (int argc, const char **argv);
Returns
An array of NULL terminate C string argument pointers that also has a terminating NULL C string pointer

Definition at line 279 of file Args.cpp.

References m_argv.

Referenced by lldb_private::CommandInterpreter::BuildAliasCommandArgs(), lldb_private::ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(), lldb_private::CommandObjectParsed::Execute(), LaunchProcessPosixSpawn(), MaybeLogLaunchInfo(), and operator Environment().

◆ GetQuotedCommandString()

bool Args::GetQuotedCommandString ( std::string &  command) const

Definition at line 228 of file Args.cpp.

References m_entries.

Referenced by CommandObjectThreadBacktrace::GetRepeatCommand().

◆ GetShellSafeArgument()

std::string Args::GetShellSafeArgument ( const FileSpec shell,
llvm::StringRef  unsafe_arg 
)
static

◆ InsertArgumentAtIndex()

void Args::InsertArgumentAtIndex ( size_t  idx,
llvm::StringRef  arg_str,
char  quote_char = '\0' 
)

Insert the argument value at index idx to arg_str.

Parameters
[in]idxThe index of where to insert the argument.
[in]arg_strThe new argument.
[in]quote_charIf the argument was originally quoted, put in the quote char here.

Definition at line 326 of file Args.cpp.

References m_argv, and m_entries.

Referenced by AppendArgument(), lldb_private::ProcessInfo::SetExecutableFile(), and Unshift().

◆ operator Environment()

lldb_private::Args::operator Environment ( ) const
inlineexplicit

Definition at line 78 of file Args.h.

References GetConstArgumentVector().

◆ operator=()

Args & Args::operator= ( const Args rhs)

Definition at line 182 of file Args.cpp.

References Clear(), m_argv, and m_entries.

◆ operator[]()

const ArgEntry & lldb_private::Args::operator[] ( size_t  n) const
inline

Definition at line 136 of file Args.h.

References m_entries.

◆ ReplaceArgumentAtIndex()

void Args::ReplaceArgumentAtIndex ( size_t  idx,
llvm::StringRef  arg_str,
char  quote_char = '\0' 
)

Replaces the argument value at index idx to arg_str if idx is a valid argument index.

Parameters
[in]idxThe index of the argument that will have its value replaced.
[in]arg_strThe new argument.
[in]quote_charIf the argument was originally quoted, put in the quote char here.

Definition at line 337 of file Args.cpp.

References m_argv, and m_entries.

Referenced by lldb_private::platform_android::PlatformAndroidRemoteGDBServer::ConnectRemote(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoLaunch(), lldb_private::CommandObjectParsed::Execute(), CommandObjectThreadBacktrace::GetRepeatCommand(), and lldb_private::platform_gdb_server::PlatformRemoteGDBServer::LaunchProcess().

◆ SetArguments() [1/2]

void Args::SetArguments ( const char **  argv)

Definition at line 374 of file Args.cpp.

References ArgvToArgc(), and SetArguments().

◆ SetArguments() [2/2]

void Args::SetArguments ( size_t  argc,
const char **  argv 
)

Sets the argument vector value, optionally copying all arguments into an internal buffer.

Sets the arguments to match those found in argv. All argument strings will be copied into an internal buffers.

Definition at line 357 of file Args.cpp.

References Clear(), m_argv, and m_entries.

Referenced by Args(), lldb_private::CommandInterpreter::BuildAliasCommandArgs(), lldb_private::ProcessInfo::SetArguments(), and SetArguments().

◆ SetCommandString()

void Args::SetCommandString ( llvm::StringRef  command)

Sets the command string contained by this object.

The command string will be copied and split up into arguments that can be accessed via the accessor functions.

Parameters
[in]commandA command StringRef that will be copied and split up into arguments.
See also
Args::GetArgumentCount() const
Args::GetArgumentAtIndex (size_t) const
Args::GetArgumentVector ()
Args::Shift ()
Args::Unshift (const char *)

Definition at line 247 of file Args.cpp.

References Clear(), ltrimForArgs(), m_argv, m_entries, and ParseSingleArgument().

Referenced by Args().

◆ Shift()

void Args::Shift ( )

◆ size()

size_t lldb_private::Args::size ( ) const
inline

◆ StringToEncoding()

lldb::Encoding Args::StringToEncoding ( llvm::StringRef  s,
lldb::Encoding  fail_value = lldb::eEncodingInvalid 
)
static

◆ StringToGenericRegister()

uint32_t Args::StringToGenericRegister ( llvm::StringRef  s)
static

◆ Unshift()

void Args::Unshift ( llvm::StringRef  arg_str,
char  quote_char = '\0' 
)

Inserts a class owned copy of arg_str at the beginning of the argument vector.

A copy arg_str will be made.

Parameters
[in]arg_strThe argument to push on the front of the argument stack.
[in]quote_charIf the argument was originally quoted, put in the quote char here.

Definition at line 293 of file Args.cpp.

References InsertArgumentAtIndex().

Referenced by lldb_private::CommandInterpreter::BuildAliasCommandArgs(), and lldb_private::CommandInterpreter::BuildAliasResult().

Member Data Documentation

◆ m_argv

std::vector<char *> lldb_private::Args::m_argv
private

The arguments as C strings with a trailing nullptr element.

These strings are owned by the ArgEntry object in m_entries with the same index.

Definition at line 293 of file Args.h.

Referenced by AppendArguments(), Clear(), DeleteArgumentAtIndex(), GetArgumentArrayRef(), GetArgumentAtIndex(), GetArgumentVector(), GetConstArgumentVector(), InsertArgumentAtIndex(), operator=(), ReplaceArgumentAtIndex(), SetArguments(), SetCommandString(), and Shift().

◆ m_entries

std::vector<ArgEntry> lldb_private::Args::m_entries
private

The documentation for this class was generated from the following files: