[Lldb-commits] [lldb] [lldb] Remove Listener::SetShadow (PR #97555)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 8 01:33:27 PDT 2024


https://github.com/labath updated https://github.com/llvm/llvm-project/pull/97555

>From 9f81f804c4c451a5ff2266405740d208dffae60f Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Wed, 3 Jul 2024 10:37:52 +0000
Subject: [PATCH 1/2] [lldb] Remove Listener::SetShadow

It's not used since https://reviews.llvm.org/D157556.
---
 lldb/include/lldb/Utility/Listener.h | 3 ---
 lldb/source/API/SBAttachInfo.cpp     | 8 +-------
 lldb/source/API/SBLaunchInfo.cpp     | 8 +-------
 lldb/source/Utility/Listener.cpp     | 9 +++------
 4 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/lldb/include/lldb/Utility/Listener.h b/lldb/include/lldb/Utility/Listener.h
index daa7deb345f301..f687852d558bdb 100644
--- a/lldb/include/lldb/Utility/Listener.h
+++ b/lldb/include/lldb/Utility/Listener.h
@@ -94,8 +94,6 @@ class Listener : public std::enable_shared_from_this<Listener> {
 
   size_t HandleBroadcastEvent(lldb::EventSP &event_sp);
 
-  void SetShadow(bool is_shadow) { m_is_shadow = is_shadow; }
-
 private:
   // Classes that inherit from Listener can see and modify these
   struct BroadcasterInfo {
@@ -132,7 +130,6 @@ class Listener : public std::enable_shared_from_this<Listener> {
   std::mutex m_events_mutex; // Protects m_broadcasters and m_events
   std::condition_variable m_events_condition;
   broadcaster_manager_collection m_broadcaster_managers;
-  bool m_is_shadow = false;
 
   void BroadcasterWillDestruct(Broadcaster *);
 
diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp
index 8ce1f1d65c4964..a9f712c79c7fe0 100644
--- a/lldb/source/API/SBAttachInfo.cpp
+++ b/lldb/source/API/SBAttachInfo.cpp
@@ -266,13 +266,7 @@ SBListener SBAttachInfo::GetShadowListener() {
 void SBAttachInfo::SetShadowListener(SBListener &listener) {
   LLDB_INSTRUMENT_VA(this, listener);
 
-  ListenerSP listener_sp = listener.GetSP();
-  if (listener_sp && listener.IsValid())
-    listener_sp->SetShadow(true);
-  else
-    listener_sp = nullptr;
-
-  m_opaque_sp->SetShadowListener(listener_sp);
+  m_opaque_sp->SetShadowListener(listener.GetSP());
 }
 
 const char *SBAttachInfo::GetScriptedProcessClassName() const {
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index d5f935083e6c1e..d6b52e8a67a49e 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -402,11 +402,5 @@ SBListener SBLaunchInfo::GetShadowListener() {
 void SBLaunchInfo::SetShadowListener(SBListener &listener) {
   LLDB_INSTRUMENT_VA(this, listener);
 
-  ListenerSP listener_sp = listener.GetSP();
-  if (listener_sp && listener.IsValid())
-    listener_sp->SetShadow(true);
-  else
-    listener_sp = nullptr;
-
-  m_opaque_sp->SetShadowListener(listener_sp);
+  m_opaque_sp->SetShadowListener(listener.GetSP());
 }
diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index 0b28cb5cdc6424..317525335f0f6f 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -18,13 +18,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-Listener::Listener(const char *name)
-    : m_name(name), m_broadcasters(), m_broadcasters_mutex(), m_events(),
-      m_events_mutex(), m_is_shadow() {
+Listener::Listener(const char *name) : m_name(name) {
   Log *log = GetLog(LLDBLog::Object);
-  if (log != nullptr)
-    LLDB_LOGF(log, "%p Listener::Listener('%s')", static_cast<void *>(this),
-              m_name.c_str());
+  LLDB_LOGF(log, "%p Listener::Listener('%s')", static_cast<void *>(this),
+            m_name.c_str());
 }
 
 Listener::~Listener() {

>From 7259eab8b5660df7c57d18392e9d14cb5c877f7a Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Mon, 8 Jul 2024 10:32:48 +0200
Subject: [PATCH 2/2] rid of log

---
 lldb/source/Utility/Listener.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index 317525335f0f6f..5bbe6908afd2a6 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -19,18 +19,15 @@ using namespace lldb;
 using namespace lldb_private;
 
 Listener::Listener(const char *name) : m_name(name) {
-  Log *log = GetLog(LLDBLog::Object);
-  LLDB_LOGF(log, "%p Listener::Listener('%s')", static_cast<void *>(this),
-            m_name.c_str());
+  LLDB_LOGF(GetLog(LLDBLog::Object), "%p Listener::Listener('%s')",
+            static_cast<void *>(this), m_name.c_str());
 }
 
 Listener::~Listener() {
-  Log *log = GetLog(LLDBLog::Object);
-
   // Don't call Clear() from here as that can cause races. See #96750.
 
-  LLDB_LOGF(log, "%p Listener::%s('%s')", static_cast<void *>(this),
-            __FUNCTION__, m_name.c_str());
+  LLDB_LOGF(GetLog(LLDBLog::Object), "%p Listener::%s('%s')",
+            static_cast<void *>(this), __FUNCTION__, m_name.c_str());
 }
 
 void Listener::Clear() {



More information about the lldb-commits mailing list