Skip to content

Commit fcad0a3

Browse files
committed
Add external progress bit category
1 parent 72e8b9a commit fcad0a3

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

lldb/include/lldb/Core/Progress.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
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+
2430
/// A Progress indicator helper class.
2531
///
2632
/// Any potentially long running sections of code in LLDB should report
@@ -83,7 +89,8 @@ class Progress {
8389
Progress(std::string title, std::string details = {},
8490
std::optional<uint64_t> total = std::nullopt,
8591
lldb_private::Debugger *debugger = nullptr,
86-
Timeout<std::nano> minimum_report_time = std::nullopt);
92+
Timeout<std::nano> minimum_report_time = std::nullopt,
93+
ProgressOrigin origin = ProgressOrigin::eLLDBInternal);
8794

8895
/// Destroy the progress object.
8996
///
@@ -149,6 +156,9 @@ class Progress {
149156

150157
/// The "completed" value of the last reported event.
151158
std::optional<uint64_t> m_prev_completed;
159+
160+
/// The origin of this progress event.
161+
ProgressOrigin m_origin;
152162
};
153163

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

lldb/include/lldb/lldb-enumerations.h

Lines changed: 7 additions & 6 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,6 +1357,7 @@ enum DebuggerBroadcastBit {
13571357
eBroadcastBitError = (1 << 2),
13581358
eBroadcastSymbolChange = (1 << 3),
13591359
eBroadcastBitProgressCategory = (1 << 4),
1360+
eBroadcastBitExternalProgressCategory = (1 << 5),
13601361
};
13611362

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

lldb/source/Core/Progress.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static llvm::ManagedStatic<llvm::SignpostEmitter> g_progress_signposts;
2828
Progress::Progress(std::string title, std::string details,
2929
std::optional<uint64_t> total,
3030
lldb_private::Debugger *debugger,
31-
Timeout<std::nano> minimum_report_time)
31+
Timeout<std::nano> minimum_report_time,
32+
ProgressOrigin origin)
3233
: m_total(total.value_or(Progress::kNonDeterministicTotal)),
3334
m_minimum_report_time(minimum_report_time),
3435
m_progress_data{title, ++g_id,
@@ -38,7 +39,7 @@ Progress::Progress(std::string title, std::string details,
3839
std::chrono::nanoseconds(
3940
std::chrono::steady_clock::now().time_since_epoch())
4041
.count()),
41-
m_details(std::move(details)) {
42+
m_details(std::move(details)), m_origin(origin) {
4243
std::lock_guard<std::mutex> guard(m_mutex);
4344
ReportProgress();
4445

@@ -106,9 +107,15 @@ void Progress::ReportProgress() {
106107
if (completed < m_prev_completed)
107108
return; // An overflow in the m_completed counter. Just ignore these events.
108109

110+
// 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;
115+
109116
Debugger::ReportProgress(m_progress_data.progress_id, m_progress_data.title,
110117
m_details, completed, m_total,
111-
m_progress_data.debugger_id);
118+
m_progress_data.debugger_id, progress_category_bit);
112119
m_prev_completed = completed;
113120
}
114121

0 commit comments

Comments
 (0)