LLDB  mainline
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lldb_private::UserIDResolver Class Referenceabstract

An abstract interface for things that know how to map numeric user/group IDs into names. More...

#include <UserIDResolver.h>

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

Public Types

typedef uint32_t id_t
 

Public Member Functions

virtual ~UserIDResolver ()
 
llvm::Optional< llvm::StringRef > GetUserName (id_t uid)
 
llvm::Optional< llvm::StringRef > GetGroupName (id_t gid)
 

Static Public Member Functions

static UserIDResolverGetNoopResolver ()
 Returns a resolver which returns a failure value for each query. More...
 

Protected Member Functions

virtual llvm::Optional< std::string > DoGetUserName (id_t uid)=0
 
virtual llvm::Optional< std::string > DoGetGroupName (id_t gid)=0
 

Private Types

using Map = llvm::DenseMap< id_t, llvm::Optional< std::string > >
 

Private Member Functions

llvm::Optional< llvm::StringRef > Get (id_t id, Map &cache, llvm::Optional< std::string >(UserIDResolver::*do_get)(id_t))
 

Private Attributes

std::mutex m_mutex
 
Map m_uid_cache
 
Map m_gid_cache
 

Detailed Description

An abstract interface for things that know how to map numeric user/group IDs into names.

It caches the resolved names to avoid repeating expensive queries. The cache is internally protected by a mutex, so concurrent queries are safe.

Definition at line 22 of file UserIDResolver.h.

Member Typedef Documentation

◆ id_t

Definition at line 24 of file UserIDResolver.h.

◆ Map

using lldb_private::UserIDResolver::Map = llvm::DenseMap<id_t, llvm::Optional<std::string> >
private

Definition at line 43 of file UserIDResolver.h.

Constructor & Destructor Documentation

◆ ~UserIDResolver()

UserIDResolver::~UserIDResolver ( )
virtualdefault

Member Function Documentation

◆ DoGetGroupName()

virtual llvm::Optional<std::string> lldb_private::UserIDResolver::DoGetGroupName ( id_t  gid)
protectedpure virtual

◆ DoGetUserName()

virtual llvm::Optional<std::string> lldb_private::UserIDResolver::DoGetUserName ( id_t  uid)
protectedpure virtual

◆ Get()

llvm::Optional< llvm::StringRef > UserIDResolver::Get ( id_t  id,
Map cache,
llvm::Optional< std::string >(UserIDResolver::*)(id_t do_get 
)
private

Definition at line 16 of file UserIDResolver.cpp.

References DoGetGroupName(), DoGetUserName(), and m_mutex.

Referenced by GetGroupName(), and GetUserName().

◆ GetGroupName()

llvm::Optional<llvm::StringRef> lldb_private::UserIDResolver::GetGroupName ( id_t  gid)
inline

◆ GetNoopResolver()

UserIDResolver & UserIDResolver::GetNoopResolver ( )
static

Returns a resolver which returns a failure value for each query.

Useful as a fallback value for the case when we know all lookups will fail.

Definition at line 44 of file UserIDResolver.cpp.

References g_noop_resolver.

Referenced by GetGroupName(), and lldb_private::RemoteAwarePlatform::GetUserIDResolver().

◆ GetUserName()

llvm::Optional<llvm::StringRef> lldb_private::UserIDResolver::GetUserName ( id_t  uid)
inline

Member Data Documentation

◆ m_gid_cache

Map lldb_private::UserIDResolver::m_gid_cache
private

Definition at line 51 of file UserIDResolver.h.

Referenced by GetGroupName().

◆ m_mutex

std::mutex lldb_private::UserIDResolver::m_mutex
private

Definition at line 49 of file UserIDResolver.h.

Referenced by Get().

◆ m_uid_cache

Map lldb_private::UserIDResolver::m_uid_cache
private

Definition at line 50 of file UserIDResolver.h.

Referenced by GetUserName().


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