LLDB  mainline
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
lldb_private::ConstString Class Reference

A uniqued constant string class. More...

#include "lldb/Utility/ConstString.h"

Collaboration diagram for lldb_private::ConstString:
Collaboration graph
[legend]

Classes

struct  StringIsEqual
 C string equality binary predicate function object for ConstString objects. More...
 

Public Member Functions

 ConstString ()
 Default constructor. More...
 
 ConstString (const ConstString &rhs)
 Copy constructor. More...
 
 ConstString (const llvm::StringRef &s)
 
 ConstString (const char *cstr)
 Construct with C String value. More...
 
 ConstString (const char *cstr, size_t max_cstr_len)
 Construct with C String value with max length. More...
 
 ~ConstString ()=default
 Destructor. More...
 
 operator bool () const
 Convert to bool operator. More...
 
ConstString operator= (ConstString rhs)
 Assignment operator. More...
 
bool operator== (ConstString rhs) const
 Equal to operator. More...
 
bool operator== (const char *rhs) const
 Equal to operator against a non-ConstString value. More...
 
bool operator!= (ConstString rhs) const
 Not equal to operator. More...
 
bool operator!= (const char *rhs) const
 Not equal to operator against a non-ConstString value. More...
 
bool operator< (ConstString rhs) const
 
const char * AsCString (const char *value_if_empty=nullptr) const
 Get the string value as a C string. More...
 
llvm::StringRef GetStringRef () const
 Get the string value as a llvm::StringRef. More...
 
const char * GetCString () const
 Get the string value as a C string. More...
 
size_t GetLength () const
 Get the length in bytes of string value. More...
 
void Clear ()
 Clear this object's state. More...
 
void Dump (Stream *s, const char *value_if_empty=nullptr) const
 Dump the object description to a stream. More...
 
void DumpDebug (Stream *s) const
 Dump the object debug description to a stream. More...
 
bool IsEmpty () const
 Test for empty string. More...
 
bool IsNull () const
 Test for null string. More...
 
void SetCString (const char *cstr)
 Set the C string value. More...
 
void SetString (const llvm::StringRef &s)
 
void SetStringWithMangledCounterpart (llvm::StringRef demangled, ConstString mangled)
 Set the C string value and its mangled counterpart. More...
 
bool GetMangledCounterpart (ConstString &counterpart) const
 Retrieve the mangled or demangled counterpart for a mangled or demangled ConstString. More...
 
void SetCStringWithLength (const char *cstr, size_t cstr_len)
 Set the C string value with length. More...
 
void SetTrimmedCStringWithLength (const char *cstr, size_t fixed_cstr_len)
 Set the C string value with the minimum length between fixed_cstr_len and the actual length of the C string. More...
 
size_t MemorySize () const
 Get the memory cost of this object. More...
 

Static Public Member Functions

static bool Equals (ConstString lhs, ConstString rhs, const bool case_sensitive=true)
 Equal to operator. More...
 
static int Compare (ConstString lhs, ConstString rhs, const bool case_sensitive=true)
 Compare two string objects. More...
 
static size_t StaticMemorySize ()
 Get the size in bytes of the current global string pool. More...
 

Protected Attributes

const char * m_string
 

Detailed Description

A uniqued constant string class.

Provides an efficient way to store strings as uniqued strings. After the strings are uniqued, finding strings that are equal to one another is very fast as just the pointers need to be compared. It also allows for many common strings from many different sources to be shared to keep the memory footprint low.

No reference counting is done on strings that are added to the string pool, once strings are added they are in the string pool for the life of the program.

Definition at line 38 of file ConstString.h.

Constructor & Destructor Documentation

◆ ConstString() [1/5]

lldb_private::ConstString::ConstString ( )
inline

Default constructor.

Initializes the string to an empty string.

Definition at line 43 of file ConstString.h.

◆ ConstString() [2/5]

lldb_private::ConstString::ConstString ( const ConstString rhs)
inline

Copy constructor.

Copies the string value in rhs into this object.

Parameters
[in]rhsAnother string object to copy.

Definition at line 51 of file ConstString.h.

◆ ConstString() [3/5]

ConstString::ConstString ( const llvm::StringRef &  s)
explicit

Definition at line 202 of file ConstString.cpp.

◆ ConstString() [4/5]

ConstString::ConstString ( const char *  cstr)
explicit

Construct with C String value.

Constructs this object with a C string by looking to see if the C string already exists in the global string pool. If it doesn't exist, it is added to the string pool.

Parameters
[in]cstrA NULL terminated C string to add to the string pool.

Definition at line 196 of file ConstString.cpp.

◆ ConstString() [5/5]

ConstString::ConstString ( const char *  cstr,
size_t  max_cstr_len 
)
explicit

Construct with C String value with max length.

Constructs this object with a C string with a length. If max_cstr_len is greater than the actual length of the string, the string length will be truncated. This allows substrings to be created without the need to NULL terminate the string as it is passed into this function.

Parameters
[in]cstrA pointer to the first character in the C string. The C string can be NULL terminated in a buffer that contains more characters than the length of the string, or the string can be part of another string and a new substring can be created.
[in]max_cstr_lenThe max length of cstr. If the string length of cstr is less than max_cstr_len, then the string will be truncated. If the string length of cstr is greater than max_cstr_len, then only max_cstr_len bytes will be used from cstr.

Definition at line 199 of file ConstString.cpp.

◆ ~ConstString()

lldb_private::ConstString::~ConstString ( )
default

Destructor.

Since constant string values are currently not reference counted, there isn't much to do here.

Member Function Documentation

◆ AsCString()

const char* lldb_private::ConstString::AsCString ( const char *  value_if_empty = nullptr) const
inline

Get the string value as a C string.

Get the value of the contained string as a NULL terminated C string value.

If value_if_empty is nullptr, then nullptr will be returned.

Returns
Returns value_if_empty if the string is empty, otherwise the C string value contained in this object.

Definition at line 224 of file ConstString.h.

Referenced by AddLocalVariableDecls(), AddMacros(), DynamicRegisterInfo::AddRegister(), lldb_private::ValueObjectConstResultImpl::AddressOf(), lldb_private::ValueObject::AddressOf(), lldb_private::AddressResolverName::AddressResolverName(), CommandObjectTypeSynthAdd::AddSynth(), AdjustForBitfieldness(), lldb_private::AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(), lldb_private::Target::ApplyNameToBreakpoints(), lldb_private::x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite(), lldb_private::ClangFunctionCaller::CompileFunction(), lldb_private::ClangUserExpression::Complete(), lldb_private::Process::CompleteAttach(), SymbolFileDWARF::CompleteType(), DWARFASTParserClang::CompleteTypeFromDWARF(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(), lldb_private::ThreadPlanCallFunction::ConstructorSetup(), lldb_private::ItaniumABILanguageRuntime::CouldHaveDynamicValue(), lldb_private::ClangASTContext::CountDeclLevels(), lldb_private::REPL::Create(), lldb_private::RenderScriptRuntime::CreateExceptionResolver(), SymbolVendorMacOSX::CreateInstance(), lldb_private::ClangASTContext::DeclContextFindDeclByName(), lldb_private::ThreadPlanStepInRange::DefaultShouldStopHereCallback(), lldb_private::Target::DeleteBreakpointName(), EntityResultVariable::Dematerialize(), SymbolFileDWARF::DIEInDeclContext(), CommandObjectTypeFormatterList< TypeFilterImpl >::DoExecute(), CommandObjectMemoryRegion::DoExecute(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoLaunch(), lldb_private::Symbol::Dump(), lldb_private::Address::Dump(), Dump(), lldb_private::RenderScriptRuntime::DumpAllocation(), DumpBasename(), DumpDirectory(), CommandObjectSourceInfo::DumpFileLinesInCompUnit(), CommandObjectSourceInfo::DumpLinesInFunctions(), CommandObjectSourceInfo::DumpLinesInSymbolContexts(), lldb_private::Section::DumpName(), InstructionLLVMC::DumpOperand(), lldb_private::InlineFunctionInfo::DumpStopContext(), DumpValue(), lldb_private::SourceManager::File::File(), lldb_private::SymbolContext::FindBestGlobalDataSymbol(), lldb_private::Target::FindBreakpointName(), PlatformDarwin::FindBundleBinaryInExecSearchPaths(), SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(), lldb_private::AppleObjCDeclVendor::FindDecls(), lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(), lldb_private::Module::FindFirstSymbolWithNameAndType(), lldb_private::Module::FindFunctionSymbols(), SymbolFileDWARF::FindNamespace(), lldb_private::ClangASTSource::FindObjCMethodDecls(), lldb_private::Module::FindSymbolsWithNameAndType(), lldb_private::Module::FindTypes(), lldb_private::FormatEntity::Format(), lldb_private::FormatEntity::FormatFileSpec(), CommandObjectTypeSummaryList::FormatterSpecificList(), lldb_private::IRExecutionUnit::FreeNow(), lldb::SBEvent::GetBroadcasterClass(), lldb_private::AppleObjCRuntimeV2::GetByteOffsetForIvar(), lldb_private::ClangASTContext::GetChildCompilerTypeAtIndex(), lldb_private::ValueObjectRegisterSet::GetChildMemberWithName(), PlatformRemoteDarwinDevice::GetConnectedSDKIndex(), lldb::SBEvent::GetDataFlavor(), lldb_private::ThreadPlanStepInRange::GetDescription(), lldb_private::AddressResolverFileLine::GetDescription(), lldb_private::AddressResolverName::GetDescription(), lldb::SBFunction::GetDescription(), lldb_private::Symbol::GetDescription(), lldb_private::BreakpointLocation::GetDescription(), lldb_private::TypeFormatImpl_EnumType::GetDescription(), lldb::SBProcess::GetDescription(), lldb_private::SearchFilterByModule::GetDescription(), lldb::SBCommandReturnObject::GetError(), lldb_private::ValueObject::GetExpressionPath(), lldb_private::FormatManager::GetFormat(), lldb_private::DWARFCallFrameInfo::GetFunctionAddressAndSizeVector(), lldb_private::ValueObjectRegisterSet::GetIndexOfChildWithName(), lldb_private::formatters::BlockPointerSyntheticFrontEnd::GetIndexOfChildWithName(), lldb::SBBlock::GetInlinedName(), GetItaniumDemangledStr(), lldb_private::process_linux::NativeProcessLinux::GetLoadedModuleFileSpec(), SymbolFileDWARF::GetMangledNamesForFunction(), ObjectFileELF::GetModuleSpecifications(), lldb::SBFunction::GetName(), lldb::SBSymbol::GetName(), lldb_private::UserExpression::GetObjectPointer(), lldb::SBCommandReturnObject::GetOutput(), DynamicRegisterInfo::GetRegisterSetIndexByName(), lldb_private::ModuleList::GetSharedModule(), PlatformDarwin::GetSharedModuleWithLocalCache(), lldb::SBLaunchInfo::GetShell(), lldb_private::UnixSignals::GetShortName(), lldb_private::UnixSignals::GetSignalInfo(), lldb_private::Process::GetStaticBroadcasterClass(), lldb_private::Target::GetStaticBroadcasterClass(), lldb_private::FormatManager::GetSummaryFormat(), lldb_private::ValueObject::GetSyntheticBase(), lldb_private::FormatManager::GetSyntheticChildren(), lldb_private::platform_linux::PlatformLinux::GetSystemIncludeDirectories(), DynamicLoaderHexagonDYLD::GetThreadLocalData(), lldb_private::FormattersContainer< KeyType, ValueType >::GetTypeNameSpecifierAtIndex_Impl(), lldb_private::FormatManager::GetValidator(), lldb_private::GetValidTypeName_Impl(), lldb_private::Value::GetValueAsData(), lldb_private::StackFrame::GuessLanguage(), lldb_private::StackFrame::GuessValueForAddress(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qHostInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo(), lldb_private::StructuredDataDarwinLog::HandleArrivalOfStructuredData(), lldb_private::CommandInterpreter::HandleCommandsFromFile(), SymbolFileDWARFDebugMap::InitOSO(), lldb_private::Thread::JumpToLine(), lldb_private::RenderScriptRuntime::ListAllocations(), lldb_private::Platform::LoadImage(), DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded(), lldb_private::DynamicLoader::LoadModuleAtAddress(), LocateDSYMInVincinityOfExecutable(), lldb_private::Symbols::LocateExecutableObjectFile(), lldb_private::Symbols::LocateExecutableSymbolFile(), LocateExecutableSymbolFileDsym(), LookForDsymNextToExecutablePath(), lldb_private::AppleObjCRuntimeV2::LookupRuntimeSymbol(), lldb_private::Module::Module(), lldb_private::StructuredDataDarwinLog::ModulesDidLoad(), lldb_private::Variable::NameMatches(), lldb_private::formatters::ObjCClassSummaryProvider(), OperatingSystemPython::OperatingSystemPython(), SymbolFileSymtab::ParseCompileUnitAtIndex(), ObjectFileMachO::ParseSymtab(), lldb_private::ClangExpressionParser::PrepareForExecution(), PrivateAutoComplete(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::ReadExtFeature(), lldb_private::RenderScriptRuntime::RefreshAllocation(), lldb_private::Target::RemoveNameFromBreakpoint(), lldb_private::Type::ResolveClangType(), lldb_private::Process::ResolveIndirectFunction(), lldb_private::ClangExpressionDeclMap::ResolveUnknownTypes(), IRForTarget::runOnModule(), lldb_private::BreakpointResolverFileLine::SearchCallback(), lldb_private::AddressResolverFileLine::SearchCallback(), lldb_private::lldb_renderscript::RSScriptGroupBreakpointResolver::SearchCallback(), lldb_private::IRExecutionUnit::SearchSpec::SearchSpec(), elf::ELFSymbol::sectionIndexToCString(), DynamicRegisterInfo::SetRegisterInfo(), lldb_private::CommandInterpreter::SourceInitFile(), lldb_private::Debugger::StartEventHandlerThread(), StaticMemorySize(), lldb_private::ValueObjectSynthetic::UpdateValue(), lldb_private::ClangModulesDeclVendor::~ClangModulesDeclVendor(), and lldb_private::Module::~Module().

◆ Clear()

void lldb_private::ConstString::Clear ( )
inline

◆ Compare()

int ConstString::Compare ( ConstString  lhs,
ConstString  rhs,
const bool  case_sensitive = true 
)
static

Compare two string objects.

Compares the C string values contained in lhs and rhs and returns an integer result.

NOTE: only call this function when you want a true string comparison. If you want string equality use the, use the == operator as it is much more efficient. Also if you want string inequality, use the != operator for the same reasons.

Parameters
[in]lhsThe Left Hand Side const ConstString object reference.
[in]rhsThe Right Hand Side const ConstString object reference.
[in]case_sensitiveCase sensitivity of compare. If true, case sensitive compare will be performed, otherwise character case will be ignored
Returns
  • -1 if lhs < rhs
  • 0 if lhs == rhs
  • 1 if lhs > rhs

Definition at line 249 of file ConstString.cpp.

References GetStringRef(), and m_string.

Referenced by lldb_private::FunctionInfo::Compare(), lldb_private::FileSpec::Compare(), lldb_private::lldb_renderscript::RSScriptGroupBreakpointResolver::FindScriptGroup(), and get_demangled_name_without_arguments().

◆ Dump()

void ConstString::Dump ( Stream s,
const char *  value_if_empty = nullptr 
) const

Dump the object description to a stream.

Dump the string value to the stream s. If the contained string is empty, print value_if_empty to the stream instead. If value_if_empty is nullptr, then nothing will be dumped to the stream.

Parameters
[in]sThe stream that will be used to dump the object description.
[in]value_if_emptyThe value to dump if the string is empty. If nullptr, nothing will be output to the stream.

Definition at line 273 of file ConstString.cpp.

References AsCString(), and lldb_private::Stream::PutCString().

Referenced by DumpBasename(), DumpDirectory(), lldb_private::LineEntry::DumpStopContext(), lldb_private::Declaration::DumpStopContext(), lldb_private::SymbolContext::DumpStopContext(), and lldb_private::Type::DumpTypeName().

◆ DumpDebug()

void ConstString::DumpDebug ( Stream s) const

Dump the object debug description to a stream.

Parameters
[in]sThe stream that will be used to dump the object description.

Definition at line 281 of file ConstString.cpp.

References GetCString(), GetLength(), and lldb_private::Stream::Printf().

◆ Equals()

bool ConstString::Equals ( ConstString  lhs,
ConstString  rhs,
const bool  case_sensitive = true 
)
static

Equal to operator.

Returns true if this string is equal to the string in rhs. If case sensitive equality is tested, this operation is very fast as it results in a pointer comparison since all strings are in a uniqued in a global string pool.

Parameters
[in]rhsThe Left Hand Side const ConstString object reference.
[in]rhsThe Right Hand Side const ConstString object reference.
[in]case_sensitiveCase sensitivity. If true, case sensitive equality will be tested, otherwise character case will be ignored
Returns
  • true if this object is equal to rhs.
  • false if this object is not equal to rhs.

Definition at line 232 of file ConstString.cpp.

References GetStringRef(), and m_string.

Referenced by lldb_private::FileSpec::DirectoryEquals(), lldb_private::FileSpec::Equal(), and lldb_private::FileSpec::FileEquals().

◆ GetCString()

const char* lldb_private::ConstString::GetCString ( ) const
inline

Get the string value as a C string.

Get the value of the contained string as a NULL terminated C string value. Similar to the ConstString::AsCString() function, yet this function will always return nullptr if the string is not valid. So this function is a direct accessor to the string pointer value.

Returns
Returns nullptr the string is invalid, otherwise the C string value contained in this object.

Definition at line 247 of file ConstString.h.

Referenced by lldb_private::BreakpointResolverName::AddNameLookup(), lldb_private::ClangExpressionDeclMap::AddValueToStruct(), lldb_private::TypeCategoryImpl::AnyMatches(), SymbolFileDWARF::CalculateAbilities(), lldb_private::ClangASTSource::CompleteNamespaceMap(), DWARFASTParserClang::CopyUniqueClassMethodTypes(), lldb_private::ItaniumABILanguageRuntime::CouldHaveDynamicValue(), lldb_private::Platform::Create(), lldb_private::RenderScriptRuntime::CreateExceptionResolver(), sddarwinlog_private::FilterRule::CreateRule(), lldb_private::RenderScriptRuntime::CreateScriptGroupBreakpoint(), lldb_private::ClangASTContext::CreateStructForIdentifier(), SymbolFileDWARF::DIEInDeclContext(), CommandObjectSourceList::DisplayFunctionSource(), ValueObjectListDelegate::DisplayRowObject(), CommandObjectPlatformPutFile::DoExecute(), NameToDIE::Dump(), lldb_private::Symbol::Dump(), ObjectFileELF::Dump(), lldb_private::ProcessInstanceInfo::Dump(), lldb_private::ModuleSpec::Dump(), lldb_private::Event::Dump(), lldb_private::Address::Dump(), lldb_private::Module::Dump(), lldb_private::Target::Dump(), DumpDebug(), lldb_private::Disassembler::ElideMixedSourceAndDisassemblyLine(), EnumerateDirectoryCallback(), ExciseGuardStore(), UniqueDWARFASTTypeMap::Find(), lldb_private::CPlusPlusLanguage::FindAlternateFunctionManglings(), lldb_private::Module::FindCompileUnits(), lldb_private::DynamicLoaderDarwin::FindEquivalentSymbols(), lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(), lldb_private::ClangASTSource::FindExternalVisibleDeclsByName(), SymbolFileDWARF::FindGlobalVariables(), lldb_private::CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(), SymbolFileDWARF::FindNamespace(), PDBASTParser::FindNamespaceDecl(), lldb_private::Module::FindTypes(), FixArrayTypeNameWithRegex(), lldb_private::ItaniumABILanguageRuntime::FixUpDynamicType(), lldb_private::AppleObjCRuntime::FixUpDynamicType(), lldb_private::FormatEntity::Format(), lldb_private::ThreadPlanStepInRange::FrameMatchesAvoidCriteria(), lldb_private::RichManglingContext::FromItaniumName(), get_demangled_name_without_arguments(), lldb_private::ObjCLanguage::MethodName::GetCategory(), lldb_private::ClangASTContext::GetChildCompilerTypeAtIndex(), lldb_private::ValueObject::GetChildMemberWithName(), lldb_private::ObjCLanguage::MethodName::GetClassName(), lldb_private::ObjCLanguage::MethodName::GetClassNameWithCategory(), ObjectFileMachO::GetDependentModules(), lldb_private::BreakpointLocation::GetDescription(), lldb_private::Module::GetDescription(), lldb_private::SymbolContext::GetDescription(), lldb_private::Function::GetDescription(), PlatformRemoteDarwinDevice::GetDeviceSupportDirectoryForOSVersion(), lldb::SBFrame::GetDisplayFunctionName(), ProcessMachCore::GetDynamicLoader(), ProcessElfCore::GetDynamicLoader(), ProcessKDP::GetDynamicLoader(), lldb_private::ProcessWindows::GetDynamicLoader(), lldb_private::ValueObject::GetExpressionPath(), GetFreeBSDProcessArgs(), PlatformDarwin::GetFullNameForDylib(), lldb_private::PlatformWindows::GetFullNameForDylib(), PlatformPOSIX::GetFullNameForDylib(), lldb_private::ObjCLanguage::MethodName::GetFullNames(), lldb::SBFrame::GetFunctionName(), lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::NSSetISyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName(), lldb_private::ValueObjectSynthetic::GetIndexOfChildWithName(), lldb_private::formatters::GenericNSSetMSyntheticFrontEnd< D32, D64 >::GetIndexOfChildWithName(), lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetIndexOfChildWithName(), NSIndexPathSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd< D32, D64 >::GetIndexOfChildWithName(), lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::Foundation1100::NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::VectorTypeSyntheticFrontEnd::GetIndexOfChildWithName(), lldb_private::formatters::GenericNSArrayISyntheticFrontEnd< D32, D64, Inline >::GetIndexOfChildWithName(), lldb_private::TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(), lldb_private::ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(), lldb_private::ValueObject::GetIndexOfChildWithName(), lldb::SBCommandInterpreter::GetIOHandlerControlSequence(), GetItaniumDemangledStr(), lldb_private::RenderScriptRuntime::GetKernelCoordinate(), GetLLDBNSPairType(), lldb::SBPlatformConnectOptions::GetLocalCacheDirectory(), GetMacOSXProcessArgs(), lldb_private::HostProcessPosix::GetMainModule(), SymbolFileDWARF::GetMangledNamesForFunction(), lldb_private::process_netbsd::NativeProcessNetBSD::GetMemoryRegionInfo(), lldb_private::process_linux::NativeProcessLinux::GetMemoryRegionInfo(), SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(), lldb_private::ProcessInfo::GetName(), lldb::SBBroadcaster::GetName(), GetNetBSDProcessArgs(), lldb_private::ObjectFile::GetNextSyntheticSymbolName(), GetOpenBSDProcessArgs(), lldb_private::ClangPersistentVariables::GetPersistentDecl(), DynamicRegisterInfo::GetRegisterInfo(), ABIMacOSX_arm::GetRegisterInfoArray(), ABISysV_arm::GetRegisterInfoArray(), ABISysV_s390x::GetRegisterInfoArray(), ABIMacOSX_arm64::GetRegisterInfoArray(), ABIMacOSX_i386::GetRegisterInfoArray(), ABISysV_arm64::GetRegisterInfoArray(), ABISysV_x86_64::GetRegisterInfoArray(), ABISysV_hexagon::GetRegisterInfoArray(), ABISysV_i386::GetRegisterInfoArray(), lldb_private::ABI::GetRegisterInfoByName(), lldb_private::ObjCLanguage::MethodName::GetSelector(), lldb_private::Module::GetSpecificationDescription(), lldb_private::DynamicLoaderDarwin::GetStepThroughTrampolinePlan(), lldb_private::CPPLanguageRuntime::GetStepThroughTrampolinePlan(), GetSymbolNameFromAddress(), lldb::SBModuleSpec::GetTriple(), lldb::SBModule::GetTriple(), lldb::SBTarget::GetTriple(), lldb_private::ClangASTContext::GetTypeForIdentifier(), lldb_private::StackFrame::GetValueForVariableExpressionPath(), GetXcodeContentsPath(), lldb_private::Symtab::InitNameIndexes(), SymbolFileDWARFDebugMap::InitOSO(), UniqueDWARFASTTypeMap::Insert(), lldb_private::Platform::Install(), lldb_private::formatters::LibcxxFunctionSummaryProvider(), lldb_private::formatters::LibcxxVariantSummaryProvider(), DynamicLoaderPOSIXDYLD::LoadInterpreterModule(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), PlatformDarwin::LocateExecutableScriptingResources(), lldb_private::PersistentExpressionState::LookupSymbol(), lldb_private::InstrumentationRuntime::ModulesDidLoad(), lldb_private::formatters::NSSetSummaryProvider(), lldb_private::formatters::NSSetSyntheticFrontEndCreator(), lldb_private::formatters::NSStringSummaryProvider(), lldb_private::UniqueCStringMap< T >::Entry::operator<(), CommandObjectSourceList::SourceInfo::operator<(), lldb_private::operator<<(), DWARFASTParserClang::ParseChildMembers(), DWARFASTParserClang::ParseTypeFromDWARF(), SymbolFileDWARF::ParseVariableDIE(), lldb_private::ValueObjectPrinter::PrintDecl(), CommandObjectTargetModulesList::PrintModule(), ObjectFileELF::ReadSectionData(), lldb_private::ClangPersistentVariables::RegisterPersistentDecl(), ObjectFileELF::RelocateSection(), RemoveFunctionsWithModuleNotEqualTo(), lldb_private::TypeList::RemoveMismatchedTypes(), lldb_private::TypeMap::RemoveMismatchedTypes(), PlatformRemoteDarwinDevice::ResolveExecutable(), PlatformPOSIX::ResolveExecutable(), lldb_private::PlatformWindows::ResolveExecutable(), PlatformAppleTVSimulator::ResolveExecutable(), PlatformAppleWatchSimulator::ResolveExecutable(), PlatformiOSSimulator::ResolveExecutable(), lldb_private::FileSystem::ResolveExecutableLocation(), lldb_private::RenderScriptRuntime::ResolveKernelName(), lldb_private::ClangExpressionDeclMap::ResolveUnknownTypes(), lldb_private::CommandCompletions::SourceFileCompleter::SearchCallback(), lldb_private::IRExecutionUnit::SearchSpec::SearchSpec(), lldb_private::BreakpointResolverAddress::SerializeToStructuredData(), lldb_private::Symbol::SetReExportedSymbolName(), DynamicRegisterInfo::SetRegisterInfo(), lldb_private::process_gdb_remote::ProcessGDBRemote::SetThreadStopInfo(), lldb_private::OptionValueEnumeration::SetValueFromString(), lldb_private::TypeNameSpecifierImpl::TypeNameSpecifierImpl(), PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded(), SourceFileWindowDelegate::WindowDelegateDraw(), and IRForTarget::~IRForTarget().

◆ GetLength()

size_t ConstString::GetLength ( ) const

Get the length in bytes of string value.

The string pool stores the length of the string, so we can avoid calling strlen() on the pointer value with this function.

Returns
Returns the number of bytes that this string occupies in memory, not including the NULL termination byte.

Definition at line 228 of file ConstString.cpp.

References Pool::GetConstCStringLength(), and m_string.

Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(), DumpDebug(), lldb_private::HostProcessPosix::GetMainModule(), lldb_private::ProcessInfo::GetNameLength(), lldb_private::ClangASTContext::GetTypeForIdentifier(), lldb_private::StackFrame::GetValueForVariableExpressionPath(), and lldb_private::Debugger::StartEventHandlerThread().

◆ GetMangledCounterpart()

bool ConstString::GetMangledCounterpart ( ConstString counterpart) const

Retrieve the mangled or demangled counterpart for a mangled or demangled ConstString.

Object files and debug symbols often use mangled string to represent the linkage name for a symbol, function or global. The string pool can efficiently store these values and their counterparts so when we run into another instance of a mangled name, we can avoid calling the name demangler over and over on the same strings and then trying to unique them.

Parameters
[in]counterpartA reference to a ConstString object that might get filled in with the demangled/mangled counterpart.
Returns
/b True if counterpart was filled in with the counterpart /b false otherwise.

Definition at line 306 of file ConstString.cpp.

References Pool::GetMangledCounterpart(), m_string, and StringPool().

◆ GetStringRef()

llvm::StringRef lldb_private::ConstString::GetStringRef ( ) const
inline

Get the string value as a llvm::StringRef.

Returns
Returns a new llvm::StringRef object filled in with the needed data.

Definition at line 233 of file ConstString.h.

Referenced by lldb_private::formatters::AddCXXSummary(), lldb_private::formatters::AddCXXSynthetic(), lldb_private::formatters::AddFilter(), lldb_private::formatters::AddFormat(), AddLocalVariableDecls(), lldb_private::formatters::AddOneLineSummary(), lldb_private::AddressResolverName::AddressResolverName(), lldb_private::formatters::AddStringSummary(), CommandObjectTypeSummaryAdd::AddSummary(), SymbolFilePDB::AddSymbols(), CommandObjectTypeSynthAdd::AddSynth(), lldb_private::OptionValueEnumeration::AutoComplete(), lldb_private::Watchpoint::CaptureWatchedValue(), Compare(), lldb_private::RenderScriptRuntime::CreateExceptionResolver(), lldb_private::FormattersContainer< KeyType, ValueType >::Delete_Impl(), DoesProcessHaveSharedCache(), CommandObjectTypeFormatterList< TypeFilterImpl >::DoExecute(), lldb_private::Property::DumpDescription(), lldb_private::ValueObject::DumpPrintableRepresentation(), lldb_private::OptionValueEnumeration::DumpValue(), Equals(), lldb_private::BreakpointResolverFileLine::FilterContexts(), lldb_private::CPlusPlusLanguage::FindAlternateFunctionManglings(), lldb_private::Target::FindBreakpointName(), SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(), lldb_private::AppleObjCDeclVendor::FindDecls(), SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(), lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(), lldb_private::npdb::SymbolFileNativePDB::FindGlobalVariables(), SymbolFilePDB::FindGlobalVariables(), SymbolFileDWARF::FindGlobalVariables(), lldb_private::CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(), SymbolFilePDB::FindNamespace(), SymbolFileDWARF::FindNamespace(), lldb_private::npdb::SymbolFileNativePDB::FindTypes(), SymbolFileDWARF::FindTypes(), lldb_private::FormattersContainer< KeyType, ValueType >::Get_Impl(), lldb_private::DebugNamesDWARFIndex::GetCompleteObjCClass(), lldb_private::AppleDWARFIndex::GetCompleteObjCClass(), lldb_private::ObjCLanguageRuntime::GetDescriptorIterator(), lldb_private::FormattersContainer< KeyType, ValueType >::GetExact_Impl(), lldb_private::FileSpec::GetFileNameExtension(), lldb_private::FileSpec::GetFileNameStrippingExtension(), lldb_private::DebugNamesDWARFIndex::GetFunctions(), lldb_private::AppleDWARFIndex::GetFunctions(), lldb_private::DebugNamesDWARFIndex::GetGlobalVariables(), lldb_private::AppleDWARFIndex::GetGlobalVariables(), lldb_private::RenderScriptRuntime::GetKernelCoordinate(), lldb_private::HostProcessPosix::GetMainModule(), SymbolFileDWARF::GetMangledNamesForFunction(), lldb_private::DebugNamesDWARFIndex::GetNamespaces(), lldb_private::AppleDWARFIndex::GetNamespaces(), lldb_private::AppleDWARFIndex::GetObjCMethods(), lldb_private::FileSpec::GetPath(), StackFrameRecognizerManagerImpl::GetRecognizerForFrame(), lldb_private::DebugNamesDWARFIndex::GetTypes(), lldb_private::AppleDWARFIndex::GetTypes(), lldb_private::ClangASTSource::IgnoreName(), lldb_private::FileSpec::IsSourceImplementationFile(), lldb_private::ClangModulesDeclVendor::LanguageSupportsClangModules(), lldb_private::Platform::LoadImageUsingPaths(), LookupSymbolInModule(), lldb_private::FileSpec::MakeAbsolute(), lldb_private::formatters::NSDictionary_Additionals::AdditionalFormatterMatching::Prefix::Match(), operator<(), ObjectFileELF::ReadSectionData(), lldb_private::PathMappingList::RemapPath(), IRForTarget::runOnModule(), PlatformRemoteDarwinDevice::SDKDirectoryInfo::SDKDirectoryInfo(), PlatformDarwin::SDKSupportsModules(), and lldb_private::ClangModulesDeclVendor::~ClangModulesDeclVendor().

◆ IsEmpty()

bool lldb_private::ConstString::IsEmpty ( ) const
inline

Test for empty string.

Returns
  • true if the contained string is empty.
  • false if the contained string is not empty.

Definition at line 340 of file ConstString.h.

Referenced by lldb_private::HostInfoLinux::ComputeSupportExeDirectory(), lldb_private::ClangASTContext::CreateStructForIdentifier(), SymbolFileDWARF::DIEInDeclContext(), lldb_private::FileSpec::Equal(), SymbolFilePDB::FindGlobalVariables(), ProcessMachCore::GetDynamicLoader(), ProcessKDP::GetDynamicLoader(), lldb_private::ValueObject::GetExpressionPath(), lldb_private::ObjCLanguage::GetFormatterPrefixSuffix(), PlatformDarwin::GetFullNameForDylib(), lldb_private::PlatformWindows::GetFullNameForDylib(), PlatformPOSIX::GetFullNameForDylib(), lldb_private::Target::GetOrCreateModule(), lldb_private::ValueObject::GetSyntheticBase(), lldb_private::ValueObject::GetSyntheticChildAtOffset(), lldb_private::ValueObjectChild::GetTypeName(), lldb_private::GetValidTypeName_Impl(), lldb_private::ObjCLanguage::MethodName::HasCategory(), lldb_private::RenderScriptRuntime::ListAllocations(), DynamicLoaderPOSIXDYLD::LoadInterpreterModule(), lldb_private::DynamicLoader::LoadModuleAtAddress(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), lldb_private::Symbols::LocateExecutableSymbolFile(), lldb_private::ModuleSpec::Matches(), lldb_private::Module::Module(), lldb_private::formatters::NSDateSummaryProvider(), lldb_private::formatters::ObjCClassSummaryProvider(), SymbolFilePDB::ParseDeclsForContext(), lldb_private::RenderScriptRuntime::RefreshAllocation(), lldb_private::FileSystem::Resolve(), IRForTarget::runOnModule(), lldb_private::CommandCompletions::SymbolCompleter::SearchCallback(), lldb_private::IRExecutionUnit::SearchSpec::SearchSpec(), DynamicRegisterInfo::SetRegisterInfo(), and lldb_private::Module::~Module().

◆ IsNull()

bool lldb_private::ConstString::IsNull ( ) const
inline

Test for null string.

Returns
  • true if there is no string associated with this instance.
  • false if there is a string associated with this instance.

Definition at line 347 of file ConstString.h.

◆ MemorySize()

size_t lldb_private::ConstString::MemorySize ( ) const
inline

Get the memory cost of this object.

Return the size in bytes that this object takes in memory. This returns the size in bytes of this object, which does not include any the shared string values it may refer to.

Returns
The number of bytes that this object occupies in memory.
See also
ConstString::StaticMemorySize ()

Definition at line 435 of file ConstString.h.

Referenced by lldb_private::FunctionInfo::MemorySize(), and lldb_private::FileSpec::MemorySize().

◆ operator bool()

lldb_private::ConstString::operator bool ( ) const
inlineexplicit

Convert to bool operator.

This allows code to check a ConstString object to see if it contains a valid string using code such as:

ConstString str(...);
if (str)
{ ...
Returns
/b True this object contains a valid non-empty C string, false otherwise.

Definition at line 123 of file ConstString.h.

◆ operator!=() [1/2]

bool lldb_private::ConstString::operator!= ( ConstString  rhs) const
inline

Not equal to operator.

Returns true if this string is not equal to the string in rhs. This operation is very fast as it results in a pointer comparison since all strings are in a uniqued in a global string pool.

Parameters
[in]rhsAnother string object to compare this object to.
Returns
  • true if this object is not equal to rhs.
  • false if this object is equal to rhs.

Definition at line 193 of file ConstString.h.

References m_string.

◆ operator!=() [2/2]

bool lldb_private::ConstString::operator!= ( const char *  rhs) const
inline

Not equal to operator against a non-ConstString value.

Returns true if this string is not equal to the string in rhs. This overload is usually slower than comparing against a ConstString value. However, if the rhs string not already a ConstString and it is impractical to turn it into a non-temporary variable, then this overload is faster.

Parameters
[in]rhsAnother string object to compare this object to.
Returns
  • true if this object is not equal to rhs.
  • false if this object is equal to rhs.

Definition at line 210 of file ConstString.h.

References lldb_private::operator<().

◆ operator<()

bool ConstString::operator< ( ConstString  rhs) const

Definition at line 205 of file ConstString.cpp.

References GetStringRef(), and m_string.

◆ operator=()

ConstString lldb_private::ConstString::operator= ( ConstString  rhs)
inline

Assignment operator.

Assigns the string in this object with the value from rhs.

Parameters
[in]rhsAnother string object to copy into this object.
Returns
A const reference to this object.

Definition at line 134 of file ConstString.h.

References m_string.

◆ operator==() [1/2]

bool lldb_private::ConstString::operator== ( ConstString  rhs) const
inline

Equal to operator.

Returns true if this string is equal to the string in rhs. This operation is very fast as it results in a pointer comparison since all strings are in a uniqued in a global string pool.

Parameters
[in]rhsAnother string object to compare this object to.
Returns
  • true if this object is equal to rhs.
  • false if this object is not equal to rhs.

Definition at line 151 of file ConstString.h.

References m_string.

◆ operator==() [2/2]

bool lldb_private::ConstString::operator== ( const char *  rhs) const
inline

Equal to operator against a non-ConstString value.

Returns true if this string is equal to the string in rhs. This overload is usually slower than comparing against a ConstString value. However, if the rhs string not already a ConstString and it is impractical to turn it into a non-temporary variable, then this overload is faster.

Parameters
[in]rhsAnother string object to compare this object to.
Returns
  • true if this object is equal to rhs.
  • false if this object is not equal to rhs.

Definition at line 170 of file ConstString.h.

◆ SetCString()

void ConstString::SetCString ( const char *  cstr)

Set the C string value.

Set the string value in the object by uniquing the cstr string value in our global string pool.

If the C string already exists in the global string pool, it finds the current entry and returns the existing value. If it doesn't exist, it is added to the string pool.

Parameters
[in]cstrA NULL terminated C string to add to the string pool.

Definition at line 292 of file ConstString.cpp.

References Pool::GetConstCString(), m_string, and StringPool().

Referenced by AdjustForBitfieldness(), lldb_private::ClangUserExpression::Complete(), lldb_private::HostInfoBase::ComputeGlobalTempFileDirectory(), lldb_private::HostInfoPosix::ComputeHeaderDirectory(), lldb_private::HostInfoBase::ComputeProcessTempFileDirectory(), lldb_private::HostInfoLinux::ComputeSystemPluginsDirectory(), lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory(), lldb_private::HostInfoLinux::ComputeUserPluginsDirectory(), lldb_private::REPL::Create(), lldb_private::ValueObjectConstResultImpl::CreateChildAtIndex(), lldb_private::ValueObject::CreateChildAtIndex(), lldb_private::RenderScriptRuntime::CreateExceptionResolver(), lldb_private::ClangASTContext::DeclContextIsClassMethod(), lldb_private::ValueObject::Dereference(), ObjectContainerBSDArchive::Object::Extract(), FixArrayTypeNameWithRegex(), lldb::SBType::GetFieldAtIndex(), lldb_private::process_gdb_remote::ProcessGDBRemote::GetHostOSVersion(), lldb_private::StructuredData::Array::GetItemAtIndexAsString(), lldb_private::DynamicLoaderDarwin::GetPThreadLibraryModule(), lldb_private::ValueObject::GetSyntheticBase(), lldb_private::ValueObject::GetSyntheticChildAtOffset(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsString(), lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(), lldb_private::Platform::Install(), LaunchInNewTerminalWithAppleScript(), lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator(), lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator(), PlatformDarwin::LocateExecutable(), LocateMacOSXFilesUsingDebugSymbols(), ParseTrieEntries(), DWARFASTParserClang::ParseTypeFromDWARF(), RecurseCopy_Callback(), lldb_private::BreakpointResolverAddress::SerializeToStructuredData(), lldb_private::ArchSpec::SetDistributionId(), lldb::SBPlatformConnectOptions::SetLocalCacheDirectory(), lldb_private::TypeAndOrName::SetName(), lldb_private::ThreadPlanStepInRange::SetStepInTarget(), and lldb_private::ObjectFile::SplitArchivePathWithObject().

◆ SetCStringWithLength()

void ConstString::SetCStringWithLength ( const char *  cstr,
size_t  cstr_len 
)

Set the C string value with length.

Set the string value in the object by uniquing cstr_len bytes starting at the cstr string value in our global string pool. If trim is true, then cstr_len indicates a maximum length of the CString and if the actual length of the string is less, then it will be trimmed.

If the C string already exists in the global string pool, it finds the current entry and returns the existing value. If it doesn't exist, it is added to the string pool.

Parameters
[in]cstrA NULL terminated C string to add to the string pool.
[in]cstr_lenThe maximum length of the C string.

Definition at line 311 of file ConstString.cpp.

References Pool::GetConstCStringWithLength(), m_string, and StringPool().

Referenced by lldb_private::HostProcessPosix::GetMainModule(), lldb_private::ScriptInterpreterPythonImpl::GetSyntheticTypeName(), and ParseTrieEntries().

◆ SetString()

void ConstString::SetString ( const llvm::StringRef &  s)

◆ SetStringWithMangledCounterpart()

void ConstString::SetStringWithMangledCounterpart ( llvm::StringRef  demangled,
ConstString  mangled 
)

Set the C string value and its mangled counterpart.

Object files and debug symbols often use mangled string to represent the linkage name for a symbol, function or global. The string pool can efficiently store these values and their counterparts so when we run into another instance of a mangled name, we can avoid calling the name demangler over and over on the same strings and then trying to unique them.

Parameters
[in]demangledThe demangled string to correlate with the mangled name.
[in]mangledThe already uniqued mangled ConstString to correlate the soon to be uniqued version of demangled.

Definition at line 300 of file ConstString.cpp.

References Pool::GetConstCStringAndSetMangledCounterPart(), m_string, and StringPool().

◆ SetTrimmedCStringWithLength()

void ConstString::SetTrimmedCStringWithLength ( const char *  cstr,
size_t  fixed_cstr_len 
)

Set the C string value with the minimum length between fixed_cstr_len and the actual length of the C string.

This can be used for data structures that have a fixed length to store a C string where the string might not be NULL terminated if the string takes the entire buffer.

Definition at line 315 of file ConstString.cpp.

References Pool::GetConstTrimmedCStringWithLength(), m_string, and StringPool().

Referenced by DynamicLoaderMacOSXDYLD::ParseLoadCommands(), and ObjectFileMachO::ProcessSegmentCommand().

◆ StaticMemorySize()

size_t ConstString::StaticMemorySize ( )
static

Get the size in bytes of the current global string pool.

Reports the size in bytes of all shared C string values, containers and any other values as a byte size for the entire string pool.

Returns
The number of bytes that the global string pool occupies in memory.

Definition at line 320 of file ConstString.cpp.

References AsCString(), Pool::MemorySize(), and StringPool().

Member Data Documentation

◆ m_string

const char* lldb_private::ConstString::m_string
protected

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