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

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> >

Definition at line 44 of file UserIDResolver.h.

Constructor & Destructor Documentation

◆ ~UserIDResolver()

UserIDResolver::~UserIDResolver ( )

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 

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)

◆ GetNoopResolver()

UserIDResolver & UserIDResolver::GetNoopResolver ( )

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)

Member Data Documentation

◆ m_gid_cache

Map lldb_private::UserIDResolver::m_gid_cache

Definition at line 52 of file UserIDResolver.h.

Referenced by GetGroupName().

◆ m_mutex

std::mutex lldb_private::UserIDResolver::m_mutex

Definition at line 50 of file UserIDResolver.h.

Referenced by Get().

◆ m_uid_cache

Map lldb_private::UserIDResolver::m_uid_cache

Definition at line 51 of file UserIDResolver.h.

Referenced by GetUserName().

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