[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-28 Thread Adrian Vogelsgesang via lldb-commits


@@ -0,0 +1,175 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+response["success"] = false;
+response["message"] =
+"Malformed memory reference: " + memoryReference.str();
+dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }
+
+  lldb::addr_t address = *addr_opt;
+  lldb::addr_t address_offset =
+  address + GetInteger(arguments, "offset").value_or(0);
+
+  llvm::StringRef data64 = GetString(arguments, "data").value_or("");
+
+  // The VSCode IDE or other DAP clients send memory data as a Base64 string.
+  // This function decodes it into raw binary before writing it to the target
+  // process memory.
+  std::vector output;
+  auto decodeError = llvm::decodeBase64(data64, output);
+
+  if (decodeError) {
+response["success"] = false;
+EmplaceSafeString(response, "message",
+  llvm::t

[Lldb-commits] [lldb] [lldb][debugserver] Interrupt should reset outstanding SIGSTOP (PR #132128)

2025-03-28 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda edited 
https://github.com/llvm/llvm-project/pull/132128
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Create a default rate limit constant in Progress (NFC) (PR #133506)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/133506

In #133211, Greg suggested making the rate limit configurable through a 
setting. Although adding the setting is easy, the two places where we currently 
use rate limiting aren't tied to a particular debugger.

I still think it's a good idea to be consistent and make it easy to pick the 
same rate limiting value, so I've moved it into a constant in the Progress 
class.

>From 497d45360ad50ae909d946b4a34b55346c56ff69 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 28 Mar 2025 11:55:23 -0700
Subject: [PATCH] [lldb] Create a default rate limit constant in Progress (NFC)

In #133211, Greg suggested making the rate limit configurable through a
setting. Although adding the setting is easy, the two places where we
currently use rate limiting aren't tied to a particular debugger.

I still think it's a good idea to be consistent and make it easy to pick
the same rate limiting value, so I've moved it into a constant in the
Progress class.
---
 lldb/include/lldb/Core/Progress.h | 4 
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp  | 3 +--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 3003568e8946b..104a8c0feb80a 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -115,6 +115,10 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// The default rate limit for high frequency progress reports.
+  static constexpr std::chrono::milliseconds kDefaultRateLimit =
+  std::chrono::milliseconds(20);
+
 private:
   void ReportProgress();
   static std::atomic g_id;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 6f2c45e74132c..f6304a7a4b9ba 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -81,7 +81,7 @@ void ManualDWARFIndex::Index() {
   const uint64_t total_progress = units_to_index.size() * 2 + 8;
   Progress progress("Manually indexing DWARF", module_desc.GetData(),
 total_progress, /*debugger=*/nullptr,
-/*minimum_report_time=*/std::chrono::milliseconds(20));
+Progress::kDefaultRateLimit);
 
   // Share one thread pool across operations to avoid the overhead of
   // recreating the threads.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index e346d588a449f..8b72c96dc6f33 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -723,8 +723,7 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
 std::function closure) {
   const size_t num_oso_idxs = m_compile_unit_infos.size();
   Progress progress(std::move(description), "", num_oso_idxs,
-/*debugger=*/nullptr,
-/*minimum_report_time=*/std::chrono::milliseconds(20));
+/*debugger=*/nullptr, Progress::kDefaultRateLimit);
   for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
   progress.Increment(oso_idx, oso_dwarf->GetObjectFile()

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-28 Thread Ebuka Ezike via lldb-commits


@@ -79,6 +79,27 @@ enum class PacketStatus {
 
 enum class ReplMode { Variable = 0, Command, Auto };
 
+class Gotos {
+public:
+  /// \return the line_entry corresponding with \p id
+  ///
+  /// If \p id is invalid std::nullopt is returned.
+  std::optional GetLineEntry(uint64_t id) const;
+
+  /// Insert a new \p line_entry.
+  /// \return id assigned to this line_entry.
+  uint64_t InsertLineEntry(lldb::SBLineEntry line_entry);
+
+  /// Clears all line entries and reset the generated ids.
+  void Clear();

da-viper wrote:

Yes, It is used here. 

https://github.com/llvm/llvm-project/blob/a2a2cb85e5f17a7468970c6014947918d9805e80/lldb/tools/lldb-dap/DAP.h#L378-L379



https://github.com/llvm/llvm-project/pull/130503
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new affordance that the Python module in a dSYM (PR #133290)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM. Jim and I have been discussing this offline and this solves the problem 
without opening other cans of works. This will be particularly helpful for the 
XNU macros. 

https://github.com/llvm/llvm-project/pull/133290
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new affordance that the Python module in a dSYM (PR #133290)

2025-03-28 Thread Jonas Devlieghere via lldb-commits


@@ -2495,6 +2495,12 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
   PyRefType::Owned, static_cast(module_pyobj)));
   }
 
+  // Finally, if we got a target passed in, then we should tell the new module
+  // about this target:
+  if (target_sp) {
+return SWIGBridge::LLDBSwigPythonCallModuleNewTarget(
+module_name.c_str(), m_dictionary_name.c_str(), target_sp);
+  }

JDevlieghere wrote:

Nit: no braces around single-line (statement?) `if`s. 

https://github.com/llvm/llvm-project/pull/133290
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new affordance that the Python module in a dSYM (PR #133290)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/133290
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2025-03-28 Thread David Spickett via lldb-commits


@@ -185,6 +185,8 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
+if available_ports := self.getPlatformAvailablePorts():
+return int(random.choice(available_ports))

DavidSpickett wrote:

Once a test chooses a port, other tests can still choose that port. Is that a 
problem?

https://github.com/llvm/llvm-project/pull/112555
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2025-03-28 Thread David Spickett via lldb-commits

DavidSpickett wrote:

This change is fine I just want to understand whether you'll still get test 
cases competing for ports even with this option.

https://github.com/llvm/llvm-project/pull/112555
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-28 Thread Santhosh Kumar Ellendula via lldb-commits


@@ -0,0 +1,175 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+response["success"] = false;
+response["message"] =
+"Malformed memory reference: " + memoryReference.str();
+dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }
+
+  lldb::addr_t address = *addr_opt;
+  lldb::addr_t address_offset =
+  address + GetInteger(arguments, "offset").value_or(0);
+
+  llvm::StringRef data64 = GetString(arguments, "data").value_or("");
+
+  // The VSCode IDE or other DAP clients send memory data as a Base64 string.
+  // This function decodes it into raw binary before writing it to the target
+  // process memory.
+  std::vector output;
+  auto decodeError = llvm::decodeBase64(data64, output);
+
+  if (decodeError) {
+response["success"] = false;
+EmplaceSafeString(response, "message",
+  llvm::t

[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2025-03-28 Thread David Spickett via lldb-commits


@@ -292,6 +292,13 @@ def create_parser():
 metavar="platform-working-dir",
 help="The directory to use on the remote platform.",
 )
+group.add_argument(
+"--platform-available-ports",
+dest="lldb_platform_available_ports",
+nargs="*",

DavidSpickett wrote:

Then you can remove the `int(` later on.

https://github.com/llvm/llvm-project/pull/112555
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2025-03-28 Thread David Spickett via lldb-commits


@@ -292,6 +292,13 @@ def create_parser():
 metavar="platform-working-dir",
 help="The directory to use on the remote platform.",
 )
+group.add_argument(
+"--platform-available-ports",
+dest="lldb_platform_available_ports",
+nargs="*",

DavidSpickett wrote:

You could make this parse into integers as well, so it will fail earlier - 
https://docs.python.org/3/library/argparse.html#type

I think `type=int` would work here.

https://github.com/llvm/llvm-project/pull/112555
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Create a default rate limit constant in Progress (NFC) (PR #133506)

2025-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

In #133211, Greg suggested making the rate limit configurable through a 
setting. Although adding the setting is easy, the two places where we currently 
use rate limiting aren't tied to a particular debugger.

I still think it's a good idea to be consistent and make it easy to pick the 
same rate limiting value, so I've moved it into a constant in the Progress 
class.

---
Full diff: https://github.com/llvm/llvm-project/pull/133506.diff


3 Files Affected:

- (modified) lldb/include/lldb/Core/Progress.h (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+1-2) 


``diff
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 3003568e8946b..104a8c0feb80a 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -115,6 +115,10 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// The default rate limit for high frequency progress reports.
+  static constexpr std::chrono::milliseconds kDefaultRateLimit =
+  std::chrono::milliseconds(20);
+
 private:
   void ReportProgress();
   static std::atomic g_id;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 6f2c45e74132c..f6304a7a4b9ba 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -81,7 +81,7 @@ void ManualDWARFIndex::Index() {
   const uint64_t total_progress = units_to_index.size() * 2 + 8;
   Progress progress("Manually indexing DWARF", module_desc.GetData(),
 total_progress, /*debugger=*/nullptr,
-/*minimum_report_time=*/std::chrono::milliseconds(20));
+Progress::kDefaultRateLimit);
 
   // Share one thread pool across operations to avoid the overhead of
   // recreating the threads.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index e346d588a449f..8b72c96dc6f33 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -723,8 +723,7 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
 std::function closure) {
   const size_t num_oso_idxs = m_compile_unit_infos.size();
   Progress progress(std::move(description), "", num_oso_idxs,
-/*debugger=*/nullptr,
-/*minimum_report_time=*/std::chrono::milliseconds(20));
+/*debugger=*/nullptr, Progress::kDefaultRateLimit);
   for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
   progress.Increment(oso_idx, oso_dwarf->GetObjectFile()

``




https://github.com/llvm/llvm-project/pull/133506
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose the Target API mutex through the SB API (PR #133295)

2025-03-28 Thread Alex Langford via lldb-commits


@@ -0,0 +1,59 @@
+//===-- SBMutexTest.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
+//
+//===--===//
+
+// Use the umbrella header for -Wdocumentation.
+#include "lldb/API/LLDB.h"
+
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+class SBMutexTest : public testing::Test {
+protected:
+  void SetUp() override { debugger = SBDebugger::Create(); }
+  void TearDown() override { SBDebugger::Destroy(debugger); }
+
+  SubsystemRAII subsystems;
+  SBDebugger debugger;
+};
+
+TEST_F(SBMutexTest, LockTest) {
+  lldb::SBTarget target = debugger.GetDummyTarget();
+
+  std::future f;
+  {
+std::atomic locked = false;
+lldb::SBMutex lock = target.GetAPIMutex();
+std::lock_guard lock_guard(lock);
+ASSERT_FALSE(locked.exchange(true));
+
+f = std::async(std::launch::async, [&]() {
+  {
+ASSERT_TRUE(locked);
+target.BreakpointCreateByName("foo", "bar");
+ASSERT_FALSE(locked);
+  }
+});
+ASSERT_TRUE(f.valid());
+
+// Wait 500ms to confirm the thread is blocked.
+auto status = f.wait_for(std::chrono::milliseconds(500));

bulbazord wrote:

Oh I see, this is because you're using a recursive mutex. Makes sense, thanks 
for the clarification!

https://github.com/llvm/llvm-project/pull/133295
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-28 Thread Santhosh Kumar Ellendula via lldb-commits


@@ -394,6 +394,13 @@ class TestGetTargetBreakpointsRequestHandler : public 
LegacyRequestHandler {
   void operator()(const llvm::json::Object &request) const override;
 };
 
+class WriteMemoryRequestHandler : public LegacyRequestHandler {

santhoshe447 wrote:

> I would prefer if we would directly use the non-legacy approach here

What is non legacy handler approach ?

https://github.com/llvm/llvm-project/pull/131820
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Parallelize module loading in POSIX dyld code (PR #130912)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/130912
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (PR #127505)

2025-03-28 Thread via lldb-commits

https://github.com/dlav-sc edited 
https://github.com/llvm/llvm-project/pull/127505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (PR #127505)

2025-03-28 Thread via lldb-commits

https://github.com/dlav-sc edited 
https://github.com/llvm/llvm-project/pull/127505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Show the path to the .o instead of the containing .a in progress events (PR #133370)

2025-03-28 Thread via lldb-commits

jimingham wrote:

One common mistake with .o files is to strip the .a file before linking.  Then 
you end up with no debug info even though the original .o file definitely HAS 
debug info.  In that case showing the .o file rather than the usual form 
libfoo.a(bar.o) would be confusing.  
But I can't think of a way that we would know about the original .o file if the 
.a file got stripped too early.  So I think this concern is moot.

https://github.com/llvm/llvm-project/pull/133370
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/133078

>From 4a0d13ef2751071505ab797c63c2ee20d14a6c61 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 13:20:24 +
Subject: [PATCH 1/4] [lldb][Target] Clear selected frame index after a
 StopInfo::PerformAction

---
 lldb/include/lldb/Target/StackFrameList.h | 3 +++
 lldb/include/lldb/Target/Thread.h | 5 +
 lldb/source/Target/Process.cpp| 2 ++
 lldb/source/Target/StackFrameList.cpp | 4 
 4 files changed, 14 insertions(+)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..d805b644b0b31 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -46,6 +46,9 @@ class StackFrameList {
   /// Mark a stack frame as the currently selected frame and return its index.
   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex();
+
   /// Get the currently selected frame index.
   /// We should only call SelectMostRelevantFrame if (a) the user hasn't 
already
   /// selected a frame, and (b) if this really is a user facing
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 6ede7fa301a82..688c056da2633 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -479,6 +479,11 @@ class Thread : public std::enable_shared_from_this,
   bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
   Stream &output_stream);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex() {
+return GetStackFrameList()->ClearSelectedFrameIndex();
+  }
+
   void SetDefaultFileAndLineToSelectedFrame() {
 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
   }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..c51bab20f56ee 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4295,6 +4295,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+thread_sp->ClearSelectedFrameIndex();
+
 // FIXME: we might have run.
 if (stop_info_sp->HasTargetRunSinceMe()) {
   SetRestarted(true);
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 9c6208e9e0a65..3592c3c03db74 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {
+  m_selected_frame_idx.reset();
+}

>From 1a1a55786de369b1c9771623c21de459848c7e20 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 13:35:23 +
Subject: [PATCH 2/4] fixup! clang-format

---
 lldb/source/Target/Process.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c51bab20f56ee..46e8028160d04 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4295,6 +4295,12 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+// Clear the selected frame which may have been set as part of utility
+// expressions that have been run as part of this stop. If we didn't
+// clear this, then StopInfo::GetSuggestedStackFrameIndex would not
+// take affect when we next called SelectMostRelevantFrame. 
PerformAction
+// should not be the one setting a selected frame, instead this should 
be
+// done via GetSuggestedStackFrameIndex.
 thread_sp->ClearSelectedFrameIndex();
 
 // FIXME: we might have run.

>From 158f0b2cd664ba1864e510bf8293d16790c6a65a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 28 Mar 2025 15:40:47 +
Subject: [PATCH 3/4] fixup! add thread-safety comment

---
 lldb/include/lldb/Target/StackFrameList.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index d805b644b0b31..8d455dc831df3 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -175,6 +175,15 @@ class StackFrameList {
   /// The currently selected frame. An optional is used to record whether 
anyone
   /// has set the selected frame on this stack yet. We only let recognizers
   /// change the frame if this is the first time GetSelectedFrame is cal

[Lldb-commits] [lldb] [lldb] Expose the Target API mutex through the SB API (PR #133295)

2025-03-28 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

LGTM, though you might want to wait for Pavel's review since this was his 
suggestion originally.

https://github.com/llvm/llvm-project/pull/133295
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove raw access to PluginInstances vector (PR #132884)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM. Thanks!

https://github.com/llvm/llvm-project/pull/132884
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use *Set::insert_range and a range constructor (NFC) (PR #133548)

2025-03-28 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/133548
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b33cc64 - [lldb] Use *Set::insert_range and a range constructor (NFC) (#133548)

2025-03-28 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-03-28T19:54:30-07:00
New Revision: b33cc642ed398b13875dbb9099916affce355b49

URL: 
https://github.com/llvm/llvm-project/commit/b33cc642ed398b13875dbb9099916affce355b49
DIFF: 
https://github.com/llvm/llvm-project/commit/b33cc642ed398b13875dbb9099916affce355b49.diff

LOG: [lldb] Use *Set::insert_range and a range constructor (NFC) (#133548)

This patch uses *Set::insert_range and a range constructor of DenseSet
to clean up the code to populate sets.

Added: 


Modified: 
lldb/source/Host/common/NativeProcessProtocol.cpp
lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp

Removed: 




diff  --git a/lldb/source/Host/common/NativeProcessProtocol.cpp 
b/lldb/source/Host/common/NativeProcessProtocol.cpp
index e36eefaa6f4a4..405acbb5662d6 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -43,7 +43,7 @@ lldb_private::Status NativeProcessProtocol::Interrupt() {
 
 Status NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef signals) {
   m_signals_to_ignore.clear();
-  m_signals_to_ignore.insert(signals.begin(), signals.end());
+  m_signals_to_ignore.insert_range(signals);
   return Status();
 }
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 3ae32d4afd27a..9381a29f56f43 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -42,7 +42,7 @@ CxxModuleHandler::CxxModuleHandler(ASTImporter &importer, 
ASTContext *target)
   "allocator",
   "pair",
   };
-  m_supported_templates.insert(supported_names.begin(), supported_names.end());
+  m_supported_templates.insert_range(supported_names);
 }
 
 /// Builds a list of scopes that point into the given context.

diff  --git 
a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
index ec9576d4ab415..b1e47942de8e6 100644
--- a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
@@ -213,9 +213,8 @@ void SetInstructionBreakpointsRequestHandler::operator()(
   // Disable any instruction breakpoints that aren't in this request.
   // There is no call to remove instruction breakpoints other than calling this
   // function with a smaller or empty "breakpoints" list.
-  llvm::DenseSet seen;
-  for (const auto &addr : dap.instruction_breakpoints)
-seen.insert(addr.first);
+  llvm::DenseSet seen(
+  llvm::from_range, llvm::make_first_range(dap.instruction_breakpoints));
 
   for (const auto &bp : *breakpoints) {
 const auto *bp_obj = bp.getAsObject();



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

We recently added an explicit finalize to SBProgress, #128966. I 
realized while adding some additional implementations of SBProgress that we 
should to add `with` support for ease of use. This patch addresses adding and 
`__enter()__` method (which a no-op) and an `__exit()__` to swig. I also 
refactor the emitter for the test to leverage `with` instead of explicitly 
calling finalize, and I've updated the docstrings.

---
Full diff: https://github.com/llvm/llvm-project/pull/133527.diff


4 Files Affected:

- (modified) lldb/bindings/interface/SBProgressDocstrings.i (+7) 
- (added) lldb/bindings/interface/SBProgressExtensions.i (+13) 
- (modified) lldb/bindings/interfaces.swig (+1) 
- (modified) lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py (+10-13) 


``diff
diff --git a/lldb/bindings/interface/SBProgressDocstrings.i 
b/lldb/bindings/interface/SBProgressDocstrings.i
index 8d252ef1f370c..0aff4c502f3a4 100644
--- a/lldb/bindings/interface/SBProgressDocstrings.i
+++ b/lldb/bindings/interface/SBProgressDocstrings.i
@@ -52,6 +52,13 @@ Non-deterministic progresses behave the same, but omit the 
total in the construc
 # Explicitly send a progressEnd, otherwise this will be sent
 # when the python runtime cleans up this object.
 non_deterministic_progress.Finalize()
+
+Additionally for Python, progress is supported in a with statement. ::
+with lldb.SBProgress('Non deterministic progress, 'Detail', 
lldb.SBDebugger) as progress:
+for i in range(10):
+progress.Increment(1)
+# The progress object is automatically finalized when the with statement
+
 ") lldb::SBProgress;
 
 %feature("docstring",
diff --git a/lldb/bindings/interface/SBProgressExtensions.i 
b/lldb/bindings/interface/SBProgressExtensions.i
new file mode 100644
index 0..6ecf3a1af93b7
--- /dev/null
+++ b/lldb/bindings/interface/SBProgressExtensions.i
@@ -0,0 +1,13 @@
+%extend lldb::SBProgress {
+#ifdef SWIGPYTHON
+%pythoncode %{
+def __enter__(self):
+'''No-op for with statement'''
+pass
+
+def __exit__(self, exc_type, exc_value, traceback):
+'''Finalize the progress object'''
+self.Finalize()
+%}
+#endif
+}
\ No newline at end of file
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 08df9a1a8d539..6da56e4e0fa52 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -200,6 +200,7 @@
 %include "./interface/SBModuleSpecExtensions.i"
 %include "./interface/SBModuleSpecListExtensions.i"
 %include "./interface/SBProcessExtensions.i"
+%include "./interface/SBProgressExtensions.i"
 %include "./interface/SBProcessInfoListExtensions.i"
 %include "./interface/SBQueueItemExtensions.i"
 %include "./interface/SBScriptObjectExtensions.i"
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index e94a09676e067..445d1bdf4e496 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -88,21 +88,18 @@ def __call__(self, debugger, command, exe_ctx, result):
 progress = lldb.SBProgress(
 "Progress tester", "Initial Detail", total, debugger
 )
-
 # Check to see if total is set to None to indicate an indeterminate 
progress
 # then default to 10 steps.
-if total is None:
-total = 10
-
-for i in range(1, total):
-if cmd_options.no_details:
-progress.Increment(1)
-else:
-progress.Increment(1, f"Step {i}")
-time.sleep(cmd_options.seconds)
-
-# Not required for deterministic progress, but required for 
indeterminate progress.
-progress.Finalize()
+with progress:
+if total is None:
+total = 10
+
+for i in range(1, total):
+if cmd_options.no_details:
+progress.Increment(1)
+else:
+progress.Increment(1, f"Step {i}")
+time.sleep(cmd_options.seconds)
 
 
 def __lldb_init_module(debugger, dict):

``




https://github.com/llvm/llvm-project/pull/133527
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Combine disassembler gtest binaries for efficiency (PR #133539)

2025-03-28 Thread Reid Kleckner via lldb-commits

https://github.com/rnk created https://github.com/llvm/llvm-project/pull/133539

Each of these executables is 642MB for me locally with split DWARF, and we 
don't need 3 statically linked gtest binaries when one will do.

>From 1c16745d1779d91bcc0b34e1a82cc98e70def316 Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Fri, 28 Mar 2025 15:37:49 -0700
Subject: [PATCH] [lldb] Combine disassembler gtest binaries for efficiency

Each of these executables is 642MB for me locally with split DWARF, and
we don't need 3 statically linked gtest binaries when one will do.
---
 .../unittests/Disassembler/ARM/CMakeLists.txt | 12 -
 lldb/unittests/Disassembler/CMakeLists.txt| 27 ---
 .../Disassembler/RISCV/CMakeLists.txt | 12 -
 .../unittests/Disassembler/x86/CMakeLists.txt | 12 -
 4 files changed, 24 insertions(+), 39 deletions(-)
 delete mode 100644 lldb/unittests/Disassembler/ARM/CMakeLists.txt
 delete mode 100644 lldb/unittests/Disassembler/RISCV/CMakeLists.txt
 delete mode 100644 lldb/unittests/Disassembler/x86/CMakeLists.txt

diff --git a/lldb/unittests/Disassembler/ARM/CMakeLists.txt 
b/lldb/unittests/Disassembler/ARM/CMakeLists.txt
deleted file mode 100644
index 91af06fa19d6f..0
--- a/lldb/unittests/Disassembler/ARM/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(DisassemblerTests
-  TestArm64Disassembly.cpp
-  TestArmv7Disassembly.cpp
-  LINK_LIBS
-lldbCore
-lldbSymbol
-lldbTarget
-lldbPluginDisassemblerLLVMC
-lldbPluginProcessUtility
-  LINK_COMPONENTS
-Support
-${LLVM_TARGETS_TO_BUILD})
diff --git a/lldb/unittests/Disassembler/CMakeLists.txt 
b/lldb/unittests/Disassembler/CMakeLists.txt
index 208f1807427f4..4d443b69f29b1 100644
--- a/lldb/unittests/Disassembler/CMakeLists.txt
+++ b/lldb/unittests/Disassembler/CMakeLists.txt
@@ -1,11 +1,32 @@
+set(disas_srcs "")
+
 if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  add_subdirectory(ARM)
+  set(disas_srcs ${disas_srcs}
+ARM/TestArm64Disassembly.cpp
+ARM/TestArmv7Disassembly.cpp
+  )
 endif()
 
 if("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
-  add_subdirectory(x86)
+  set(disas_srcs ${disas_srcs}
+x86/TestGetControlFlowKindx86.cpp
+  )
 endif()
 
 if("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
-   add_subdirectory(RISCV)
+  set(disas_srcs ${disas_srcs}
+RISCV/TestMCDisasmInstanceRISCV.cpp
+  )
 endif()
+
+add_lldb_unittest(DisassemblerTests
+  ${disas_srcs}
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginDisassemblerLLVMC
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+${LLVM_TARGETS_TO_BUILD})
diff --git a/lldb/unittests/Disassembler/RISCV/CMakeLists.txt 
b/lldb/unittests/Disassembler/RISCV/CMakeLists.txt
deleted file mode 100644
index 5bcc3e948335c..0
--- a/lldb/unittests/Disassembler/RISCV/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(MCDisasmInstanceRISCVTests
-   TestMCDisasmInstanceRISCV.cpp
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  lldbPluginDisassemblerLLVMC
-  lldbPluginProcessUtility
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-  )
diff --git a/lldb/unittests/Disassembler/x86/CMakeLists.txt 
b/lldb/unittests/Disassembler/x86/CMakeLists.txt
deleted file mode 100644
index 31d84cf5d8365..0
--- a/lldb/unittests/Disassembler/x86/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(GetControlFlowKindx86Tests
-TestGetControlFlowKindx86.cpp
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  lldbPluginDisassemblerLLVMC
-  lldbPluginProcessUtility
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-  )

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> @JDevlieghere @bulbazord Is there a Discourse on the recent changes to the 
> terminal colors? On Linux I'm getting this white bar that crosses the whole 
> terminal. I think this is part of your reverse video change Jonas? 
> ![image](https://private-user-images.githubusercontent.com/25160653/428218316-95783b29-99a2-4423-bdc6-b2243790c328.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDMyMDE0OTgsIm5iZiI6MTc0MzIwMTE5OCwicGF0aCI6Ii8yNTE2MDY1My80MjgyMTgzMTYtOTU3ODNiMjktOTlhMi00NDIzLWJkYzYtYjIyNDM3OTBjMzI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAzMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMzI4VDIyMzMxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU5NDA5MjEyOGMwYTkwNDI3NTJlYTc2YmY0NDIwMjRhMzIzMGEzOGU0OWJkM2UxMGMwZTcwMjljZmExNjM0OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PmF7xP1gbFA2IYclCxw3MuDyjjQTdoEOS2ReWIQcbDc)

Yes, what you're seeing is the new 
[Statusline](https://discourse.llvm.org/t/rfc-lldb-statusline/83948/14). The 
reverse video change (#133315) just changes the default color. Based on your 
screenshot, that looks expected. 

https://github.com/llvm/llvm-project/pull/133527
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/133527

>From ec90252f34b358e1eba65f4b430d267833fa9ec8 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Fri, 28 Mar 2025 15:01:31 -0700
Subject: [PATCH 1/4] Implement methods for 'with' in python

---
 .../bindings/interface/SBProgressExtensions.i |  0
 .../lldb-dap/progress/Progress_emitter.py | 38 ++-
 2 files changed, 20 insertions(+), 18 deletions(-)
 create mode 100644 lldb/bindings/interface/SBProgressExtensions.i

diff --git a/lldb/bindings/interface/SBProgressExtensions.i 
b/lldb/bindings/interface/SBProgressExtensions.i
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index e94a09676e067..140a6fce99b48 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -67,6 +67,16 @@ def get_short_help(self):
 def get_long_help(self):
 return self.help_string
 
+def __get__progress(self, debugger, total):
+if total is None:
+progress = lldb.SBProgress(
+"Progress tester", "Initial Indeterminate Detail", debugger
+)
+else:
+progress = lldb.SBProgress(
+"Progress tester", "Initial Detail", total, debugger
+)
+
 def __init__(self, debugger, unused):
 self.parser = self.create_options()
 self.help_string = self.parser.format_help()
@@ -80,26 +90,18 @@ def __call__(self, debugger, command, exe_ctx, result):
 return
 
 total = cmd_options.total
-if total is None:
-progress = lldb.SBProgress(
-"Progress tester", "Initial Indeterminate Detail", debugger
-)
-else:
-progress = lldb.SBProgress(
-"Progress tester", "Initial Detail", total, debugger
-)
-
 # Check to see if total is set to None to indicate an indeterminate 
progress
 # then default to 10 steps.
-if total is None:
-total = 10
-
-for i in range(1, total):
-if cmd_options.no_details:
-progress.Increment(1)
-else:
-progress.Increment(1, f"Step {i}")
-time.sleep(cmd_options.seconds)
+with self.__get_progress(debugger, total) as progress:
+if total is None:
+total = 10
+
+for i in range(1, total):
+if cmd_options.no_details:
+progress.Increment(1)
+else:
+progress.Increment(1, f"Step {i}")
+time.sleep(cmd_options.seconds)
 
 # Not required for deterministic progress, but required for 
indeterminate progress.
 progress.Finalize()

>From 353aac719f3223683eab21b113d22043c5ad9575 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Fri, 28 Mar 2025 15:19:29 -0700
Subject: [PATCH 2/4] Fix swig interfaces, and the emitter class

---
 .../bindings/interface/SBProgressExtensions.i | 13 +++
 lldb/bindings/interfaces.swig |  1 +
 .../lldb-dap/progress/Progress_emitter.py | 23 ---
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/lldb/bindings/interface/SBProgressExtensions.i 
b/lldb/bindings/interface/SBProgressExtensions.i
index e69de29bb2d1d..6ecf3a1af93b7 100644
--- a/lldb/bindings/interface/SBProgressExtensions.i
+++ b/lldb/bindings/interface/SBProgressExtensions.i
@@ -0,0 +1,13 @@
+%extend lldb::SBProgress {
+#ifdef SWIGPYTHON
+%pythoncode %{
+def __enter__(self):
+'''No-op for with statement'''
+pass
+
+def __exit__(self, exc_type, exc_value, traceback):
+'''Finalize the progress object'''
+self.Finalize()
+%}
+#endif
+}
\ No newline at end of file
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 08df9a1a8d539..6da56e4e0fa52 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -200,6 +200,7 @@
 %include "./interface/SBModuleSpecExtensions.i"
 %include "./interface/SBModuleSpecListExtensions.i"
 %include "./interface/SBProcessExtensions.i"
+%include "./interface/SBProgressExtensions.i"
 %include "./interface/SBProcessInfoListExtensions.i"
 %include "./interface/SBQueueItemExtensions.i"
 %include "./interface/SBScriptObjectExtensions.i"
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index 140a6fce99b48..445d1bdf4e496 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -67,16 +67,6 @@ def get_short_help(self):
 def get_long_help(self):
 return self.help_string
 
-def __get__pro

[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Jacob Lalonde via lldb-commits


@@ -52,6 +52,13 @@ Non-deterministic progresses behave the same, but omit the 
total in the construc
 # Explicitly send a progressEnd, otherwise this will be sent
 # when the python runtime cleans up this object.
 non_deterministic_progress.Finalize()
+
+Additionally for Python, progress is supported in a with statement. ::
+with lldb.SBProgress('Non deterministic progress, 'Detail', 
lldb.SBDebugger) as progress:

Jlalond wrote:

It's copied from above, and that was also unescaped, good catch

https://github.com/llvm/llvm-project/pull/133527
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 812efdb - [lldb-dap] Bump the version to 0.2.11

2025-03-28 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2025-03-28T13:20:37-07:00
New Revision: 812efdb0940f82fbfd2a139573764364cb55cdc2

URL: 
https://github.com/llvm/llvm-project/commit/812efdb0940f82fbfd2a139573764364cb55cdc2
DIFF: 
https://github.com/llvm/llvm-project/commit/812efdb0940f82fbfd2a139573764364cb55cdc2.diff

LOG: [lldb-dap] Bump the version to 0.2.11

Added: 


Modified: 
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 289e07c12682c..c339178cbc126 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -1,7 +1,7 @@
 {
   "name": "lldb-dap",
   "displayName": "LLDB DAP",
-  "version": "0.2.10",
+  "version": "0.2.11",
   "publisher": "llvm-vs-code-extensions",
   "homepage": "https://lldb.llvm.org";,
   "description": "Debugging with LLDB in Visual Studio Code",



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use *Set::insert_range and a range constructor (NFC) (PR #133548)

2025-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes

This patch uses *Set::insert_range and a range constructor of DenseSet
to clean up the code to populate sets.


---
Full diff: https://github.com/llvm/llvm-project/pull/133548.diff


3 Files Affected:

- (modified) lldb/source/Host/common/NativeProcessProtocol.cpp (+1-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
(+1-1) 
- (modified) 
lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp (+2-3) 


``diff
diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp 
b/lldb/source/Host/common/NativeProcessProtocol.cpp
index e36eefaa6f4a4..405acbb5662d6 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -43,7 +43,7 @@ lldb_private::Status NativeProcessProtocol::Interrupt() {
 
 Status NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef signals) {
   m_signals_to_ignore.clear();
-  m_signals_to_ignore.insert(signals.begin(), signals.end());
+  m_signals_to_ignore.insert_range(signals);
   return Status();
 }
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 3ae32d4afd27a..9381a29f56f43 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -42,7 +42,7 @@ CxxModuleHandler::CxxModuleHandler(ASTImporter &importer, 
ASTContext *target)
   "allocator",
   "pair",
   };
-  m_supported_templates.insert(supported_names.begin(), supported_names.end());
+  m_supported_templates.insert_range(supported_names);
 }
 
 /// Builds a list of scopes that point into the given context.
diff --git 
a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
index ec9576d4ab415..b1e47942de8e6 100644
--- a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
@@ -213,9 +213,8 @@ void SetInstructionBreakpointsRequestHandler::operator()(
   // Disable any instruction breakpoints that aren't in this request.
   // There is no call to remove instruction breakpoints other than calling this
   // function with a smaller or empty "breakpoints" list.
-  llvm::DenseSet seen;
-  for (const auto &addr : dap.instruction_breakpoints)
-seen.insert(addr.first);
+  llvm::DenseSet seen(
+  llvm::from_range, llvm::make_first_range(dap.instruction_breakpoints));
 
   for (const auto &bp : *breakpoints) {
 const auto *bp_obj = bp.getAsObject();

``




https://github.com/llvm/llvm-project/pull/133548
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Alexandre Perez via lldb-commits


@@ -52,6 +52,13 @@ Non-deterministic progresses behave the same, but omit the 
total in the construc
 # Explicitly send a progressEnd, otherwise this will be sent
 # when the python runtime cleans up this object.
 non_deterministic_progress.Finalize()
+
+Additionally for Python, progress is supported in a with statement. ::
+with lldb.SBProgress('Non deterministic progress, 'Detail', 
lldb.SBDebugger) as progress:

aperez wrote:

Just a nit, the string in the first argument is not terminated:
```
with lldb.SBProgress('Non deterministic progress', 'Detail', lldb.SBDebugger) 
as progress:
```

https://github.com/llvm/llvm-project/pull/133527
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8ea3f81 - [lldb][test] TestCCallingConventions.py: skip on older AArch64 compilers

2025-03-28 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-03-28T15:32:18Z
New Revision: 8ea3f818dea7d1104429040486614c96e0698901

URL: 
https://github.com/llvm/llvm-project/commit/8ea3f818dea7d1104429040486614c96e0698901
DIFF: 
https://github.com/llvm/llvm-project/commit/8ea3f818dea7d1104429040486614c96e0698901.diff

LOG: [lldb][test] TestCCallingConventions.py: skip on older AArch64 compilers

With our Clang-15 arm64 CI this test-case crashes when compiling the test 
program:
```
user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c
Unexpected callee-save save/restore opcode!
UNREACHABLE executed at 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:1129!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501_build/bin/clang
 -g -O0 -isysroot 
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
 -arch arm64 
-I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include
 
-I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/lldb-build/tools/lldb/include
 
-I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions
 
-I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make
 -include 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
 -fno-limit-debug-info -Werror=ignored-attributes -MT ms_abi.o -MD -MP -MF 
ms_abi.d -c -o ms_abi.o 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c
1.   parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 
'/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c'.
4.  Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on 
function '@func'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH 
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-15 0x000105d512b0 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  clang-15 0x000105d500e4 llvm::sys::RunSignalHandlers() + 
112
2  clang-15 0x000105d507c4 
llvm::sys::CleanupOnSignal(unsigned long) + 232
3  clang-15 0x000105c79d78 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 128
4  clang-15 0x000105c79f94 CrashRecoverySignalHandler(int) 
+ 124
5  libsystem_platform.dylib 0x000185ecba24 _sigtramp + 56
6  libsystem_pthread.dylib  0x000185e9ccc0 pthread_kill + 288
7  libsystem_c.dylib0x000185daca40 abort + 180
8  clang-15 0x000105c88508 
llvm::install_out_of_memory_new_handler() + 0
9  clang-15 0x000104af7404 
fixupCalleeSaveRestoreStackOffset(llvm::MachineInstr&, unsigned long long, 
bool, bool*) + 0
10 clang-15 0x000104af53e0 
llvm::AArch64FrameLowering::emitPrologue(llvm::MachineFunction&, 
llvm::MachineBasicBlock&) const + 3564
```

Added: 


Modified: 
lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py

Removed: 




diff  --git 
a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py 
b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
index 0304482e899b8..9540dc066f308 100644
--- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
+++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
@@ -50,6 +50,7 @@ def test_regcall(self):
 return
 self.expect_expr("func(1, 2, 3, 4)", result_type="int", 
result_value="10")
 
+@skipIf(compiler="clang", compiler_version=["<", "17.0"], archs=["arm64"])
 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
 def test_ms_abi(self):
 if not self.build_and_run("ms_abi.c"):



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/133078

>From 4a0d13ef2751071505ab797c63c2ee20d14a6c61 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 13:20:24 +
Subject: [PATCH 1/3] [lldb][Target] Clear selected frame index after a
 StopInfo::PerformAction

---
 lldb/include/lldb/Target/StackFrameList.h | 3 +++
 lldb/include/lldb/Target/Thread.h | 5 +
 lldb/source/Target/Process.cpp| 2 ++
 lldb/source/Target/StackFrameList.cpp | 4 
 4 files changed, 14 insertions(+)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..d805b644b0b31 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -46,6 +46,9 @@ class StackFrameList {
   /// Mark a stack frame as the currently selected frame and return its index.
   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex();
+
   /// Get the currently selected frame index.
   /// We should only call SelectMostRelevantFrame if (a) the user hasn't 
already
   /// selected a frame, and (b) if this really is a user facing
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 6ede7fa301a82..688c056da2633 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -479,6 +479,11 @@ class Thread : public std::enable_shared_from_this,
   bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
   Stream &output_stream);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex() {
+return GetStackFrameList()->ClearSelectedFrameIndex();
+  }
+
   void SetDefaultFileAndLineToSelectedFrame() {
 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
   }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..c51bab20f56ee 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4295,6 +4295,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+thread_sp->ClearSelectedFrameIndex();
+
 // FIXME: we might have run.
 if (stop_info_sp->HasTargetRunSinceMe()) {
   SetRestarted(true);
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 9c6208e9e0a65..3592c3c03db74 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {
+  m_selected_frame_idx.reset();
+}

>From 1a1a55786de369b1c9771623c21de459848c7e20 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 13:35:23 +
Subject: [PATCH 2/3] fixup! clang-format

---
 lldb/source/Target/Process.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c51bab20f56ee..46e8028160d04 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4295,6 +4295,12 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+// Clear the selected frame which may have been set as part of utility
+// expressions that have been run as part of this stop. If we didn't
+// clear this, then StopInfo::GetSuggestedStackFrameIndex would not
+// take affect when we next called SelectMostRelevantFrame. 
PerformAction
+// should not be the one setting a selected frame, instead this should 
be
+// done via GetSuggestedStackFrameIndex.
 thread_sp->ClearSelectedFrameIndex();
 
 // FIXME: we might have run.

>From 158f0b2cd664ba1864e510bf8293d16790c6a65a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 28 Mar 2025 15:40:47 +
Subject: [PATCH 3/3] fixup! add thread-safety comment

---
 lldb/include/lldb/Target/StackFrameList.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index d805b644b0b31..8d455dc831df3 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -175,6 +175,15 @@ class StackFrameList {
   /// The currently selected frame. An optional is used to record whether 
anyone
   /// has set the selected frame on this stack yet. We only let recognizers
   /// change the frame if this is the first time GetSelectedFrame is cal

[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-28 Thread Michael Buch via lldb-commits


@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {

Michael137 wrote:

I see, yea it would be pretty unusual for two bits of LLDB to try to control 
this. Could be called concurrently `ProcessEventData::ShouldStop` and access 
the same `StackFrameList` somehow?

I added your explanation as to why we might not need synchronization to the 
member documentation.

https://github.com/llvm/llvm-project/pull/133078
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/133078
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

2025-03-28 Thread John Harrison via lldb-commits

https://github.com/ashgti closed 
https://github.com/llvm/llvm-project/pull/133007
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-03-28 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129728

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/23] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-03-28 Thread Vy Nguyen via lldb-commits


@@ -965,6 +965,22 @@ SBTarget SBDebugger::GetDummyTarget() {
   return sb_target;
 }
 
+void SBDebugger::DispatchClientTelemetry(const lldb::SBStructuredData &entry) {
+  LLDB_INSTRUMENT_VA(this);
+  // Disable client-telemetry for SWIG.
+  // This prevent arbitrary python client (pretty printers, whatnot) from 
sending
+  // telemetry without vendors knowing.
+#ifndef SWIG

oontvoo wrote:

Ok, I've defined a ENABLE_CLIENT_TELEMETRY macro at the top of SBDebugger and 
use the ifdef with it.
(It's currently hard-coded to `! SWIG` , might be overkill to make that a build 
option? )

https://github.com/llvm/llvm-project/pull/129728
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-03-28 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129728

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/22] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/133542

Running tests with ubsan enabled showed that the current 
`protocol::AdapterFeature` and `protocol::ClientFeature` enums are incorrectly 
defined if we want to use them in a `llvm::DenseSet`. The enums are currently 
untyped and this results in the undefined behavior.

Adding `FLAGS_ENUM()` wrappers to all the enums in the `lldb-dap::protocol` 
namespace to ensure they're typed so they can be used with types like 
`llvm::DenseSet`.

>From 55aa8ef8cc65307948a1cf0803c5c7c240be0efa Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 28 Mar 2025 16:29:06 -0700
Subject: [PATCH] [lldb-dap] Addressing ubsan enum usage.

Running tests with ubsan enabled showed that the current 
protocol::AdapterFeature and protocol::ClientFeature enums are incorrectly 
defined if we want to use them in a `llvm::DenseSet`. The enums are currently 
untyped and this results in the undefined behavior.

Adding `FLAGS_ENUM()` wrappers to all the enums in the `lldb-dap::protocol` 
namespace to ensure they're typed so they can be used with types like 
`llvm::DenseSet`.
---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp |  24 +-
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  15 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  |  36 +--
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  | 235 +-
 4 files changed, 152 insertions(+), 158 deletions(-)

diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index 86e26f4deb111..0d63e37d3eafb 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Protocol/ProtocolBase.h"
+#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -31,11 +32,8 @@ static bool mapRaw(const json::Value &Params, StringLiteral 
Prop,
 
 namespace lldb_dap::protocol {
 
-enum MessageType {
-  eMessageTypeRequest,
-  eMessageTypeResponse,
-  eMessageTypeEvent
-};
+FLAGS_ENUM(MessageType){eMessageTypeRequest, eMessageTypeResponse,
+eMessageTypeEvent};
 
 bool fromJSON(const json::Value &Params, MessageType &M, json::Path P) {
   auto rawType = Params.getAsString();
@@ -107,12 +105,12 @@ json::Value toJSON(const Response &R) {
 
   if (R.message) {
 assert(!R.success && "message can only be used if success is false");
-if (const auto *messageEnum = std::get_if(&*R.message)) 
{
+if (const auto *messageEnum = std::get_if(&*R.message)) {
   switch (*messageEnum) {
-  case Response::Message::cancelled:
+  case eResponseMessageCancelled:
 Result.insert({"message", "cancelled"});
 break;
-  case Response::Message::notStopped:
+  case eResponseMessageNotStopped:
 Result.insert({"message", "notStopped"});
 break;
   }
@@ -129,16 +127,16 @@ json::Value toJSON(const Response &R) {
 }
 
 bool fromJSON(json::Value const &Params,
-  std::variant &M, json::Path P) {
+  std::variant &M, json::Path P) {
   auto rawMessage = Params.getAsString();
   if (!rawMessage) {
 P.report("expected a string");
 return false;
   }
-  std::optional message =
-  StringSwitch>(*rawMessage)
-  .Case("cancelled", Response::Message::cancelled)
-  .Case("notStopped", Response::Message::notStopped)
+  std::optional message =
+  StringSwitch>(*rawMessage)
+  .Case("cancelled", eResponseMessageCancelled)
+  .Case("notStopped", eResponseMessageNotStopped)
   .Default(std::nullopt);
   if (message)
 M = *message;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
index baf5f8f165183..5ac68e38cb9c4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
@@ -20,6 +20,7 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 
+#include "lldb/lldb-enumerations.h"
 #include "llvm/Support/JSON.h"
 #include 
 #include 
@@ -64,15 +65,15 @@ struct Event {
 llvm::json::Value toJSON(const Event &);
 bool fromJSON(const llvm::json::Value &, Event &, llvm::json::Path);
 
-/// Response for a request.
-struct Response {
-  enum class Message {
+FLAGS_ENUM(ResponseMessage){
 /// The request was cancelled
-cancelled,
+eResponseMessageCancelled,
 /// The request may be retried once the adapter is in a 'stopped' state
-notStopped,
-  };
+eResponseMessageNotStopped,
+};
 
+/// Response for a request.
+struct Response {
   /// Sequence number of the corresponding request.
   int64_t request_seq;
 
@@ -90,7 +91,7 @@ struct Response {
   /// Contains the raw error in short form if `success` is false. This raw 
error
   /// might be interpreted by th

[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Running tests with ubsan enabled showed that the current 
`protocol::AdapterFeature` and `protocol::ClientFeature` enums are incorrectly 
defined if we want to use them in a `llvm::DenseSet`. The enums are currently 
untyped and this results in the undefined behavior.

Adding `FLAGS_ENUM()` wrappers to all the enums in the `lldb-dap::protocol` 
namespace to ensure they're typed so they can be used with types like 
`llvm::DenseSet`.

---
Full diff: https://github.com/llvm/llvm-project/pull/133542.diff


4 Files Affected:

- (modified) lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp (+11-13) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolBase.h (+8-7) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+19-17) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.h (+114-121) 


``diff
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index 86e26f4deb111..0d63e37d3eafb 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Protocol/ProtocolBase.h"
+#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -31,11 +32,8 @@ static bool mapRaw(const json::Value &Params, StringLiteral 
Prop,
 
 namespace lldb_dap::protocol {
 
-enum MessageType {
-  eMessageTypeRequest,
-  eMessageTypeResponse,
-  eMessageTypeEvent
-};
+FLAGS_ENUM(MessageType){eMessageTypeRequest, eMessageTypeResponse,
+eMessageTypeEvent};
 
 bool fromJSON(const json::Value &Params, MessageType &M, json::Path P) {
   auto rawType = Params.getAsString();
@@ -107,12 +105,12 @@ json::Value toJSON(const Response &R) {
 
   if (R.message) {
 assert(!R.success && "message can only be used if success is false");
-if (const auto *messageEnum = std::get_if(&*R.message)) 
{
+if (const auto *messageEnum = std::get_if(&*R.message)) {
   switch (*messageEnum) {
-  case Response::Message::cancelled:
+  case eResponseMessageCancelled:
 Result.insert({"message", "cancelled"});
 break;
-  case Response::Message::notStopped:
+  case eResponseMessageNotStopped:
 Result.insert({"message", "notStopped"});
 break;
   }
@@ -129,16 +127,16 @@ json::Value toJSON(const Response &R) {
 }
 
 bool fromJSON(json::Value const &Params,
-  std::variant &M, json::Path P) {
+  std::variant &M, json::Path P) {
   auto rawMessage = Params.getAsString();
   if (!rawMessage) {
 P.report("expected a string");
 return false;
   }
-  std::optional message =
-  StringSwitch>(*rawMessage)
-  .Case("cancelled", Response::Message::cancelled)
-  .Case("notStopped", Response::Message::notStopped)
+  std::optional message =
+  StringSwitch>(*rawMessage)
+  .Case("cancelled", eResponseMessageCancelled)
+  .Case("notStopped", eResponseMessageNotStopped)
   .Default(std::nullopt);
   if (message)
 M = *message;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
index baf5f8f165183..5ac68e38cb9c4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
@@ -20,6 +20,7 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 
+#include "lldb/lldb-enumerations.h"
 #include "llvm/Support/JSON.h"
 #include 
 #include 
@@ -64,15 +65,15 @@ struct Event {
 llvm::json::Value toJSON(const Event &);
 bool fromJSON(const llvm::json::Value &, Event &, llvm::json::Path);
 
-/// Response for a request.
-struct Response {
-  enum class Message {
+FLAGS_ENUM(ResponseMessage){
 /// The request was cancelled
-cancelled,
+eResponseMessageCancelled,
 /// The request may be retried once the adapter is in a 'stopped' state
-notStopped,
-  };
+eResponseMessageNotStopped,
+};
 
+/// Response for a request.
+struct Response {
   /// Sequence number of the corresponding request.
   int64_t request_seq;
 
@@ -90,7 +91,7 @@ struct Response {
   /// Contains the raw error in short form if `success` is false. This raw 
error
   /// might be interpreted by the client and is not shown in the UI. Some
   /// predefined values exist.
-  std::optional> message;
+  std::optional> message;
 
   /// Contains request result if success is true and error details if success 
is
   /// false.
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index c49a13711f8c7..116cf8516c52e 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -22,6 +22,8 @@
 
 #include "Protocol/Protoco

[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread Walter Lee via lldb-commits

https://github.com/googlewalt approved this pull request.


https://github.com/llvm/llvm-project/pull/133542
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/133542

>From 55aa8ef8cc65307948a1cf0803c5c7c240be0efa Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 28 Mar 2025 16:29:06 -0700
Subject: [PATCH 1/2] [lldb-dap] Addressing ubsan enum usage.

Running tests with ubsan enabled showed that the current 
protocol::AdapterFeature and protocol::ClientFeature enums are incorrectly 
defined if we want to use them in a `llvm::DenseSet`. The enums are currently 
untyped and this results in the undefined behavior.

Adding `FLAGS_ENUM()` wrappers to all the enums in the `lldb-dap::protocol` 
namespace to ensure they're typed so they can be used with types like 
`llvm::DenseSet`.
---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp |  24 +-
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  15 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  |  36 +--
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  | 235 +-
 4 files changed, 152 insertions(+), 158 deletions(-)

diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index 86e26f4deb111..0d63e37d3eafb 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Protocol/ProtocolBase.h"
+#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -31,11 +32,8 @@ static bool mapRaw(const json::Value &Params, StringLiteral 
Prop,
 
 namespace lldb_dap::protocol {
 
-enum MessageType {
-  eMessageTypeRequest,
-  eMessageTypeResponse,
-  eMessageTypeEvent
-};
+FLAGS_ENUM(MessageType){eMessageTypeRequest, eMessageTypeResponse,
+eMessageTypeEvent};
 
 bool fromJSON(const json::Value &Params, MessageType &M, json::Path P) {
   auto rawType = Params.getAsString();
@@ -107,12 +105,12 @@ json::Value toJSON(const Response &R) {
 
   if (R.message) {
 assert(!R.success && "message can only be used if success is false");
-if (const auto *messageEnum = std::get_if(&*R.message)) 
{
+if (const auto *messageEnum = std::get_if(&*R.message)) {
   switch (*messageEnum) {
-  case Response::Message::cancelled:
+  case eResponseMessageCancelled:
 Result.insert({"message", "cancelled"});
 break;
-  case Response::Message::notStopped:
+  case eResponseMessageNotStopped:
 Result.insert({"message", "notStopped"});
 break;
   }
@@ -129,16 +127,16 @@ json::Value toJSON(const Response &R) {
 }
 
 bool fromJSON(json::Value const &Params,
-  std::variant &M, json::Path P) {
+  std::variant &M, json::Path P) {
   auto rawMessage = Params.getAsString();
   if (!rawMessage) {
 P.report("expected a string");
 return false;
   }
-  std::optional message =
-  StringSwitch>(*rawMessage)
-  .Case("cancelled", Response::Message::cancelled)
-  .Case("notStopped", Response::Message::notStopped)
+  std::optional message =
+  StringSwitch>(*rawMessage)
+  .Case("cancelled", eResponseMessageCancelled)
+  .Case("notStopped", eResponseMessageNotStopped)
   .Default(std::nullopt);
   if (message)
 M = *message;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
index baf5f8f165183..5ac68e38cb9c4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
@@ -20,6 +20,7 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 
+#include "lldb/lldb-enumerations.h"
 #include "llvm/Support/JSON.h"
 #include 
 #include 
@@ -64,15 +65,15 @@ struct Event {
 llvm::json::Value toJSON(const Event &);
 bool fromJSON(const llvm::json::Value &, Event &, llvm::json::Path);
 
-/// Response for a request.
-struct Response {
-  enum class Message {
+FLAGS_ENUM(ResponseMessage){
 /// The request was cancelled
-cancelled,
+eResponseMessageCancelled,
 /// The request may be retried once the adapter is in a 'stopped' state
-notStopped,
-  };
+eResponseMessageNotStopped,
+};
 
+/// Response for a request.
+struct Response {
   /// Sequence number of the corresponding request.
   int64_t request_seq;
 
@@ -90,7 +91,7 @@ struct Response {
   /// Contains the raw error in short form if `success` is false. This raw 
error
   /// might be interpreted by the client and is not shown in the UI. Some
   /// predefined values exist.
-  std::optional> message;
+  std::optional> message;
 
   /// Contains request result if success is true and error details if success 
is
   /// false.
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index c49a13711f8c7..116cf8516c52e 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.

[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@JDevlieghere @bulbazord Is there a Discourse on the recent changes to the 
terminal colors? On Linux I'm getting this white bar that crosses the whole 
terminal. I think this is part of your reverse video change Jonas?
![image](https://github.com/user-attachments/assets/95783b29-99a2-4423-bdc6-b2243790c328)


https://github.com/llvm/llvm-project/pull/133527
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread Walter Lee via lldb-commits

https://github.com/googlewalt approved this pull request.


https://github.com/llvm/llvm-project/pull/133542
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Expose the Target API lock through the SB API (PR #131404)

2025-03-28 Thread Pavel Labath via lldb-commits


@@ -1692,6 +1692,20 @@ class Target : public 
std::enable_shared_from_this,
   }
 };
 
+/// The private implementation backing SBLock.
+struct APILock {
+  APILock(std::recursive_mutex &mutex) : lock(mutex) {}
+  std::lock_guard lock;
+};
+
+/// The private implementation used by SBLock to hand out the target API mutex.
+/// It has a TargetSP to ensure the lock cannot outlive the target.
+struct TargetAPILock : public APILock {

labath wrote:

What I meant was that you don't need the *Target*APILock class as this can be 
implemented generically in the APILock base class (although it looks like my 
snippet https://github.com/llvm/llvm-project/pull/131404/files#r1998175315 
still calls this TargetAPILock). I.e., you could do something like:

```
class APILock {
  APILock(std::shared_ptr mutex) : 
m_mutex(std::move(mutex)), m_lock(*m_mutex) {}

private:
  std::shared_ptr m_mutex;
  std::lock_guard m_lock;
};
```

and this can be used with anything that can turn itself into a shared pointer 
(using the aliasing constructor)

https://github.com/llvm/llvm-project/pull/131404
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-03-28 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/133527

We recently added an explicit finalize to SBProgress, #128966. I realized while 
adding some additional implementations of SBProgress that we should to add 
`with` support for ease of use. This patch addresses adding and `__enter()__` 
method (which a no-op) and an `__exit()__` to swig. I also refactor the emitter 
for the test to leverage `with` instead of explicitly calling finalize, and 
I've updated the docstrings.

>From ec90252f34b358e1eba65f4b430d267833fa9ec8 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Fri, 28 Mar 2025 15:01:31 -0700
Subject: [PATCH 1/3] Implement methods for 'with' in python

---
 .../bindings/interface/SBProgressExtensions.i |  0
 .../lldb-dap/progress/Progress_emitter.py | 38 ++-
 2 files changed, 20 insertions(+), 18 deletions(-)
 create mode 100644 lldb/bindings/interface/SBProgressExtensions.i

diff --git a/lldb/bindings/interface/SBProgressExtensions.i 
b/lldb/bindings/interface/SBProgressExtensions.i
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index e94a09676e067..140a6fce99b48 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -67,6 +67,16 @@ def get_short_help(self):
 def get_long_help(self):
 return self.help_string
 
+def __get__progress(self, debugger, total):
+if total is None:
+progress = lldb.SBProgress(
+"Progress tester", "Initial Indeterminate Detail", debugger
+)
+else:
+progress = lldb.SBProgress(
+"Progress tester", "Initial Detail", total, debugger
+)
+
 def __init__(self, debugger, unused):
 self.parser = self.create_options()
 self.help_string = self.parser.format_help()
@@ -80,26 +90,18 @@ def __call__(self, debugger, command, exe_ctx, result):
 return
 
 total = cmd_options.total
-if total is None:
-progress = lldb.SBProgress(
-"Progress tester", "Initial Indeterminate Detail", debugger
-)
-else:
-progress = lldb.SBProgress(
-"Progress tester", "Initial Detail", total, debugger
-)
-
 # Check to see if total is set to None to indicate an indeterminate 
progress
 # then default to 10 steps.
-if total is None:
-total = 10
-
-for i in range(1, total):
-if cmd_options.no_details:
-progress.Increment(1)
-else:
-progress.Increment(1, f"Step {i}")
-time.sleep(cmd_options.seconds)
+with self.__get_progress(debugger, total) as progress:
+if total is None:
+total = 10
+
+for i in range(1, total):
+if cmd_options.no_details:
+progress.Increment(1)
+else:
+progress.Increment(1, f"Step {i}")
+time.sleep(cmd_options.seconds)
 
 # Not required for deterministic progress, but required for 
indeterminate progress.
 progress.Finalize()

>From 353aac719f3223683eab21b113d22043c5ad9575 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Fri, 28 Mar 2025 15:19:29 -0700
Subject: [PATCH 2/3] Fix swig interfaces, and the emitter class

---
 .../bindings/interface/SBProgressExtensions.i | 13 +++
 lldb/bindings/interfaces.swig |  1 +
 .../lldb-dap/progress/Progress_emitter.py | 23 ---
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/lldb/bindings/interface/SBProgressExtensions.i 
b/lldb/bindings/interface/SBProgressExtensions.i
index e69de29bb2d1d..6ecf3a1af93b7 100644
--- a/lldb/bindings/interface/SBProgressExtensions.i
+++ b/lldb/bindings/interface/SBProgressExtensions.i
@@ -0,0 +1,13 @@
+%extend lldb::SBProgress {
+#ifdef SWIGPYTHON
+%pythoncode %{
+def __enter__(self):
+'''No-op for with statement'''
+pass
+
+def __exit__(self, exc_type, exc_value, traceback):
+'''Finalize the progress object'''
+self.Finalize()
+%}
+#endif
+}
\ No newline at end of file
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 08df9a1a8d539..6da56e4e0fa52 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -200,6 +200,7 @@
 %include "./interface/SBModuleSpecExtensions.i"
 %include "./interface/SBModuleSpecListExtensions.i"
 %include "./interface/SBProcessExtensions.i"
+%include "./interface/SBProgressExtensions.i"
 %include "./interface/SBProcessInfoListExtensions.i"
 %include "./interface/SBQueueItemExtensions.i"
 %include "./interface/SBScriptObjectExtensions.i"
diff --

[Lldb-commits] [lldb] 539ef5e - [lldb-dap] Addressing ubsan enum usage. (#133542)

2025-03-28 Thread via lldb-commits

Author: John Harrison
Date: 2025-03-28T20:35:19-05:00
New Revision: 539ef5eee2c26b93923ed7872c6f847ff54c71ae

URL: 
https://github.com/llvm/llvm-project/commit/539ef5eee2c26b93923ed7872c6f847ff54c71ae
DIFF: 
https://github.com/llvm/llvm-project/commit/539ef5eee2c26b93923ed7872c6f847ff54c71ae.diff

LOG: [lldb-dap] Addressing ubsan enum usage. (#133542)

Running tests with ubsan enabled showed that the current
`protocol::AdapterFeature` and `protocol::ClientFeature` enums are
incorrectly defined if we want to use them in a `llvm::DenseSet`. The
enums are currently untyped and this results in the undefined behavior.

Adding `FLAGS_ENUM()` wrappers to all the enums in the
`lldb-dap::protocol` namespace to ensure they're typed so they can be
used with types like `llvm::DenseSet`.

Added: 


Modified: 
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
lldb/tools/lldb-dap/Protocol/ProtocolBase.h
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 23f0400c8bd4d..512cabdf77880 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -711,12 +711,12 @@ bool DAP::HandleObject(const protocol::Message &M) {
[](const std::string &message) -> llvm::StringRef {
  return message;
},
-   [](const protocol::Response::Message &message)
+   [](const protocol::ResponseMessage &message)
-> llvm::StringRef {
  switch (message) {
- case protocol::Response::Message::cancelled:
+ case protocol::eResponseMessageCancelled:
return "cancelled";
- case protocol::Response::Message::notStopped:
+ case protocol::eResponseMessageNotStopped:
return "notStopped";
  }
}),

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index 86e26f4deb111..0d63e37d3eafb 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Protocol/ProtocolBase.h"
+#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -31,11 +32,8 @@ static bool mapRaw(const json::Value &Params, StringLiteral 
Prop,
 
 namespace lldb_dap::protocol {
 
-enum MessageType {
-  eMessageTypeRequest,
-  eMessageTypeResponse,
-  eMessageTypeEvent
-};
+FLAGS_ENUM(MessageType){eMessageTypeRequest, eMessageTypeResponse,
+eMessageTypeEvent};
 
 bool fromJSON(const json::Value &Params, MessageType &M, json::Path P) {
   auto rawType = Params.getAsString();
@@ -107,12 +105,12 @@ json::Value toJSON(const Response &R) {
 
   if (R.message) {
 assert(!R.success && "message can only be used if success is false");
-if (const auto *messageEnum = std::get_if(&*R.message)) 
{
+if (const auto *messageEnum = std::get_if(&*R.message)) {
   switch (*messageEnum) {
-  case Response::Message::cancelled:
+  case eResponseMessageCancelled:
 Result.insert({"message", "cancelled"});
 break;
-  case Response::Message::notStopped:
+  case eResponseMessageNotStopped:
 Result.insert({"message", "notStopped"});
 break;
   }
@@ -129,16 +127,16 @@ json::Value toJSON(const Response &R) {
 }
 
 bool fromJSON(json::Value const &Params,
-  std::variant &M, json::Path P) {
+  std::variant &M, json::Path P) {
   auto rawMessage = Params.getAsString();
   if (!rawMessage) {
 P.report("expected a string");
 return false;
   }
-  std::optional message =
-  StringSwitch>(*rawMessage)
-  .Case("cancelled", Response::Message::cancelled)
-  .Case("notStopped", Response::Message::notStopped)
+  std::optional message =
+  StringSwitch>(*rawMessage)
+  .Case("cancelled", eResponseMessageCancelled)
+  .Case("notStopped", eResponseMessageNotStopped)
   .Default(std::nullopt);
   if (message)
 M = *message;

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
index baf5f8f165183..5ac68e38cb9c4 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.h
@@ -20,6 +20,7 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_H
 
+#include "

[Lldb-commits] [lldb] [lldb-dap] Addressing ubsan enum usage. (PR #133542)

2025-03-28 Thread Jordan Rupprecht via lldb-commits

https://github.com/rupprecht closed 
https://github.com/llvm/llvm-project/pull/133542
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use *Set::insert_range and a range constructor (NFC) (PR #133548)

2025-03-28 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/133548

This patch uses *Set::insert_range and a range constructor of DenseSet
to clean up the code to populate sets.


>From 41505bad0af11b0ee9fa8d92408facbe2445ea75 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 27 Mar 2025 20:27:46 -0700
Subject: [PATCH] [lldb] Use *Set::insert_range and a range constructor (NFC)

This patch uses *Set::insert_range and a range constructor of DenseSet
to clean up the code to populate sets.
---
 lldb/source/Host/common/NativeProcessProtocol.cpp| 2 +-
 .../Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp  | 2 +-
 .../Handler/SetInstructionBreakpointsRequestHandler.cpp  | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp 
b/lldb/source/Host/common/NativeProcessProtocol.cpp
index e36eefaa6f4a4..405acbb5662d6 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -43,7 +43,7 @@ lldb_private::Status NativeProcessProtocol::Interrupt() {
 
 Status NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef signals) {
   m_signals_to_ignore.clear();
-  m_signals_to_ignore.insert(signals.begin(), signals.end());
+  m_signals_to_ignore.insert_range(signals);
   return Status();
 }
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 3ae32d4afd27a..9381a29f56f43 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -42,7 +42,7 @@ CxxModuleHandler::CxxModuleHandler(ASTImporter &importer, 
ASTContext *target)
   "allocator",
   "pair",
   };
-  m_supported_templates.insert(supported_names.begin(), supported_names.end());
+  m_supported_templates.insert_range(supported_names);
 }
 
 /// Builds a list of scopes that point into the given context.
diff --git 
a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
index ec9576d4ab415..b1e47942de8e6 100644
--- a/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/SetInstructionBreakpointsRequestHandler.cpp
@@ -213,9 +213,8 @@ void SetInstructionBreakpointsRequestHandler::operator()(
   // Disable any instruction breakpoints that aren't in this request.
   // There is no call to remove instruction breakpoints other than calling this
   // function with a smaller or empty "breakpoints" list.
-  llvm::DenseSet seen;
-  for (const auto &addr : dap.instruction_breakpoints)
-seen.insert(addr.first);
+  llvm::DenseSet seen(
+  llvm::from_range, llvm::make_first_range(dap.instruction_breakpoints));
 
   for (const auto &bp : *breakpoints) {
 const auto *bp_obj = bp.getAsObject();

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Combine disassembler gtest binaries for efficiency (PR #133539)

2025-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Reid Kleckner (rnk)


Changes

Each of these executables is 642MB for me locally with split DWARF, and we 
don't need 3 statically linked gtest binaries when one will do.

---
Full diff: https://github.com/llvm/llvm-project/pull/133539.diff


4 Files Affected:

- (removed) lldb/unittests/Disassembler/ARM/CMakeLists.txt (-12) 
- (modified) lldb/unittests/Disassembler/CMakeLists.txt (+24-3) 
- (removed) lldb/unittests/Disassembler/RISCV/CMakeLists.txt (-12) 
- (removed) lldb/unittests/Disassembler/x86/CMakeLists.txt (-12) 


``diff
diff --git a/lldb/unittests/Disassembler/ARM/CMakeLists.txt 
b/lldb/unittests/Disassembler/ARM/CMakeLists.txt
deleted file mode 100644
index 91af06fa19d6f..0
--- a/lldb/unittests/Disassembler/ARM/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(DisassemblerTests
-  TestArm64Disassembly.cpp
-  TestArmv7Disassembly.cpp
-  LINK_LIBS
-lldbCore
-lldbSymbol
-lldbTarget
-lldbPluginDisassemblerLLVMC
-lldbPluginProcessUtility
-  LINK_COMPONENTS
-Support
-${LLVM_TARGETS_TO_BUILD})
diff --git a/lldb/unittests/Disassembler/CMakeLists.txt 
b/lldb/unittests/Disassembler/CMakeLists.txt
index 208f1807427f4..4d443b69f29b1 100644
--- a/lldb/unittests/Disassembler/CMakeLists.txt
+++ b/lldb/unittests/Disassembler/CMakeLists.txt
@@ -1,11 +1,32 @@
+set(disas_srcs "")
+
 if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  add_subdirectory(ARM)
+  set(disas_srcs ${disas_srcs}
+ARM/TestArm64Disassembly.cpp
+ARM/TestArmv7Disassembly.cpp
+  )
 endif()
 
 if("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
-  add_subdirectory(x86)
+  set(disas_srcs ${disas_srcs}
+x86/TestGetControlFlowKindx86.cpp
+  )
 endif()
 
 if("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
-   add_subdirectory(RISCV)
+  set(disas_srcs ${disas_srcs}
+RISCV/TestMCDisasmInstanceRISCV.cpp
+  )
 endif()
+
+add_lldb_unittest(DisassemblerTests
+  ${disas_srcs}
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginDisassemblerLLVMC
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+${LLVM_TARGETS_TO_BUILD})
diff --git a/lldb/unittests/Disassembler/RISCV/CMakeLists.txt 
b/lldb/unittests/Disassembler/RISCV/CMakeLists.txt
deleted file mode 100644
index 5bcc3e948335c..0
--- a/lldb/unittests/Disassembler/RISCV/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(MCDisasmInstanceRISCVTests
-   TestMCDisasmInstanceRISCV.cpp
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  lldbPluginDisassemblerLLVMC
-  lldbPluginProcessUtility
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-  )
diff --git a/lldb/unittests/Disassembler/x86/CMakeLists.txt 
b/lldb/unittests/Disassembler/x86/CMakeLists.txt
deleted file mode 100644
index 31d84cf5d8365..0
--- a/lldb/unittests/Disassembler/x86/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_lldb_unittest(GetControlFlowKindx86Tests
-TestGetControlFlowKindx86.cpp
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  lldbPluginDisassemblerLLVMC
-  lldbPluginProcessUtility
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-  )

``




https://github.com/llvm/llvm-project/pull/133539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Create a default rate limit constant in Progress (NFC) (PR #133506)

2025-03-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/133506
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Combine disassembler gtest binaries for efficiency (PR #133539)

2025-03-28 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/133539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Combine disassembler gtest binaries for efficiency (PR #133539)

2025-03-28 Thread Alex Langford via lldb-commits


@@ -1,11 +1,32 @@
+set(disas_srcs "")
+
 if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  add_subdirectory(ARM)
+  set(disas_srcs ${disas_srcs}

bulbazord wrote:

Suggestion: use `list(APPEND disas_srcs ...)` to more clearly express the 
intent that you're collecting a list of source files.

This one would be:
```
list(APPEND disas_srcs
ARM/TestArm64Disassembly.cpp
ARM/TestArmv7Disassembly.cpp
)
```

https://github.com/llvm/llvm-project/pull/133539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-28 Thread Santhosh Kumar Ellendula via lldb-commits


@@ -0,0 +1,175 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+response["success"] = false;
+response["message"] =
+"Malformed memory reference: " + memoryReference.str();
+dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }

santhoshe447 wrote:

> Can we add a utility function for decoding memory references? This code is 
> going to be duplicated everywhere that uses memory references. Maybe 
> something like:
> 
> ```
> std::optional memory_reference = GetMemoryReference(arguments, 
> "memoryReference");
> ```

We can add a utility function, but it may not be very useful in all cases.
Sometimes, we need memoryReference in string format, while other times, we need 
it as addr_t.
Given these variations, I don't think having a separate utility function would 
be beneficial, and we won't reduce signifi

[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-28 Thread Adrian Vogelsgesang via lldb-commits


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

vogelsgesang wrote:

If we add a new API, we should make sure it also covers the "get column 
breakpoints" use case. See the [current source 
code](https://github.com/llvm/llvm-project/blob/b82fd7110972c52cf4e58bf08b65bce7a91ecb0e/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp#L157)
 which iterates over the line tables manually. In the PR which introduced 
column-breakpoint support for lldb-dap, we already had a [similar discussion on 
exposing a new 
SB-API](https://github.com/llvm/llvm-project/pull/113787/files/4e05a8e1bb01e4b1472e9ec8d9a169cdf793#r1827507293).

For the API, this would mean that:
* We should be able to search for a line-range and not only for a single line
* We should be able to restrict the column numbers
* We need a way to return all column positions within the line(s) on which we 
could potentially stop

https://github.com/llvm/llvm-project/pull/130503
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-28 Thread Adrian Vogelsgesang via lldb-commits


@@ -0,0 +1,175 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+response["success"] = false;
+response["message"] =
+"Malformed memory reference: " + memoryReference.str();
+dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }
+
+  lldb::addr_t address = *addr_opt;
+  lldb::addr_t address_offset =
+  address + GetInteger(arguments, "offset").value_or(0);
+
+  llvm::StringRef data64 = GetString(arguments, "data").value_or("");
+
+  // The VSCode IDE or other DAP clients send memory data as a Base64 string.
+  // This function decodes it into raw binary before writing it to the target
+  // process memory.
+  std::vector output;
+  auto decodeError = llvm::decodeBase64(data64, output);
+
+  if (decodeError) {
+response["success"] = false;
+EmplaceSafeString(response, "message",
+  llvm::t

[Lldb-commits] [lldb] [lldb] Adjust skips on reverse continue tests (PR #133240)

2025-03-28 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/133240
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b82fd71 - [lldb] Adjust skips on reverse continue tests (#133240)

2025-03-28 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-03-28T09:41:56Z
New Revision: b82fd7110972c52cf4e58bf08b65bce7a91ecb0e

URL: 
https://github.com/llvm/llvm-project/commit/b82fd7110972c52cf4e58bf08b65bce7a91ecb0e
DIFF: 
https://github.com/llvm/llvm-project/commit/b82fd7110972c52cf4e58bf08b65bce7a91ecb0e.diff

LOG: [lldb] Adjust skips on reverse continue tests (#133240)

The x86-specific issue has been fixed with #132122. Watchpoint tests
fail on aarch64 with macos<15.0 due to a kernel bug.

Added: 


Modified: 

lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py

lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
index a159e0f716dbe..0a5f2d88fb917 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
@@ -10,12 +10,10 @@
 
 class TestReverseContinueBreakpoints(ReverseTestBase):
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue(self):
 self.reverse_continue_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue_async(self):
 self.reverse_continue_internal(async_mode=True)
 
@@ -44,12 +42,10 @@ def reverse_continue_internal(self, async_mode):
 self.assertEqual(process.GetExitStatus(), 0)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue_breakpoint(self):
 self.reverse_continue_breakpoint_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue_breakpoint_async(self):
 self.reverse_continue_breakpoint_internal(async_mode=True)
 
@@ -67,12 +63,10 @@ def reverse_continue_breakpoint_internal(self, async_mode):
 self.assertEqual(threads_now, initial_threads)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue_skip_breakpoint(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_reverse_continue_skip_breakpoint_async(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=True)
 
@@ -97,12 +91,10 @@ def reverse_continue_skip_breakpoint_internal(self, 
async_mode):
 )
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_continue_preserves_direction(self):
 self.continue_preserves_direction_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
 def test_continue_preserves_direction_asyhc(self):
 self.continue_preserves_direction_internal(async_mode=True)
 

diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
index c942f2a0386e5..a9e1bec5750e7 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
@@ -10,12 +10,14 @@
 
 class TestReverseContinueWatchpoints(ReverseTestBase):
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
+# Watchpoints don't work in single-step mode
+@skipIf(macos_version=["<", "15.0"], archs=["arm64"])
 def test_reverse_continue_watchpoint(self):
 self.reverse_continue_watchpoint_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
+# Watchpoints don't work in single-step mode
+@skipIf(macos_version=["<", "15.0"], archs=["arm64"])
 def test_reverse_continue_watchpoint_async(self):
 self.reverse_continue_watchpoint_internal(async_mode=True)
 
@@ -60,12 +62,14 @@ def reverse_continue_watchpoint_internal(self, async_mode):
 )
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
+# Watchpoints don't work in single-step mode
+@skipIf(macos_version=["<", "15.0"], archs=["arm64"])
 def test_reverse_continue_skip_watchpoint(self):
 self.reverse_continue_skip_watchpoint_internal(async_mode=False)
 
 @skipIfRemote
-@skipIf(macos_version=["<", "15.0"])
+# Watchpoints don't work in single-step mode
+@skipIf(macos_version=["<", "15.0"], archs=["arm64"])
 def test_reverse_continue_skip_watchpoint_async(self):
 self.reverse_continue_skip_watchpoint_internal(async_mode=True)
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-

[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-03-28 Thread via lldb-commits

jimingham wrote:



> On Mar 20, 2025, at 1:47 AM, Pavel Labath ***@***.***> wrote:
> 
> 
> labath
>  left a comment 
> (llvm/llvm-project#129092)
> So having a way to indicate you need the faster vrs. the more bullet-proof 
> behavior might be an acceptable solution. You might even argue that the 
> setting should be "bullet-proof behavior" by default. If you are shipping a 
> data formatter that benefits from this setting, you can also set the setting 
> in the module that installs the data formatters...
> 
> Or make it an expression flag that can be set (in SBExpressionOptions) on 
> expressions that you know are safe.
> 
>   
> 
> 
> labath
>  left a comment 
> (llvm/llvm-project#129092)
>  
> So having a way to indicate you need the faster vrs. the more bullet-proof 
> behavior might be an acceptable solution. You might even argue that the 
> setting should be "bullet-proof behavior" by default. If you are shipping a 
> data formatter that benefits from this setting, you can also set the setting 
> in the module that installs the data formatters...
> 
> Or make it an expression flag that can be set (in SBExpressionOptions) on 
> expressions that you know are safe.
> 
Yes, that's certainly a better way to do it, since then we can make the default 
in SBExpressionOptions be "bullet-proof" and fast behavior can be dialed up in 
the formatter without having to touch generic state.

Jim

> (But generally yes, it's better (and faster) to avoid expression evaluation 
> altogether. I don't know how many data formatters are you dealing with, but I 
> would recommend changing them to not do that.)
> 
> —
> Reply to this email directly, view it on GitHub 
> , 
> or unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



https://github.com/llvm/llvm-project/pull/129092
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-03-28 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129728

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/21] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL