summaryrefslogtreecommitdiff
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
committerMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
commit38500d63e14ce340236840f60d356cdefb56a52c (patch)
tree17edbec446ce9b50d2f215a483b83afb293a635d /lldb/source/Core
parent1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff)
parent27f30029741ecf023baece7b3dde1ff9011ffefc (diff)
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/CoreProperties.td4
-rw-r--r--lldb/source/Core/Debugger.cpp28
-rw-r--r--lldb/source/Core/Progress.cpp82
-rw-r--r--lldb/source/Core/Section.cpp10
4 files changed, 89 insertions, 35 deletions
diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td
index e11aad2660b4..d3816c3070bb 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -136,6 +136,10 @@ let Definition = "debugger" in {
Global,
DefaultUnsignedValue<80>,
Desc<"The maximum number of columns to use for displaying text.">;
+ def TerminalHeight: Property<"term-height", "UInt64">,
+ Global,
+ DefaultUnsignedValue<24>,
+ Desc<"The number of rows used for displaying text.">;
def ThreadFormat: Property<"thread-format", "FormatEntity">,
Global,
DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\\\\nReturn value: ${thread.return-value}}{\\\\nCompleted expression: ${thread.completed-expression}}\\\\n">,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index bb0a78790a96..6ceb209269c9 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -371,11 +371,29 @@ uint64_t Debugger::GetTerminalWidth() const {
}
bool Debugger::SetTerminalWidth(uint64_t term_width) {
+ const uint32_t idx = ePropertyTerminalWidth;
+ const bool success = SetPropertyAtIndex(idx, term_width);
+
if (auto handler_sp = m_io_handler_stack.Top())
handler_sp->TerminalSizeChanged();
- const uint32_t idx = ePropertyTerminalWidth;
- return SetPropertyAtIndex(idx, term_width);
+ return success;
+}
+
+uint64_t Debugger::GetTerminalHeight() const {
+ const uint32_t idx = ePropertyTerminalHeight;
+ return GetPropertyAtIndexAs<uint64_t>(
+ idx, g_debugger_properties[idx].default_uint_value);
+}
+
+bool Debugger::SetTerminalHeight(uint64_t term_height) {
+ const uint32_t idx = ePropertyTerminalHeight;
+ const bool success = SetPropertyAtIndex(idx, term_height);
+
+ if (auto handler_sp = m_io_handler_stack.Top())
+ handler_sp->TerminalSizeChanged();
+
+ return success;
}
bool Debugger::GetUseExternalEditor() const {
@@ -919,7 +937,11 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(
ePropertyTerminalWidth);
term_width->SetMinimumValue(10);
- term_width->SetMaximumValue(1024);
+
+ OptionValueUInt64 *term_height =
+ m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64(
+ ePropertyTerminalHeight);
+ term_height->SetMinimumValue(10);
// Turn off use-color if this is a dumb terminal.
const char *term = getenv("TERM");
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index c9a556472c06..ed8dfb85639b 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -11,7 +11,8 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/Signposts.h"
-
+#include <atomic>
+#include <chrono>
#include <cstdint>
#include <mutex>
#include <optional>
@@ -26,17 +27,18 @@ static llvm::ManagedStatic<llvm::SignpostEmitter> g_progress_signposts;
Progress::Progress(std::string title, std::string details,
std::optional<uint64_t> total,
- lldb_private::Debugger *debugger)
- : m_details(details), m_completed(0),
- m_total(Progress::kNonDeterministicTotal),
+ lldb_private::Debugger *debugger,
+ Timeout<std::nano> minimum_report_time)
+ : m_total(total.value_or(Progress::kNonDeterministicTotal)),
+ m_minimum_report_time(minimum_report_time),
m_progress_data{title, ++g_id,
- /*m_progress_data.debugger_id=*/std::nullopt} {
- if (total)
- m_total = *total;
-
- if (debugger)
- m_progress_data.debugger_id = debugger->GetID();
-
+ debugger ? std::optional<user_id_t>(debugger->GetID())
+ : std::nullopt},
+ m_last_report_time_ns(
+ std::chrono::nanoseconds(
+ std::chrono::steady_clock::now().time_since_epoch())
+ .count()),
+ m_details(std::move(details)) {
std::lock_guard<std::mutex> guard(m_mutex);
ReportProgress();
@@ -65,29 +67,49 @@ Progress::~Progress() {
void Progress::Increment(uint64_t amount,
std::optional<std::string> updated_detail) {
- if (amount > 0) {
- std::lock_guard<std::mutex> guard(m_mutex);
- if (updated_detail)
- m_details = std::move(updated_detail.value());
- // Watch out for unsigned overflow and make sure we don't increment too
- // much and exceed the total.
- if (m_total && (amount > (m_total - m_completed)))
- m_completed = m_total;
- else
- m_completed += amount;
- ReportProgress();
+ if (amount == 0)
+ return;
+
+ m_completed.fetch_add(amount, std::memory_order_relaxed);
+
+ if (m_minimum_report_time) {
+ using namespace std::chrono;
+
+ nanoseconds now;
+ uint64_t last_report_time_ns =
+ m_last_report_time_ns.load(std::memory_order_relaxed);
+
+ do {
+ now = steady_clock::now().time_since_epoch();
+ if (now < nanoseconds(last_report_time_ns) + *m_minimum_report_time)
+ return; // Too little time has passed since the last report.
+
+ } while (!m_last_report_time_ns.compare_exchange_weak(
+ last_report_time_ns, now.count(), std::memory_order_relaxed,
+ std::memory_order_relaxed));
}
+
+ std::lock_guard<std::mutex> guard(m_mutex);
+ if (updated_detail)
+ m_details = std::move(updated_detail.value());
+ ReportProgress();
}
void Progress::ReportProgress() {
- if (!m_complete) {
- // Make sure we only send one notification that indicates the progress is
- // complete
- m_complete = m_completed == m_total;
- Debugger::ReportProgress(m_progress_data.progress_id, m_progress_data.title,
- m_details, m_completed, m_total,
- m_progress_data.debugger_id);
- }
+ // NB: Comparisons with optional<T> rely on the fact that std::nullopt is
+ // "smaller" than zero.
+ if (m_prev_completed >= m_total)
+ return; // We've reported completion already.
+
+ uint64_t completed =
+ std::min(m_completed.load(std::memory_order_relaxed), m_total);
+ if (completed < m_prev_completed)
+ return; // An overflow in the m_completed counter. Just ignore these events.
+
+ Debugger::ReportProgress(m_progress_data.progress_id, m_progress_data.title,
+ m_details, completed, m_total,
+ m_progress_data.debugger_id);
+ m_prev_completed = completed;
}
ProgressManager::ProgressManager()
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 0763e88d4608..31273ede618f 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -147,10 +147,14 @@ const char *Section::GetTypeAsCString() const {
return "dwarf-gnu-debugaltlink";
case eSectionTypeCTF:
return "ctf";
- case eSectionTypeOther:
- return "regular";
+ case eSectionTypeLLDBTypeSummaries:
+ return "lldb-type-summaries";
+ case eSectionTypeLLDBFormatters:
+ return "lldb-formatters";
case eSectionTypeSwiftModules:
return "swift-modules";
+ case eSectionTypeOther:
+ return "regular";
}
return "unknown";
}
@@ -457,6 +461,8 @@ bool Section::ContainsOnlyDebugInfo() const {
case eSectionTypeDWARFAppleObjC:
case eSectionTypeDWARFGNUDebugAltLink:
case eSectionTypeCTF:
+ case eSectionTypeLLDBTypeSummaries:
+ case eSectionTypeLLDBFormatters:
case eSectionTypeSwiftModules:
return true;
}