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]

Public Types

typedef uint32_t id_t
 

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Private Types

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

Private Member Functions

std::optional< llvm::StringRef > Get (id_t id, Map &cache, std::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 23 of file UserIDResolver.h.

Member Typedef Documentation

◆ id_t

Definition at line 25 of file UserIDResolver.h.

◆ Map

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

Definition at line 44 of file UserIDResolver.h.

Constructor & Destructor Documentation

◆ ~UserIDResolver()

UserIDResolver::~UserIDResolver ( )
virtualdefault

Member Function Documentation

◆ DoGetGroupName()

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

◆ DoGetUserName()

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

◆ Get()

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

Definition at line 17 of file UserIDResolver.cpp.

References m_mutex.

Referenced by GetGroupName(), and GetUserName().

◆ GetGroupName()

std::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 45 of file UserIDResolver.cpp.

References g_noop_resolver.

Referenced by lldb_private::Platform::GetUserIDResolver().

◆ GetUserName()

std::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 52 of file UserIDResolver.h.

Referenced by GetGroupName().

◆ m_mutex

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

Definition at line 50 of file UserIDResolver.h.

Referenced by Get().

◆ m_uid_cache

Map lldb_private::UserIDResolver::m_uid_cache
private

Definition at line 51 of file UserIDResolver.h.

Referenced by GetUserName().


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