LLDB mainline
|
An event broadcasting class. More...
#include "lldb/Utility/Broadcaster.h"
Classes | |
class | BroadcasterImpl |
BroadcasterImpl contains the actual Broadcaster implementation. More... | |
Public Member Functions | |
Broadcaster (lldb::BroadcasterManagerSP manager_sp, std::string 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) |
void | BroadcastEventIfUnique (uint32_t event_type) |
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. | |
const std::string & | GetBroadcasterName () |
Get this broadcaster's name. | |
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 llvm::StringRef | GetBroadcasterClass () 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 () |
void | SetPrimaryListener (lldb::ListenerSP listener_sp) |
lldb::ListenerSP | GetPrimaryListener () |
Protected Types | |
typedef std::shared_ptr< BroadcasterImpl > | BroadcasterImplSP |
typedef std::weak_ptr< BroadcasterImpl > | BroadcasterImplWP |
Protected Member Functions | |
BroadcasterImplSP | GetBroadcasterImpl () |
const char * | GetHijackingListenerName () |
Private Member Functions | |
Broadcaster (const Broadcaster &)=delete | |
const Broadcaster & | operator= (const Broadcaster &)=delete |
Private Attributes | |
BroadcasterImplSP | m_broadcaster_sp |
lldb::BroadcasterManagerSP | m_manager_sp |
const std::string | m_broadcaster_name |
The name of this broadcaster object. | |
Friends | |
class | Listener |
class | Event |
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:
Subclasses should provide broadcast bit definitions for any events they vend, typically using an enumeration:
Definition at line 146 of file Broadcaster.h.
|
protected |
Definition at line 464 of file Broadcaster.h.
|
protected |
Definition at line 465 of file Broadcaster.h.
Broadcaster::Broadcaster | ( | lldb::BroadcasterManagerSP | manager_sp, |
std::string | name | ||
) |
Construct with a broadcaster with a name.
[in] | manager_sp | A shared pointer to the BroadcasterManager that will manage this broadcaster. |
[in] | name | A std::string of the name that this broadcaster will have. |
Definition at line 26 of file Broadcaster.cpp.
References GetBroadcasterName(), lldb_private::GetLog(), LLDB_LOG, and lldb_private::Object.
|
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.
|
privatedelete |
|
virtual |
Definition at line 131 of file Broadcaster.cpp.
Referenced by lldb::SBBroadcaster::AddInitialEventsToListener().
|
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.
[in] | listener_sp | The Listener object that wants to monitor the events that get broadcast by this object. |
[in] | event_mask | A bit mask that indicates which events the listener is asking to monitor. |
Definition at line 213 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb::SBBroadcaster::AddListener(), lldb_private::Process::SetShadowListener(), and lldb_private::Listener::StartListeningForEvents().
|
inline |
Broadcast an event which has no associated data.
Definition at line 168 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::TargetList::SendAsyncInterrupt(), lldb_private::Process::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().
|
inline |
Definition at line 181 of file Broadcaster.h.
References m_broadcaster_sp.
|
inline |
Definition at line 176 of file Broadcaster.h.
References m_broadcaster_sp.
|
inline |
Definition at line 172 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::ThreadedCommunication::AppendBytesToCache(), lldb_private::Process::AppendSTDERR(), lldb_private::Process::AppendSTDOUT(), lldb_private::Process::BroadcastAsyncProfileData(), lldb::SBBroadcaster::BroadcastEvent(), and lldb::SBBroadcaster::BroadcastEventByType().
|
inline |
Definition at line 185 of file Broadcaster.h.
References m_broadcaster_sp.
void Broadcaster::CheckInWithManager | ( | ) |
Definition at line 46 of file Broadcaster.cpp.
References m_manager_sp.
Referenced by lldb_private::CommandInterpreter::CommandInterpreter(), lldb_private::Process::Process(), lldb_private::Target::Target(), lldb_private::TargetList::TargetList(), lldb_private::Thread::Thread(), and lldb_private::ThreadedCommunication::ThreadedCommunication().
|
inline |
Definition at line 189 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::Finalize(), lldb_private::CommandObjectDisassemble::CommandOptions::OptionParsingStarting(), and ~Broadcaster().
|
inline |
Definition at line 251 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Thread::BroadcastSelectedFrameChange(), lldb::SBBroadcaster::EventTypeHasListeners(), NotifyChange(), PrivateReportDiagnostic(), PrivateReportProgress(), lldb_private::Thread::ReturnFromFrame(), and lldb_private::BreakpointLocation::SendBreakpointLocationChangedEvent().
|
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 376 of file Broadcaster.cpp.
Referenced by lldb_private::Debugger::DefaultEventHandler(), lldb::SBEvent::GetBroadcasterClass(), lldb_private::BroadcastEventSpec::operator<(), and lldb_private::BroadcasterManager::SignUpListenersForBroadcaster().
|
inlineprotected |
Definition at line 467 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Listener::BroadcasterWillDestruct(), lldb_private::Listener::HandleBroadcastEvent(), lldb_private::Event::SetBroadcaster(), lldb_private::Listener::StartListeningForEvents(), and lldb_private::Listener::StopListeningForEvents().
|
inline |
Get this broadcaster's name.
Definition at line 223 of file Broadcaster.h.
References m_broadcaster_name.
Referenced by Broadcaster(), lldb_private::Event::Dump(), lldb_private::Broadcaster::BroadcasterImpl::GetBroadcasterName(), lldb_private::Broadcaster::BroadcasterImpl::GetEventNames(), lldb::SBBroadcaster::GetName(), lldb_private::Broadcaster::BroadcasterImpl::HijackBroadcaster(), lldb_private::Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(), lldb_private::Broadcaster::BroadcasterImpl::RestoreBroadcaster(), lldb_private::ThreadedCommunication::StartReadThread(), ~Broadcaster(), and lldb_private::ThreadedCommunication::~ThreadedCommunication().
|
inline |
Definition at line 247 of file Broadcaster.h.
References m_broadcaster_sp.
|
inline |
Get the event name(s) for one or more event bits.
[in] | event_mask | A bit mask that indicates which events to get names for. |
Definition at line 232 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Event::Dump().
|
inlineprotected |
Definition at line 469 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::StateChangedIsExternallyHijacked(), and lldb_private::Process::StateChangedIsHijackedForSynchronousResume().
lldb::BroadcasterManagerSP lldb_private::Broadcaster::GetManager | ( | ) |
|
inline |
Definition at line 319 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::GetNextEvent(), lldb_private::Process::GetStateChangedEvents(), and lldb_private::Process::PeekAtStateChangedEvents().
|
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.
[in] | listener_sp | A 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_mask | The event bits listener wishes to hijack. |
Definition at line 294 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::HijackProcessEvents().
|
inline |
Definition at line 299 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::HandlePrivateEvent(), lldb_private::Process::StateChangedIsExternallyHijacked(), and lldb_private::Process::StateChangedIsHijackedForSynchronousResume().
|
privatedelete |
|
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.
[in] | listener_sp | A Listener object that previously called AddListener. |
[in] | event_mask | The event bits listener wishes to relinquish. |
Definition at line 271 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Broadcaster::BroadcasterImpl::RemoveListener(), lldb::SBBroadcaster::RemoveListener(), lldb_private::Broadcaster::BroadcasterImpl::SetPrimaryListener(), and lldb_private::Listener::StopListeningForEvents().
|
inline |
Restore the state of the Broadcaster from a previous hijack attempt.
Definition at line 304 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::RestoreProcessEvents().
|
inline |
Set the name for an event bit.
[in] | event_mask | A bit mask that indicates which events the listener is asking to monitor. |
Definition at line 243 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::CommandInterpreter::CommandInterpreter(), lldb_private::Process::Process(), lldb_private::process_gdb_remote::ProcessGDBRemote::ProcessGDBRemote(), ProcessKDP::ProcessKDP(), lldb_private::Target::Target(), and lldb_private::ThreadedCommunication::ThreadedCommunication().
|
inline |
Definition at line 315 of file Broadcaster.h.
References m_broadcaster_sp.
Referenced by lldb_private::Process::Process().
|
friend |
Definition at line 148 of file Broadcaster.h.
Referenced by lldb_private::Process::SetPrivateState(), and lldb_private::CommandInterpreter::UpdatePrompt().
|
friend |
Definition at line 147 of file Broadcaster.h.
|
private |
The name of this broadcaster object.
Definition at line 478 of file Broadcaster.h.
Referenced by GetBroadcasterName().
|
private |
Definition at line 474 of file Broadcaster.h.
Referenced by AddListener(), BroadcastEvent(), BroadcastEventIfUnique(), Clear(), EventTypeHasListeners(), GetBroadcasterImpl(), GetEventName(), GetEventNames(), GetHijackingListenerName(), GetPrimaryListener(), HijackBroadcaster(), IsHijackedForEvent(), RemoveListener(), RestoreBroadcaster(), SetEventName(), and SetPrimaryListener().
|
private |
Definition at line 475 of file Broadcaster.h.
Referenced by CheckInWithManager().