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

A file utility class. More...

#include "lldb/Host/FileSpec.h"

Inheritance diagram for lldb_private::FileSpec:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::FileSpec:
Collaboration graph
[legend]

Public Types

using Style = llvm::sys::path::Style
 

Public Member Functions

 FileSpec ()
 
 FileSpec (llvm::StringRef path, Style style=Style::native)
 Constructor with path. More...
 
 FileSpec (llvm::StringRef path, const llvm::Triple &Triple)
 
 FileSpec (const FileSpec &rhs)
 Copy constructor. More...
 
 FileSpec (const FileSpec *rhs)
 Copy constructor. More...
 
 ~FileSpec ()
 Destructor. More...
 
bool DirectoryEquals (const FileSpec &other) const
 
bool FileEquals (const FileSpec &other) const
 
const FileSpecoperator= (const FileSpec &rhs)
 Assignment operator. More...
 
bool operator== (const FileSpec &rhs) const
 Equal to operator. More...
 
bool operator!= (const FileSpec &rhs) const
 Not equal to operator. More...
 
bool operator< (const FileSpec &rhs) const
 Less than to operator. More...
 
 operator bool () const
 Convert to pointer operator. More...
 
bool operator! () const
 Logical NOT operator. More...
 
void Clear ()
 Clears the object state. More...
 
bool IsCaseSensitive () const
 Case sensitivity of path. More...
 
void Dump (Stream *s) const
 Dump this object to a Stream. More...
 
Style GetPathStyle () const
 
ConstStringGetDirectory ()
 Directory string get accessor. More...
 
ConstString GetDirectory () const
 Directory string const get accessor. More...
 
ConstStringGetFilename ()
 Filename string get accessor. More...
 
ConstString GetFilename () const
 Filename string const get accessor. More...
 
bool IsSourceImplementationFile () const
 Returns true if the filespec represents an implementation source file (files with a ".c", ".cpp", ".m", ".mm" (many more) extension). More...
 
bool IsRelative () const
 Returns true if the filespec represents a relative path. More...
 
bool IsAbsolute () const
 Returns true if the filespec represents an absolute path. More...
 
void MakeAbsolute (const FileSpec &dir)
 Make the FileSpec absolute by treating it relative to dir. More...
 
void SetPath (llvm::StringRef p)
 Temporary helper for FileSystem change. More...
 
size_t GetPath (char *path, size_t max_path_length, bool denormalize=true) const
 Extract the full path to the file. More...
 
std::string GetPath (bool denormalize=true) const
 Extract the full path to the file. More...
 
const char * GetCString (bool denormalize=true) const
 
void GetPath (llvm::SmallVectorImpl< char > &path, bool denormalize=true) const
 Extract the full path to the file. More...
 
ConstString GetFileNameExtension () const
 Extract the extension of the file. More...
 
ConstString GetFileNameStrippingExtension () const
 Return the filename without the extension part. More...
 
size_t MemorySize () const
 Get the memory cost of this object. More...
 
void SetFile (llvm::StringRef path, Style style)
 Change the file specified with a new path. More...
 
void SetFile (llvm::StringRef path, const llvm::Triple &Triple)
 
bool IsResolved () const
 
void SetIsResolved (bool is_resolved)
 Set if the file path has been resolved or not. More...
 
FileSpec CopyByAppendingPathComponent (llvm::StringRef component) const
 
FileSpec CopyByRemovingLastPathComponent () const
 
void PrependPathComponent (llvm::StringRef component)
 
void PrependPathComponent (const FileSpec &new_path)
 
void AppendPathComponent (llvm::StringRef component)
 
void AppendPathComponent (const FileSpec &new_path)
 
bool RemoveLastPathComponent ()
 Removes the last path component by replacing the current path with its parent. More...
 
ConstString GetLastPathComponent () const
 

Static Public Member Functions

static int Compare (const FileSpec &lhs, const FileSpec &rhs, bool full)
 Compare two FileSpec objects. More...
 
static bool Equal (const FileSpec &a, const FileSpec &b, bool full)
 
static llvm::Optional< StyleGuessPathStyle (llvm::StringRef absolute_path)
 Attempt to guess path style for a given path string. More...
 

Protected Member Functions

void SetFile (llvm::StringRef path)
 

Protected Attributes

ConstString m_directory
 The uniqued directory path. More...
 
ConstString m_filename
 The uniqued filename path. More...
 
bool m_is_resolved = false
 True if this path has been resolved. More...
 
Style m_style
 The syntax that this path uses (e.g. Windows / Posix) More...
 

Detailed Description

A file utility class.

A file specification class that divides paths up into a directory and basename. These string values of the paths are put into uniqued string pools for fast comparisons and efficient memory usage.

Another reason the paths are split into the directory and basename is to allow efficient debugger searching. Often in a debugger the user types in the basename of the file, for example setting a breakpoint by file and line, or specifying a module (shared library) to limit the scope in which to execute a command. The user rarely types in a full path. When the paths are already split up, it makes it easy for us to compare only the basenames of a lot of file specifications without having to split up the file path each time to get to the basename.

Definition at line 55 of file FileSpec.h.

Member Typedef Documentation

◆ Style

using lldb_private::FileSpec::Style = llvm::sys::path::Style

Definition at line 57 of file FileSpec.h.

Constructor & Destructor Documentation

◆ FileSpec() [1/5]

FileSpec::FileSpec ( )

Definition at line 68 of file FileSpec.cpp.

Referenced by CopyByRemovingLastPathComponent().

◆ FileSpec() [2/5]

FileSpec::FileSpec ( llvm::StringRef  path,
Style  style = Style::native 
)
explicit

Constructor with path.

Takes a path to a file which can be just a filename, or a full path. If path is not nullptr or empty, this function will call FileSpec::SetFile (const char *path).

Parameters
[in]pathThe full or partial path to a file.
[in]styleThe style of the path
See also
FileSpec::SetFile (const char *path)

Definition at line 71 of file FileSpec.cpp.

References SetFile().

◆ FileSpec() [3/5]

FileSpec::FileSpec ( llvm::StringRef  path,
const llvm::Triple &  Triple 
)
explicit

Definition at line 75 of file FileSpec.cpp.

◆ FileSpec() [4/5]

FileSpec::FileSpec ( const FileSpec rhs)

Copy constructor.

Makes a copy of the uniqued directory and filename strings from rhs.

Parameters
[in]rhsA const FileSpec object reference to copy.

Definition at line 79 of file FileSpec.cpp.

◆ FileSpec() [5/5]

FileSpec::FileSpec ( const FileSpec rhs)

Copy constructor.

Makes a copy of the uniqued directory and filename strings from rhs if it is not nullptr.

Parameters
[in]rhsA const FileSpec object pointer to copy if non-nullptr.

Definition at line 84 of file FileSpec.cpp.

◆ ~FileSpec()

FileSpec::~FileSpec ( )

Destructor.

Definition at line 90 of file FileSpec.cpp.

Member Function Documentation

◆ AppendPathComponent() [1/2]

void FileSpec::AppendPathComponent ( llvm::StringRef  component)

◆ AppendPathComponent() [2/2]

void FileSpec::AppendPathComponent ( const FileSpec new_path)

Definition at line 470 of file FileSpec.cpp.

References AppendPathComponent(), and GetPath().

◆ Clear()

void FileSpec::Clear ( )

◆ Compare()

int FileSpec::Compare ( const FileSpec lhs,
const FileSpec rhs,
bool  full 
)
static

Compare two FileSpec objects.

If full is true, then both the directory and the filename must match. If full is false, then the directory names for lhs and rhs are only compared if they are both not empty. This allows a FileSpec object to only contain a filename and it can match FileSpec objects that have matching filenames with different paths.

Parameters
[in]lhsA const reference to the Left Hand Side object to compare.
[in]rhsA const reference to the Right Hand Side object to compare.
[in]fullIf true, then both the directory and filenames will have to match for a compare to return zero (equal to). If false and either directory from lhs or rhs is empty, then only the filename will be compared, else a full comparison is done.
Returns
  • -1 if lhs is less than rhs
  • 0 if lhs is equal to rhs
  • 1 if lhs is greater than rhs

Definition at line 298 of file FileSpec.cpp.

References lldb_private::ConstString::Compare(), IsCaseSensitive(), m_directory, and m_filename.

Referenced by lldb_private::Declaration::Compare(), lldb_private::LineEntry::Compare(), lldb_private::Declaration::FileAndLineEqual(), operator<(), and lldb_private::FileLineResolver::SearchCallback().

◆ CopyByAppendingPathComponent()

FileSpec FileSpec::CopyByAppendingPathComponent ( llvm::StringRef  component) const

◆ CopyByRemovingLastPathComponent()

FileSpec FileSpec::CopyByRemovingLastPathComponent ( ) const

◆ DirectoryEquals()

bool FileSpec::DirectoryEquals ( const FileSpec other) const

Definition at line 254 of file FileSpec.cpp.

References lldb_private::ConstString::Equals(), IsCaseSensitive(), and m_directory.

Referenced by operator==().

◆ Dump()

void FileSpec::Dump ( Stream s) const

Dump this object to a Stream.

Dump the object to the supplied stream s. If the object contains a valid directory name, it will be displayed followed by a directory delimiter, and the filename.

Parameters
[in]sThe stream to which to dump the object description.

Definition at line 350 of file FileSpec.cpp.

References GetPath(), m_filename, m_style, lldb_private::Stream::PutChar(), and lldb_private::Stream::PutCString().

Referenced by lldb_private::SymbolVendor::Dump(), lldb_private::ProcessInstanceInfo::Dump(), DumpFullpath(), lldb_private::LineEntry::DumpStopContext(), lldb_private::FormatEntity::FormatFileSpec(), lldb_private::BreakpointLocation::GetDescription(), lldb_private::operator<<(), and UUIDsMatch().

◆ Equal()

bool FileSpec::Equal ( const FileSpec a,
const FileSpec b,
bool  full 
)
static

◆ FileEquals()

bool FileSpec::FileEquals ( const FileSpec other) const

Definition at line 259 of file FileSpec.cpp.

References lldb_private::ConstString::Equals(), IsCaseSensitive(), and m_filename.

Referenced by operator==().

◆ GetCString()

const char * FileSpec::GetCString ( bool  denormalize = true) const

Definition at line 392 of file FileSpec.cpp.

References GetPath().

Referenced by ChildFunc(), lldb_private::HostInfoBase::ComputeGlobalTempFileDirectory(), lldb_private::HostInfoBase::ComputeProcessTempFileDirectory(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::CreateSymlink(), ProcessMonitor::Detach(), lldb_private::ProcessWindows::DoLaunch(), ProcessFreeBSD::DoLaunch(), lldb_private::FileAction::Dump(), DupDescriptor(), DYLDRendezvous::DYLDRendezvous(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::FreePortForProcess(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetFilePermissions(), lldb_private::FileAction::GetPath(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteWorkingDirectory(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(), lldb_private::Platform::Install(), lldb_private::ProcessLauncherWindows::LaunchProcess(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::MakeDirectory(), lldb_private::darwin_process_launcher::PosixSpawnChildForPTraceDebugging(), lldb_private::FileSystem::Readlink(), RecurseCopy_Callback(), lldb_private::FileSystem::ResolveSymbolicLink(), lldb_private::SaveMiniDump(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::SetFilePermissions(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::SetRemoteWorkingDirectory(), lldb_private::Platform::SetRemoteWorkingDirectory(), lldb_private::FileSystem::Symlink(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Unlink(), and ProcessMonitor::~ProcessMonitor().

◆ GetDirectory() [1/2]

ConstString & FileSpec::GetDirectory ( )

Directory string get accessor.

Returns
A reference to the directory string object.

Definition at line 363 of file FileSpec.cpp.

References m_directory.

Referenced by SymbolFileDWARF::CalculateAbilities(), SymbolFileDWARFDebugMap::CompleteType(), lldb_private::ComputeClangResourceDirectory(), lldb_private::HostInfoBase::ComputeGlobalTempFileDirectory(), lldb_private::HostInfoMacOSX::ComputeHeaderDirectory(), lldb_private::HostInfoPosix::ComputeHeaderDirectory(), lldb_private::HostInfoBase::ComputePathRelativeToLibrary(), lldb_private::HostInfoBase::ComputeProcessTempFileDirectory(), lldb_private::HostInfoBase::ComputeSharedLibraryDirectory(), lldb_private::HostInfoMacOSX::ComputeSupportExeDirectory(), lldb_private::HostInfoLinux::ComputeSupportExeDirectory(), lldb_private::HostInfoMacOSX::ComputeSystemPluginsDirectory(), lldb_private::HostInfoLinux::ComputeSystemPluginsDirectory(), lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory(), lldb_private::HostInfoLinux::ComputeUserPluginsDirectory(), DefaultComputeClangResourceDirectory(), CommandObjectTargetCreate::DoExecute(), DumpDirectory(), DumpFile(), CommandObjectSourceInfo::DumpFileLinesInCompUnit(), CommandObjectSourceInfo::DumpLinesInSymbolContexts(), Equal(), lldb_private::SourceManager::File::File(), lldb_private::BreakpointResolverFileLine::FilterContexts(), lldb_private::SymbolContext::FindBestGlobalDataSymbol(), lldb_private::Module::FindCompileUnits(), lldb_private::TargetList::FindTargetWithExecutableAndArchitecture(), ObjectFileMachO::GetDependentModules(), SymbolFileDWARF::GetGlobalAranges(), lldb_private::Target::GetOrCreateModule(), lldb_private::ScriptInterpreterPython::GetPythonDir(), PlatformDarwin::GetSharedModuleWithLocalCache(), lldb_private::ClangExpressionDeclMap::GetSymbolAddress(), lldb_private::Platform::Install(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), PlatformDarwin::LocateExecutable(), lldb_private::Symbols::LocateExecutableSymbolFile(), LocateMacOSXFilesUsingDebugSymbols(), MakeAbsolute(), lldb_private::ModuleSpec::Matches(), lldb_private::Module::MatchesModuleSpec(), lldb_private::SearchFilterByModule::ModulePasses(), CommandObjectSourceList::SourceInfo::operator<(), SymbolFilePDB::ParseDeclsForContext(), ObjectFilePECOFF::ParseDependentModules(), ObjectFileMachO::ParseSymtab(), lldb_private::minidump::ProcessMinidump::ReadModuleList(), RecurseCopy_Callback(), lldb_private::FileSystem::Resolve(), lldb_private::FileSystem::ResolveExecutableLocation(), lldb_private::Symbol::ResolveReExportedSymbolInModuleSpec(), lldb_private::CompileUnit::ResolveSymbolContext(), lldb_private::SearchFilterByModule::Search(), lldb_private::BreakpointResolverFileLine::SearchCallback(), lldb_private::FileLineResolver::SearchCallback(), lldb_private::CommandCompletions::SourceFileCompleter::SearchCallback(), lldb_private::CommandInterpreter::SourceInitFile(), and lldb_private::TargetList::~TargetList().

◆ GetDirectory() [2/2]

ConstString FileSpec::GetDirectory ( ) const

Directory string const get accessor.

Returns
A const reference to the directory string object.

Definition at line 366 of file FileSpec.cpp.

References m_directory.

◆ GetFilename() [1/2]

ConstString & FileSpec::GetFilename ( )

Filename string get accessor.

Returns
A reference to the filename string object.

Definition at line 369 of file FileSpec.cpp.

References m_filename.

Referenced by CommandObjectTargetSymbolsAdd::AddModuleSymbols(), lldb_private::AppleObjCRuntime::AppleIsModuleObjCLibrary(), lldb_private::Target::Attach(), DynamicLoaderMacOS::CanLoadImage(), lldb_private::ThreadPlanCallFunction::ConstructorSetup(), lldb_private::REPL::Create(), CommandObjectPlatformPutFile::DoExecute(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoLaunch(), ObjectFileELF::Dump(), lldb_private::ProcessInstanceInfo::Dump(), lldb_private::Target::Dump(), DumpBasename(), DumpCompileUnitLineTable(), DumpFile(), CommandObjectSourceInfo::DumpFileLinesInCompUnit(), CommandObjectSourceInfo::DumpLinesInSymbolContexts(), lldb_private::Section::DumpName(), lldb_private::LineEntry::DumpStopContext(), lldb_private::Declaration::DumpStopContext(), EnumerateDirectoryCallback(), lldb_private::SourceManager::File::File(), SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(), lldb_private::RenderScriptRuntime::FixupScriptDetails(), lldb_private::FormatEntity::FormatFileSpec(), PlatformRemoteDarwinDevice::GetConnectedSDKIndex(), lldb_private::AddressResolverFileLine::GetDescription(), lldb::SBProcess::GetDescription(), lldb_private::Module::GetDescription(), lldb_private::SearchFilterByModule::GetDescription(), GetFreeBSDProcessArgs(), lldb_private::DWARFCallFrameInfo::GetFunctionAddressAndSizeVector(), lldb_private::process_linux::NativeProcessLinux::GetLoadedModuleFileSpec(), GetMacOSXProcessArgs(), lldb_private::HostProcessPosix::GetMainModule(), lldb_private::Breakpoint::GetMatchingFileLine(), lldb_private::ProcessInfo::GetName(), lldb_private::ProcessInfo::GetNameLength(), GetNetBSDProcessArgs(), GetOpenBSDProcessArgs(), lldb_private::Target::GetOrCreateModule(), lldb_private::DynamicLoaderDarwin::GetPThreadLibraryModule(), lldb_private::ModuleList::GetSharedModule(), PlatformDarwin::GetSharedModuleWithLocalCache(), lldb_private::Args::GetShellSafeArgument(), GetXcodeContentsPath(), lldb_private::CommandInterpreter::HandleCommandsFromFile(), lldb_private::ClangUtilityFunction::Install(), lldb_private::Platform::Install(), lldb_private::Thread::JumpToLine(), LaunchInNewTerminalWithAppleScript(), lldb_private::formatters::LibcxxFunctionSummaryProvider(), lldb_private::Platform::LoadImage(), lldb_private::Platform::LoadImageUsingPaths(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), LocateDSYMInVincinityOfExecutable(), PlatformDarwin::LocateExecutable(), lldb_private::Symbols::LocateExecutableObjectFile(), PlatformDarwin::LocateExecutableScriptingResources(), lldb_private::Symbols::LocateExecutableSymbolFile(), LocateExecutableSymbolFileDsym(), LocateMacOSXFilesUsingDebugSymbols(), LookForDsymNextToExecutablePath(), MakeAbsolute(), lldb_private::InstrumentationRuntime::ModulesDidLoad(), OperatingSystemPython::OperatingSystemPython(), CommandObjectSourceList::SourceInfo::operator<(), lldb_private::ClangUserExpression::Parse(), ObjectFileMachO::ParseSymtab(), RecurseCopy_Callback(), RegisterObjCExceptionRecognizer(), lldb_private::FileSystem::Resolve(), lldb_private::FileSystem::ResolveExecutableLocation(), PlatformRemoteDarwinDevice::SDKDirectoryInfo::SDKDirectoryInfo(), lldb_private::BreakpointResolverFileLine::SearchCallback(), lldb_private::AddressResolverFileLine::SearchCallback(), lldb_private::CommandCompletions::SourceFileCompleter::SearchCallback(), lldb_private::CommandInterpreter::SourceInitFile(), and lldb_private::FunctionCaller::WriteFunctionWrapper().

◆ GetFilename() [2/2]

ConstString FileSpec::GetFilename ( ) const

Filename string const get accessor.

Returns
A const reference to the filename string object.

Definition at line 372 of file FileSpec.cpp.

References m_filename.

◆ GetFileNameExtension()

ConstString FileSpec::GetFileNameExtension ( ) const

Extract the extension of the file.

Returns a ConstString that represents the extension of the filename for this FileSpec object. If this object does not represent a file, or the filename has no extension, ConstString(nullptr) is returned. The dot ('.') character is not returned as part of the extension

Returns
Returns the extension of the file as a ConstString object.

Definition at line 412 of file FileSpec.cpp.

References lldb_private::ConstString::GetStringRef(), m_filename, and m_style.

Referenced by IsSourceImplementationFile(), LoadPluginCallback(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), and SymbolFileDWARF::UpdateExternalModuleListIfNeeded().

◆ GetFileNameStrippingExtension()

ConstString FileSpec::GetFileNameStrippingExtension ( ) const

Return the filename without the extension part.

Returns a ConstString that represents the filename of this object without the extension part (e.g. for a file named "foo.bar", "foo" is returned)

Returns
Returns the filename without extension as a ConstString object.

Definition at line 417 of file FileSpec.cpp.

References lldb_private::ConstString::GetStringRef(), m_filename, and m_style.

Referenced by CommandObjectTargetSymbolsAdd::AddModuleSymbols(), and PlatformDarwin::LocateExecutableScriptingResources().

◆ GetLastPathComponent()

ConstString FileSpec::GetLastPathComponent ( ) const

◆ GetPath() [1/3]

size_t FileSpec::GetPath ( char *  path,
size_t  max_path_length,
bool  denormalize = true 
) const

Extract the full path to the file.

Extract the directory and path into a fixed buffer. This is needed as the directory and path are stored in separate string values.

Parameters
[out]pathThe buffer in which to place the extracted full path.
[in]max_path_lengthThe maximum length of path.
Returns
Returns the number of characters that would be needed to properly copy the full path into path. If the returned number is less than max_path_length, then the path is properly copied and terminated. If the return value is >= max_path_length, then the path was truncated (but is still NULL terminated).

Definition at line 376 of file FileSpec.cpp.

Referenced by PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(), lldb_private::FileCollector::AddFile(), lldb_private::FileCollector::AddFileImpl(), CommandObjectTargetSymbolsAdd::AddModuleSymbols(), lldb_private::Block::AddRange(), AppendPathComponent(), lldb_private::Process::Attach(), lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo(), SymbolFilePDB::CalculateAbilities(), lldb_private::npdb::SymbolFileNativePDB::CalculateAbilities(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::CalculateMD5(), lldb_private::Platform::CalculateMD5(), CheckPathForXcode(), lldb_private::ComputeClangResourceDirectory(), lldb_private::HostInfoBase::ComputeGlobalTempFileDirectory(), lldb_private::HostInfoMacOSX::ComputeHeaderDirectory(), lldb_private::HostInfoPosix::ComputeHeaderDirectory(), lldb_private::HostInfoBase::ComputePathRelativeToLibrary(), lldb_private::HostInfoBase::ComputeProcessTempFileDirectory(), lldb_private::HostInfoMacOSX::ComputeSupportExeDirectory(), lldb_private::HostInfoMacOSX::ComputeSystemPluginsDirectory(), lldb_private::HostInfoLinux::ComputeSystemPluginsDirectory(), lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory(), lldb_private::ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(), CopyByRemovingLastPathComponent(), lldb_private::ClangModulesDeclVendor::Create(), lldb_private::REPL::Create(), CommandLoader::Create(), lldb_private::Target::CreateBreakpointsFromFile(), lldb_private::FileSystem::CreateDataBuffer(), SymbolVendorMacOSX::CreateInstance(), ProcessMachCore::CreateInstance(), lldb_private::minidump::ProcessMinidump::CreateInstance(), ProcessElfCore::CreateInstance(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::CreateSymlink(), lldb_private::DebuggerThread::DebugAttach(), lldb_private::DebuggerThread::DebugLaunch(), DefaultComputeClangResourceDirectory(), lldb_private::FileSystem::DirBegin(), lldb_private::repro::Generator::Discard(), CommandObjectSourceList::DisplayFunctionSource(), lldb_private::SourceManager::File::DisplaySourceLines(), CommandObjectBugreportUnwind::DoExecute(), CommandObjectMemoryRead::DoExecute(), CommandObjectSettingsWrite::DoExecute(), CommandObjectTargetVariable::DoExecute(), CommandObjectPlatformProcessLaunch::DoExecute(), CommandObjectTargetModulesAdd::DoExecute(), CommandObjectTargetModulesLoad::DoExecute(), CommandObjectTargetSymbolsAdd::DoExecute(), CommandObjectRenderScriptRuntimeAllocationDump::DoExecute(), lldb_private::ProcessWindows::DoLaunch(), ProcessFreeBSD::DoLaunch(), PlatformPOSIX::DoLoadImage(), lldb_private::Platform::DownloadModuleSlice(), lldb_private::Symtab::Dump(), Dump(), lldb_private::Module::Dump(), DumpFullpath(), CommandObjectTargetVariable::DumpGlobalVariableList(), lldb::DumpProcessGDBRemotePacketHistory(), DumpTargetInfo(), lldb_private::OptionValueFileSpec::DumpValue(), lldb_private::FileSystem::Exists(), lldb_private::FileCollector::FileCollector(), lldb_private::PathMappingList::FindFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::FindModuleFile(), PlatformDarwin::FindSDKInXcodeForModules(), lldb_private::Function::GetBlock(), lldb_private::FileSystem::GetByteSize(), lldb_private::GetClangResourceDir(), GetCString(), lldb_private::BreakpointResolverFileLine::GetDescription(), lldb_private::FileLineResolver::GetDescription(), lldb_private::Module::GetDescription(), PlatformDarwin::GetDeveloperDirectory(), PlatformRemoteDarwinDevice::GetDeviceSupportDirectoryForOSVersion(), SymbolFileDWARF::GetDwpSymbolFile(), lldb_private::FileSystem::GetExternalPath(), PlatformPOSIX::GetFile(), lldb_private::platform_android::PlatformAndroid::GetFile(), lldb_private::OptionValueFileSpec::GetFileContents(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFileExists(), lldb_private::process_gdb_remote::ProcessGDBRemote::GetFileLoadAddress(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFilePermissions(), lldb_private::Platform::GetFilePermissions(), lldb_private::RemoteAwarePlatform::GetFileSize(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFileSize(), PlatformMacOSX::GetFileWithUUID(), GetLastPathComponent(), lldb_private::FileSystem::GetModificationTime(), SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetModuleInfo(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetModuleSpec(), lldb_private::process_gdb_remote::ProcessGDBRemote::GetModuleSpec(), ObjectFilePECOFF::GetModuleSpecifications(), ObjectFileELF::GetModuleSpecifications(), lldb_private::ObjectFile::GetModuleSpecifications(), GetModuleSpecInfoFromUUIDDictionary(), lldb_private::SymbolContext::GetParentOfInlinedScope(), GetPath(), SymbolFilePDB::GetPDBSession(), lldb_private::FileSystem::GetPermissions(), lldb_private::ScriptInterpreterPython::GetPythonDir(), lldb_private::platform_linux::PlatformLinux::GetResumeCountForLaunchInfo(), lldb_private::platform_netbsd::PlatformNetBSD::GetResumeCountForLaunchInfo(), PlatformDarwin::GetResumeCountForLaunchInfo(), lldb_private::repro::Generator::GetRoot(), PlatformMacOSX::GetSDKDirectory(), lldb::SBSection::GetSectionData(), ObjectFileMachO::GetSharedCacheUUID(), PlatformRemoteDarwinDevice::GetSharedModule(), PlatformDarwin::GetSharedModule(), lldb_private::ModuleList::GetSharedModule(), PlatformDarwin::GetSharedModuleWithLocalCache(), PlatformRemoteDarwinDevice::GetStatus(), lldb_private::FileSystem::GetStatus(), GetSymbolDeclarationFromAddress(), PlatformRemoteDarwinDevice::GetSymbolFile(), PlatformAppleTVSimulator::GetSymbolFile(), PlatformAppleWatchSimulator::GetSymbolFile(), PlatformiOSSimulator::GetSymbolFile(), lldb_private::platform_android::AdbClient::GetSyncService(), lldb_private::Value::GetValueAsData(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_jModulesInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(), lldb_private::CommandInterpreter::HandleCommandsFromFile(), HandleFileAction(), HexagonDYLDRendezvous::HexagonDYLDRendezvous(), lldb_private::FileSystem::Initialize(), lldb::SBPlatform::Install(), lldb_private::Platform::Install(), IsAbsolute(), lldb_private::FileSystem::IsDirectory(), lldb_private::FileSystem::IsLocal(), lldb_private::repro::CommandProvider::Keep(), lldb_private::Target::Launch(), lldb_private::Process::Launch(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchGDBServer(), lldb_private::darwin_process_launcher::LaunchInferior(), LaunchInNewTerminalWithAppleScript(), lldb_private::ProcessLauncherPosixFork::LaunchProcess(), lldb_private::ProcessLauncherWindows::LaunchProcess(), lldb_private::Platform::LaunchProcess(), lldb_private::repro::Loader::LoadIndex(), LoadPlugin(), LoadPluginCallback(), lldb_private::ScriptInterpreterPythonImpl::LoadPluginModule(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), lldb_private::Module::LoadScriptingResourceInTarget(), LocateDSYMInVincinityOfExecutable(), PlatformDarwin::LocateExecutable(), lldb_private::Symbols::LocateExecutableSymbolFile(), LocateMacOSXFilesUsingDebugSymbols(), lldb_private::ModuleList::LogUUIDAndPaths(), lldb_private::FileSystem::MakeAbsolute(), MakeCacheFolderForFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::MakeDirectory(), lldb_private::Platform::MakeDirectory(), lldb_private::ObjectFile::MapFileData(), lldb_private::Module::Module(), lldb_private::ObjectFile::ObjectFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::OpenFile(), OperatingSystemPython::OperatingSystemPython(), DWARFASTParserClang::ParseChildMembers(), SymbolFilePDB::ParseDeclsForContext(), ObjectFilePECOFF::ParseDependentModules(), lldb_private::StructuredData::ParseJSONFromFile(), lldb_private::lldb_renderscript::RSModuleDescriptor::ParseRSInfo(), DWARFDebugLine::ParseSupportFiles(), DWARFASTParserClang::ParseTypeFromDWARF(), PrependPathComponent(), lldb::SBPlatform::Put(), PlatformPOSIX::PutFile(), lldb_private::platform_android::PlatformAndroid::PutFile(), lldb_private::Platform::PutFile(), lldb_private::FileSystem::Readable(), lldb_private::Process::ReadModuleFromMemory(), RecurseCopy_Callback(), RemoveLastPathComponent(), lldb_private::repro::Registry::Replay(), lldb_private::FileSystem::Resolve(), resolveCompDir(), PlatformRemoteDarwinDevice::ResolveExecutable(), lldb_private::PlatformWindows::ResolveExecutable(), PlatformPOSIX::ResolveExecutable(), PlatformAppleWatchSimulator::ResolveExecutable(), PlatformAppleTVSimulator::ResolveExecutable(), PlatformiOSSimulator::ResolveExecutable(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ResolveExecutable(), lldb_private::Platform::ResolveExecutable(), DynamicLoaderPOSIXDYLD::ResolveExecutableModule(), lldb_private::Module::ResolveSymbolContextsForFileSpec(), lldb_private::FileSystem::ResolveSymbolicLink(), lldb_private::PathMappingList::ReverseRemapPath(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::RunShellCommand(), ObjectFileMachO::SaveCore(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SendArgumentsPacket(), lldb_private::Target::SerializeBreakpointsToFile(), lldb_private::BreakpointResolverFileLine::SerializeToStructuredData(), lldb_private::BreakpointResolverAddress::SerializeToStructuredData(), lldb_private::SearchFilterByModule::SerializeToStructuredData(), lldb_private::ProcessInfo::SetExecutableFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetFilePermissions(), lldb_private::Platform::SetFilePermissions(), lldb_private::Symbol::SetReExportedSymbolSharedLibrary(), lldb_private::SectionLoadList::SetSectionUnloaded(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDERR(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDIN(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDOUT(), lldb_private::Module::SetSymbolFileFileSpec(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetWorkingDir(), lldb_private::Platform::SetWorkingDirectory(), lldb_private::platform_android::AdbClient::ShellToFile(), ShouldLaunchUsingXPC(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), lldb_private::RemoteAwarePlatform::Unlink(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::Unlink(), lldb_private::DynamicLoaderDarwin::UnloadModuleSections(), SymbolFileDWARF::UpdateExternalModuleListIfNeeded(), PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded(), lldb_private::FileCollector::WriteMapping(), lldb_private::Module::~Module(), and lldb_private::TargetList::~TargetList().

◆ GetPath() [2/3]

std::string FileSpec::GetPath ( bool  denormalize = true) const

Extract the full path to the file.

Extract the directory and path into a std::string, which is returned.

Returns
Returns a std::string with the directory and filename concatenated.

Definition at line 386 of file FileSpec.cpp.

References GetPath().

◆ GetPath() [3/3]

void FileSpec::GetPath ( llvm::SmallVectorImpl< char > &  path,
bool  denormalize = true 
) const

Extract the full path to the file.

Extract the directory and path into an llvm::SmallVectorImpl<>

Returns
Returns a std::string with the directory and filename concatenated.

Definition at line 396 of file FileSpec.cpp.

References lldb_private::ConstString::GetStringRef(), m_directory, m_filename, and m_style.

◆ GetPathStyle()

FileSpec::Style FileSpec::GetPathStyle ( ) const

◆ GuessPathStyle()

llvm::Optional< FileSpec::Style > FileSpec::GuessPathStyle ( llvm::StringRef  absolute_path)
static

Attempt to guess path style for a given path string.

It returns a style, if it was able to make a reasonable guess, or None if it wasn't. The guess will be correct if the input path was a valid absolute path on the system which produced it. On other paths the result of this function is unreliable (e.g. "c:\foo.txt" is a valid relative posix path).

Definition at line 336 of file FileSpec.cpp.

References lldb_private::None.

◆ IsAbsolute()

bool FileSpec::IsAbsolute ( ) const

Returns true if the filespec represents an absolute path.

Returns
true if the filespec represents an absolute path, false otherwise.

Definition at line 507 of file FileSpec.cpp.

References GetPath(), and m_style.

Referenced by lldb_private::HostInfoLinux::ComputeSupportExeDirectory(), IsRelative(), lldb_private::Platform::LoadImageUsingPaths(), and lldb_private::Symbols::LocateExecutableSymbolFile().

◆ IsCaseSensitive()

bool lldb_private::FileSpec::IsCaseSensitive ( ) const
inline

Case sensitivity of path.

Returns
true if the file path is case sensitive (POSIX), false if case insensitive (Windows).

Definition at line 231 of file FileSpec.h.

Referenced by Compare(), DirectoryEquals(), Equal(), and FileEquals().

◆ IsRelative()

bool FileSpec::IsRelative ( ) const

◆ IsResolved()

bool lldb_private::FileSpec::IsResolved ( ) const
inline

Definition at line 390 of file FileSpec.h.

◆ IsSourceImplementationFile()

bool FileSpec::IsSourceImplementationFile ( ) const

Returns true if the filespec represents an implementation source file (files with a ".c", ".cpp", ".m", ".mm" (many more) extension).

Returns
true if the filespec represents an implementation source file, false otherwise.

Definition at line 490 of file FileSpec.cpp.

References lldb_private::RegularExpression::Execute(), GetFileNameExtension(), and lldb_private::ConstString::GetStringRef().

Referenced by lldb_private::Target::CreateBreakpoint().

◆ MakeAbsolute()

void FileSpec::MakeAbsolute ( const FileSpec dir)

Make the FileSpec absolute by treating it relative to dir.

Absolute FileSpecs are never changed by this function.

Definition at line 522 of file FileSpec.cpp.

References GetDirectory(), GetFilename(), GetPathStyle(), lldb_private::ConstString::GetStringRef(), IsRelative(), and PrependPathComponent().

Referenced by SymbolFileDWARF::ParseCompileUnit().

◆ MemorySize()

size_t FileSpec::MemorySize ( ) const

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, not any 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 423 of file FileSpec.cpp.

References m_directory, m_filename, and lldb_private::ConstString::MemorySize().

◆ operator bool()

FileSpec::operator bool ( ) const
explicit

Convert to pointer operator.

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

FileSpec file_spec(...);
if (file_spec)
{ ...
Returns
A pointer to this object if either the directory or filename is valid, nullptr otherwise.

Definition at line 245 of file FileSpec.cpp.

References m_directory, and m_filename.

◆ operator!()

bool FileSpec::operator! ( ) const

Logical NOT operator.

This allows code to check a FileSpec object to see if it is invalid using code such as:

FileSpec file_spec(...);
if (!file_spec)
{ ...
Returns
Returns true if the object has an empty directory and filename, false otherwise.

Definition at line 252 of file FileSpec.cpp.

References m_directory, and m_filename.

◆ operator!=()

bool FileSpec::operator!= ( const FileSpec rhs) const

Not equal to operator.

Tests if this object is not equal to rhs.

Parameters
[in]rhsA const FileSpec object reference to compare this object to.
Returns
true if this object is equal to rhs, false otherwise.

Definition at line 270 of file FileSpec.cpp.

◆ operator<()

bool FileSpec::operator< ( const FileSpec rhs) const

Less than to operator.

Tests if this object is less than rhs.

Parameters
[in]rhsA const FileSpec object reference to compare this object to.
Returns
true if this object is less than rhs, false otherwise.

Definition at line 273 of file FileSpec.cpp.

References Compare().

◆ operator=()

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

Assignment operator.

Makes a copy of the uniqued directory and filename strings from rhs.

Parameters
[in]rhsA const FileSpec object reference to assign to this object.
Returns
A const reference to this object.

Definition at line 183 of file FileSpec.cpp.

References m_directory, m_filename, m_is_resolved, and m_style.

◆ operator==()

bool FileSpec::operator== ( const FileSpec rhs) const

Equal to operator.

Tests if this object is equal to rhs.

Parameters
[in]rhsA const FileSpec object reference to compare this object to.
Returns
true if this object is equal to rhs, false otherwise.

Definition at line 265 of file FileSpec.cpp.

References DirectoryEquals(), and FileEquals().

◆ PrependPathComponent() [1/2]

void FileSpec::PrependPathComponent ( llvm::StringRef  component)

◆ PrependPathComponent() [2/2]

void FileSpec::PrependPathComponent ( const FileSpec new_path)

Definition at line 459 of file FileSpec.cpp.

References GetPath(), and PrependPathComponent().

◆ RemoveLastPathComponent()

bool FileSpec::RemoveLastPathComponent ( )

Removes the last path component by replacing the current path with its parent.

When the current path has no parent, this is a no-op.

Returns
A boolean value indicating whether the path was updated.

Definition at line 474 of file FileSpec.cpp.

References GetPath(), m_style, and SetFile().

Referenced by SymbolVendorMacOSX::CreateInstance(), PlatformDarwin::FindBundleBinaryInExecSearchPaths(), GetModuleSpecInfoFromUUIDDictionary(), LocateDSYMInVincinityOfExecutable(), and LookForDsymNextToExecutablePath().

◆ SetFile() [1/3]

void FileSpec::SetFile ( llvm::StringRef  path,
Style  style 
)

Change the file specified with a new path.

Update the contents of this object with a new path. The path will be split up into a directory and filename and stored as uniqued string values for quick comparison and efficient memory usage.

Parameters
[in]pathA full, partial, or relative path to a file.
[in]resolve_pathIf true, then we will try to resolve links the path using the static FileSpec::Resolve.

Definition at line 198 of file FileSpec.cpp.

References lldb_private::ConstString::Clear(), m_directory, m_filename, m_is_resolved, m_style, and lldb_private::ConstString::SetString().

Referenced by lldb::SBTarget::AddModule(), AppendPathComponent(), lldb::SBTarget::AttachToProcessWithName(), lldb_private::BreakpointResolverAddress::CreateFromStructuredData(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::DecodeProcessInfoResponse(), CommandObjectTargetCreate::DoExecute(), CommandObjectTargetSymbolsAdd::DoExecute(), ProcessElfCore::DoLoadCore(), PlatformPOSIX::DoLoadImage(), FileSpec(), DYLDRendezvous::FillSOEntryFromModuleInfo(), lldb_private::PathMappingList::FindFile(), PlatformDarwin::GetDeveloperDirectory(), SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(), DWARFDebugLine::Prologue::GetFile(), PlatformRemoteDarwinDevice::GetFileInSDK(), lldb_private::File::GetFileSpec(), GetFreeBSDProcessArgs(), GetMacOSXProcessArgs(), lldb_private::HostProcessWindows::GetMainModule(), lldb_private::Host::GetModuleFileSpecForHostAddress(), GetModuleSpecInfoFromUUIDDictionary(), GetNetBSDProcessArgs(), GetOpenBSDProcessArgs(), GetProcessAndStatInfo(), lldb_private::HostInfoNetBSD::GetProgramFileSpec(), lldb_private::HostInfoFreeBSD::GetProgramFileSpec(), lldb_private::HostInfoMacOSX::GetProgramFileSpec(), lldb_private::HostInfoLinux::GetProgramFileSpec(), PlatformMacOSX::GetSDKDirectory(), PlatformRemoteDarwinDevice::GetSymbolFile(), PlatformAppleTVSimulator::GetSymbolFile(), PlatformAppleWatchSimulator::GetSymbolFile(), PlatformiOSSimulator::GetSymbolFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetWorkingDir(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_A(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(), CommandObjectProcessAttach::CommandOptions::HandleOptionArgumentCompletion(), CommandObjectPlatformProcessAttach::CommandOptions::HandleOptionArgumentCompletion(), DynamicLoaderMacOSXDYLD::ParseLoadCommands(), DWARFDebugLine::ParseSupportFiles(), ObjectFileMachO::ParseSymtab(), PrependPathComponent(), lldb_private::FileSystem::Readlink(), DYLDRendezvous::ReadSOEntryFromMemory(), RemoveLastPathComponent(), PlatformPOSIX::ResolveExecutable(), lldb_private::PlatformWindows::ResolveExecutable(), lldb_private::PathMappingList::ReverseRemapPath(), lldb_private::ProcessInfo::SetArguments(), SetFile(), lldb_private::OptionValueFileSpec::SetValueFromString(), lldb_private::CommandInterpreter::SourceInitFile(), lldb_private::ObjectFile::SplitArchivePathWithObject(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), SymbolFileDWARF::UpdateExternalModuleListIfNeeded(), and lldb_private::TargetList::~TargetList().

◆ SetFile() [2/3]

void FileSpec::SetFile ( llvm::StringRef  path,
const llvm::Triple &  Triple 
)

Definition at line 236 of file FileSpec.cpp.

References SetFile().

◆ SetFile() [3/3]

void FileSpec::SetFile ( llvm::StringRef  path)
protected

Definition at line 193 of file FileSpec.cpp.

References m_style, and SetFile().

◆ SetIsResolved()

void lldb_private::FileSpec::SetIsResolved ( bool  is_resolved)
inline

Set if the file path has been resolved or not.

If you know a file path is already resolved and avoided passing a true parameter for any functions that take a "bool resolve_path" parameter, you can set the value manually using this call to make sure we don't try and resolve it later, or try and resolve a path that has already been resolved.

Parameters
[in]is_resolvedA boolean value that will replace the current value that indicates if the paths in this object have been resolved.

Definition at line 403 of file FileSpec.h.

Referenced by lldb_private::FileSystem::Resolve().

◆ SetPath()

void lldb_private::FileSpec::SetPath ( llvm::StringRef  p)
inline

Temporary helper for FileSystem change.

Definition at line 296 of file FileSpec.h.

Referenced by lldb_private::FileSystem::Resolve().

Member Data Documentation

◆ m_directory

ConstString lldb_private::FileSpec::m_directory
protected

The uniqued directory path.

Definition at line 428 of file FileSpec.h.

Referenced by Clear(), Compare(), DirectoryEquals(), GetDirectory(), GetPath(), MemorySize(), operator bool(), operator!(), operator=(), and SetFile().

◆ m_filename

ConstString lldb_private::FileSpec::m_filename
protected

◆ m_is_resolved

bool lldb_private::FileSpec::m_is_resolved = false
mutableprotected

True if this path has been resolved.

Definition at line 430 of file FileSpec.h.

Referenced by operator=(), and SetFile().

◆ m_style

Style lldb_private::FileSpec::m_style
protected

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