[Lldb-commits] [lldb] [lldb][enums] Remove broadcast bits from debugger (PR #91618)
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Thu May 9 09:26:45 PDT 2024
https://github.com/chelcassanova created https://github.com/llvm/llvm-project/pull/91618
Removes the debugger broadcast bits from `Debugger.h` and instead uses the enum from `lldb-enumerations.h`. Also adds the `eBroadcastSymbolChange` bit to the enum in `lldb-enumerations.h`.
>From f338108d6b0cbb47e72663c58c1cbb17ee446cbc Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova <chelsea_cassanova at apple.com>
Date: Thu, 9 May 2024 09:23:02 -0700
Subject: [PATCH] [lldb][enums] Remove broadcast bits from debugger
Removes the debugger broadcast bits from `Debugger.h` and instead uses
the enum from `lldb-enumerations.h`. Also adds the
`eBroadcastSymbolChange` bit to the enum in `lldb-enumerations.h`.
---
lldb/include/lldb/Core/Debugger.h | 11 +----------
lldb/include/lldb/lldb-enumerations.h | 3 ++-
lldb/source/Core/Debugger.cpp | 16 ++++++++--------
lldb/source/Core/Progress.cpp | 2 +-
lldb/unittests/Core/DiagnosticEventTest.cpp | 14 +++++++-------
lldb/unittests/Core/ProgressReportTest.cpp | 8 ++++----
6 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index c0f7c732ad2d..ea994bf8c28d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -78,15 +78,6 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
public UserID,
public Properties {
public:
- /// Broadcaster event bits definitions.
- enum {
- eBroadcastBitProgress = (1 << 0),
- eBroadcastBitWarning = (1 << 1),
- eBroadcastBitError = (1 << 2),
- eBroadcastSymbolChange = (1 << 3),
- eBroadcastBitProgressCategory = (1 << 4),
- };
-
using DebuggerList = std::vector<lldb::DebuggerSP>;
static llvm::StringRef GetStaticBroadcasterClass();
@@ -628,7 +619,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
ReportProgress(uint64_t progress_id, std::string title, std::string details,
uint64_t completed, uint64_t total,
std::optional<lldb::user_id_t> debugger_id,
- uint32_t progress_category_bit = eBroadcastBitProgress);
+ uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
static void ReportDiagnosticImpl(lldb::Severity severity, std::string message,
std::optional<lldb::user_id_t> debugger_id,
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 437971b3364c..8e05f6ba9c87 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1344,7 +1344,8 @@ enum DebuggerBroadcastBit {
eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
- eBroadcastBitProgressCategory = (1 << 3),
+ eBroadcastSymbolChange = (1 << 3),
+ eBroadcastBitProgressCategory = (1 << 4),
};
/// Used for expressing severity in logs and diagnostics.
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 976420a43443..1c2d4e378e20 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1485,10 +1485,10 @@ static void PrivateReportDiagnostic(Debugger &debugger, Severity severity,
assert(false && "eSeverityInfo should not be broadcast");
return;
case eSeverityWarning:
- event_type = Debugger::eBroadcastBitWarning;
+ event_type = lldb::eBroadcastBitWarning;
break;
case eSeverityError:
- event_type = Debugger::eBroadcastBitError;
+ event_type = lldb::eBroadcastBitError;
break;
}
@@ -1572,7 +1572,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec &module_spec) {
std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr);
for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
EventSP event_sp = std::make_shared<Event>(
- Debugger::eBroadcastSymbolChange,
+ lldb::eBroadcastSymbolChange,
new SymbolChangeEventData(debugger_sp, module_spec));
debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
}
@@ -1879,8 +1879,8 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
CommandInterpreter::eBroadcastBitAsynchronousErrorData);
listener_sp->StartListeningForEvents(
- &m_broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
- eBroadcastBitError | eBroadcastSymbolChange);
+ &m_broadcaster, lldb::eBroadcastBitProgress | lldb::eBroadcastBitWarning |
+ lldb::eBroadcastBitError | lldb::eBroadcastSymbolChange);
// Let the thread that spawned us know that we have started up and that we
// are now listening to all required events so no events get missed
@@ -1932,11 +1932,11 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
}
}
} else if (broadcaster == &m_broadcaster) {
- if (event_type & Debugger::eBroadcastBitProgress)
+ if (event_type & lldb::eBroadcastBitProgress)
HandleProgressEvent(event_sp);
- else if (event_type & Debugger::eBroadcastBitWarning)
+ else if (event_type & lldb::eBroadcastBitWarning)
HandleDiagnosticEvent(event_sp);
- else if (event_type & Debugger::eBroadcastBitError)
+ else if (event_type & lldb::eBroadcastBitError)
HandleDiagnosticEvent(event_sp);
}
}
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 161038284e21..1a779e2ddf92 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -172,7 +172,7 @@ void ProgressManager::ReportProgress(
Debugger::ReportProgress(progress_data.progress_id, progress_data.title, "",
completed, Progress::kNonDeterministicTotal,
progress_data.debugger_id,
- Debugger::eBroadcastBitProgressCategory);
+ lldb::eBroadcastBitProgressCategory);
}
void ProgressManager::Expire(llvm::StringRef key) {
diff --git a/lldb/unittests/Core/DiagnosticEventTest.cpp b/lldb/unittests/Core/DiagnosticEventTest.cpp
index d06f164e87e7..0916e05f78ab 100644
--- a/lldb/unittests/Core/DiagnosticEventTest.cpp
+++ b/lldb/unittests/Core/DiagnosticEventTest.cpp
@@ -55,9 +55,9 @@ TEST_F(DiagnosticEventTest, Warning) {
ListenerSP listener_sp = Listener::MakeListener("test-listener");
listener_sp->StartListeningForEvents(&broadcaster,
- Debugger::eBroadcastBitWarning);
+ lldb::eBroadcastBitWarning);
EXPECT_TRUE(
- broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitWarning));
+ broadcaster.EventTypeHasListeners(lldb::eBroadcastBitWarning));
Debugger::ReportWarning("foo", debugger_sp->GetID());
@@ -81,8 +81,8 @@ TEST_F(DiagnosticEventTest, Error) {
ListenerSP listener_sp = Listener::MakeListener("test-listener");
listener_sp->StartListeningForEvents(&broadcaster,
- Debugger::eBroadcastBitError);
- EXPECT_TRUE(broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitError));
+ lldb::eBroadcastBitError);
+ EXPECT_TRUE(broadcaster.EventTypeHasListeners(lldb::eBroadcastBitError));
Debugger::ReportError("bar", debugger_sp->GetID());
@@ -111,7 +111,7 @@ TEST_F(DiagnosticEventTest, MultipleDebuggers) {
listeners.push_back(listener);
listener->StartListeningForEvents(&debugger->GetBroadcaster(),
- Debugger::eBroadcastBitError);
+ lldb::eBroadcastBitError);
}
Debugger::ReportError("baz");
@@ -140,9 +140,9 @@ TEST_F(DiagnosticEventTest, WarningOnce) {
ListenerSP listener_sp = Listener::MakeListener("test-listener");
listener_sp->StartListeningForEvents(&broadcaster,
- Debugger::eBroadcastBitWarning);
+ lldb::eBroadcastBitWarning);
EXPECT_TRUE(
- broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitWarning));
+ broadcaster.EventTypeHasListeners(lldb::eBroadcastBitWarning));
std::once_flag once;
Debugger::ReportWarning("foo", debugger_sp->GetID(), &once);
diff --git a/lldb/unittests/Core/ProgressReportTest.cpp b/lldb/unittests/Core/ProgressReportTest.cpp
index f0d253be9bf6..141244feb1f0 100644
--- a/lldb/unittests/Core/ProgressReportTest.cpp
+++ b/lldb/unittests/Core/ProgressReportTest.cpp
@@ -61,7 +61,7 @@ class ProgressReportTest : public ::testing::Test {
};
TEST_F(ProgressReportTest, TestReportCreation) {
- ListenerSP listener_sp = CreateListenerFor(Debugger::eBroadcastBitProgress);
+ ListenerSP listener_sp = CreateListenerFor(lldb::eBroadcastBitProgress);
EventSP event_sp;
const ProgressEventData *data;
@@ -135,7 +135,7 @@ TEST_F(ProgressReportTest, TestReportCreation) {
TEST_F(ProgressReportTest, TestProgressManager) {
ListenerSP listener_sp =
- CreateListenerFor(Debugger::eBroadcastBitProgressCategory);
+ CreateListenerFor(lldb::eBroadcastBitProgressCategory);
EventSP event_sp;
const ProgressEventData *data;
@@ -173,7 +173,7 @@ TEST_F(ProgressReportTest, TestProgressManager) {
TEST_F(ProgressReportTest, TestOverlappingEvents) {
ListenerSP listener_sp =
- CreateListenerFor(Debugger::eBroadcastBitProgressCategory);
+ CreateListenerFor(lldb::eBroadcastBitProgressCategory);
EventSP event_sp;
const ProgressEventData *data;
@@ -214,7 +214,7 @@ TEST_F(ProgressReportTest, TestOverlappingEvents) {
TEST_F(ProgressReportTest, TestProgressManagerDisjointReports) {
ListenerSP listener_sp =
- CreateListenerFor(Debugger::eBroadcastBitProgressCategory);
+ CreateListenerFor(lldb::eBroadcastBitProgressCategory);
EventSP event_sp;
const ProgressEventData *data;
uint64_t expected_progress_id;
More information about the lldb-commits
mailing list