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

An event broadcasting class. More...

#include "lldb/Utility/Broadcaster.h"

Inheritance diagram for lldb_private::Broadcaster:
Inheritance graph
[legend]

Classes

class  BroadcasterImpl
 

Public Member Functions

 Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name)
 Construct with a broadcaster with a name. More...
 
virtual ~Broadcaster ()
 Destructor. More...
 
void CheckInWithManager ()
 
void BroadcastEvent (lldb::EventSP &event_sp)
 Broadcast an event which has no associated data. More...
 
void BroadcastEventIfUnique (lldb::EventSP &event_sp)
 
void BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp)
 
void BroadcastEvent (uint32_t event_type, EventData *event_data=nullptr)
 
void BroadcastEventIfUnique (uint32_t event_type, EventData *event_data=nullptr)
 
void Clear ()
 
virtual void AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events)
 
uint32_t AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
 Listen for any events specified by event_mask. More...
 
ConstString GetBroadcasterName ()
 Get the NULL terminated C string name of this Broadcaster object. More...
 
bool GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
 Get the event name(s) for one or more event bits. More...
 
void SetEventName (uint32_t event_mask, const char *name)
 Set the name for an event bit. More...
 
const char * GetEventName (uint32_t event_mask) const
 
bool EventTypeHasListeners (uint32_t event_type)
 
bool RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that were previously acquired by listener (assuming listener was listening to this object) for other listener objects to use. More...
 
bool HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Provides a simple mechanism to temporarily redirect events from broadcaster. More...
 
bool IsHijackedForEvent (uint32_t event_mask)
 
void RestoreBroadcaster ()
 Restore the state of the Broadcaster from a previous hijack attempt. More...
 
virtual ConstStringGetBroadcasterClass () const
 
lldb::BroadcasterManagerSP GetManager ()
 

Protected Types

typedef std::shared_ptr< BroadcasterImplBroadcasterImplSP
 
typedef std::weak_ptr< BroadcasterImplBroadcasterImplWP
 

Protected Member Functions

BroadcasterImplSP GetBroadcasterImpl ()
 
const char * GetHijackingListenerName ()
 

Friends

class Listener
 
class Event
 

Detailed Description

An event broadcasting class.

The Broadcaster class is designed to be subclassed by objects that wish to vend events in a multi-threaded environment. Broadcaster objects can each vend 32 events. Each event is represented by a bit in a 32 bit value and these bits can be set:

See also
Broadcaster::SetEventBits(uint32_t) or cleared:
Broadcaster::ResetEventBits(uint32_t) When an event gets set the Broadcaster object will notify the Listener object that is listening for the event (if there is one).

Subclasses should provide broadcast bit definitions for any events they vend, typically using an enumeration:

class Foo : public Broadcaster
{
public:
// Broadcaster event bits definitions.
enum
{
eBroadcastBitOne = (1 << 0),
eBroadcastBitTwo = (1 << 1),
eBroadcastBitThree = (1 << 2),
...
};

Definition at line 250 of file Broadcaster.h.

Member Typedef Documentation

◆ BroadcasterImplSP

Definition at line 541 of file Broadcaster.h.

◆ BroadcasterImplWP

Definition at line 542 of file Broadcaster.h.

Constructor & Destructor Documentation

◆ Broadcaster()

Broadcaster::Broadcaster ( lldb::BroadcasterManagerSP  manager_sp,
const char *  name 
)

Construct with a broadcaster with a name.

Parameters
[in]nameA NULL terminated C string that contains the name of the broadcaster object.

Definition at line 28 of file Broadcaster.cpp.

References GetBroadcasterName(), lldb_private::GetLogIfAllCategoriesSet(), LIBLLDB_LOG_OBJECT, and lldb_private::Log::Printf().

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

◆ ~Broadcaster()

Broadcaster::~Broadcaster ( )
virtual

Destructor.

The destructor is virtual since this class gets subclassed.

Definition at line 41 of file Broadcaster.cpp.

References lldb_private::Broadcaster::BroadcasterImpl::Clear(), lldb_private::GetLogIfAllCategoriesSet(), LIBLLDB_LOG_OBJECT, and lldb_private::Log::Printf().

Member Function Documentation

◆ AddInitialEventsToListener()

void Broadcaster::AddInitialEventsToListener ( const lldb::ListenerSP &  listener_sp,
uint32_t  requested_events 
)
virtual

◆ AddListener()

uint32_t lldb_private::Broadcaster::AddListener ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask 
)
inline

Listen for any events specified by event_mask.

Only one listener can listen to each event bit in a given Broadcaster. Once a listener has acquired an event bit, no other broadcaster will have access to it until it is relinquished by the first listener that gets it. The actual event bits that get acquired by listener may be different from what is requested in event_mask, and to track this the actual event bits that are acquired get returned.

Parameters
[in]listenerThe Listener object that wants to monitor the events that get broadcast by this object.
[in]event_maskA bit mask that indicates which events the listener is asking to monitor.
Returns
The actual event bits that were acquired by listener.

Definition at line 329 of file Broadcaster.h.

Referenced by lldb::SBBroadcaster::AddListener(), and lldb_private::Listener::StartListeningForEvents().

◆ BroadcastEvent() [1/3]

void lldb_private::Broadcaster::BroadcastEvent ( lldb::EventSP &  event_sp)
inline

Broadcast an event which has no associated data.

Parameters
[in]event_typeThe element from the enum defining this broadcaster's events that is being broadcast.
[in]event_dataUser event data that will be owned by the lldb::Event that is created internally.
[in]uniqueIf true, then only add an event of this type if there isn't one already in the queue.

Definition at line 283 of file Broadcaster.h.

Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::AppendBytesToCache(), lldb::SBBroadcaster::BroadcastEvent(), lldb::SBBroadcaster::BroadcastEventByType(), lldb_private::Process::BroadcastStructuredData(), lldb_private::Process::Destroy(), lldb_private::Thread::DestroyThread(), lldb_private::Process::Detach(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoAttachToProcessWithID(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoAttachToProcessWithName(), lldb_private::CommandObjectQuit::DoExecute(), ProcessKDP::DoResume(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoResume(), lldb_private::Watchpoint::GetConditionText(), lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(), lldb_private::Process::Halt(), lldb_private::Process::HaltPrivate(), lldb_private::Process::HandlePrivateEvent(), lldb_private::Target::ModulesDidLoad(), lldb_private::Target::ModulesDidUnload(), NotifyChange(), lldb_private::process_gdb_remote::GDBRemoteClientBase::OnRunPacketSent(), lldb_private::Communication::ReadThread(), lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::ReceivePacket(), lldb_private::Thread::ReturnFromFrame(), lldb_private::Process::RunThreadPlan(), lldb_private::Process::SendAsyncInterrupt(), lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::StartAsyncThread(), lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::StopAsyncThread(), ProcessKDP::StopAsyncThread(), lldb_private::process_gdb_remote::ProcessGDBRemote::StopAsyncThread(), lldb_private::Process::StopPrivateStateThread(), lldb_private::Communication::StopReadThread(), lldb_private::Target::SymbolsDidLoad(), and lldb_private::CommandInterpreter::UpdatePrompt().

◆ BroadcastEvent() [2/3]

void lldb_private::Broadcaster::BroadcastEvent ( uint32_t  event_type,
const lldb::EventDataSP &  event_data_sp 
)
inline

Definition at line 291 of file Broadcaster.h.

◆ BroadcastEvent() [3/3]

void lldb_private::Broadcaster::BroadcastEvent ( uint32_t  event_type,
EventData event_data = nullptr 
)
inline

Definition at line 296 of file Broadcaster.h.

◆ BroadcastEventIfUnique() [1/2]

void lldb_private::Broadcaster::BroadcastEventIfUnique ( lldb::EventSP &  event_sp)
inline

◆ BroadcastEventIfUnique() [2/2]

void lldb_private::Broadcaster::BroadcastEventIfUnique ( uint32_t  event_type,
EventData event_data = nullptr 
)
inline

Definition at line 300 of file Broadcaster.h.

◆ CheckInWithManager()

void Broadcaster::CheckInWithManager ( )

◆ Clear()

void lldb_private::Broadcaster::Clear ( )
inline

Definition at line 305 of file Broadcaster.h.

Referenced by lldb_private::Process::Finalize().

◆ EventTypeHasListeners()

bool lldb_private::Broadcaster::EventTypeHasListeners ( uint32_t  event_type)
inline

◆ GetBroadcasterClass()

ConstString & Broadcaster::GetBroadcasterClass ( ) const
virtual

◆ GetBroadcasterImpl()

BroadcasterImplSP lldb_private::Broadcaster::GetBroadcasterImpl ( )
inlineprotected

◆ GetBroadcasterName()

ConstString lldb_private::Broadcaster::GetBroadcasterName ( )
inline

Get the NULL terminated C string name of this Broadcaster object.

Returns
The NULL terminated C string name of this Broadcaster.

Definition at line 338 of file Broadcaster.h.

Referenced by Broadcaster(), lldb_private::Event::Dump(), lldb::SBBroadcaster::GetName(), lldb_private::Communication::StartReadThread(), and lldb_private::Communication::~Communication().

◆ GetEventName()

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

Definition at line 365 of file Broadcaster.h.

◆ GetEventNames()

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

Get the event name(s) for one or more event bits.

Parameters
[in]event_maskA bit mask that indicates which events to get names for.
Returns
The NULL terminated C string name of this Broadcaster.

Definition at line 347 of file Broadcaster.h.

Referenced by lldb_private::Event::Dump().

◆ GetHijackingListenerName()

const char* lldb_private::Broadcaster::GetHijackingListenerName ( )
inlineprotected

Definition at line 546 of file Broadcaster.h.

◆ GetManager()

lldb::BroadcasterManagerSP lldb_private::Broadcaster::GetManager ( )

◆ HijackBroadcaster()

bool lldb_private::Broadcaster::HijackBroadcaster ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask = UINT32_MAX 
)
inline

Provides a simple mechanism to temporarily redirect events from broadcaster.

When you call this function passing in a listener and event type mask, all events from the broadcaster matching the mask will now go to the hijacking listener. Only one hijack can occur at a time. If we need more than this we will have to implement a Listener stack.

Parameters
[in]listenerA Listener object. You do not need to call StartListeningForEvents for this broadcaster (that would fail anyway since the event bits would most likely be taken by the listener(s) you are usurping.
[in]event_maskThe event bits listener wishes to hijack.
Returns
True if the event mask could be hijacked, false otherwise.
See also
uint32_t Broadcaster::AddListener (Listener*, uint32_t)

Definition at line 412 of file Broadcaster.h.

◆ IsHijackedForEvent()

bool lldb_private::Broadcaster::IsHijackedForEvent ( uint32_t  event_mask)
inline

Definition at line 417 of file Broadcaster.h.

Referenced by lldb_private::Process::HandlePrivateEvent().

◆ RemoveListener()

bool lldb_private::Broadcaster::RemoveListener ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask = UINT32_MAX 
)
inline

Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that were previously acquired by listener (assuming listener was listening to this object) for other listener objects to use.

Parameters
[in]listenerA Listener object that previously called AddListener.
[in]event_maskThe event bits listener wishes to relinquish.
Returns
True if the listener was listening to this broadcaster and was removed, false otherwise.
See also
uint32_t Broadcaster::AddListener (Listener*, uint32_t)

Definition at line 389 of file Broadcaster.h.

Referenced by lldb::SBBroadcaster::RemoveListener(), and lldb_private::Listener::StopListeningForEvents().

◆ RestoreBroadcaster()

void lldb_private::Broadcaster::RestoreBroadcaster ( )
inline

Restore the state of the Broadcaster from a previous hijack attempt.

Definition at line 423 of file Broadcaster.h.

References lldb_private::BroadcastEventSpec::GetBroadcasterClass().

◆ SetEventName()

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

Friends And Related Function Documentation

◆ Event

friend class Event
friend

Definition at line 252 of file Broadcaster.h.

Referenced by lldb_private::CommandInterpreter::UpdatePrompt().

◆ Listener

friend class Listener
friend

Definition at line 251 of file Broadcaster.h.


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