[Lldb-commits] [lldb] 3541965 - [lldb][NFCI] Remove use of ConstString from Listener
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 13 10:17:35 PDT 2023
Author: Alex Langford
Date: 2023-06-13T10:14:38-07:00
New Revision: 35419651c53c9f9a58d2b86a4ec61d47c2105c55
URL: https://github.com/llvm/llvm-project/commit/35419651c53c9f9a58d2b86a4ec61d47c2105c55
DIFF: https://github.com/llvm/llvm-project/commit/35419651c53c9f9a58d2b86a4ec61d47c2105c55.diff
LOG: [lldb][NFCI] Remove use of ConstString from Listener
The only place ConstString was used in Listener was for filtering
broadcasters by name when looking for the next event. This functionality
is completely unused from what I can tell (even in downstream forks).
Differential Revision: https://reviews.llvm.org/D152573
Added:
Modified:
lldb/include/lldb/Utility/Listener.h
lldb/source/Utility/Listener.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/Listener.h b/lldb/include/lldb/Utility/Listener.h
index 8d50fe77d6a29..daa7deb345f30 100644
--- a/lldb/include/lldb/Utility/Listener.h
+++ b/lldb/include/lldb/Utility/Listener.h
@@ -27,7 +27,6 @@
#include <cstdint>
namespace lldb_private {
-class ConstString;
class Event;
}
@@ -119,15 +118,12 @@ class Listener : public std::enable_shared_from_this<Listener> {
bool
FindNextEventInternal(std::unique_lock<std::mutex> &lock,
Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources, uint32_t event_type_mask,
- lldb::EventSP &event_sp, bool remove);
+ uint32_t event_type_mask, lldb::EventSP &event_sp,
+ bool remove);
bool GetEventInternal(const Timeout<std::micro> &timeout,
Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *sources, // nullptr for any event
- uint32_t num_sources, uint32_t event_type_mask,
- lldb::EventSP &event_sp);
+ uint32_t event_type_mask, lldb::EventSP &event_sp);
std::string m_name;
broadcaster_collection m_broadcasters;
diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index 060fc2b1cedf1..34bfde401f586 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -8,7 +8,6 @@
#include "lldb/Utility/Listener.h"
#include "lldb/Utility/Broadcaster.h"
-#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Event.h"
#include "lldb/Utility/LLDBLog.h"
@@ -222,46 +221,25 @@ class EventBroadcasterMatches {
class EventMatcher {
public:
- EventMatcher(Broadcaster *broadcaster, const ConstString *broadcaster_names,
- uint32_t num_broadcaster_names, uint32_t event_type_mask)
- : m_broadcaster(broadcaster), m_broadcaster_names(broadcaster_names),
- m_num_broadcaster_names(num_broadcaster_names),
- m_event_type_mask(event_type_mask) {}
+ EventMatcher(Broadcaster *broadcaster, uint32_t event_type_mask)
+ : m_broadcaster(broadcaster), m_event_type_mask(event_type_mask) {}
bool operator()(const EventSP &event_sp) const {
if (m_broadcaster && !event_sp->BroadcasterIs(m_broadcaster))
return false;
- if (m_broadcaster_names) {
- bool found_source = false;
- 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) {
- found_source = true;
- break;
- }
- }
- if (!found_source)
- return false;
- }
-
return m_event_type_mask == 0 || m_event_type_mask & event_sp->GetType();
}
private:
Broadcaster *m_broadcaster;
- const ConstString *m_broadcaster_names;
- const uint32_t m_num_broadcaster_names;
const uint32_t m_event_type_mask;
};
bool Listener::FindNextEventInternal(
std::unique_lock<std::mutex> &lock,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *broadcaster_names, // nullptr for any event
- uint32_t num_broadcaster_names, uint32_t event_type_mask, EventSP &event_sp,
- bool remove) {
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ uint32_t event_type_mask, EventSP &event_sp, bool remove) {
// NOTE: callers of this function must lock m_events_mutex using a
// Mutex::Locker
// and pass the locker as the first argument. m_events_mutex is no longer
@@ -273,13 +251,11 @@ bool Listener::FindNextEventInternal(
Listener::event_collection::iterator pos = m_events.end();
- if (broadcaster == nullptr && broadcaster_names == nullptr &&
- event_type_mask == 0) {
+ if (broadcaster == nullptr && event_type_mask == 0) {
pos = m_events.begin();
} else {
pos = std::find_if(m_events.begin(), m_events.end(),
- EventMatcher(broadcaster, broadcaster_names,
- num_broadcaster_names, event_type_mask));
+ EventMatcher(broadcaster, event_type_mask));
}
if (pos != m_events.end()) {
@@ -288,12 +264,10 @@ bool Listener::FindNextEventInternal(
if (log != nullptr)
LLDB_LOGF(log,
"%p '%s' Listener::FindNextEventInternal(broadcaster=%p, "
- "broadcaster_names=%p[%u], event_type_mask=0x%8.8x, "
+ "event_type_mask=0x%8.8x, "
"remove=%i) event %p",
static_cast<void *>(this), GetName(),
- static_cast<void *>(broadcaster),
- static_cast<const void *>(broadcaster_names),
- num_broadcaster_names, event_type_mask, remove,
+ static_cast<void *>(broadcaster), event_type_mask, remove,
static_cast<void *>(event_sp.get()));
if (remove) {
@@ -315,7 +289,7 @@ bool Listener::FindNextEventInternal(
Event *Listener::PeekAtNextEvent() {
std::unique_lock<std::mutex> guard(m_events_mutex);
EventSP event_sp;
- if (FindNextEventInternal(guard, nullptr, nullptr, 0, 0, event_sp, false))
+ if (FindNextEventInternal(guard, nullptr, 0, event_sp, false))
return event_sp.get();
return nullptr;
}
@@ -323,7 +297,7 @@ Event *Listener::PeekAtNextEvent() {
Event *Listener::PeekAtNextEventForBroadcaster(Broadcaster *broadcaster) {
std::unique_lock<std::mutex> guard(m_events_mutex);
EventSP event_sp;
- if (FindNextEventInternal(guard, broadcaster, nullptr, 0, 0, event_sp, false))
+ if (FindNextEventInternal(guard, broadcaster, 0, event_sp, false))
return event_sp.get();
return nullptr;
}
@@ -333,26 +307,23 @@ Listener::PeekAtNextEventForBroadcasterWithType(Broadcaster *broadcaster,
uint32_t event_type_mask) {
std::unique_lock<std::mutex> guard(m_events_mutex);
EventSP event_sp;
- if (FindNextEventInternal(guard, broadcaster, nullptr, 0, event_type_mask,
- event_sp, false))
+ if (FindNextEventInternal(guard, broadcaster, event_type_mask, event_sp,
+ false))
return event_sp.get();
return nullptr;
}
bool Listener::GetEventInternal(
const Timeout<std::micro> &timeout,
- Broadcaster *broadcaster, // nullptr for any broadcaster
- const ConstString *broadcaster_names, // nullptr for any event
- uint32_t num_broadcaster_names, uint32_t event_type_mask,
- EventSP &event_sp) {
+ Broadcaster *broadcaster, // nullptr for any broadcaster
+ uint32_t event_type_mask, EventSP &event_sp) {
Log *log = GetLog(LLDBLog::Events);
LLDB_LOG(log, "this = {0}, timeout = {1} for {2}", this, timeout, m_name);
std::unique_lock<std::mutex> lock(m_events_mutex);
while (true) {
- if (FindNextEventInternal(lock, broadcaster, broadcaster_names,
- num_broadcaster_names, event_type_mask, event_sp,
+ if (FindNextEventInternal(lock, broadcaster, event_type_mask, event_sp,
true)) {
return true;
} else {
@@ -382,18 +353,17 @@ bool Listener::GetEventInternal(
bool Listener::GetEventForBroadcasterWithType(
Broadcaster *broadcaster, uint32_t event_type_mask, EventSP &event_sp,
const Timeout<std::micro> &timeout) {
- return GetEventInternal(timeout, broadcaster, nullptr, 0, event_type_mask,
- event_sp);
+ return GetEventInternal(timeout, broadcaster, event_type_mask, event_sp);
}
bool Listener::GetEventForBroadcaster(Broadcaster *broadcaster,
EventSP &event_sp,
const Timeout<std::micro> &timeout) {
- return GetEventInternal(timeout, broadcaster, nullptr, 0, 0, event_sp);
+ return GetEventInternal(timeout, broadcaster, 0, event_sp);
}
bool Listener::GetEvent(EventSP &event_sp, const Timeout<std::micro> &timeout) {
- return GetEventInternal(timeout, nullptr, nullptr, 0, 0, event_sp);
+ return GetEventInternal(timeout, nullptr, 0, event_sp);
}
size_t Listener::HandleBroadcastEvent(EventSP &event_sp) {
More information about the lldb-commits
mailing list