diff --git a/lldb/include/lldb/Utility/Broadcaster.h b/lldb/include/lldb/Utility/Broadcaster.h --- a/lldb/include/lldb/Utility/Broadcaster.h +++ b/lldb/include/lldb/Utility/Broadcaster.h @@ -149,10 +149,12 @@ public: /// Construct with a broadcaster with a name. /// + /// \param[in] manager_sp + /// A shared pointer to the BroadcasterManager that will manage this + /// broadcaster. /// \param[in] name - /// A NULL terminated C string that contains the name of the - /// broadcaster object. - Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name); + /// A std::string of the name that this broadcaster will have. + Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name); /// Destructor. /// @@ -213,11 +215,12 @@ return m_broadcaster_sp->AddListener(listener_sp, event_mask); } - /// Get the NULL terminated C string name of this Broadcaster object. + /// Get this broadcaster's name. /// /// \return - /// The NULL terminated C string name of this Broadcaster. - ConstString GetBroadcasterName() { return m_broadcaster_name; } + /// A reference to a constant std::string containing the name of the + /// broadcaster. + const std::string &GetBroadcasterName() { return m_broadcaster_name; } /// Get the event name(s) for one or more event bits. /// @@ -352,8 +355,8 @@ uint32_t AddListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask); - const char *GetBroadcasterName() const { - return m_broadcaster.GetBroadcasterName().AsCString(); + const std::string &GetBroadcasterName() const { + return m_broadcaster.GetBroadcasterName(); } Broadcaster *GetBroadcaster(); @@ -443,7 +446,7 @@ lldb::BroadcasterManagerSP m_manager_sp; /// The name of this broadcaster object. - const ConstString m_broadcaster_name; + const std::string m_broadcaster_name; Broadcaster(const Broadcaster &) = delete; const Broadcaster &operator=(const Broadcaster &) = delete; diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -92,7 +92,7 @@ LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) - return m_opaque_ptr->GetBroadcasterName().GetCString(); + return ConstString(m_opaque_ptr->GetBroadcasterName()).GetCString(); return nullptr; } diff --git a/lldb/source/Core/ThreadedCommunication.cpp b/lldb/source/Core/ThreadedCommunication.cpp --- a/lldb/source/Core/ThreadedCommunication.cpp +++ b/lldb/source/Core/ThreadedCommunication.cpp @@ -57,7 +57,7 @@ ThreadedCommunication::~ThreadedCommunication() { LLDB_LOG(GetLog(LLDBLog::Object | LLDBLog::Communication), "{0} ThreadedCommunication::~ThreadedCommunication (name = {1})", - this, GetBroadcasterName().AsCString()); + this, GetBroadcasterName()); } void ThreadedCommunication::Clear() { diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp --- a/lldb/source/Utility/Broadcaster.cpp +++ b/lldb/source/Utility/Broadcaster.cpp @@ -23,9 +23,9 @@ using namespace lldb; using namespace lldb_private; -Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name) +Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, std::string name) : m_broadcaster_sp(std::make_shared(*this)), - m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name) { + m_manager_sp(std::move(manager_sp)), m_broadcaster_name(std::move(name)) { Log *log = GetLog(LLDBLog::Object); LLDB_LOG(log, "{0} Broadcaster::Broadcaster(\"{1}\")", static_cast(this), GetBroadcasterName()); @@ -215,12 +215,12 @@ if (log) { StreamString event_description; event_sp->Dump(&event_description); - LLDB_LOGF(log, - "%p Broadcaster(\"%s\")::BroadcastEvent (event_sp = {%s}, " - "unique =%i) hijack = %p", - static_cast(this), GetBroadcasterName(), - event_description.GetData(), unique, - static_cast(hijacking_listener_sp.get())); + LLDB_LOG(log, + "{0:x} Broadcaster(\"{1}\")::BroadcastEvent (event_sp = {2}, " + "unique={3}) hijack = {4:x}", + static_cast(this), GetBroadcasterName(), + event_description.GetData(), unique, + static_cast(hijacking_listener_sp.get())); } if (hijacking_listener_sp) { diff --git a/lldb/source/Utility/Event.cpp b/lldb/source/Utility/Event.cpp --- a/lldb/source/Utility/Event.cpp +++ b/lldb/source/Utility/Event.cpp @@ -58,13 +58,13 @@ s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x (%s), data = ", static_cast(this), static_cast(broadcaster), - broadcaster->GetBroadcasterName().GetCString(), m_type, + broadcaster->GetBroadcasterName().c_str(), m_type, event_name.GetData()); else s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ", static_cast(this), static_cast(broadcaster), - broadcaster->GetBroadcasterName().GetCString(), m_type); + broadcaster->GetBroadcasterName().c_str(), m_type); } else s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ", static_cast(this), m_type); diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp --- a/lldb/source/Utility/Listener.cpp +++ b/lldb/source/Utility/Listener.cpp @@ -234,7 +234,7 @@ if (m_broadcaster_names) { bool found_source = false; - ConstString event_broadcaster_name = + const llvm::StringRef event_broadcaster_name = event_sp->GetBroadcaster()->GetBroadcasterName(); for (uint32_t i = 0; i < m_num_broadcaster_names; ++i) { if (m_broadcaster_names[i] == event_broadcaster_name) {