[Lldb-commits] [lldb] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (PR #126715)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michał Górny (mgorny) Changes Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than `PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently work in `lldb_add_library()`, and while it could be fixed, it seems to be used contrary to its purpose — in other parts of LLVM project, the option is used to indicate that the sources found in the directory are split between different targets (e.g. a library and a tool), not to include sources conditionally. --- Full diff: https://github.com/llvm/llvm-project/pull/126715.diff 2 Files Affected: - (modified) lldb/source/Core/CMakeLists.txt (+2-3) - (modified) lldb/source/Core/Telemetry.cpp (+5) ``diff diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index 4b1f4181620160..fa79a40ac4bd4f 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -17,8 +17,8 @@ if (LLDB_ENABLE_CURSES) endif() if (LLVM_BUILD_TELEMETRY) - set(TELEMETRY_SOURCES Telemetry.cpp) set(TELEMETRY_DEPS Telemetry) + add_definitions(-DLLVM_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore @@ -57,11 +57,10 @@ add_lldb_library(lldbCore SourceLocationSpec.cpp SourceManager.cpp StreamAsynchronousIO.cpp + Telemetry.cpp ThreadedCommunication.cpp UserSettingsController.cpp Value.cpp - ${TELEMETRY_SOURCES} - PARTIAL_SOURCES_INTENDED DEPENDS clang-tablegen-targets diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index d479488bbc3994..adbef9655fcb62 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -5,6 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--===// + +#ifdef LLVM_BUILD_TELEMETRY + #include "lldb/Core/Telemetry.h" #include "lldb/Core/Debugger.h" #include "lldb/Utility/LLDBLog.h" @@ -67,3 +70,5 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { } // namespace telemetry } // namespace lldb_private + +#endif // LLVM_BUILD_TELEMETRY `` https://github.com/llvm/llvm-project/pull/126715 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)
https://github.com/anjenner updated https://github.com/llvm/llvm-project/pull/115331 >From 3fdba46d41ad9668a114766fe892af497f121cd5 Mon Sep 17 00:00:00 2001 From: Andrew Jenner Date: Thu, 7 Nov 2024 10:47:42 -0500 Subject: [PATCH 1/3] Modify the localCache API to require an explicit commit on CachedFileStream. CachedFileStream has previously performed the commit step in its destructor, but this means its only recourse for error handling is report_fatal_error. Modify this to add an explicit commit() method, and call this in the appropriate places with appropriate error handling for the location. Currently the destructor of CacheStream gives an assert failure in Debug builds if commit() was not called. This will help track down any remaining uses of the API that assume the old destructior behaviour. In Release builds we fall back to the previous behaviour and call report_fatal_error if the commit fails. --- lldb/source/Core/DataFileCache.cpp | 5 llvm/include/llvm/Support/Caching.h | 1 + llvm/lib/Debuginfod/Debuginfod.cpp | 9 +++ llvm/lib/LTO/LTOBackend.cpp | 3 +++ llvm/lib/Support/Caching.cpp| 40 + llvm/tools/gold/gold-plugin.cpp | 4 ++- llvm/tools/llvm-lto2/llvm-lto2.cpp | 4 ++- 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/lldb/source/Core/DataFileCache.cpp b/lldb/source/Core/DataFileCache.cpp index ef0e07a8b03420d..910926971123174 100644 --- a/lldb/source/Core/DataFileCache.cpp +++ b/lldb/source/Core/DataFileCache.cpp @@ -132,6 +132,11 @@ bool DataFileCache::SetCachedData(llvm::StringRef key, if (file_or_err) { llvm::CachedFileStream *cfs = file_or_err->get(); cfs->OS->write((const char *)data.data(), data.size()); +if (llvm::Error err = cfs->commit()) { + Log *log = GetLog(LLDBLog::Modules); + LLDB_LOG_ERROR(log, std::move(err), + "failed to commit to the cache for key: {0}"); +} return true; } else { Log *log = GetLog(LLDBLog::Modules); diff --git a/llvm/include/llvm/Support/Caching.h b/llvm/include/llvm/Support/Caching.h index cf45145619d95b8..120bcd9da02edea 100644 --- a/llvm/include/llvm/Support/Caching.h +++ b/llvm/include/llvm/Support/Caching.h @@ -30,6 +30,7 @@ class CachedFileStream { CachedFileStream(std::unique_ptr OS, std::string OSPath = "") : OS(std::move(OS)), ObjectPathName(OSPath) {} + virtual Error commit() { return Error::success(); } std::unique_ptr OS; std::string ObjectPathName; virtual ~CachedFileStream() = default; diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp index 4c785117ae8ef77..6ff889d3a8cad2b 100644 --- a/llvm/lib/Debuginfod/Debuginfod.cpp +++ b/llvm/lib/Debuginfod/Debuginfod.cpp @@ -188,6 +188,7 @@ class StreamedHTTPResponseHandler : public HTTPResponseHandler { public: StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client) : CreateStream(CreateStream), Client(Client) {} + Error commit(); virtual ~StreamedHTTPResponseHandler() = default; Error handleBodyChunk(StringRef BodyChunk) override; @@ -210,6 +211,12 @@ Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) { return Error::success(); } +Error StreamedHTTPResponseHandler::commit() { + if (FileStream) +return FileStream->commit(); + return Error::success(); +} + // An over-accepting simplification of the HTTP RFC 7230 spec. static bool isHeader(StringRef S) { StringRef Name; @@ -298,6 +305,8 @@ Expected getCachedOrDownloadArtifact( Error Err = Client.perform(Request, Handler); if (Err) return std::move(Err); + if (Err = Handler.commit()) +return std::move(Err); unsigned Code = Client.responseCode(); if (Code && Code != 200) diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index bdf4ff8960bc821..4bfa8751a436439 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -434,6 +434,9 @@ static void codegen(const Config &Conf, TargetMachine *TM, if (DwoOut) DwoOut->keep(); + + if (Error Err = Stream->commit()) +report_fatal_error(std::move(Err)); } static void splitCodeGen(const Config &C, TargetMachine *TM, diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp index 66e540efaca972d..2ecdf53701030d1 100644 --- a/llvm/lib/Support/Caching.cpp +++ b/llvm/lib/Support/Caching.cpp @@ -80,6 +80,7 @@ Expected llvm::localCache(const Twine &CacheNameRef, sys::fs::TempFile TempFile; std::string ModuleName; unsigned Task; + bool Committed = false; CacheStream(std::unique_ptr OS, AddBufferFn AddBuffer, sys::fs::TempFile TempFile, std::string EntryPath, @@ -88,9 +89,10 @@ Expected llvm::localCache(const Twine &CacheNameRef, AddBuffer(std::move(AddBuffer)), TempFile(std::move(Temp
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126588 >From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Mon, 10 Feb 2025 14:44:11 -0500 Subject: [PATCH 1/4] Define TelemetryVendor plugin. Details: Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance. --- lldb/include/lldb/Core/TelemetryVendor.h | 39 + lldb/source/Core/TelemetryVendor.cpp | 43 2 files changed, 82 insertions(+) create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h create mode 100644 lldb/source/Core/TelemetryVendor.cpp diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h new file mode 100644 index 000..a2ab3b69fde4225 --- /dev/null +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -0,0 +1,39 @@ +//===-- TelemetryVendor.h -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRYVENDOR_H +#define LLDB_CORE_TELEMETRYVENDOR_H + +#include "lldb/Core/PluginInterface.h" +#include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" + +#include + +namespace lldb_private { + +class TelemetryVendor : public PluginInterface { +public: + TelemetryVendor() = default; + + llvm::StringRef GetPluginName() override; + + static void Initialize(); + + static void Terminate(); + + static std::unique_ptr GetTelemetryConfig(); + static void + SetTelemetryConfig(std::unique_ptr config); + + static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); +}; + +} // namespace lldb_private +#endif // LLDB_CORE_TELEMETRYVENDOR_H diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp new file mode 100644 index 000..520a01b9b1c7a3e --- /dev/null +++ b/lldb/source/Core/TelemetryVendor.cpp @@ -0,0 +1,43 @@ +//===-- TelemetryVendor.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/TelemetryVendor.h" + +namespace lldb_private { + +llvm::StringRef TelemetryVendor::GetPluginName() { + return "UpstreamTelemetryVendor"; +} + +void TelemetryVendor::Initialize() { + // The default (upstream) impl will have telemetry disabled by default. + SetTelemetryConfig( + std::make_unique(/*enable_telemetry*/ false)); + SetTelemetryManager(nullptr); +} + +static std::unique_ptr current_config; +std::unique_ptr TelemetryVendor::GetTelemetryConfig() { + return current_config; +} + +void TelemetryVendor::SetTelemetryConfig( +std::unique_ptr config) { + current_config = std::move(config); +} + +lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() { + static TelemteryManagerSP g_telemetry_manager_sp; + return g_telemetry_manager_sp; +} + +void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) { + GetTelemetryManager() = manager_sp; +} + +} // namespace lldb_private >From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:31:00 -0500 Subject: [PATCH 2/4] use shared ptr --- lldb/include/lldb/Core/TelemetryVendor.h | 7 --- lldb/include/lldb/lldb-forward.h | 5 + lldb/source/Core/TelemetryVendor.cpp | 14 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h index a2ab3b69fde4225..a55f06fb9141f06 100644 --- a/lldb/include/lldb/Core/TelemetryVendor.h +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface { static void Terminate(); - static std::unique_ptr GetTelemetryConfig(); - static void - SetTelemetryConfig(std::unique_ptr config); + static lldb::TelemetryConfig GetTelemetryConfig(); + + static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config); static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fc7456a4b9a32e6..2f2a4ec86a1fb89 100644 --- a/lldb/i
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
@@ -0,0 +1,69 @@ +//===-- Telemetry.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "lldb/Core/Telemetry.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/RandomNumberGenerator.h" +#include "llvm/Telemetry/Telemetry.h" +#include +#include +#include +#include +#include + +namespace lldb_private { +namespace telemetry { + +using ::llvm::Error; +using ::llvm::telemetry::Destination; +using ::llvm::telemetry::Serializer; +using ::llvm::telemetry::TelemetryInfo; + +static uint64_t ToNanosec(const SteadyTimePoint Point) { + return std::chrono::nanoseconds(Point.time_since_epoch()).count(); +} + +void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { + serializer.write("entry_kind", getKind()); + serializer.write("session_id", SessionId); + serializer.write("start_time", ToNanosec(start_time)); + if (end_time.has_value()) +serializer.write("end_time", ToNanosec(end_time.value())); +} + +static std::string MakeUUID(lldb_private::Debugger *debugger) { oontvoo wrote: done https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
@@ -0,0 +1,74 @@ +//===-- Telemetry.h ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRY_H +#define LLDB_CORE_TELEMETRY_H + +#include "lldb/Core/StructuredDataImpl.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Utility/StructuredData.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/JSON.h" +#include "llvm/Telemetry/Telemetry.h" +#include +#include +#include +#include +#include +#include + +namespace lldb_private { +namespace telemetry { + +struct LLDBEntryKind : public ::llvm::telemetry::EntryKind { + static const llvm::telemetry::KindType BaseInfo = 0b11000; +}; + +/// Defines a convenient type for timestamp of various events. +using SteadyTimePoint = std::chrono::time_point; +struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo { + /// Start time of an event + SteadyTimePoint start_time; + /// End time of an event - may be empty if not meaningful. + std::optional end_time; + // TBD: could add some memory stats here too? + + Debugger *debugger; + + // For dyn_cast, isa, etc operations. + llvm::telemetry::KindType getKind() const override { +return LLDBEntryKind::BaseInfo; + } + + static bool classof(const llvm::telemetry::TelemetryInfo *t) { +// Subclasses of this is also acceptable. +return (t->getKind() & LLDBEntryKind::BaseInfo) == LLDBEntryKind::BaseInfo; + } + + void serialize(llvm::telemetry::Serializer &serializer) const override; +}; + +/// The base Telemetry manager instance in LLDB oontvoo wrote: done https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5bf42d3 - [lldb] Fix ubsan violation with plugin loading (#126652)
Author: Keith Smiley Date: 2025-02-11T08:04:51-08:00 New Revision: 5bf42d3e2e83344db14fc0e33623840c53cebfc4 URL: https://github.com/llvm/llvm-project/commit/5bf42d3e2e83344db14fc0e33623840c53cebfc4 DIFF: https://github.com/llvm/llvm-project/commit/5bf42d3e2e83344db14fc0e33623840c53cebfc4.diff LOG: [lldb] Fix ubsan violation with plugin loading (#126652) This typedef doesn't match the signature below, specifically the signature takes a `lldb:SBDebugger` vs this was defined as `lldb:SBDebugger&`. ``` lldb/source/API/SBDebugger.cpp:199:13: runtime error: call to function lldb::PluginInitialize(lldb::SBDebugger) through pointer to incorrect function type 'bool (*)(lldb::SBDebugger &)' .../CustomPlugin.cpp:134: note: lldb::PluginInitialize(lldb::SBDebugger) defined here ``` Added: Modified: lldb/source/API/SBDebugger.cpp Removed: diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 4e6b22492a0d1c2..bdb8e538b99f861 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -185,7 +185,7 @@ lldb::SBError SBDebugger::InitializeWithErrorHandling() { llvm::sys::DynamicLibrary dynlib = llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); if (dynlib.isValid()) { - typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); + typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger debugger); lldb::SBDebugger debugger_sb(debugger_sp); // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix ubsan violation with plugin loading (PR #126652)
https://github.com/keith closed https://github.com/llvm/llvm-project/pull/126652 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
@@ -0,0 +1,69 @@ +//===-- Telemetry.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "lldb/Core/Telemetry.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/RandomNumberGenerator.h" +#include "llvm/Telemetry/Telemetry.h" +#include +#include +#include +#include +#include + +namespace lldb_private { +namespace telemetry { + +using ::llvm::Error; +using ::llvm::telemetry::Destination; +using ::llvm::telemetry::Serializer; +using ::llvm::telemetry::TelemetryInfo; + +static uint64_t ToNanosec(const SteadyTimePoint Point) { + return std::chrono::nanoseconds(Point.time_since_epoch()).count(); +} + +void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { + serializer.write("entry_kind", getKind()); + serializer.write("session_id", SessionId); + serializer.write("start_time", ToNanosec(start_time)); + if (end_time.has_value()) +serializer.write("end_time", ToNanosec(end_time.value())); +} + +static std::string MakeUUID(lldb_private::Debugger *debugger) { + uint8_t random_bytes[16]; + if (auto ec = llvm::getRandomBytes(random_bytes, 16)) { +LLDB_LOG(GetLog(LLDBLog::Object), + "Failed to generate random bytes for UUID: {0}", ec.message()); +// fallback to using timestamp + debugger ID. oontvoo wrote: done https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
@@ -0,0 +1,69 @@ +//===-- Telemetry.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "lldb/Core/Telemetry.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/RandomNumberGenerator.h" +#include "llvm/Telemetry/Telemetry.h" +#include +#include +#include +#include +#include + +namespace lldb_private { +namespace telemetry { + +using ::llvm::Error; +using ::llvm::telemetry::Destination; +using ::llvm::telemetry::Serializer; +using ::llvm::telemetry::TelemetryInfo; + +static uint64_t ToNanosec(const SteadyTimePoint Point) { + return std::chrono::nanoseconds(Point.time_since_epoch()).count(); +} + +void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { + serializer.write("entry_kind", getKind()); + serializer.write("session_id", SessionId); + serializer.write("start_time", ToNanosec(start_time)); + if (end_time.has_value()) +serializer.write("end_time", ToNanosec(end_time.value())); +} + +static std::string MakeUUID(lldb_private::Debugger *debugger) { + uint8_t random_bytes[16]; + if (auto ec = llvm::getRandomBytes(random_bytes, 16)) { +LLDB_LOG(GetLog(LLDBLog::Object), + "Failed to generate random bytes for UUID: {0}", ec.message()); +// fallback to using timestamp + debugger ID. +return llvm::formatv( +"{0}_{1}", std::chrono::steady_clock::now().time_since_epoch().count(), +debugger->GetID()); + } + return lldb_private::UUID(random_bytes).GetAsString(); +} + +TelemetryManager::TelemetryManager( +std::unique_ptr config) oontvoo wrote: done https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Addressed additional review comments from PR/119716. (PR #126757)
https://github.com/oontvoo created https://github.com/llvm/llvm-project/pull/126757 None >From 5a8b91422a017dcda595efa614a018f0a432df12 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 11:05:21 -0500 Subject: [PATCH] Addressed additional review comments from PR/119716. --- lldb/include/lldb/Core/Telemetry.h | 2 +- lldb/source/Core/Telemetry.cpp | 14 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 60a7097de5eeef5..d6c9e42ca81390e 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -56,7 +56,7 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo { void serialize(llvm::telemetry::Serializer &serializer) const override; }; -/// The base Telemetry manager instance in LLDB +/// The base Telemetry manager instance in LLDB. /// This class declares additional instrumentation points /// applicable to LLDB. class TelemetryManager : public llvm::telemetry::Manager { diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 99f5d43ccbaf036..d0d7014d9ae83e7 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -27,10 +27,7 @@ namespace lldb_private { namespace telemetry { -using ::llvm::Error; -using ::llvm::telemetry::Destination; -using ::llvm::telemetry::Serializer; -using ::llvm::telemetry::TelemetryInfo; +namespace llvm::telemetry; static uint64_t ToNanosec(const SteadyTimePoint Point) { return std::chrono::nanoseconds(Point.time_since_epoch()).count(); @@ -44,21 +41,20 @@ void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { serializer.write("end_time", ToNanosec(end_time.value())); } -[[maybe_unused]] static std::string MakeUUID(lldb_private::Debugger *debugger) { +[[maybe_unused]] static std::string MakeUUID(Debugger *debugger) { uint8_t random_bytes[16]; if (auto ec = llvm::getRandomBytes(random_bytes, 16)) { LLDB_LOG(GetLog(LLDBLog::Object), "Failed to generate random bytes for UUID: {0}", ec.message()); -// fallback to using timestamp + debugger ID. +// Fallback to using timestamp + debugger ID. return llvm::formatv( "{0}_{1}", std::chrono::steady_clock::now().time_since_epoch().count(), debugger->GetID()); } - return lldb_private::UUID(random_bytes).GetAsString(); + return MakeUUID(random_bytes).GetAsString(); } -TelemetryManager::TelemetryManager( -std::unique_ptr config) +TelemetryManager::TelemetryManager(std::unique_ptr config) : m_config(std::move(config)) {} llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
@@ -0,0 +1,69 @@ +//===-- Telemetry.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "lldb/Core/Telemetry.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/RandomNumberGenerator.h" +#include "llvm/Telemetry/Telemetry.h" +#include +#include +#include +#include +#include + +namespace lldb_private { +namespace telemetry { + +using ::llvm::Error; +using ::llvm::telemetry::Destination; +using ::llvm::telemetry::Serializer; +using ::llvm::telemetry::TelemetryInfo; + +static uint64_t ToNanosec(const SteadyTimePoint Point) { + return std::chrono::nanoseconds(Point.time_since_epoch()).count(); +} + +void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { + serializer.write("entry_kind", getKind()); + serializer.write("session_id", SessionId); + serializer.write("start_time", ToNanosec(start_time)); + if (end_time.has_value()) +serializer.write("end_time", ToNanosec(end_time.value())); +} + +static std::string MakeUUID(lldb_private::Debugger *debugger) { oontvoo wrote: (all addressed in https://github.com/llvm/llvm-project/pull/126757) https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Addressed additional review comments from PR/119716. (PR #126757)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Vy Nguyen (oontvoo) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/126757.diff 2 Files Affected: - (modified) lldb/include/lldb/Core/Telemetry.h (+1-1) - (modified) lldb/source/Core/Telemetry.cpp (+5-9) ``diff diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 60a7097de5eeef..d6c9e42ca81390 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -56,7 +56,7 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo { void serialize(llvm::telemetry::Serializer &serializer) const override; }; -/// The base Telemetry manager instance in LLDB +/// The base Telemetry manager instance in LLDB. /// This class declares additional instrumentation points /// applicable to LLDB. class TelemetryManager : public llvm::telemetry::Manager { diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 99f5d43ccbaf03..d0d7014d9ae83e 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -27,10 +27,7 @@ namespace lldb_private { namespace telemetry { -using ::llvm::Error; -using ::llvm::telemetry::Destination; -using ::llvm::telemetry::Serializer; -using ::llvm::telemetry::TelemetryInfo; +namespace llvm::telemetry; static uint64_t ToNanosec(const SteadyTimePoint Point) { return std::chrono::nanoseconds(Point.time_since_epoch()).count(); @@ -44,21 +41,20 @@ void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { serializer.write("end_time", ToNanosec(end_time.value())); } -[[maybe_unused]] static std::string MakeUUID(lldb_private::Debugger *debugger) { +[[maybe_unused]] static std::string MakeUUID(Debugger *debugger) { uint8_t random_bytes[16]; if (auto ec = llvm::getRandomBytes(random_bytes, 16)) { LLDB_LOG(GetLog(LLDBLog::Object), "Failed to generate random bytes for UUID: {0}", ec.message()); -// fallback to using timestamp + debugger ID. +// Fallback to using timestamp + debugger ID. return llvm::formatv( "{0}_{1}", std::chrono::steady_clock::now().time_since_epoch().count(), debugger->GetID()); } - return lldb_private::UUID(random_bytes).GetAsString(); + return MakeUUID(random_bytes).GetAsString(); } -TelemetryManager::TelemetryManager( -std::unique_ptr config) +TelemetryManager::TelemetryManager(std::unique_ptr config) : m_config(std::move(config)) {} llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { `` https://github.com/llvm/llvm-project/pull/126757 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
mgorny wrote: Filed #126710 to fix passing `LLVM_BUILD_TELEMETRY` in standalone builds, and #126715 to fix building with telemetry disabled. https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (PR #126715)
https://github.com/mgorny closed https://github.com/llvm/llvm-project/pull/126715 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bf2d4eb - [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (#126715)
Author: Michał Górny Date: 2025-02-11T14:22:44Z New Revision: bf2d4eb7030b809004dd1e6d0cc15a94a9e18c88 URL: https://github.com/llvm/llvm-project/commit/bf2d4eb7030b809004dd1e6d0cc15a94a9e18c88 DIFF: https://github.com/llvm/llvm-project/commit/bf2d4eb7030b809004dd1e6d0cc15a94a9e18c88.diff LOG: [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (#126715) Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than `PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently work in `lldb_add_library()`, and while it could be fixed, it seems to be used contrary to its purpose — in other parts of LLVM project, the option is used to indicate that the sources found in the directory are split between different targets (e.g. a library and a tool), not to include sources conditionally. Added: Modified: lldb/source/Core/CMakeLists.txt lldb/source/Core/Telemetry.cpp Removed: diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index 4b1f418162016..cf5f6ac9da489 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -17,8 +17,8 @@ if (LLDB_ENABLE_CURSES) endif() if (LLVM_BUILD_TELEMETRY) - set(TELEMETRY_SOURCES Telemetry.cpp) set(TELEMETRY_DEPS Telemetry) + add_definitions(-DLLDB_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore @@ -57,11 +57,10 @@ add_lldb_library(lldbCore SourceLocationSpec.cpp SourceManager.cpp StreamAsynchronousIO.cpp + Telemetry.cpp ThreadedCommunication.cpp UserSettingsController.cpp Value.cpp - ${TELEMETRY_SOURCES} - PARTIAL_SOURCES_INTENDED DEPENDS clang-tablegen-targets diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index d479488bbc399..99f5d43ccbaf0 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -5,6 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--===// + +#ifdef LLDB_BUILD_TELEMETRY + #include "lldb/Core/Telemetry.h" #include "lldb/Core/Debugger.h" #include "lldb/Utility/LLDBLog.h" @@ -67,3 +70,5 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { } // namespace telemetry } // namespace lldb_private + +#endif // LLDB_BUILD_TELEMETRY ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/126526 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
mgorny wrote: `PARTIAL_SOURCES_INTENDED` doesn't work there since it isn't passed to `llvm_add_library()`, and `llvm_process_sources()` is called again there. That said, I would personally lean towards putting the whole file around an `#if` rather than disabling the QA check. In the end, `PARTIAL_SOURCES_INTENDED` is mostly used when there are two targets built in a single CMake file, rather than for conditional sources. https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
DhruvSrivastavaX wrote: Hi @DavidSpickett @labath , Do let me know if this can be merged now https://github.com/llvm/llvm-project/pull/121273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` (PR #126715)
https://github.com/mgorny created https://github.com/llvm/llvm-project/pull/126715 Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than `PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently work in `lldb_add_library()`, and while it could be fixed, it seems to be used contrary to its purpose — in other parts of LLVM project, the option is used to indicate that the sources found in the directory are split between different targets (e.g. a library and a tool), not to include sources conditionally. From 8ec53caddb1566d0d607c6e6321da7e960bf78cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 11 Feb 2025 12:17:59 +0100 Subject: [PATCH] [lldb] Use preprocessor guard for `LLVM_BUILD_TELEMETRY` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a preprocessor `#ifdef LLVM_BUILD_TELEMETRY` guard rather than `PARTIAL_SOURCES_INTENDED` for the `Telemetry.cpp` file, to fix building with telemetry disabled. `PARTIAL_SOURCES_INTENDED` does not currently work in `lldb_add_library()`, and while it could be fixed, it seems to be used contrary to its purpose — in other parts of LLVM project, the option is used to indicate that the sources found in the directory are split between different targets (e.g. a library and a tool), not to include sources conditionally. --- lldb/source/Core/CMakeLists.txt | 5 ++--- lldb/source/Core/Telemetry.cpp | 5 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index 4b1f41816201608..fa79a40ac4bd4f0 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -17,8 +17,8 @@ if (LLDB_ENABLE_CURSES) endif() if (LLVM_BUILD_TELEMETRY) - set(TELEMETRY_SOURCES Telemetry.cpp) set(TELEMETRY_DEPS Telemetry) + add_definitions(-DLLVM_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore @@ -57,11 +57,10 @@ add_lldb_library(lldbCore SourceLocationSpec.cpp SourceManager.cpp StreamAsynchronousIO.cpp + Telemetry.cpp ThreadedCommunication.cpp UserSettingsController.cpp Value.cpp - ${TELEMETRY_SOURCES} - PARTIAL_SOURCES_INTENDED DEPENDS clang-tablegen-targets diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index d479488bbc39949..adbef9655fcb62c 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -5,6 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--===// + +#ifdef LLVM_BUILD_TELEMETRY + #include "lldb/Core/Telemetry.h" #include "lldb/Core/Debugger.h" #include "lldb/Utility/LLDBLog.h" @@ -67,3 +70,5 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { } // namespace telemetry } // namespace lldb_private + +#endif // LLVM_BUILD_TELEMETRY ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,193 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#else // For remotely cross debugging aix +#define MAP_VARIABLE 0x0 +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x10 +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +bool PlatformAIX::CanDebugProcess() { return IsHost() ? true : IsConnected(); } + +void PlatformAIX::CalculateTrapHandlerSymbolNames() {} + +lldb::UnwindPlanSP +PlatformAIX::GetTrapHandlerUnwindPlan(const llvm::Triple &triple, + ConstString name) { + return {}; +} + +MmapArgList PlatformAIX::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, + addr_t length, unsigned prot, + unsigned flags, addr_t fd, + addr_t
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -8,3 +8,4 @@ add_subdirectory(OpenBSD) add_subdirectory(POSIX) add_subdirectory(QemuUser) add_subdirectory(Windows) +add_subdirectory(AIX) labath wrote: Let's keep the list sorted (looks like you get to be first). https://github.com/llvm/llvm-project/pull/121273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,193 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#else // For remotely cross debugging aix +#define MAP_VARIABLE 0x0 +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x10 +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +bool PlatformAIX::CanDebugProcess() { return IsHost() ? true : IsConnected(); } + +void PlatformAIX::CalculateTrapHandlerSymbolNames() {} + +lldb::UnwindPlanSP +PlatformAIX::GetTrapHandlerUnwindPlan(const llvm::Triple &triple, + ConstString name) { + return {}; +} + +MmapArgList PlatformAIX::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, + addr_t length, unsigned prot, + unsigned flags, addr_t fd, + addr_t
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,193 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#else // For remotely cross debugging aix +#define MAP_VARIABLE 0x0 +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x10 +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } labath wrote: This elaborate setup doesn't make sense if you're checking for just one OS ```suggestion if (force || (arch && arch->GetTriple().getOS() == llvm::Triple::AIX) return PlatformSP(new PlatformAIX(false)) ``` https://github.com/llvm/llvm-project/pull/121273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,193 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#else // For remotely cross debugging aix +#define MAP_VARIABLE 0x0 +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x10 +#endif labath wrote: ```suggestion // For remotely cross debugging aix constexpr int MapVariable = 0x0; constexpr int MapPrivate = 0x2; constexpr int MapAnonymous = 0x10; #if defined(_AIX) #include static_assert(MapVariable == MAP_VARIABLE); static_assert(MapPrivate == MAP_PRIVATE); static_assert(MapAnonymous = MAP_ANONYMOUS); #endif ``` And then use the locally defined constants in the code. The advantage of that is that it checks the constants are defined correctly and avoids redefining macros from system headers. https://github.com/llvm/llvm-project/pull/121273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
@@ -784,14 +784,12 @@ class CommandObjectSourceList : public CommandObjectParsed { if (sc.block == nullptr) { // Not an inlined function -sc.function->GetStartLineSourceInfo(start_file, start_line); -if (start_line == 0) { - result.AppendErrorWithFormat("Could not find line information for " - "start of function: \"%s\".\n", - source_info.function.GetCString()); - return 0; -} -sc.function->GetEndLineSourceInfo(end_file, end_line); +auto expected_info = sc.function->GetSourceInfo(); +if (!expected_info) + result.AppendError(llvm::toString(expected_info.takeError())); labath wrote: Yes on both counts. I'll add a test. https://github.com/llvm/llvm-project/pull/126526 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126746 >From 008537373cd928fea9ac04b1aed39c2ecafec65a Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:36:06 -0500 Subject: [PATCH 1/5] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (by users of Telemetry) --- llvm/lib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index d0a2bc9294381..08e3d7ddb8c12 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,6 +43,7 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) + add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) >From f2a3822291d7153359286bd5efc4c080c21adedd Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 11:22:36 -0500 Subject: [PATCH 2/5] add macro def in llvm-config.h --- llvm/include/llvm/Config/llvm-config.h.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 629977cc11d68..239f9dd3f38db 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -201,4 +201,7 @@ /* Define if logf128 is available */ #cmakedefine LLVM_HAS_LOGF128 +/* Define if building LLVM with LLVM_BUILD_TELEMETRY */ +#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY} + #endif >From 1bec761f06f79fac21a063a1e5c222e274dd3ddb Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 13:07:12 -0500 Subject: [PATCH 3/5] remove macro from lldb/soruce/Core/CMakeLists.txt --- lldb/source/Core/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index cf5f6ac9da489..82fb5f42f9f4b 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -18,7 +18,6 @@ endif() if (LLVM_BUILD_TELEMETRY) set(TELEMETRY_DEPS Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore >From 88cdb5ac5f7b6f8cb8bb539a7c1291a302632ec5 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 13:08:12 -0500 Subject: [PATCH 4/5] remove macro from llvm/CMakeLists.txt --- llvm/lib/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 08e3d7ddb8c12..d0a2bc9294381 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,7 +43,6 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) >From fe6c66535eb5feb9060b0c450840c74ad49bcc1f Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 14:17:35 -0500 Subject: [PATCH 5/5] include config.h header and use new LLVM_BUILD_TELEMETRY macro --- lldb/source/Core/Telemetry.cpp | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 99f5d43ccbaf0..0d0d7c1df3bb9 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -6,7 +6,9 @@ // //===--===// -#ifdef LLDB_BUILD_TELEMETRY +#include "llvm/Config/llvm-config.h" + +#ifdef LLVM_BUILD_TELEMETRY #include "lldb/Core/Telemetry.h" #include "lldb/Core/Debugger.h" @@ -71,4 +73,4 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { } // namespace telemetry } // namespace lldb_private -#endif // LLDB_BUILD_TELEMETRY +#endif // LLVM_BUILD_TELEMETRY ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
oontvoo wrote: > .. and fix the code so that it uses the new macro name ? (You'll need to > include llvm-config.h before you can use the macro, and I'd recommend doing a > build with telemetry disabled to check that everything works as it should) Done. (also tested with explicitly specifying `-LLVM_BUILD_TELEMETRY=OFF` in the cmake command) https://github.com/llvm/llvm-project/pull/126746 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
https://github.com/mgorny approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/126746 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jordan R AW (ajordanr-google) Changes For some operating systems, terminfo is a separate package and library from ncurses. Both are still requirements for curses support in lldb, individually. This is a rebase of this original spack commit: https://github.com/spack/spack/commit/9ea261265010eacd250691a8361f661d0576f25c Fixes #101368 --- Full diff: https://github.com/llvm/llvm-project/pull/126810.diff 1 Files Affected: - (modified) lldb/cmake/modules/FindCursesAndPanel.cmake (+8-4) ``diff diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake index aaadf214bf54b..df4980cc5e0d1 100644 --- a/lldb/cmake/modules/FindCursesAndPanel.cmake +++ b/lldb/cmake/modules/FindCursesAndPanel.cmake @@ -2,12 +2,15 @@ # FindCursesAndPanel # --- # -# Find the curses and panel library as a whole. +# Find the curses, terminfo, and panel library as a whole. +# NOTE: terminfo and curses libraries are required separately, as +# some systems do not bundle them together. -if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES) +if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES) set(CURSESANDPANEL_FOUND TRUE) else() find_package(Curses QUIET) + find_package(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET) find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CursesAndPanel @@ -16,9 +19,10 @@ else() REQUIRED_VARS CURSES_INCLUDE_DIRS CURSES_LIBRARIES + TINFO_LIBRARIES PANEL_LIBRARIES) - if(CURSES_FOUND AND PANEL_LIBRARIES) -mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES) + if(CURSES_FOUND AND TINFO_LIBRARIES AND PANEL_LIBRARIES) +mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES TINFO_LIBRARIES PANEL_LIBRARIES) endif() endif() `` https://github.com/llvm/llvm-project/pull/126810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)
https://github.com/ajordanr-google created https://github.com/llvm/llvm-project/pull/126810 For some operating systems, terminfo is a separate package and library from ncurses. Both are still requirements for curses support in lldb, individually. This is a rebase of this original spack commit: https://github.com/spack/spack/commit/9ea261265010eacd250691a8361f661d0576f25c Fixes #101368 >From e2343766f65acd684adc375373f08452ce071670 Mon Sep 17 00:00:00 2001 From: Jordan R Abrahams-Whitehead Date: Tue, 1 Oct 2024 18:41:28 + Subject: [PATCH] [lldb] Add terminfo dependency for ncurses support For some operating systems, terminfo is a separate package and library from ncurses. Both are still requirements for curses support in lldb, individually. This is a rebase of this original spack commit: https://github.com/spack/spack/commit/9ea261265010eacd250691a8361f661d0576f25c Fixes #101368 --- lldb/cmake/modules/FindCursesAndPanel.cmake | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake index aaadf214bf54b..df4980cc5e0d1 100644 --- a/lldb/cmake/modules/FindCursesAndPanel.cmake +++ b/lldb/cmake/modules/FindCursesAndPanel.cmake @@ -2,12 +2,15 @@ # FindCursesAndPanel # --- # -# Find the curses and panel library as a whole. +# Find the curses, terminfo, and panel library as a whole. +# NOTE: terminfo and curses libraries are required separately, as +# some systems do not bundle them together. -if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES) +if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES) set(CURSESANDPANEL_FOUND TRUE) else() find_package(Curses QUIET) + find_package(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET) find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CursesAndPanel @@ -16,9 +19,10 @@ else() REQUIRED_VARS CURSES_INCLUDE_DIRS CURSES_LIBRARIES + TINFO_LIBRARIES PANEL_LIBRARIES) - if(CURSES_FOUND AND PANEL_LIBRARIES) -mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES) + if(CURSES_FOUND AND TINFO_LIBRARIES AND PANEL_LIBRARIES) +mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES TINFO_LIBRARIES PANEL_LIBRARIES) endif() endif() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)
https://github.com/ajordanr-google updated https://github.com/llvm/llvm-project/pull/126810 >From ddd3febff5b77cc7b2101996d49729added00f2b Mon Sep 17 00:00:00 2001 From: Jordan R Abrahams-Whitehead Date: Tue, 1 Oct 2024 18:41:28 + Subject: [PATCH] [lldb] Add terminfo dependency for ncurses support For some operating systems (e.g. chromiumos), terminfo is a separate package and library from ncurses. Both are still requirements for curses support in lldb, individually. This is a rebase of this original spack commit: https://github.com/spack/spack/commit/9ea261265010eacd250691a8361f661d0576f25c Without this fix, LLDB cannot be built on these systems. Fixes #101368 --- lldb/cmake/modules/FindCursesAndPanel.cmake | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake index aaadf214bf54b..df4980cc5e0d1 100644 --- a/lldb/cmake/modules/FindCursesAndPanel.cmake +++ b/lldb/cmake/modules/FindCursesAndPanel.cmake @@ -2,12 +2,15 @@ # FindCursesAndPanel # --- # -# Find the curses and panel library as a whole. +# Find the curses, terminfo, and panel library as a whole. +# NOTE: terminfo and curses libraries are required separately, as +# some systems do not bundle them together. -if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES) +if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES) set(CURSESANDPANEL_FOUND TRUE) else() find_package(Curses QUIET) + find_package(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET) find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CursesAndPanel @@ -16,9 +19,10 @@ else() REQUIRED_VARS CURSES_INCLUDE_DIRS CURSES_LIBRARIES + TINFO_LIBRARIES PANEL_LIBRARIES) - if(CURSES_FOUND AND PANEL_LIBRARIES) -mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES) + if(CURSES_FOUND AND TINFO_LIBRARIES AND PANEL_LIBRARIES) +mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES TINFO_LIBRARIES PANEL_LIBRARIES) endif() endif() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)
https://github.com/ajordanr-google edited https://github.com/llvm/llvm-project/pull/126810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)
https://github.com/ajordanr-google edited https://github.com/llvm/llvm-project/pull/126810 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/121273 >From 16107a423e30cc339b7529db35a75c3c26924146 Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava Date: Sat, 28 Dec 2024 13:19:21 -0600 Subject: [PATCH 1/5] Introducing PlatformAIX from PlatformLinux --- .../Plugins/Platform/AIX/CMakeLists.txt | 13 + .../Plugins/Platform/AIX/PlatformAIX.cpp | 471 ++ .../source/Plugins/Platform/AIX/PlatformAIX.h | 74 +++ lldb/source/Plugins/Platform/CMakeLists.txt | 1 + 4 files changed, 559 insertions(+) create mode 100644 lldb/source/Plugins/Platform/AIX/CMakeLists.txt create mode 100644 lldb/source/Plugins/Platform/AIX/PlatformAIX.cpp create mode 100644 lldb/source/Plugins/Platform/AIX/PlatformAIX.h diff --git a/lldb/source/Plugins/Platform/AIX/CMakeLists.txt b/lldb/source/Plugins/Platform/AIX/CMakeLists.txt new file mode 100644 index 000..85ff0a315eabd54 --- /dev/null +++ b/lldb/source/Plugins/Platform/AIX/CMakeLists.txt @@ -0,0 +1,13 @@ +add_definitions("-D_ALL_SOURCE") + +add_lldb_library(lldbPluginPlatformAIX PLUGIN + PlatformAIX.cpp + + LINK_LIBS +lldbBreakpoint +lldbCore +lldbHost +lldbInterpreter +lldbTarget +lldbPluginPlatformPOSIX + ) diff --git a/lldb/source/Plugins/Platform/AIX/PlatformAIX.cpp b/lldb/source/Plugins/Platform/AIX/PlatformAIX.cpp new file mode 100644 index 000..5c9447700297891 --- /dev/null +++ b/lldb/source/Plugins/Platform/AIX/PlatformAIX.cpp @@ -0,0 +1,471 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" + +#include +#if LLDB_ENABLE_POSIX +#include +#endif + +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Define these constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#if defined(_AIX) +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = CreateArchList( +{llvm::Triple::x86_64, llvm
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,370 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +uint32_t +PlatformAIX::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) { + uint32_t resume_count = 0; + + // Always resume past the initial stop when we use eLaunchFlagDebug + if (launch_info.GetFlags().Test(eLaunchFlagDebug)) { +// Resume past the stop for the final exec into the true inferior. +++resume_count; + } + + // If we're not launching a shell, we're done. + const FileSpec &shell = launch_info.GetShell(); + if (!shell) +return resume_count; + + std::string shell_string = shell.GetPath(); + // We're in a shell, so for sure we have to resume past the shell exec. + ++resume_count; + + // Figure out what shell we're planning on using. + const char *shell_name
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,193 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#else // For remotely cross debugging aix +#define MAP_VARIABLE 0x0 +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x10 +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +bool PlatformAIX::CanDebugProcess() { return IsHost() ? true : IsConnected(); } + +void PlatformAIX::CalculateTrapHandlerSymbolNames() {} + +lldb::UnwindPlanSP +PlatformAIX::GetTrapHandlerUnwindPlan(const llvm::Triple &triple, + ConstString name) { + return {}; +} + +MmapArgList PlatformAIX::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, + addr_t length, unsigned prot, + unsigned flags, addr_t fd, + addr_t
[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)
@@ -0,0 +1,308 @@ +//===-- DILParser.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// This implements the recursive descent parser for the Data Inspection +// Language (DIL), and its helper functions, which will eventually underlie the +// 'frame variable' command. The language that this parser recognizes is +// described in lldb/docs/dil-expr-lang.ebnf +// +//===--===// + +#include "lldb/ValueObject/DILParser.h" +#include "lldb/Target/ExecutionContextScope.h" +#include "lldb/ValueObject/DILAST.h" +#include "lldb/ValueObject/DILEval.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatAdapters.h" +#include +#include +#include +#include +#include + +namespace lldb_private::dil { + +inline void TokenKindsJoinImpl(std::ostringstream &os, Token::Kind k) { + os << "'" << Token::GetTokenName(k).str() << "'"; +} + +template +inline void TokenKindsJoinImpl(std::ostringstream &os, Token::Kind k, + Ts... ks) { + TokenKindsJoinImpl(os, k); + os << ", "; + TokenKindsJoinImpl(os, ks...); +} + +template +inline std::string TokenKindsJoin(Token::Kind k, Ts... ks) { + std::ostringstream os; + TokenKindsJoinImpl(os, k, ks...); + + return os.str(); +} + +std::string FormatDiagnostics(llvm::StringRef text, const std::string &message, + uint32_t loc) { + // Get the source buffer and the location of the current token. + size_t loc_offset = (size_t)loc; + + // Look for the start of the line. + size_t line_start = text.rfind('\n', loc_offset); + line_start = line_start == llvm::StringRef::npos ? 0 : line_start + 1; + + // Look for the end of the line. + size_t line_end = text.find('\n', loc_offset); + line_end = line_end == llvm::StringRef::npos ? text.size() : line_end; + + // Get a view of the current line in the source code and the position of the + // diagnostics pointer. + llvm::StringRef line = text.slice(line_start, line_end); + int32_t arrow = loc + 1; // Column offset starts at 1, not 0. + + // Calculate the padding in case we point outside of the expression (this can + // happen if the parser expected something, but got EOF).˚ + size_t expr_rpad = std::max(0, arrow - static_cast(line.size())); + size_t arrow_rpad = std::max(0, static_cast(line.size()) - arrow); + + return llvm::formatv(": {1}\n{2}\n{3}", loc, message, + llvm::fmt_pad(line, 0, expr_rpad), + llvm::fmt_pad("^", arrow - 1, arrow_rpad)); +} + +DILParser::DILParser(llvm::StringRef dil_input_expr, DILLexer lexer, + std::shared_ptr exe_ctx_scope, + lldb::DynamicValueType use_dynamic, bool use_synthetic, + bool fragile_ivar, bool check_ptr_vs_member) +: m_ctx_scope(exe_ctx_scope), m_input_expr(dil_input_expr), + m_dil_lexer(lexer), m_dil_token(lexer.GetCurrentToken()), + m_use_dynamic(use_dynamic), m_use_synthetic(use_synthetic), + m_fragile_ivar(fragile_ivar), m_check_ptr_vs_member(check_ptr_vs_member) { +} + +llvm::Expected DILParser::Run() { + DILASTNodeUP expr; + + expr = ParseExpression(); + + Expect(Token::Kind::eof); + + if (m_error.Fail()) +return m_error.ToError(); + + return expr; +} + +// Parse an expression. +// +// expression: +//primary_expression +// +DILASTNodeUP DILParser::ParseExpression() { return ParsePrimaryExpression(); } + +// Parse a primary_expression. +// +// primary_expression: +//id_expression +//"this" +//"(" expression ")" +// +DILASTNodeUP DILParser::ParsePrimaryExpression() { + if (m_dil_token.IsOneOf(Token::coloncolon, Token::identifier)) { +// Save the source location for the diagnostics message. +uint32_t loc = m_dil_token.GetLocation(); +auto identifier = ParseIdExpression(); + +return std::make_unique(loc, identifier, m_use_dynamic, +m_ctx_scope); + } else if (m_dil_token.Is(Token::l_paren)) { +ConsumeToken(); +auto expr = ParseExpression(); +Expect(Token::r_paren); +ConsumeToken(); +return expr; + } + + BailOut(ErrorCode::kInvalidExpressionSyntax, + llvm::formatv("Unexpected token: {0}", TokenDescription(m_dil_token)), + m_dil_token.GetLocation()); + return std::make_unique(); +} + +// Parse nested_name_specifier. +// +// nested_name_specifier: +//type_name "::" +//namespace_name "::" +//nested_name_specifier identifier "::" +// +std::string DILParser::ParseNestedNameSpecifier() { + // The first token in nested_name_specifier is always an identifier, or + // '(anonymous namespace)'. + if (m_dil_token.IsNot(Token::identifier) && + m_dil_toke
[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/120971 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
@@ -3108,13 +3108,11 @@ void CommandInterpreter::PrintCommandOutput(IOHandler &io_handler, llvm::StringRef line; std::tie(line, str) = str.split('\n'); { - std::lock_guard guard(io_handler.GetOutputMutex()); labath wrote: This is an example of an operation that used to be atomic, but now isn't. https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
@@ -52,6 +52,39 @@ class StreamFile : public Stream { const StreamFile &operator=(const StreamFile &) = delete; }; +class SynchronizedStreamFile : public StreamFile { +public: + SynchronizedStreamFile(uint32_t flags, uint32_t addr_size, + lldb::ByteOrder byte_order) + : StreamFile(flags, addr_size, byte_order) {} + + SynchronizedStreamFile(int fd, bool transfer_ownership) + : StreamFile(fd, transfer_ownership) {} + + SynchronizedStreamFile( + const char *path, File::OpenOptions options, + uint32_t permissions = lldb::eFilePermissionsFileDefault) + : StreamFile(path, options, permissions) {} + + SynchronizedStreamFile(FILE *fh, bool transfer_ownership) + : StreamFile(fh, transfer_ownership) {} + + SynchronizedStreamFile(std::shared_ptr file) : StreamFile(file) {} + + ~SynchronizedStreamFile() override; + labath wrote: I wouldn't bother declaring that. ```suggestion ``` https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
@@ -46,9 +46,16 @@ StreamFile::StreamFile(const char *path, File::OpenOptions options, StreamFile::~StreamFile() = default; +SynchronizedStreamFile::~SynchronizedStreamFile() = default; + void StreamFile::Flush() { m_file_sp->Flush(); } labath wrote: I'm pretty sure flushing also needs to be protected. https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
https://github.com/labath commented: So, the problem I see here is that this is enforcing mutual exclusion at the level of most basic write operations. That's fine if what you want to achieve is to protect the internal state of the stream object. However, I'm not sure if that's your goal, since it doesn't e.g. prevent someone from printing something in the middle of a statusline update. It also may be unnecessary since I believe that both file descriptors and FILE* objects are synchronized internally (one by the OS, the other by the C library). To achieve proper output synchronization, the exclusion needs to happen at a higher level (e.g. "a single statusline update", or "writing of one line of text", etc.). In theory, that can be done using the provided `GetMutex` accessor, but it's also very easy to forget doing that. To better guarantee that, I am wondering if a slightly different pattern wouldn't be better. We could have one object (let's call it LockableStream here, just so it differs from what you have in this PR), which holds the real stream (and a mutex) as a *member*, and doesn't allow you to access it without locking it. Then, when you want write something, you call a `Lock` function or something (it could also be constructing a guard object and passing the LockableStream to its constructor), and this returns something that allows you to access the underlying stream. As long as you hold on to the returned object (which contains a lock_guard on the stream mutex internally), you are permitted to write to the stream. The destruction of the object can automatically flush the output stream. WDYT? https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
@@ -52,6 +52,39 @@ class StreamFile : public Stream { const StreamFile &operator=(const StreamFile &) = delete; }; +class SynchronizedStreamFile : public StreamFile { +public: + SynchronizedStreamFile(uint32_t flags, uint32_t addr_size, + lldb::ByteOrder byte_order) + : StreamFile(flags, addr_size, byte_order) {} + + SynchronizedStreamFile(int fd, bool transfer_ownership) + : StreamFile(fd, transfer_ownership) {} + + SynchronizedStreamFile( + const char *path, File::OpenOptions options, + uint32_t permissions = lldb::eFilePermissionsFileDefault) + : StreamFile(path, options, permissions) {} + + SynchronizedStreamFile(FILE *fh, bool transfer_ownership) + : StreamFile(fh, transfer_ownership) {} + + SynchronizedStreamFile(std::shared_ptr file) : StreamFile(file) {} labath wrote: ```suggestion using StreamFile::StreamFile; ``` https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize Debugger's stdout and stderr at the StreamFile level (PR #126630)
JDevlieghere wrote: > it doesn't e.g. prevent someone from printing something in the middle of a > statusline update. Technically it does, because the statusline is printed as a single call to write, but I agree that's fragile and one could argue that works by accident rather than by design. I really like the idea of introducing an RAII object as it (1) makes the locking more explicit and (2) makes it easy to do the right thing and hard to do the wrong thing. https://github.com/llvm/llvm-project/pull/126630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 918848d - [lldb] Devirtualize GetValueProperties (NFC) (#126583)
Author: Jonas Devlieghere Date: 2025-02-11T09:51:18-08:00 New Revision: 918848d03bb9d0e06dea2ef588bda17ff961923c URL: https://github.com/llvm/llvm-project/commit/918848d03bb9d0e06dea2ef588bda17ff961923c DIFF: https://github.com/llvm/llvm-project/commit/918848d03bb9d0e06dea2ef588bda17ff961923c.diff LOG: [lldb] Devirtualize GetValueProperties (NFC) (#126583) Nobody is overriding GetValueProperties, so in practice we're always using `m_collection_sp`, which means we don't need to check the pointer. The temlated helpers were already operating on `m_collection_sp` directly so this makes the rest of the class consistent. Added: Modified: lldb/include/lldb/Core/UserSettingsController.h lldb/source/Core/UserSettingsController.cpp Removed: diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index 32da7e05f7040f7..29e892fdba45bf3 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -38,9 +38,7 @@ class Properties { virtual ~Properties(); - virtual lldb::OptionValuePropertiesSP GetValueProperties() const { -// This function is virtual in case subclasses want to lazily implement -// creating the properties. + lldb::OptionValuePropertiesSP GetValueProperties() const { return m_collection_sp; } diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index b57c1b0eef9b472..5408d64b406471f 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -40,64 +40,45 @@ Properties::~Properties() = default; lldb::OptionValueSP Properties::GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef path, Status &error) const { - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (properties_sp) -return properties_sp->GetSubValue(exe_ctx, path, error); - return lldb::OptionValueSP(); + return m_collection_sp->GetSubValue(exe_ctx, path, error); } Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) { - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (properties_sp) -return properties_sp->SetSubValue(exe_ctx, op, path, value); - return Status::FromErrorString("no properties"); + return m_collection_sp->SetSubValue(exe_ctx, op, path, value); } void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask, bool is_json) { - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (!properties_sp) -return; - if (is_json) { -llvm::json::Value json = properties_sp->ToJSON(exe_ctx); +llvm::json::Value json = m_collection_sp->ToJSON(exe_ctx); strm.Printf("%s", llvm::formatv("{0:2}", json).str().c_str()); } else -properties_sp->DumpValue(exe_ctx, strm, dump_mask); +m_collection_sp->DumpValue(exe_ctx, strm, dump_mask); } void Properties::DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const { strm.PutCString("Top level variables:\n\n"); - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (properties_sp) -return properties_sp->DumpAllDescriptions(interpreter, strm); + return m_collection_sp->DumpAllDescriptions(interpreter, strm); } Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json) { - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (properties_sp) { -return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path, + return m_collection_sp->DumpPropertyValue(exe_ctx, strm, property_path, dump_mask, is_json); - } - return Status::FromErrorString("empty property list"); } size_t Properties::Apropos(llvm::StringRef keyword, std::vector &matching_properties) const { - OptionValuePropertiesSP properties_sp(GetValueProperties()); - if (properties_sp) { -properties_sp->Apropos(keyword, matching_properties); - } + m_collection_sp->Apropos(keyword, matching_properties); return matching_properties.size(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126588 >From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Mon, 10 Feb 2025 14:44:11 -0500 Subject: [PATCH 1/3] Define TelemetryVendor plugin. Details: Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance. --- lldb/include/lldb/Core/TelemetryVendor.h | 39 + lldb/source/Core/TelemetryVendor.cpp | 43 2 files changed, 82 insertions(+) create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h create mode 100644 lldb/source/Core/TelemetryVendor.cpp diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h new file mode 100644 index 0..a2ab3b69fde42 --- /dev/null +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -0,0 +1,39 @@ +//===-- TelemetryVendor.h -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRYVENDOR_H +#define LLDB_CORE_TELEMETRYVENDOR_H + +#include "lldb/Core/PluginInterface.h" +#include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" + +#include + +namespace lldb_private { + +class TelemetryVendor : public PluginInterface { +public: + TelemetryVendor() = default; + + llvm::StringRef GetPluginName() override; + + static void Initialize(); + + static void Terminate(); + + static std::unique_ptr GetTelemetryConfig(); + static void + SetTelemetryConfig(std::unique_ptr config); + + static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); +}; + +} // namespace lldb_private +#endif // LLDB_CORE_TELEMETRYVENDOR_H diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp new file mode 100644 index 0..520a01b9b1c7a --- /dev/null +++ b/lldb/source/Core/TelemetryVendor.cpp @@ -0,0 +1,43 @@ +//===-- TelemetryVendor.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/TelemetryVendor.h" + +namespace lldb_private { + +llvm::StringRef TelemetryVendor::GetPluginName() { + return "UpstreamTelemetryVendor"; +} + +void TelemetryVendor::Initialize() { + // The default (upstream) impl will have telemetry disabled by default. + SetTelemetryConfig( + std::make_unique(/*enable_telemetry*/ false)); + SetTelemetryManager(nullptr); +} + +static std::unique_ptr current_config; +std::unique_ptr TelemetryVendor::GetTelemetryConfig() { + return current_config; +} + +void TelemetryVendor::SetTelemetryConfig( +std::unique_ptr config) { + current_config = std::move(config); +} + +lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() { + static TelemteryManagerSP g_telemetry_manager_sp; + return g_telemetry_manager_sp; +} + +void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) { + GetTelemetryManager() = manager_sp; +} + +} // namespace lldb_private >From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:31:00 -0500 Subject: [PATCH 2/3] use shared ptr --- lldb/include/lldb/Core/TelemetryVendor.h | 7 --- lldb/include/lldb/lldb-forward.h | 5 + lldb/source/Core/TelemetryVendor.cpp | 14 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h index a2ab3b69fde42..a55f06fb9141f 100644 --- a/lldb/include/lldb/Core/TelemetryVendor.h +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface { static void Terminate(); - static std::unique_ptr GetTelemetryConfig(); - static void - SetTelemetryConfig(std::unique_ptr config); + static lldb::TelemetryConfig GetTelemetryConfig(); + + static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config); static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fc7456a4b9a32..2f2a4ec86a1fb 100644 --- a/lldb/include/lldb/lldb
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126588 >From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Mon, 10 Feb 2025 14:44:11 -0500 Subject: [PATCH 1/3] Define TelemetryVendor plugin. Details: Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance. --- lldb/include/lldb/Core/TelemetryVendor.h | 39 + lldb/source/Core/TelemetryVendor.cpp | 43 2 files changed, 82 insertions(+) create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h create mode 100644 lldb/source/Core/TelemetryVendor.cpp diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h new file mode 100644 index 0..a2ab3b69fde42 --- /dev/null +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -0,0 +1,39 @@ +//===-- TelemetryVendor.h -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRYVENDOR_H +#define LLDB_CORE_TELEMETRYVENDOR_H + +#include "lldb/Core/PluginInterface.h" +#include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" + +#include + +namespace lldb_private { + +class TelemetryVendor : public PluginInterface { +public: + TelemetryVendor() = default; + + llvm::StringRef GetPluginName() override; + + static void Initialize(); + + static void Terminate(); + + static std::unique_ptr GetTelemetryConfig(); + static void + SetTelemetryConfig(std::unique_ptr config); + + static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); +}; + +} // namespace lldb_private +#endif // LLDB_CORE_TELEMETRYVENDOR_H diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp new file mode 100644 index 0..520a01b9b1c7a --- /dev/null +++ b/lldb/source/Core/TelemetryVendor.cpp @@ -0,0 +1,43 @@ +//===-- TelemetryVendor.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/TelemetryVendor.h" + +namespace lldb_private { + +llvm::StringRef TelemetryVendor::GetPluginName() { + return "UpstreamTelemetryVendor"; +} + +void TelemetryVendor::Initialize() { + // The default (upstream) impl will have telemetry disabled by default. + SetTelemetryConfig( + std::make_unique(/*enable_telemetry*/ false)); + SetTelemetryManager(nullptr); +} + +static std::unique_ptr current_config; +std::unique_ptr TelemetryVendor::GetTelemetryConfig() { + return current_config; +} + +void TelemetryVendor::SetTelemetryConfig( +std::unique_ptr config) { + current_config = std::move(config); +} + +lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() { + static TelemteryManagerSP g_telemetry_manager_sp; + return g_telemetry_manager_sp; +} + +void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) { + GetTelemetryManager() = manager_sp; +} + +} // namespace lldb_private >From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:31:00 -0500 Subject: [PATCH 2/3] use shared ptr --- lldb/include/lldb/Core/TelemetryVendor.h | 7 --- lldb/include/lldb/lldb-forward.h | 5 + lldb/source/Core/TelemetryVendor.cpp | 14 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h index a2ab3b69fde42..a55f06fb9141f 100644 --- a/lldb/include/lldb/Core/TelemetryVendor.h +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface { static void Terminate(); - static std::unique_ptr GetTelemetryConfig(); - static void - SetTelemetryConfig(std::unique_ptr config); + static lldb::TelemetryConfig GetTelemetryConfig(); + + static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config); static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fc7456a4b9a32..2f2a4ec86a1fb 100644 --- a/lldb/include/lldb/lldb
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
@@ -320,25 +320,37 @@ void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp, } } -void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) { - line_no = 0; - source_file.Clear(); - - // The -1 is kind of cheesy, but I want to get the last line entry for the - // given function, not the first entry of the next. - Address scratch_addr(GetAddressRange().GetBaseAddress()); - scratch_addr.SetOffset(scratch_addr.GetOffset() + - GetAddressRange().GetByteSize() - 1); - +llvm::Expected> +Function::GetSourceInfo() { + SupportFileSP source_file_sp; + uint32_t start_line; + GetStartLineSourceInfo(source_file_sp, start_line); LineTable *line_table = m_comp_unit->GetLineTable(); - if (line_table == nullptr) -return; + if (start_line == 0 || !line_table) { labath wrote: That is (and was) the assumption, but that definitely isn't guaranteed. The reason this works most of the time is because the `GetStartLineSourceInfo` will preferentially pick the line number out of the debug info section (DW_AT_decl_file), so the line table will only be consulted if that is missing (which probably only happens in this test case). That is one of the corner cases I did not want to go into in this patch, though I can if you think I should. https://github.com/llvm/llvm-project/pull/126526 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
labath wrote: > "command source" is another lldb command which this PR is not about... This > is about "source list" and/or "source info". Not important but the title was > pretty confusing... Yeah, sorry. I myself got confused because I was looking at another test case in this directory with a confusing name. I've fixed the title. https://github.com/llvm/llvm-project/pull/126526 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support disassembling discontinuous functions (PR #126505)
@@ -262,9 +269,11 @@ CommandObjectDisassemble::GetContainingAddressRanges() { addr, eSymbolContextEverything, sc, resolve_tail_call_address); if (sc.function || sc.symbol) { AddressRange range; - sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, - false, range); - ranges.push_back(range); + for (uint32_t idx = 0; + sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, + idx, false, range); + ++idx) +ranges.push_back(range); } labath wrote: Ah, I see. Sounds good. https://github.com/llvm/llvm-project/pull/126505 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/126526 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/126526 >From fda9035cddce78e2109462c9cec176bcb96392d8 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 10 Feb 2025 15:20:05 +0100 Subject: [PATCH 1/2] [lldb] Fixing edge cases in "command source" While looking at how to make Function::GetEndLineSourceInfo (which is only used in "command source") work with discontinuous functions, I realized there are other corner cases that this function doesn't handle. The code assumed that the last line entry in the function will also correspond to the last source line. This is probably true for unoptimized code, but I don't think we can rely on the optimizer to preserve this property. What's worse, the code didn't check that the last line entry belonged to the same file as the first one, so if this line entry was the result of inlining, we could end up using a line from a completely different file. To fix this, I change the algorithm to iterate over all line entries in the function (which belong to the same file) and find the max line number out of those. This way we can naturally handle the discontinuous case as well. This implementations is going to be slower than the previous one, but I don't think that matters, because: - this command is only used rarely, and interactively - we have plenty of other code which iterates through the line table I added some basic tests for the function operation. I don't claim the tests to be comprehensive, or that the function handles all edge cases, but test framework created here could be used for testing other fixes/edge cases as well. --- lldb/include/lldb/Symbol/Function.h | 15 +- lldb/source/Commands/CommandObjectSource.cpp | 14 +- lldb/source/Symbol/Function.cpp | 44 +-- .../test/Shell/Commands/command-source-list.s | 265 ++ 4 files changed, 304 insertions(+), 34 deletions(-) create mode 100644 lldb/test/Shell/Commands/command-source-list.s diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index f3b956139f3c5b..ee3a8304fc5b37 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -15,6 +15,7 @@ #include "lldb/Expression/DWARFExpressionList.h" #include "lldb/Symbol/Block.h" #include "lldb/Utility/UserID.h" +#include "lldb/lldb-forward.h" #include "llvm/ADT/ArrayRef.h" #include @@ -460,6 +461,7 @@ class Function : public UserID, public SymbolContextScope { } lldb::LanguageType GetLanguage() const; + /// Find the file and line number of the source location of the start of the /// function. This will use the declaration if present and fall back on the /// line table if that fails. So there may NOT be a line table entry for @@ -473,16 +475,9 @@ class Function : public UserID, public SymbolContextScope { void GetStartLineSourceInfo(lldb::SupportFileSP &source_file_sp, uint32_t &line_no); - /// Find the file and line number of the source location of the end of the - /// function. - /// - /// - /// \param[out] source_file - /// The source file. - /// - /// \param[out] line_no - /// The line number. - void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no); + using SourceRange = Range; + /// Find the file and line number range of the function. + llvm::Expected> GetSourceInfo(); /// Get the outgoing call edges from this function, sorted by their return /// PC addresses (in increasing order). diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 936783216f6ff5..81bf1769808bad 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -784,14 +784,12 @@ class CommandObjectSourceList : public CommandObjectParsed { if (sc.block == nullptr) { // Not an inlined function -sc.function->GetStartLineSourceInfo(start_file, start_line); -if (start_line == 0) { - result.AppendErrorWithFormat("Could not find line information for " - "start of function: \"%s\".\n", - source_info.function.GetCString()); - return 0; -} -sc.function->GetEndLineSourceInfo(end_file, end_line); +auto expected_info = sc.function->GetSourceInfo(); +if (!expected_info) + result.AppendError(llvm::toString(expected_info.takeError())); +start_file = expected_info->first; +start_line = expected_info->second.GetRangeBase(); +end_line = expected_info->second.GetRangeEnd(); } else { // We have an inlined function start_file = source_info.line_entry.file_sp; diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 11a43a9172ea67..9fbda97b7cc483 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Funct
[Lldb-commits] [lldb] [lldb] Support disassembling discontinuous functions (PR #126505)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/126505 >From a716420ee79ea03cd64cf79f1e1f727b86960995 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 9 Jan 2025 13:02:24 +0100 Subject: [PATCH 1/2] [lldb] Support disassembling discontinuous functions The command already supported disassembling multiple ranges, among other reasons because inline functions can be discontinuous. The main thing that was missing was being able to retrieve the function ranges from the top level function object. The output of the command for the case where the function entry point is not its lowest address is somewhat confusing (we're showing negative offsets), but it is correct. --- .../Commands/CommandObjectDisassemble.cpp | 88 +++--- .../Commands/CommandObjectDisassemble.h | 3 +- lldb/source/Symbol/SymbolContext.cpp | 4 +- .../test/Shell/Commands/command-disassemble.s | 112 -- 4 files changed, 154 insertions(+), 53 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 5b131fe86dedb..f66c67577c0be 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include static constexpr unsigned default_disasm_byte_size = 32; static constexpr unsigned default_disasm_num_ins = 4; @@ -236,19 +237,25 @@ CommandObjectDisassemble::CommandObjectDisassemble( CommandObjectDisassemble::~CommandObjectDisassemble() = default; -llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range, - llvm::StringRef what) { +llvm::Expected> +CommandObjectDisassemble::CheckRangeSize(std::vector ranges, + llvm::StringRef what) { + addr_t total_range_size = 0; + for (const AddressRange &r : ranges) +total_range_size += r.GetByteSize(); + if (m_options.num_instructions > 0 || m_options.force || - range.GetByteSize() < GetDebugger().GetStopDisassemblyMaxSize()) -return llvm::Error::success(); + total_range_size < GetDebugger().GetStopDisassemblyMaxSize()) +return ranges; + StreamString msg; msg << "Not disassembling " << what << " because it is very large "; - range.Dump(&msg, &GetTarget(), Address::DumpStyleLoadAddress, - Address::DumpStyleFileAddress); + for (const AddressRange &r : ranges) +r.Dump(&msg, &GetTarget(), Address::DumpStyleLoadAddress, + Address::DumpStyleFileAddress); msg << ". To disassemble specify an instruction count limit, start/stop " "addresses or use the --force option."; - return llvm::createStringError(llvm::inconvertibleErrorCode(), - msg.GetString()); + return llvm::createStringError(msg.GetString()); } llvm::Expected> @@ -262,9 +269,11 @@ CommandObjectDisassemble::GetContainingAddressRanges() { addr, eSymbolContextEverything, sc, resolve_tail_call_address); if (sc.function || sc.symbol) { AddressRange range; - sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, - false, range); - ranges.push_back(range); + for (uint32_t idx = 0; + sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, + idx, false, range); + ++idx) +ranges.push_back(range); } }; @@ -292,9 +301,7 @@ CommandObjectDisassemble::GetContainingAddressRanges() { m_options.symbol_containing_addr); } - if (llvm::Error err = CheckRangeSize(ranges[0], "the function")) -return std::move(err); - return ranges; + return CheckRangeSize(std::move(ranges), "the function"); } llvm::Expected> @@ -304,29 +311,24 @@ CommandObjectDisassemble::GetCurrentFunctionRanges() { if (!frame) { if (process) { return llvm::createStringError( - llvm::inconvertibleErrorCode(), - "Cannot disassemble around the current " - "function without the process being stopped.\n"); -} else { - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Cannot disassemble around the current " - "function without a selected frame: " - "no currently running process.\n"); + "Cannot disassemble around the current function without the process " + "being stopped.\n"); } +return llvm::createStringError( +"Cannot disassemble around the current function without a selected " +"frame: no currently running process.\n"); } - SymbolContext sc( - frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); - AddressRange range; + SymbolCo
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126588 >From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Mon, 10 Feb 2025 14:44:11 -0500 Subject: [PATCH 1/2] Define TelemetryVendor plugin. Details: Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance. --- lldb/include/lldb/Core/TelemetryVendor.h | 39 + lldb/source/Core/TelemetryVendor.cpp | 43 2 files changed, 82 insertions(+) create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h create mode 100644 lldb/source/Core/TelemetryVendor.cpp diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h new file mode 100644 index 00..a2ab3b69fde422 --- /dev/null +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -0,0 +1,39 @@ +//===-- TelemetryVendor.h -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRYVENDOR_H +#define LLDB_CORE_TELEMETRYVENDOR_H + +#include "lldb/Core/PluginInterface.h" +#include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" + +#include + +namespace lldb_private { + +class TelemetryVendor : public PluginInterface { +public: + TelemetryVendor() = default; + + llvm::StringRef GetPluginName() override; + + static void Initialize(); + + static void Terminate(); + + static std::unique_ptr GetTelemetryConfig(); + static void + SetTelemetryConfig(std::unique_ptr config); + + static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); +}; + +} // namespace lldb_private +#endif // LLDB_CORE_TELEMETRYVENDOR_H diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp new file mode 100644 index 00..520a01b9b1c7a3 --- /dev/null +++ b/lldb/source/Core/TelemetryVendor.cpp @@ -0,0 +1,43 @@ +//===-- TelemetryVendor.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/TelemetryVendor.h" + +namespace lldb_private { + +llvm::StringRef TelemetryVendor::GetPluginName() { + return "UpstreamTelemetryVendor"; +} + +void TelemetryVendor::Initialize() { + // The default (upstream) impl will have telemetry disabled by default. + SetTelemetryConfig( + std::make_unique(/*enable_telemetry*/ false)); + SetTelemetryManager(nullptr); +} + +static std::unique_ptr current_config; +std::unique_ptr TelemetryVendor::GetTelemetryConfig() { + return current_config; +} + +void TelemetryVendor::SetTelemetryConfig( +std::unique_ptr config) { + current_config = std::move(config); +} + +lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() { + static TelemteryManagerSP g_telemetry_manager_sp; + return g_telemetry_manager_sp; +} + +void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) { + GetTelemetryManager() = manager_sp; +} + +} // namespace lldb_private >From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:31:00 -0500 Subject: [PATCH 2/2] use shared ptr --- lldb/include/lldb/Core/TelemetryVendor.h | 7 --- lldb/include/lldb/lldb-forward.h | 5 + lldb/source/Core/TelemetryVendor.cpp | 14 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h index a2ab3b69fde422..a55f06fb9141f0 100644 --- a/lldb/include/lldb/Core/TelemetryVendor.h +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface { static void Terminate(); - static std::unique_ptr GetTelemetryConfig(); - static void - SetTelemetryConfig(std::unique_ptr config); + static lldb::TelemetryConfig GetTelemetryConfig(); + + static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config); static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fc7456a4b9a32e..2f2a4ec86a1fb8 100644 --- a/lldb/include/l
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126746 >From 008537373cd928fea9ac04b1aed39c2ecafec65a Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:36:06 -0500 Subject: [PATCH 1/3] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (by users of Telemetry) --- llvm/lib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index d0a2bc9294381..08e3d7ddb8c12 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,6 +43,7 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) + add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) >From f2a3822291d7153359286bd5efc4c080c21adedd Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 11:22:36 -0500 Subject: [PATCH 2/3] add macro def in llvm-config.h --- llvm/include/llvm/Config/llvm-config.h.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 629977cc11d68..239f9dd3f38db 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -201,4 +201,7 @@ /* Define if logf128 is available */ #cmakedefine LLVM_HAS_LOGF128 +/* Define if building LLVM with LLVM_BUILD_TELEMETRY */ +#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY} + #endif >From 1bec761f06f79fac21a063a1e5c222e274dd3ddb Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 13:07:12 -0500 Subject: [PATCH 3/3] remove macro from lldb/soruce/Core/CMakeLists.txt --- lldb/source/Core/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index cf5f6ac9da489..82fb5f42f9f4b 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -18,7 +18,6 @@ endif() if (LLVM_BUILD_TELEMETRY) set(TELEMETRY_DEPS Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Devirtualize GetValueProperties (NFC) (PR #126583)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/126583 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126588 >From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Mon, 10 Feb 2025 14:44:11 -0500 Subject: [PATCH 1/5] Define TelemetryVendor plugin. Details: Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance. --- lldb/include/lldb/Core/TelemetryVendor.h | 39 + lldb/source/Core/TelemetryVendor.cpp | 43 2 files changed, 82 insertions(+) create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h create mode 100644 lldb/source/Core/TelemetryVendor.cpp diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h new file mode 100644 index 000..a2ab3b69fde4225 --- /dev/null +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -0,0 +1,39 @@ +//===-- TelemetryVendor.h -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_CORE_TELEMETRYVENDOR_H +#define LLDB_CORE_TELEMETRYVENDOR_H + +#include "lldb/Core/PluginInterface.h" +#include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" + +#include + +namespace lldb_private { + +class TelemetryVendor : public PluginInterface { +public: + TelemetryVendor() = default; + + llvm::StringRef GetPluginName() override; + + static void Initialize(); + + static void Terminate(); + + static std::unique_ptr GetTelemetryConfig(); + static void + SetTelemetryConfig(std::unique_ptr config); + + static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); +}; + +} // namespace lldb_private +#endif // LLDB_CORE_TELEMETRYVENDOR_H diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp new file mode 100644 index 000..520a01b9b1c7a3e --- /dev/null +++ b/lldb/source/Core/TelemetryVendor.cpp @@ -0,0 +1,43 @@ +//===-- TelemetryVendor.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/TelemetryVendor.h" + +namespace lldb_private { + +llvm::StringRef TelemetryVendor::GetPluginName() { + return "UpstreamTelemetryVendor"; +} + +void TelemetryVendor::Initialize() { + // The default (upstream) impl will have telemetry disabled by default. + SetTelemetryConfig( + std::make_unique(/*enable_telemetry*/ false)); + SetTelemetryManager(nullptr); +} + +static std::unique_ptr current_config; +std::unique_ptr TelemetryVendor::GetTelemetryConfig() { + return current_config; +} + +void TelemetryVendor::SetTelemetryConfig( +std::unique_ptr config) { + current_config = std::move(config); +} + +lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() { + static TelemteryManagerSP g_telemetry_manager_sp; + return g_telemetry_manager_sp; +} + +void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) { + GetTelemetryManager() = manager_sp; +} + +} // namespace lldb_private >From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:31:00 -0500 Subject: [PATCH 2/5] use shared ptr --- lldb/include/lldb/Core/TelemetryVendor.h | 7 --- lldb/include/lldb/lldb-forward.h | 5 + lldb/source/Core/TelemetryVendor.cpp | 14 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h index a2ab3b69fde4225..a55f06fb9141f06 100644 --- a/lldb/include/lldb/Core/TelemetryVendor.h +++ b/lldb/include/lldb/Core/TelemetryVendor.h @@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface { static void Terminate(); - static std::unique_ptr GetTelemetryConfig(); - static void - SetTelemetryConfig(std::unique_ptr config); + static lldb::TelemetryConfig GetTelemetryConfig(); + + static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config); static lldb::TelemetryManagerSP GetTelemetryManager(); + static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index fc7456a4b9a32e6..2f2a4ec86a1fb89 100644 --- a/lldb/i
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Vy Nguyen (oontvoo) Changes Background: Telemetry code isn't always built (controlled by this LLVM_BUILD_TELEMETRY cmake flag) This means users of the library may not have the library. So we're definding the `-DLLVM_BUILD_TELEMETRY` to be used in ifdef. --- Full diff: https://github.com/llvm/llvm-project/pull/126746.diff 3 Files Affected: - (modified) lldb/source/Core/CMakeLists.txt (-1) - (modified) llvm/include/llvm/Config/llvm-config.h.cmake (+3) - (modified) llvm/lib/CMakeLists.txt (+1) ``diff diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index cf5f6ac9da4894a..82fb5f42f9f4b9e 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -18,7 +18,6 @@ endif() if (LLVM_BUILD_TELEMETRY) set(TELEMETRY_DEPS Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 629977cc11d6836..239f9dd3f38db18 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -201,4 +201,7 @@ /* Define if logf128 is available */ #cmakedefine LLVM_HAS_LOGF128 +/* Define if building LLVM with LLVM_BUILD_TELEMETRY */ +#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY} + #endif diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index d0a2bc929438179..08e3d7ddb8c12c7 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,6 +43,7 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) + add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) `` https://github.com/llvm/llvm-project/pull/126746 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126746 >From 008537373cd928fea9ac04b1aed39c2ecafec65a Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 10:36:06 -0500 Subject: [PATCH 1/4] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (by users of Telemetry) --- llvm/lib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index d0a2bc9294381..08e3d7ddb8c12 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,6 +43,7 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) + add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) >From f2a3822291d7153359286bd5efc4c080c21adedd Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 11:22:36 -0500 Subject: [PATCH 2/4] add macro def in llvm-config.h --- llvm/include/llvm/Config/llvm-config.h.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 629977cc11d68..239f9dd3f38db 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -201,4 +201,7 @@ /* Define if logf128 is available */ #cmakedefine LLVM_HAS_LOGF128 +/* Define if building LLVM with LLVM_BUILD_TELEMETRY */ +#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY} + #endif >From 1bec761f06f79fac21a063a1e5c222e274dd3ddb Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 13:07:12 -0500 Subject: [PATCH 3/4] remove macro from lldb/soruce/Core/CMakeLists.txt --- lldb/source/Core/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index cf5f6ac9da489..82fb5f42f9f4b 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -18,7 +18,6 @@ endif() if (LLVM_BUILD_TELEMETRY) set(TELEMETRY_DEPS Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore >From 88cdb5ac5f7b6f8cb8bb539a7c1291a302632ec5 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 13:08:12 -0500 Subject: [PATCH 4/4] remove macro from llvm/CMakeLists.txt --- llvm/lib/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 08e3d7ddb8c12..d0a2bc9294381 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -43,7 +43,6 @@ add_subdirectory(TargetParser) add_subdirectory(TextAPI) if (LLVM_BUILD_TELEMETRY) add_subdirectory(Telemetry) - add_definitions(-DLLDB_BUILD_TELEMETRY) endif() add_subdirectory(ToolDrivers) add_subdirectory(XRay) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
oontvoo wrote: > In that case, could you also delete the definition in llvm/lib/CMakeLists.txt > and the one introduced in #126715 ? done https://github.com/llvm/llvm-project/pull/126746 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 9387fd96314c59fc9aff1a82e478f9b89a97c20a b767a2efb6f1d39e83523cfdf330ddd26a8cf892 --extensions cpp,h -- lldb/include/lldb/Core/TelemetryVendor.h lldb/source/Core/TelemetryVendor.cpp lldb/include/lldb/lldb-forward.h `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index b1696f520a..fe237ef74f 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -12,8 +12,8 @@ #include #ifdef LLVM_BUILD_TELEMETRY -#include "llvm/Telemetry/Telemetry.h" #include "lldb/Core/Telemetry.h" +#include "llvm/Telemetry/Telemetry.h" #endif // lldb forward declarations `` https://github.com/llvm/llvm-project/pull/126588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Change lldb's breakpoint detection behavior (PR #105594)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/105594 >From 56ca564185bdceea25162a1ce3b1e8c8fa2641e2 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Fri, 19 Jul 2024 17:26:13 -0700 Subject: [PATCH 01/14] [lldb] Change lldb's breakpoint handling behavior (#96260) lldb today has two rules: When a thread stops at a BreakpointSite, we set the thread's StopReason to be "breakpoint hit" (regardless if we've actually hit the breakpoint, or if we've merely stopped *at* the breakpoint instruction/point and haven't tripped it yet). And second, when resuming a process, any thread sitting at a BreakpointSite is silently stepped over the BreakpointSite -- because we've already flagged the breakpoint hit when we stopped there originally. In this patch, I change lldb to only set a thread's stop reason to breakpoint-hit when we've actually executed the instruction/triggered the breakpoint. When we resume, we only silently step past a BreakpointSite that we've registered as hit. We preserve this state across inferior function calls that the user may do while stopped, etc. Also, when a user adds a new breakpoint at $pc while stopped, or changes $pc to be the address of a BreakpointSite, we will silently step past that breakpoint when the process resumes. This is purely a UX call, I don't think there's any person who wants to set a breakpoint at $pc and then hit it immediately on resuming. One non-intuitive UX from this change, but I'm convinced it is necessary: If you're stopped at a BreakpointSite that has not yet executed, you `stepi`, you will hit the breakpoint and the pc will not yet advance. This thread has not completed its stepi, and the thread plan is still on the stack. If you then `continue` the thread, lldb will now stop and say, "instruction step completed", one instruction past the BreakpointSite. You can continue a second time to resume execution. I discussed this with Jim, and trying to paper over this behavior will lead to more complicated scenarios behaving non-intuitively. And mostly it's the testsuite that was trying to instruction step past a breakpoint and getting thrown off -- and I changed those tests to expect the new behavior. The bugs driving this change are all from lldb dropping the real stop reason for a thread and setting it to breakpoint-hit when that was not the case. Jim hit one where we have an aarch64 watchpoint that triggers one instruction before a BreakpointSite. On this arch we are notified of the watchpoint hit after the instruction has been unrolled -- we disable the watchpoint, instruction step, re-enable the watchpoint and collect the new value. But now we're on a BreakpointSite so the watchpoint-hit stop reason is lost. Another was reported by ZequanWu in https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282 we attach to/launch a process with the pc at a BreakpointSite and misbehave. Caroline Tice mentioned it is also a problem they've had with putting a breakpoint on _dl_debug_state. The change to each Process plugin that does execution control is that 1. If we've stopped at a BreakpointSite that has not been executed yet, we will call Thread::SetThreadStoppedAtUnexecutedBP(pc) to record that. When the thread resumes, if the pc is still at the same site, we will continue, hit the breakpoint, and stop again. 2. When we've actually hit a breakpoint (enabled for this thread or not), the Process plugin should call Thread::SetThreadHitBreakpointSite(). When we go to resume the thread, we will push a step-over-breakpoint ThreadPlan before resuming. The biggest set of changes is to StopInfoMachException where we translate a Mach Exception into a stop reason. The Mach exception codes differ in a few places depending on the target (unambiguously), and I didn't want to duplicate the new code for each target so I've tested what mach exceptions we get for each action on each target, and reorganized StopInfoMachException::CreateStopReasonWithMachException to document these possible values, and handle them without specializing based on the target arch. rdar://123942164 --- lldb/include/lldb/Target/Thread.h | 24 ++ .../Process/Utility/StopInfoMachException.cpp | 322 -- .../Process/Windows/Common/ProcessWindows.cpp | 32 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 93 ++--- .../Process/scripted/ScriptedThread.cpp | 11 + lldb/source/Target/StopInfo.cpp | 2 + lldb/source/Target/Thread.cpp | 15 +- .../TestConsecutiveBreakpoints.py | 26 +- .../TestStepOverBreakpoint.py | 6 +- 9 files changed, 266 insertions(+), 265 deletions(-) diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 38b65b2bc5849..22d452c7b4b8a 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -131,6 +131,7 @@ class Thread : public std::enable_shared_from_this, register
[Lldb-commits] [lldb] Addressed additional review comments from PR/119716. (PR #126757)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/126757 >From 5a8b91422a017dcda595efa614a018f0a432df12 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 11:05:21 -0500 Subject: [PATCH 1/2] Addressed additional review comments from PR/119716. --- lldb/include/lldb/Core/Telemetry.h | 2 +- lldb/source/Core/Telemetry.cpp | 14 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 60a7097de5eee..d6c9e42ca8139 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -56,7 +56,7 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo { void serialize(llvm::telemetry::Serializer &serializer) const override; }; -/// The base Telemetry manager instance in LLDB +/// The base Telemetry manager instance in LLDB. /// This class declares additional instrumentation points /// applicable to LLDB. class TelemetryManager : public llvm::telemetry::Manager { diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 99f5d43ccbaf0..d0d7014d9ae83 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -27,10 +27,7 @@ namespace lldb_private { namespace telemetry { -using ::llvm::Error; -using ::llvm::telemetry::Destination; -using ::llvm::telemetry::Serializer; -using ::llvm::telemetry::TelemetryInfo; +namespace llvm::telemetry; static uint64_t ToNanosec(const SteadyTimePoint Point) { return std::chrono::nanoseconds(Point.time_since_epoch()).count(); @@ -44,21 +41,20 @@ void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const { serializer.write("end_time", ToNanosec(end_time.value())); } -[[maybe_unused]] static std::string MakeUUID(lldb_private::Debugger *debugger) { +[[maybe_unused]] static std::string MakeUUID(Debugger *debugger) { uint8_t random_bytes[16]; if (auto ec = llvm::getRandomBytes(random_bytes, 16)) { LLDB_LOG(GetLog(LLDBLog::Object), "Failed to generate random bytes for UUID: {0}", ec.message()); -// fallback to using timestamp + debugger ID. +// Fallback to using timestamp + debugger ID. return llvm::formatv( "{0}_{1}", std::chrono::steady_clock::now().time_since_epoch().count(), debugger->GetID()); } - return lldb_private::UUID(random_bytes).GetAsString(); + return MakeUUID(random_bytes).GetAsString(); } -TelemetryManager::TelemetryManager( -std::unique_ptr config) +TelemetryManager::TelemetryManager(std::unique_ptr config) : m_config(std::move(config)) {} llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { >From 8cb7a81b2e1afba54c520bf9dcbd532680bebdbc Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Feb 2025 14:34:07 -0500 Subject: [PATCH 2/2] typo --- lldb/source/Core/Telemetry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index d0d7014d9ae83..1a829e09ac7c0 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -27,7 +27,7 @@ namespace lldb_private { namespace telemetry { -namespace llvm::telemetry; +using namespace llvm::telemetry; static uint64_t ToNanosec(const SteadyTimePoint Point) { return std::chrono::nanoseconds(Point.time_since_epoch()).count(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
oontvoo wrote: Related follow-up : [PR/126746](https://github.com/llvm/llvm-project/pull/126746) (for excluding telemetry code) https://github.com/llvm/llvm-project/pull/119716 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)
labath wrote: .. and fix the code so that it uses the new macro name ? (You'll need to include llvm-config.h before you can use the macro, and I'd recommend doing a build with telemetry disabled to check that everything works as it should) https://github.com/llvm/llvm-project/pull/126746 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [libcxx] [lldb] [llvm] [doc] Add Discord invite link alongside channel links (PR #126352)
https://github.com/RossComputerGuy approved this pull request. https://github.com/llvm/llvm-project/pull/126352 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)
https://github.com/matthewbastien created https://github.com/llvm/llvm-project/pull/126803 The Swift extension for VS Code requires that the `lldb-dap` executable come from the Swift toolchain which may or may not be configured in `PATH`. At the moment, this can be configured via LLDB DAP's extension settings, but experience has shown that modifying other extensions' settings on behalf of the user (especially those subject to change whenever a new toolchain is selected) causes issues. Instead, it would be easier to have this configurable in the launch configuration and let the Swift extension (or any other extension that wanted to, really) configure the path to `lldb-dap` that way. This allows the Swift extension to have its own launch configuration type that delegates to the LLDB DAP extension in order to provide a more seamless debugging experience for Swift executables. This PR adds a new property to the launch configuration object called `debugAdapterExecutable` which allows overriding the `lldb-dap` executable path for a specific debug session. >From 830a56acf776046d65dada631b54c74ed2aa5f87 Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Tue, 11 Feb 2025 16:38:43 -0500 Subject: [PATCH] add `debugAdapterExecutable` property to launch configuration --- lldb/tools/lldb-dap/package.json| 6 +- lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 9 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index e866af0602d70..fb4a828795041 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -86,7 +86,7 @@ "default": {}, "description": "The environment of the lldb-dap process.", "additionalProperties": { - "type": "string" +"type": "string" } } } @@ -152,6 +152,10 @@ "program" ], "properties": { + "debugAdapterExecutable": { +"type": "string", +"markdownDescription": "The LLDB debug adapter executable to use. Either an absolute path or the name of a debug adapter executable available on the `PATH`." + }, "program": { "type": "string", "description": "Path to the program to debug." diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts index 55c2f3e9f7deb..e1c6bd4fd4300 100644 --- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts +++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts @@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise { async function getDAPExecutable( session: vscode.DebugSession, ): Promise { + // Check if the executable was provided in the launch configuration. + const launchConfigPath = session.configuration["debugAdapterExecutable"]; + if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) { +return launchConfigPath; + } + + // Check if the executable was provided in the extension's configuration. const config = vscode.workspace.getConfiguration( "lldb-dap", session.workspaceFolder, ); - - // Prefer the explicitly specified path in the extension's configuration. const configPath = config.get("executable-path"); if (configPath && configPath.length !== 0) { return configPath; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Matthew Bastien (matthewbastien) Changes The Swift extension for VS Code requires that the `lldb-dap` executable come from the Swift toolchain which may or may not be configured in `PATH`. At the moment, this can be configured via LLDB DAP's extension settings, but experience has shown that modifying other extensions' settings on behalf of the user (especially those subject to change whenever a new toolchain is selected) causes issues. Instead, it would be easier to have this configurable in the launch configuration and let the Swift extension (or any other extension that wanted to, really) configure the path to `lldb-dap` that way. This allows the Swift extension to have its own launch configuration type that delegates to the LLDB DAP extension in order to provide a more seamless debugging experience for Swift executables. This PR adds a new property to the launch configuration object called `debugAdapterExecutable` which allows overriding the `lldb-dap` executable path for a specific debug session. --- Full diff: https://github.com/llvm/llvm-project/pull/126803.diff 2 Files Affected: - (modified) lldb/tools/lldb-dap/package.json (+5-1) - (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+7-2) ``diff diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index e866af0602d70..fb4a828795041 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -86,7 +86,7 @@ "default": {}, "description": "The environment of the lldb-dap process.", "additionalProperties": { - "type": "string" +"type": "string" } } } @@ -152,6 +152,10 @@ "program" ], "properties": { + "debugAdapterExecutable": { +"type": "string", +"markdownDescription": "The LLDB debug adapter executable to use. Either an absolute path or the name of a debug adapter executable available on the `PATH`." + }, "program": { "type": "string", "description": "Path to the program to debug." diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts index 55c2f3e9f7deb..e1c6bd4fd4300 100644 --- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts +++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts @@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise { async function getDAPExecutable( session: vscode.DebugSession, ): Promise { + // Check if the executable was provided in the launch configuration. + const launchConfigPath = session.configuration["debugAdapterExecutable"]; + if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) { +return launchConfigPath; + } + + // Check if the executable was provided in the extension's configuration. const config = vscode.workspace.getConfiguration( "lldb-dap", session.workspaceFolder, ); - - // Prefer the explicitly specified path in the extension's configuration. const configPath = config.get("executable-path"); if (configPath && configPath.length !== 0) { return configPath; `` https://github.com/llvm/llvm-project/pull/126803 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)
https://github.com/matthewbastien updated https://github.com/llvm/llvm-project/pull/126803 >From a07148100b02fa109cd3131d2d7742cdc0ae2bfa Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Tue, 11 Feb 2025 16:38:43 -0500 Subject: [PATCH] add `debugAdapterExecutable` property to launch configuration --- lldb/tools/lldb-dap/package.json| 10 +- lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 9 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index e866af0602d70..d45c78432fa23 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -86,7 +86,7 @@ "default": {}, "description": "The environment of the lldb-dap process.", "additionalProperties": { - "type": "string" +"type": "string" } } } @@ -152,6 +152,10 @@ "program" ], "properties": { + "debugAdapterExecutable": { +"type": "string", +"markdownDescription": "The LLDB debug adapter executable to use. Either an absolute path or the name of a debug adapter executable available on the `PATH`." + }, "program": { "type": "string", "description": "Path to the program to debug." @@ -338,6 +342,10 @@ }, "attach": { "properties": { + "debugAdapterExecutable": { +"type": "string", +"markdownDescription": "The LLDB debug adapter executable to use. Either an absolute path or the name of a debug adapter executable available on the `PATH`." + }, "program": { "type": "string", "description": "Path to the program to attach to." diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts index 55c2f3e9f7deb..e1c6bd4fd4300 100644 --- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts +++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts @@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise { async function getDAPExecutable( session: vscode.DebugSession, ): Promise { + // Check if the executable was provided in the launch configuration. + const launchConfigPath = session.configuration["debugAdapterExecutable"]; + if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) { +return launchConfigPath; + } + + // Check if the executable was provided in the extension's configuration. const config = vscode.workspace.getConfiguration( "lldb-dap", session.workspaceFolder, ); - - // Prefer the explicitly specified path in the extension's configuration. const configPath = config.get("executable-path"); if (configPath && configPath.length !== 0) { return configPath; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove Debugger::Get{Output, Error}Stream (NFC) (PR #126821)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Remove Debugger::GetOutputStream and Debugger::GetErrorStream in preparation for replacing both with a new variant that needs to be locked and hence can't be handed out like we do right now. The patch replaces most uses with GetAsyncOutputStream and GetAsyncErrorStream respectively. There methods return new StreamSP objects that automatically get flushed on destruction. See #126630 for more details. --- Patch is 25.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126821.diff 15 Files Affected: - (modified) lldb/include/lldb/Core/Debugger.h (-4) - (modified) lldb/source/API/SBDebugger.cpp (+10-18) - (modified) lldb/source/Core/Debugger.cpp (+4-5) - (modified) lldb/source/Core/DynamicLoader.cpp (+8-8) - (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+2-2) - (modified) lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (+40-41) - (modified) lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp (+11-12) - (modified) lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (+6-5) - (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (+2-2) - (modified) lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp (+2-2) - (modified) lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp (+2-2) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+2-2) - (modified) lldb/source/Target/Process.cpp (+2-2) - (modified) lldb/source/Target/Target.cpp (+3-3) - (modified) lldb/source/Target/ThreadPlanTracer.cpp (+1-1) ``diff diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 70f4c4216221c..d7751ca045bb2 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -143,10 +143,6 @@ class Debugger : public std::enable_shared_from_this, File &GetErrorFile() { return m_error_stream_sp->GetFile(); } - StreamFile &GetOutputStream() { return *m_output_stream_sp; } - - StreamFile &GetErrorStream() { return *m_error_stream_sp; } - repro::DataRecorder *GetInputRecorder(); Status SetInputString(const char *data); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index bdb8e538b99f8..5d7cfef07c138 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -508,39 +508,31 @@ SBFile SBDebugger::GetInputFile() { FILE *SBDebugger::GetOutputFileHandle() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -StreamFile &stream_file = m_opaque_sp->GetOutputStream(); -return stream_file.GetFile().GetStream(); - } + if (m_opaque_sp) +return m_opaque_sp->GetOutputStreamSP()->GetFile().GetStream(); return nullptr; } SBFile SBDebugger::GetOutputFile() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -SBFile file(m_opaque_sp->GetOutputStream().GetFileSP()); -return file; - } + if (m_opaque_sp) +return SBFile(m_opaque_sp->GetOutputStreamSP()->GetFileSP()); return SBFile(); } FILE *SBDebugger::GetErrorFileHandle() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -StreamFile &stream_file = m_opaque_sp->GetErrorStream(); -return stream_file.GetFile().GetStream(); - } + if (m_opaque_sp) +return m_opaque_sp->GetErrorStreamSP()->GetFile().GetStream(); return nullptr; } SBFile SBDebugger::GetErrorFile() { LLDB_INSTRUMENT_VA(this); SBFile file; - if (m_opaque_sp) { -SBFile file(m_opaque_sp->GetErrorStream().GetFileSP()); -return file; - } + if (m_opaque_sp) +return SBFile(m_opaque_sp->GetErrorStreamSP()->GetFileSP()); return SBFile(); } @@ -581,8 +573,8 @@ void SBDebugger::HandleCommand(const char *command) { sb_interpreter.HandleCommand(command, result, false); -result.PutError(m_opaque_sp->GetErrorStream().GetFileSP()); -result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP()); +result.PutError(m_opaque_sp->GetErrorFile().GetStream()); +result.PutOutput(m_opaque_sp->GetOutputFile().GetStream()); if (!m_opaque_sp->GetAsyncExecution()) { SBProcess process(GetCommandInterpreter().GetProcess()); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 2df2aeb20aa26..18569e155b517 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -257,12 +257,11 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, std::list errors; StreamString feedback_stream; if (!target_sp->LoadScriptingResources(errors, feedback_stream)) { - Stream &s = GetErrorStream(); - for (auto &error : errors) { -s.Printf("%s\n", error.AsCString()); - } + lldb::StreamSP s = GetAsyncErrorStream(); +
[Lldb-commits] [lldb] [lldb] Remove Debugger::Get{Output, Error}Stream (NFC) (PR #126821)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/126821 Remove Debugger::GetOutputStream and Debugger::GetErrorStream in preparation for replacing both with a new variant that needs to be locked and hence can't be handed out like we do right now. The patch replaces most uses with GetAsyncOutputStream and GetAsyncErrorStream respectively. There methods return new StreamSP objects that automatically get flushed on destruction. See #126630 for more details. >From 34cf65b2b485d8f284091f21f7a8cabe48e8e9d6 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 11 Feb 2025 15:02:31 -0800 Subject: [PATCH] [lldb] Remove Debugger::Get{Output,Error}Stream (NFC) Remove Debugger::GetOutputStream and Debugger::GetErrorStream in preparation for replacing both with a new variant that needs to be locked and hence can't be handed out like we do right now. The patch replaces most uses with GetAsyncOutputStream and GetAsyncErrorStream respectively. There methods return new StreamSP objects that automatically get flushed on destruction. See #126630 for more details. --- lldb/include/lldb/Core/Debugger.h | 4 - lldb/source/API/SBDebugger.cpp| 28 +++ lldb/source/Core/Debugger.cpp | 9 +-- lldb/source/Core/DynamicLoader.cpp| 16 ++-- lldb/source/Interpreter/ScriptInterpreter.cpp | 4 +- .../DynamicLoaderDarwinKernel.cpp | 81 +-- .../DynamicLoaderFreeBSDKernel.cpp| 23 +++--- .../TSan/InstrumentationRuntimeTSan.cpp | 11 +-- .../AppleObjCTrampolineHandler.cpp| 4 +- .../Lua/ScriptInterpreterLua.cpp | 4 +- .../None/ScriptInterpreterNone.cpp| 4 +- .../Python/ScriptInterpreterPython.cpp| 4 +- lldb/source/Target/Process.cpp| 4 +- lldb/source/Target/Target.cpp | 6 +- lldb/source/Target/ThreadPlanTracer.cpp | 2 +- 15 files changed, 95 insertions(+), 109 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 70f4c4216221c..d7751ca045bb2 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -143,10 +143,6 @@ class Debugger : public std::enable_shared_from_this, File &GetErrorFile() { return m_error_stream_sp->GetFile(); } - StreamFile &GetOutputStream() { return *m_output_stream_sp; } - - StreamFile &GetErrorStream() { return *m_error_stream_sp; } - repro::DataRecorder *GetInputRecorder(); Status SetInputString(const char *data); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index bdb8e538b99f8..5d7cfef07c138 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -508,39 +508,31 @@ SBFile SBDebugger::GetInputFile() { FILE *SBDebugger::GetOutputFileHandle() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -StreamFile &stream_file = m_opaque_sp->GetOutputStream(); -return stream_file.GetFile().GetStream(); - } + if (m_opaque_sp) +return m_opaque_sp->GetOutputStreamSP()->GetFile().GetStream(); return nullptr; } SBFile SBDebugger::GetOutputFile() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -SBFile file(m_opaque_sp->GetOutputStream().GetFileSP()); -return file; - } + if (m_opaque_sp) +return SBFile(m_opaque_sp->GetOutputStreamSP()->GetFileSP()); return SBFile(); } FILE *SBDebugger::GetErrorFileHandle() { LLDB_INSTRUMENT_VA(this); - if (m_opaque_sp) { -StreamFile &stream_file = m_opaque_sp->GetErrorStream(); -return stream_file.GetFile().GetStream(); - } + if (m_opaque_sp) +return m_opaque_sp->GetErrorStreamSP()->GetFile().GetStream(); return nullptr; } SBFile SBDebugger::GetErrorFile() { LLDB_INSTRUMENT_VA(this); SBFile file; - if (m_opaque_sp) { -SBFile file(m_opaque_sp->GetErrorStream().GetFileSP()); -return file; - } + if (m_opaque_sp) +return SBFile(m_opaque_sp->GetErrorStreamSP()->GetFileSP()); return SBFile(); } @@ -581,8 +573,8 @@ void SBDebugger::HandleCommand(const char *command) { sb_interpreter.HandleCommand(command, result, false); -result.PutError(m_opaque_sp->GetErrorStream().GetFileSP()); -result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP()); +result.PutError(m_opaque_sp->GetErrorFile().GetStream()); +result.PutOutput(m_opaque_sp->GetOutputFile().GetStream()); if (!m_opaque_sp->GetAsyncExecution()) { SBProcess process(GetCommandInterpreter().GetProcess()); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 2df2aeb20aa26..18569e155b517 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -257,12 +257,11 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, std::list errors; StreamString feedback_stream; if (!target_sp->LoadScriptingResources(errors, feedback
[Lldb-commits] [lldb] [llvm] [lldb] Change lldb's breakpoint detection behavior (PR #105594)
jasonmolenda wrote: The details of the bug that Martin found were actually bit a interesting. The core of the issue is that the thread has a ThreadPlanStepOut, and before we resume execution, because we're at a BreakpointSite that has been hit, we push a ThreadPlanStepOverBreakpoint plan. It sees that the thread's state is eStateRunning (not eStateStepping -- so this is a thread doing a "continue" style resume). StepOverBreakpoint marks itself as "AutoResume == true" so that when it completes, it will run the thread as it was intended to be doing originally. We do our instruction step. StepOverBreakpoint has completed, and it says we should resume execution. StepOut says it has completed execution because the StackID == the StackID it needed to execute to. It pops itself off the stack and removes its breakpoint. Thread::ShouldResume uses the StepOverBreakpoint's "auto resume == true" state to resume execution, and we lose control. Jim points out that StepOverBreakpoint is unique because it was not tied to any higher level/controlling thread plan. It was injected on the thread just before we resume execution, and it tries to guess is the thread wants to stop when it's done or resume execution based on the thread's running state when it's added. He thinks StepOverBreakpoint should maybe be owned by the first thread plan on the stack, so when StepOut removes itself from the stack, StepOverBreakpoint's opinion about resuming is not relevant. The other part I did not dig in to was what exactly Thread::ShouldStop is doing when the current thread plan (StepOverBreakpoint) says 'auto resume' and the next one up the stack (StepOut) says "I'm complete, stop", and it resumed. I wanted to avoid touching something as central as Thread::ShouldStop's logic here, but I don't quite understand why the result of these two inputs was, "resume". https://github.com/llvm/llvm-project/pull/105594 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits