LLDB mainline
Classes | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | 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
 BroadcasterImpl contains the actual Broadcaster implementation. More...
 

Public Member Functions

 Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name)
 Construct with a broadcaster with a name.
 
virtual ~Broadcaster ()
 Destructor.
 
void CheckInWithManager ()
 
void BroadcastEvent (lldb::EventSP &event_sp)
 Broadcast an event which has no associated data.
 
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.
 
ConstString GetBroadcasterName ()
 Get the NULL terminated C string name of this Broadcaster object.
 
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.
 
void SetEventName (uint32_t event_mask, const char *name)
 Set the name for an event bit.
 
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.
 
bool HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Provides a simple mechanism to temporarily redirect events from broadcaster.
 
bool IsHijackedForEvent (uint32_t event_mask)
 
void RestoreBroadcaster ()
 Restore the state of the Broadcaster from a previous hijack attempt.
 
virtual ConstStringGetBroadcasterClass () const
 This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching.
 
lldb::BroadcasterManagerSP GetManager ()
 
virtual void SetShadowListener (lldb::ListenerSP listener_sp)
 

Protected Types

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

Protected Member Functions

BroadcasterImplSP GetBroadcasterImpl ()
 
const char * GetHijackingListenerName ()
 

Private Member Functions

 Broadcaster (const Broadcaster &)=delete
 
const Broadcasteroperator= (const Broadcaster &)=delete
 

Private Attributes

BroadcasterImplSP m_broadcaster_sp
 
lldb::BroadcasterManagerSP m_manager_sp
 
const ConstString m_broadcaster_name
 The name of this broadcaster object.
 

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),
...
};
An event broadcasting class.
Definition: Broadcaster.h:145

Definition at line 145 of file Broadcaster.h.

Member Typedef Documentation

◆ BroadcasterImplSP

Definition at line 432 of file Broadcaster.h.

◆ BroadcasterImplWP

Definition at line 433 of file Broadcaster.h.

Constructor & Destructor Documentation

◆ Broadcaster() [1/2]

lldb_private::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.

◆ ~Broadcaster()

Broadcaster::~Broadcaster ( )
virtual

Destructor.

The destructor is virtual since this class gets subclassed.

Definition at line 38 of file Broadcaster.cpp.

References Clear(), GetBroadcasterName(), lldb_private::GetLog(), LLDB_LOG, and lldb_private::Object.

◆ Broadcaster() [2/2]

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

Member Function Documentation

◆ AddInitialEventsToListener()

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

Definition at line 110 of file Broadcaster.cpp.

Referenced by lldb::SBBroadcaster::AddInitialEventsToListener().

◆ 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]listener_spThe 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 211 of file Broadcaster.h.

References m_broadcaster_sp.

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.

Definition at line 165 of file Broadcaster.h.

References m_broadcaster_sp.

Referenced by lldb::SBBroadcaster::BroadcastEvent(), lldb::SBBroadcaster::BroadcastEventByType(), lldb_private::Thread::BroadcastSelectedFrameChange(), lldb_private::Process::BroadcastStructuredData(), lldb_private::Process::ControlPrivateStateThread(), lldb_private::Debugger::DefaultEventHandler(), lldb_private::Process::DestroyImpl(), lldb_private::Process::Detach(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoAttachToProcessWithID(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoAttachToProcessWithName(), lldb_private::CommandObjectQuit::DoExecute(), lldb_private::process_gdb_remote::ProcessGDBRemote::DoResume(), ProcessKDP::DoResume(), lldb_private::Process::Halt(), lldb_private::Process::HandlePrivateEvent(), lldb_private::Target::ModulesDidLoad(), lldb_private::Target::ModulesDidUnload(), NotifyChange(), lldb_private::process_gdb_remote::GDBRemoteClientBase::OnRunPacketSent(), PrivateReportDiagnostic(), PrivateReportProgress(), lldb_private::ThreadedCommunication::ReadThread(), lldb_private::Thread::ReturnFromFrame(), lldb_private::Process::RunPrivateStateThread(), lldb_private::Process::RunThreadPlan(), lldb_private::Process::SendAsyncInterrupt(), lldb_private::TargetList::SendAsyncInterrupt(), lldb_private::Breakpoint::SendBreakpointChangedEvent(), lldb_private::BreakpointLocation::SendBreakpointLocationChangedEvent(), lldb_private::Watchpoint::SendWatchpointChangedEvent(), lldb_private::Process::SetPrivateState(), lldb_private::Debugger::SetPropertyValue(), lldb_private::process_gdb_remote::ProcessGDBRemote::StopAsyncThread(), ProcessKDP::StopAsyncThread(), lldb_private::Debugger::StopEventHandlerThread(), lldb_private::ThreadedCommunication::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 173 of file Broadcaster.h.

References m_broadcaster_sp.

◆ BroadcastEvent() [3/3]

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

Definition at line 178 of file Broadcaster.h.

References m_broadcaster_sp.

◆ 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 182 of file Broadcaster.h.

References m_broadcaster_sp.

◆ CheckInWithManager()

void Broadcaster::CheckInWithManager ( )

◆ Clear()

void lldb_private::Broadcaster::Clear ( )
inline

◆ EventTypeHasListeners()

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

◆ GetBroadcasterClass()

ConstString & Broadcaster::GetBroadcasterClass ( ) const
virtual

This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching.

FIXME: Probably should make a ManagedBroadcaster subclass with all the bits needed to work with the BroadcasterManager, so that it is clearer how to add one.

Reimplemented in lldb_private::ThreadedCommunication, lldb_private::CommandInterpreter, lldb_private::Process, lldb_private::Target, lldb_private::TargetList, and lldb_private::Thread.

Definition at line 314 of file Broadcaster.cpp.

Referenced by lldb_private::Debugger::DefaultEventHandler(), lldb::SBEvent::GetBroadcasterClass(), lldb_private::BroadcastEventSpec::operator<(), and lldb_private::BroadcasterManager::SignUpListenersForBroadcaster().

◆ GetBroadcasterImpl()

BroadcasterImplSP lldb_private::Broadcaster::GetBroadcasterImpl ( )
inlineprotected

◆ GetBroadcasterName()

ConstString lldb_private::Broadcaster::GetBroadcasterName ( )
inline

◆ GetEventName()

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

Definition at line 244 of file Broadcaster.h.

References m_broadcaster_sp.

◆ 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 229 of file Broadcaster.h.

References m_broadcaster_sp.

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

◆ GetHijackingListenerName()

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

◆ 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]listener_spA 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 291 of file Broadcaster.h.

References m_broadcaster_sp.

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

◆ IsHijackedForEvent()

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

◆ operator=()

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

◆ 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]listener_spA 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 268 of file Broadcaster.h.

References m_broadcaster_sp.

Referenced by lldb_private::Broadcaster::BroadcasterImpl::RemoveListener(), 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 301 of file Broadcaster.h.

References m_broadcaster_sp.

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

◆ SetEventName()

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

Set the name for an event bit.

Parameters
[in]event_maskA bit mask that indicates which events the listener is asking to monitor.

Definition at line 240 of file Broadcaster.h.

References m_broadcaster_sp.

Referenced by lldb_private::CommandInterpreter::CommandInterpreter(), lldb_private::Target::Target(), and lldb_private::ThreadedCommunication::ThreadedCommunication().

◆ SetShadowListener()

virtual void lldb_private::Broadcaster::SetShadowListener ( lldb::ListenerSP  listener_sp)
inlinevirtual

Reimplemented in lldb_private::Process.

Definition at line 312 of file Broadcaster.h.

References m_broadcaster_sp.

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

Friends And Related Function Documentation

◆ Event

friend class Event
friend

◆ Listener

friend class Listener
friend

Definition at line 146 of file Broadcaster.h.

Member Data Documentation

◆ m_broadcaster_name

const ConstString lldb_private::Broadcaster::m_broadcaster_name
private

The name of this broadcaster object.

Definition at line 446 of file Broadcaster.h.

Referenced by GetBroadcasterName().

◆ m_broadcaster_sp

BroadcasterImplSP lldb_private::Broadcaster::m_broadcaster_sp
private

◆ m_manager_sp

lldb::BroadcasterManagerSP lldb_private::Broadcaster::m_manager_sp
private

Definition at line 443 of file Broadcaster.h.

Referenced by CheckInWithManager().


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