LLDB mainline
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
lldb_private::Broadcaster::BroadcasterImpl Class Reference

BroadcasterImpl contains the actual Broadcaster implementation. More...

#include <Broadcaster.h>

Public Member Functions

 BroadcasterImpl (Broadcaster &broadcaster)
 
 ~BroadcasterImpl ()=default
 
void BroadcastEvent (lldb::EventSP &event_sp)
 
void BroadcastEventIfUnique (lldb::EventSP &event_sp)
 
void BroadcastEvent (uint32_t event_type)
 
void BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp)
 
void BroadcastEventIfUnique (uint32_t event_type)
 
void Clear ()
 
uint32_t AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
 
const std::string & GetBroadcasterName () const
 
BroadcasterGetBroadcaster ()
 
bool GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
 
void SetEventName (uint32_t event_mask, const char *name)
 
const char * GetEventName (uint32_t event_mask) const
 
bool EventTypeHasListeners (uint32_t event_type)
 
void SetPrimaryListener (lldb::ListenerSP listener_sp)
 
bool RemoveListener (lldb_private::Listener *listener, uint32_t event_mask=UINT32_MAX)
 
bool RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 
bool HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 
bool IsHijackedForEvent (uint32_t event_mask)
 
void RestoreBroadcaster ()
 

Protected Types

typedef llvm::SmallVector< std::pair< lldb::ListenerWP, uint32_t >, 4 > collection
 
typedef std::map< uint32_t, std::string > event_names_map
 

Protected Member Functions

void PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique)
 
const char * GetHijackingListenerName ()
 
llvm::SmallVector< std::pair< lldb::ListenerSP, uint32_t & >, 4 > GetListeners (uint32_t event_mask=UINT32_MAX, bool include_primary=true)
 
bool HasListeners (uint32_t event_mask)
 

Protected Attributes

Broadcasterm_broadcaster
 The broadcaster that this implements.
 
event_names_map m_event_names
 Optionally define event names for readability and logging for each event bit.
 
collection m_listeners
 A Broadcaster can have zero, one or many listeners.
 
std::mutex m_listeners_mutex
 A mutex that protects m_listeners.
 
lldb::ListenerSP m_primary_listener_sp
 See the discussion of Broadcasters and Listeners above.
 
uint32_t m_primary_listener_mask = UINT32_MAX
 
std::vector< lldb::ListenerSPm_hijacking_listeners
 A simple mechanism to intercept events from a broadcaster.
 
std::vector< uint32_t > m_hijacking_masks
 At some point we may want to have a stack or Listener collections, but for now this is just for private hijacking.
 

Private Member Functions

 BroadcasterImpl (const BroadcasterImpl &)=delete
 
const BroadcasterImploperator= (const BroadcasterImpl &)=delete
 

Friends

class Listener
 
class Broadcaster
 

Detailed Description

BroadcasterImpl contains the actual Broadcaster implementation.

The Broadcaster makes a BroadcasterImpl which lives as long as it does. The Listeners & the Events hold a weak pointer to the BroadcasterImpl, so that they can survive if a Broadcaster they were listening to is destroyed w/o their being able to unregister from it (which can happen if the Broadcasters & Listeners are being destroyed on separate threads simultaneously. The Broadcaster itself can't be shared out as a weak pointer, because some things that are broadcasters (e.g. the Target and the Process) are shared in their own right.

For the most part, the Broadcaster functions dispatch to the BroadcasterImpl, and are documented in the public Broadcaster API above.

Definition at line 336 of file Broadcaster.h.

Member Typedef Documentation

◆ collection

typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4> lldb_private::Broadcaster::BroadcasterImpl::collection
protected

Definition at line 404 of file Broadcaster.h.

◆ event_names_map

typedef std::map<uint32_t, std::string> lldb_private::Broadcaster::BroadcasterImpl::event_names_map
protected

Definition at line 405 of file Broadcaster.h.

Constructor & Destructor Documentation

◆ BroadcasterImpl() [1/2]

Broadcaster::BroadcasterImpl::BroadcasterImpl ( Broadcaster broadcaster)

Definition at line 34 of file Broadcaster.cpp.

◆ ~BroadcasterImpl()

lldb_private::Broadcaster::BroadcasterImpl::~BroadcasterImpl ( )
default

◆ BroadcasterImpl() [2/2]

lldb_private::Broadcaster::BroadcasterImpl::BroadcasterImpl ( const BroadcasterImpl )
privatedelete

Member Function Documentation

◆ AddListener()

uint32_t Broadcaster::BroadcasterImpl::AddListener ( const lldb::ListenerSP listener_sp,
uint32_t  event_mask 
)

Definition at line 135 of file Broadcaster.cpp.

References UINT32_MAX.

◆ BroadcastEvent() [1/3]

void Broadcaster::BroadcasterImpl::BroadcastEvent ( lldb::EventSP event_sp)

Definition at line 227 of file Broadcaster.cpp.

◆ BroadcastEvent() [2/3]

void Broadcaster::BroadcasterImpl::BroadcastEvent ( uint32_t  event_type)

Definition at line 303 of file Broadcaster.cpp.

◆ BroadcastEvent() [3/3]

void Broadcaster::BroadcasterImpl::BroadcastEvent ( uint32_t  event_type,
const lldb::EventDataSP event_data_sp 
)

Definition at line 308 of file Broadcaster.cpp.

◆ BroadcastEventIfUnique() [1/2]

void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique ( lldb::EventSP event_sp)

Definition at line 231 of file Broadcaster.cpp.

◆ BroadcastEventIfUnique() [2/2]

void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique ( uint32_t  event_type)

Definition at line 314 of file Broadcaster.cpp.

◆ Clear()

void Broadcaster::BroadcasterImpl::Clear ( )

Definition at line 89 of file Broadcaster.cpp.

◆ EventTypeHasListeners()

bool Broadcaster::BroadcasterImpl::EventTypeHasListeners ( uint32_t  event_type)

Definition at line 173 of file Broadcaster.cpp.

◆ GetBroadcaster()

Broadcaster * Broadcaster::BroadcasterImpl::GetBroadcaster ( )

Definition at line 101 of file Broadcaster.cpp.

◆ GetBroadcasterName()

const std::string & lldb_private::Broadcaster::BroadcasterImpl::GetBroadcasterName ( ) const
inline

◆ GetEventName()

const char * lldb_private::Broadcaster::BroadcasterImpl::GetEventName ( uint32_t  event_mask) const
inline

Definition at line 374 of file Broadcaster.h.

References m_event_names.

◆ GetEventNames()

bool Broadcaster::BroadcasterImpl::GetEventNames ( Stream s,
const uint32_t  event_mask,
bool  prefix_with_broadcaster_name 
) const

◆ GetHijackingListenerName()

const char * Broadcaster::BroadcasterImpl::GetHijackingListenerName ( )
protected

Definition at line 351 of file Broadcaster.cpp.

◆ GetListeners()

llvm::SmallVector< std::pair< ListenerSP, uint32_t & >, 4 > Broadcaster::BroadcasterImpl::GetListeners ( uint32_t  event_mask = UINT32_MAX,
bool  include_primary = true 
)
protected

Definition at line 53 of file Broadcaster.cpp.

◆ HasListeners()

bool Broadcaster::BroadcasterImpl::HasListeners ( uint32_t  event_mask)
protected

Definition at line 77 of file Broadcaster.cpp.

◆ HijackBroadcaster()

bool Broadcaster::BroadcasterImpl::HijackBroadcaster ( const lldb::ListenerSP listener_sp,
uint32_t  event_mask = UINT32_MAX 
)

◆ IsHijackedForEvent()

bool Broadcaster::BroadcasterImpl::IsHijackedForEvent ( uint32_t  event_mask)

Definition at line 343 of file Broadcaster.cpp.

◆ operator=()

const BroadcasterImpl & lldb_private::Broadcaster::BroadcasterImpl::operator= ( const BroadcasterImpl )
privatedelete

◆ PrivateBroadcastEvent()

void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent ( lldb::EventSP event_sp,
bool  unique 
)
protected

◆ RemoveListener() [1/2]

bool Broadcaster::BroadcasterImpl::RemoveListener ( const lldb::ListenerSP listener_sp,
uint32_t  event_mask = UINT32_MAX 
)

Definition at line 222 of file Broadcaster.cpp.

References lldb_private::Broadcaster::RemoveListener().

◆ RemoveListener() [2/2]

bool Broadcaster::BroadcasterImpl::RemoveListener ( lldb_private::Listener listener,
uint32_t  event_mask = UINT32_MAX 
)

Definition at line 186 of file Broadcaster.cpp.

◆ RestoreBroadcaster()

void Broadcaster::BroadcasterImpl::RestoreBroadcaster ( )

◆ SetEventName()

void lldb_private::Broadcaster::BroadcasterImpl::SetEventName ( uint32_t  event_mask,
const char *  name 
)
inline

Definition at line 370 of file Broadcaster.h.

References m_event_names.

◆ SetPrimaryListener()

void Broadcaster::BroadcasterImpl::SetPrimaryListener ( lldb::ListenerSP  listener_sp)

Definition at line 319 of file Broadcaster.cpp.

References lldb_private::Broadcaster::RemoveListener(), and UINT32_MAX.

Friends And Related Function Documentation

◆ Broadcaster

friend class Broadcaster
friend

Definition at line 338 of file Broadcaster.h.

◆ Listener

friend class Listener
friend

Definition at line 337 of file Broadcaster.h.

Member Data Documentation

◆ m_broadcaster

Broadcaster& lldb_private::Broadcaster::BroadcasterImpl::m_broadcaster
protected

The broadcaster that this implements.

Definition at line 413 of file Broadcaster.h.

Referenced by GetBroadcasterName().

◆ m_event_names

event_names_map lldb_private::Broadcaster::BroadcasterImpl::m_event_names
protected

Optionally define event names for readability and logging for each event bit.

Definition at line 417 of file Broadcaster.h.

Referenced by GetEventName(), and SetEventName().

◆ m_hijacking_listeners

std::vector<lldb::ListenerSP> lldb_private::Broadcaster::BroadcasterImpl::m_hijacking_listeners
protected

A simple mechanism to intercept events from a broadcaster.

Definition at line 453 of file Broadcaster.h.

◆ m_hijacking_masks

std::vector<uint32_t> lldb_private::Broadcaster::BroadcasterImpl::m_hijacking_masks
protected

At some point we may want to have a stack or Listener collections, but for now this is just for private hijacking.

Definition at line 457 of file Broadcaster.h.

◆ m_listeners

collection lldb_private::Broadcaster::BroadcasterImpl::m_listeners
protected

A Broadcaster can have zero, one or many listeners.

A Broadcaster with zero listeners is a no-op, with one Listener is trivial. In most cases of multiple Listeners,the Broadcaster treats all its Listeners as equal, sending each event to all of the Listeners in no guaranteed order. However, some Broadcasters - in particular the Process broadcaster, can designate one Listener to be the "Primary Listener". In the case of the Process Broadcaster, the Listener passed to the Process constructor will be the Primary Listener. If the broadcaster has a Primary Listener, then the event gets sent first to the Primary Listener, and then when the Primary Listener pulls the event and the the event's DoOnRemoval finishes running, the event is forwarded to all the other Listeners. The other wrinkle is that a Broadcaster may be serving a Hijack Listener. If the Hijack Listener is present, events are only sent to the Hijack Listener. We use that, for instance, to absorb all the events generated by running an expression so that they don't show up to the driver or UI as starts and stops. If a Broadcaster has both a Primary and a Hijack Listener, the top-most Hijack Listener is treated as the current Primary Listener. A list of Listener / event_mask pairs that are listening to this broadcaster.

Definition at line 442 of file Broadcaster.h.

◆ m_listeners_mutex

std::mutex lldb_private::Broadcaster::BroadcasterImpl::m_listeners_mutex
protected

A mutex that protects m_listeners.

Definition at line 445 of file Broadcaster.h.

◆ m_primary_listener_mask

uint32_t lldb_private::Broadcaster::BroadcasterImpl::m_primary_listener_mask = UINT32_MAX
protected

Definition at line 450 of file Broadcaster.h.

◆ m_primary_listener_sp

lldb::ListenerSP lldb_private::Broadcaster::BroadcasterImpl::m_primary_listener_sp
protected

See the discussion of Broadcasters and Listeners above.

Definition at line 448 of file Broadcaster.h.


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