Skip to content

Commit 8a20470

Browse files
committed
Split the progress manager category bit and setting the external bit for each event
1 parent fcad0a3 commit 8a20470

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

lldb/include/lldb/Core/Progress.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121

2222
namespace lldb_private {
2323

24-
/// Enum to indicate the origin of a progress event, internal or external.
25-
enum class ProgressOrigin : uint8_t {
26-
eLLDBInternal = 0,
27-
eExternal = 1,
28-
};
29-
3024
/// A Progress indicator helper class.
3125
///
3226
/// Any potentially long running sections of code in LLDB should report
@@ -65,6 +59,12 @@ enum class ProgressOrigin : uint8_t {
6559

6660
class Progress {
6761
public:
62+
/// Enum to indicate the origin of a progress event, internal or external.
63+
enum class ProgressOrigin : uint8_t {
64+
eInternal = 0,
65+
eExternal = 1,
66+
};
67+
6868
/// Construct a progress object that will report information.
6969
///
7070
/// The constructor will create a unique progress reporting object and
@@ -90,7 +90,7 @@ class Progress {
9090
std::optional<uint64_t> total = std::nullopt,
9191
lldb_private::Debugger *debugger = nullptr,
9292
Timeout<std::nano> minimum_report_time = std::nullopt,
93-
ProgressOrigin origin = ProgressOrigin::eLLDBInternal);
93+
ProgressOrigin origin = ProgressOrigin::eInternal);
9494

9595
/// Destroy the progress object.
9696
///
@@ -125,6 +125,9 @@ class Progress {
125125
/// The optional debugger ID to report progress to. If this has no value
126126
/// then all debuggers will receive this event.
127127
std::optional<lldb::user_id_t> debugger_id;
128+
129+
/// The origin of the progress event, wheter it is internal or external.
130+
Progress::ProgressOrigin origin;
128131
};
129132

130133
private:
@@ -141,6 +144,9 @@ class Progress {
141144
/// Data needed by the debugger to broadcast a progress event.
142145
const ProgressData m_progress_data;
143146

147+
/// The origin of this progress event.
148+
const ProgressOrigin m_origin;
149+
144150
/// How much work ([0...m_total]) that has been completed.
145151
std::atomic<uint64_t> m_completed = 0;
146152

@@ -156,9 +162,6 @@ class Progress {
156162

157163
/// The "completed" value of the last reported event.
158164
std::optional<uint64_t> m_prev_completed;
159-
160-
/// The origin of this progress event.
161-
ProgressOrigin m_origin;
162165
};
163166

164167
/// A class used to group progress reports by category. This is done by using a

lldb/include/lldb/lldb-enumerations.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ enum Format {
195195
///< character arrays that can contain non printable
196196
///< characters
197197
eFormatAddressInfo, ///< Describe what an address points to (func + offset
198-
///< with file/line, symbol + offset, data, etc)
199-
eFormatHexFloat, ///< ISO C99 hex float string
200-
eFormatInstruction, ///< Disassemble an opcode
201-
eFormatVoid, ///< Do not print this
198+
///< with file/line, symbol + offset, data, etc)
199+
eFormatHexFloat, ///< ISO C99 hex float string
200+
eFormatInstruction, ///< Disassemble an opcode
201+
eFormatVoid, ///< Do not print this
202202
eFormatUnicode8,
203203
kNumFormats
204204
};
@@ -302,7 +302,7 @@ enum ConnectionStatus {
302302
eConnectionStatusNoConnection, ///< No connection
303303
eConnectionStatusLostConnection, ///< Lost connection while connected to a
304304
///< valid connection
305-
eConnectionStatusInterrupted ///< Interrupted read
305+
eConnectionStatusInterrupted ///< Interrupted read
306306
};
307307

308308
enum ErrorType {
@@ -1094,7 +1094,7 @@ enum PathType {
10941094
ePathTypeGlobalLLDBTempSystemDir, ///< The LLDB temp directory for this
10951095
///< system, NOT cleaned up on a process
10961096
///< exit.
1097-
ePathTypeClangDir ///< Find path to Clang builtin headers
1097+
ePathTypeClangDir ///< Find path to Clang builtin headers
10981098
};
10991099

11001100
/// Kind of member function.
@@ -1357,7 +1357,8 @@ enum DebuggerBroadcastBit {
13571357
eBroadcastBitError = (1 << 2),
13581358
eBroadcastSymbolChange = (1 << 3),
13591359
eBroadcastBitProgressCategory = (1 << 4),
1360-
eBroadcastBitExternalProgressCategory = (1 << 5),
1360+
eBroadcastBitExternalProgress = (1 << 5),
1361+
eBroadcastBitExternalProgressCategory = (1 << 6),
13611362
};
13621363

13631364
/// Used for expressing severity in logs and diagnostics.

lldb/source/Core/Progress.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ Progress::Progress(std::string title, std::string details,
2929
std::optional<uint64_t> total,
3030
lldb_private::Debugger *debugger,
3131
Timeout<std::nano> minimum_report_time,
32-
ProgressOrigin origin)
32+
Progress::ProgressOrigin origin)
3333
: m_total(total.value_or(Progress::kNonDeterministicTotal)),
3434
m_minimum_report_time(minimum_report_time),
3535
m_progress_data{title, ++g_id,
3636
debugger ? std::optional<user_id_t>(debugger->GetID())
37-
: std::nullopt},
37+
: std::nullopt,
38+
origin},
39+
m_origin(origin),
3840
m_last_report_time_ns(
3941
std::chrono::nanoseconds(
4042
std::chrono::steady_clock::now().time_since_epoch())
4143
.count()),
42-
m_details(std::move(details)), m_origin(origin) {
44+
m_details(std::move(details)) {
4345
std::lock_guard<std::mutex> guard(m_mutex);
4446
ReportProgress();
4547

@@ -108,10 +110,9 @@ void Progress::ReportProgress() {
108110
return; // An overflow in the m_completed counter. Just ignore these events.
109111

110112
// Change the category bit if we're an internal or external progress.
111-
uint32_t progress_category_bit =
112-
m_origin == ProgressOrigin::eExternal
113-
? lldb::eBroadcastBitExternalProgressCategory
114-
: lldb::eBroadcastBitProgressCategory;
113+
uint32_t progress_category_bit = m_origin == ProgressOrigin::eExternal
114+
? lldb::eBroadcastBitProgress
115+
: lldb::eBroadcastBitExternalProgress;
115116

116117
Debugger::ReportProgress(m_progress_data.progress_id, m_progress_data.title,
117118
m_details, completed, m_total,
@@ -208,10 +209,13 @@ void ProgressManager::ReportProgress(
208209
// broadcasting to it since that bit doesn't need that information.
209210
const uint64_t completed =
210211
(type == EventType::Begin) ? 0 : Progress::kNonDeterministicTotal;
212+
const uint32_t progress_category_bit =
213+
progress_data.origin == Progress::ProgressOrigin::eExternal
214+
? lldb::eBroadcastBitExternalProgressCategory
215+
: lldb::eBroadcastBitProgressCategory;
211216
Debugger::ReportProgress(progress_data.progress_id, progress_data.title, "",
212217
completed, Progress::kNonDeterministicTotal,
213-
progress_data.debugger_id,
214-
lldb::eBroadcastBitProgressCategory);
218+
progress_data.debugger_id, progress_category_bit);
215219
}
216220

217221
void ProgressManager::Expire(llvm::StringRef key) {

0 commit comments

Comments
 (0)