[Lldb-commits] [lldb] [lldb-dap] Add external terminal support (PR #146950)

2025-07-08 Thread Druzhkov Sergei via lldb-commits


@@ -235,7 +235,8 @@ contain the following key/value pairs:
 | **cwd**   | string  | | The program working 
directory.
 | **env**   | dictionary  | | Environment 
variables to set when launching the program. The format of each environment 
variable string is "VAR=VALUE" for environment variables with values or just 
"VAR" for environment variables with no values.
 | **stopOnEntry**   | boolean | | Whether to stop 
program immediately after launching.
-| **runInTerminal** | boolean | | Launch the program 
inside an integrated terminal in the IDE. Useful for debugging interactive 
command line programs.
+| **runInTerminal** (deprecated)| boolean | | Launch the program 
inside an integrated terminal in the IDE. Useful for debugging interactive 
command line programs.
+| **console**   | string  | | Specify where to 
launch the program: internal console (`internalConsole`), integrated terminal 
(`integratedTerminal`) or external terminal (`externalTerminal`).

DrSergei wrote:

Just to clarify, which version do you mean? I see the extension version 
(0.2.15), but I don’t see a separate lldb-dap version. Running `lldb-dap 
--version` only reports the full LLVM version.

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


[Lldb-commits] [lldb] [DRAFT][lldb][rpc] Upstream RPC Client Library Emitters (PR #147655)

2025-07-08 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/147655

This commit upstreams the client side emitters for the lldb-rpc-gen tool 
alongside tests for its functionality and heuristics.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804

>From cbcab9124ca15bc768305283d99ad85e8c16d2c0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 2 Jul 2025 00:17:31 -0700
Subject: [PATCH] [lldb][rpc] Upstream RPC Client Library Emitters

FIND A BETTER DESCRIPTION FOR THIS COMMIT CHELS GODDAMN

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
---
 .../Inputs/Client/CheckArrayPointer.h |  20 +
 .../Client/CheckConstCharPtrPtrWithLen.h  |  19 +
 .../Generator/Inputs/Client/CheckConstSBRef.h |  19 +
 .../Inputs/Client/CheckNonConstSBRef.h|  20 +
 .../Generator/Inputs/Client/CheckSBPointer.h  |  21 +
 .../Generator/Inputs/Client/CheckVoidPtr.h|  19 +
 .../Tests/Client/CheckArrayPointer.test   |  11 +
 .../Client/CheckConstCharPtrPtrWithLen.test   |  10 +
 .../Tests/Client/CheckConstSBRef.test |  14 +
 .../Tests/Client/CheckNonConstSBRef.test  |  13 +
 .../Tests/Client/CheckSBPointer.test  |  15 +
 .../Generator/Tests/Client/CheckVoidPtr.test  |  10 +
 .../client/RPCLibraryHeaderEmitter.cpp| 124 
 .../client/RPCLibraryHeaderEmitter.h  |  44 ++
 .../client/RPCLibrarySourceEmitter.cpp| 542 ++
 .../client/RPCLibrarySourceEmitter.h  |  92 +++
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp| 414 +
 17 files changed, 1407 insertions(+)
 create mode 100644 
lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h
 create mode 100644 
lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h
 create mode 100644 
lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h
 create mode 100644 
lldb/test/Shell/RPC/Generator/Inputs/Client/CheckNonConstSBRef.h
 create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Client/CheckSBPointer.h
 create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Client/CheckVoidPtr.h
 create mode 100644 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckArrayPointer.test
 create mode 100644 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckConstCharPtrPtrWithLen.test
 create mode 100644 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckConstSBRef.test
 create mode 100644 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckNonConstSBRef.test
 create mode 100644 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckSBPointer.test
 create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Client/CheckVoidPtr.test
 create mode 100644 
lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibraryHeaderEmitter.cpp
 create mode 100644 
lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibraryHeaderEmitter.h
 create mode 100644 
lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibrarySourceEmitter.cpp
 create mode 100644 
lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibrarySourceEmitter.h
 create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp

diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h
new file mode 100644
index 0..18ec92a976b8a
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h
@@ -0,0 +1,20 @@
+#ifndef LLDB_API_SBRPC_CHECKARRAYPTR_H
+#define LLDB_API_SBRPC_CHECKARRAYPTR_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKARRAYPTR {
+public:
+  // Pointers to arrays followed by length must use a
+  // Bytes object constructed using that pointer and the sizeof()
+  // the array object.
+  int CheckArrayPtr(uint64_t *array, size_t array_len);
+
+}; // class SBRPC_CHECKARRAYPTR
+} // namespace lldb
+
+#endif // LLDB_API_SBRPC_CHECKARRAYPTR_H
diff --git 
a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h
new file mode 100644
index 0..fa64492cf5aa7
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h
@@ -0,0 +1,19 @@
+#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
+#define LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKCONSTCHARPTRPTRWITHLEN {
+public:
+  // const char ** followed by len must use a StringList
+  // when being encoded.
+  int CheckConstCharPtrPtrWithLen(const char **arg1, size_t len);
+
+}; // class SBRPC_CHECKCONSTCHARPTRPTRWITHLEN
+} // namespace lldb
+
+#endif // LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h
new file mode 100644
index 0..153fdad60a494
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/Che

[Lldb-commits] [lldb] [DRAFT][lldb][rpc] Upstream RPC Client Library Emitters (PR #147655)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

This commit upstreams the client side emitters for the lldb-rpc-gen tool 
alongside tests for its functionality and heuristics.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804

---

Patch is 55.20 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/147655.diff


17 Files Affected:

- (added) lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h (+20) 
- (added) 
lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h (+19) 
- (added) lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h (+19) 
- (added) lldb/test/Shell/RPC/Generator/Inputs/Client/CheckNonConstSBRef.h 
(+20) 
- (added) lldb/test/Shell/RPC/Generator/Inputs/Client/CheckSBPointer.h (+21) 
- (added) lldb/test/Shell/RPC/Generator/Inputs/Client/CheckVoidPtr.h (+19) 
- (added) lldb/test/Shell/RPC/Generator/Tests/Client/CheckArrayPointer.test 
(+11) 
- (added) 
lldb/test/Shell/RPC/Generator/Tests/Client/CheckConstCharPtrPtrWithLen.test 
(+10) 
- (added) lldb/test/Shell/RPC/Generator/Tests/Client/CheckConstSBRef.test (+14) 
- (added) lldb/test/Shell/RPC/Generator/Tests/Client/CheckNonConstSBRef.test 
(+13) 
- (added) lldb/test/Shell/RPC/Generator/Tests/Client/CheckSBPointer.test (+15) 
- (added) lldb/test/Shell/RPC/Generator/Tests/Client/CheckVoidPtr.test (+10) 
- (added) lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibraryHeaderEmitter.cpp 
(+124) 
- (added) lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibraryHeaderEmitter.h 
(+44) 
- (added) lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibrarySourceEmitter.cpp 
(+542) 
- (added) lldb/tools/lldb-rpc/lldb-rpc-gen/client/RPCLibrarySourceEmitter.h 
(+92) 
- (added) lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp (+414) 


``diff
diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h
new file mode 100644
index 0..18ec92a976b8a
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckArrayPointer.h
@@ -0,0 +1,20 @@
+#ifndef LLDB_API_SBRPC_CHECKARRAYPTR_H
+#define LLDB_API_SBRPC_CHECKARRAYPTR_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKARRAYPTR {
+public:
+  // Pointers to arrays followed by length must use a
+  // Bytes object constructed using that pointer and the sizeof()
+  // the array object.
+  int CheckArrayPtr(uint64_t *array, size_t array_len);
+
+}; // class SBRPC_CHECKARRAYPTR
+} // namespace lldb
+
+#endif // LLDB_API_SBRPC_CHECKARRAYPTR_H
diff --git 
a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h
new file mode 100644
index 0..fa64492cf5aa7
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstCharPtrPtrWithLen.h
@@ -0,0 +1,19 @@
+#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
+#define LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKCONSTCHARPTRPTRWITHLEN {
+public:
+  // const char ** followed by len must use a StringList
+  // when being encoded.
+  int CheckConstCharPtrPtrWithLen(const char **arg1, size_t len);
+
+}; // class SBRPC_CHECKCONSTCHARPTRPTRWITHLEN
+} // namespace lldb
+
+#endif // LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h
new file mode 100644
index 0..153fdad60a494
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckConstSBRef.h
@@ -0,0 +1,19 @@
+#ifndef LLDB_API_SBRPC_CHECKCONSTSBREF_H
+#define LLDB_API_SBRPC_CHECKCONSTSBREF_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKCONSTSBREF {
+public:
+  // Const references to SB classes should be encoded as usual without
+  // needing to create a new object with its own connection.
+  int CheckConstSBRef(const SBDebugger &debugger_ref);
+
+}; // class SBRPC_CHECKCONSTSBREF
+} // namespace lldb
+
+#endif // LLDB_API_SBRPC_CHECKCONSTSBREF_H
diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckNonConstSBRef.h 
b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckNonConstSBRef.h
new file mode 100644
index 0..90ee3d3a7fbd6
--- /dev/null
+++ b/lldb/test/Shell/RPC/Generator/Inputs/Client/CheckNonConstSBRef.h
@@ -0,0 +1,20 @@
+#ifndef LLDB_API_SBRPC_CHECKNONCONSTSBREF_H
+#define LLDB_API_SBRPC_CHECKNONCONSTSBREF_H
+
+#include 
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+class LLDB_API SBRPC_CHECKNONCONSTSBREF {
+public:
+  // Non-const references to SB classes will have new objects
+  // of that class constructed with the connection as the first parameter
+  // befor

[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-08 Thread Erich Keane via lldb-commits

erichkeane wrote:

> > Why is this a new review? What changed from the last one I looked at?
> 
> Ah, right -- this patch is actually derived from the previous one, and it is 
> simpler. That older patch became a bit outdated since some of its changes 
> were split out and already landed in main. I found it easier to start fresh 
> with a new patch rather than rebasing the old one.
> 
> That said, if you’d prefer to stick with the old review (to preserve the 
> initial comments there), I can force-push this patch to the old review 
> instead.

Ah, not a problem, the new one is fine.  I was just very thrown/wondering why I 
was reviewing something so similar again.

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


[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)

2025-07-08 Thread via lldb-commits

https://github.com/athierry-oct updated 
https://github.com/llvm/llvm-project/pull/144919

>From 28e1078877df5466dec8791a7b2c8a2da1633bed Mon Sep 17 00:00:00 2001
From: Adrien Thierry 
Date: Thu, 3 Jul 2025 10:13:28 -0400
Subject: [PATCH] [lldb] Transfer events from previous listener when hijacking

This patch addresses a race condition that can occur when a script using
the Python API calls SBProcess::Kill() around the same time a breakpoint
is hit.

If a stop event is broadcast before the hijack listener is installed, it
may be delivered to the default listener and missed entirely by the
hijack listener. This causes Process::WaitForProcessToStop() to hang
until it times out, waiting for a public stop event that is never
received.

To fix this, we now transfer all pending events from the original
listener to the hijack listener before hijacking, using a new
Listener::MoveEvents method. We also do the reverse operation when
restoring the original listener to avoid dropping any event.
---
 lldb/include/lldb/Utility/Listener.h|  7 +++
 lldb/source/Utility/Broadcaster.cpp | 25 
 lldb/source/Utility/Listener.cpp| 27 +
 lldb/unittests/Utility/ListenerTest.cpp | 81 +
 4 files changed, 140 insertions(+)

diff --git a/lldb/include/lldb/Utility/Listener.h 
b/lldb/include/lldb/Utility/Listener.h
index d48816ec0ea4d..393169091390c 100644
--- a/lldb/include/lldb/Utility/Listener.h
+++ b/lldb/include/lldb/Utility/Listener.h
@@ -53,6 +53,13 @@ class Listener : public 
std::enable_shared_from_this {
 
   void AddEvent(lldb::EventSP &event);
 
+  /// Transfers all events matching the specified broadcaster and type to the
+  /// destination listener. This can be useful when setting up a hijack 
listener,
+  /// to ensure that no relevant events are missed.
+  void MoveEvents(lldb::ListenerSP destination,
+  Broadcaster *broadcaster, // nullptr for any broadcaster
+  uint32_t event_type_mask);
+
   void Clear();
 
   const char *GetName() { return m_name.c_str(); }
diff --git a/lldb/source/Utility/Broadcaster.cpp 
b/lldb/source/Utility/Broadcaster.cpp
index c6b2606afe0c8..41b782fee55fa 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -335,6 +335,18 @@ bool Broadcaster::BroadcasterImpl::HijackBroadcaster(
   "{0} Broadcaster(\"{1}\")::HijackBroadcaster (listener(\"{2}\")={3})",
   static_cast(this), GetBroadcasterName(),
   listener_sp->m_name.c_str(), static_cast(listener_sp.get()));
+
+  // Move pending events from the previous listener to the hijack listener.
+  // This ensures that no relevant event queued before the transition is missed
+  // by the hijack listener.
+  ListenerSP prev_listener;
+  if (!m_hijacking_listeners.empty())
+prev_listener = m_hijacking_listeners.back();
+  else if (m_primary_listener_sp)
+prev_listener = m_primary_listener_sp;
+  if (prev_listener && listener_sp)
+prev_listener->MoveEvents(listener_sp, &m_broadcaster, event_mask);
+
   m_hijacking_listeners.push_back(listener_sp);
   m_hijacking_masks.push_back(event_mask);
   return true;
@@ -367,6 +379,19 @@ void Broadcaster::BroadcasterImpl::RestoreBroadcaster() {
  static_cast(this), GetBroadcasterName(),
  listener_sp->m_name.c_str(),
  static_cast(listener_sp.get()));
+
+// Move any remaining events from the hijack listener back to
+// the previous listener. This ensures that no events are dropped when
+// restoring the original listener.
+ListenerSP prev_listener;
+if (m_hijacking_listeners.size() > 1)
+  prev_listener = m_hijacking_listeners[m_hijacking_listeners.size() - 2];
+else if (m_primary_listener_sp)
+  prev_listener = m_primary_listener_sp;
+if (listener_sp && prev_listener && !m_hijacking_masks.empty())
+  listener_sp->MoveEvents(prev_listener, &m_broadcaster,
+  m_hijacking_masks.back());
+
 m_hijacking_listeners.pop_back();
   }
   if (!m_hijacking_masks.empty())
diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index d4ce3bf25ec5a..a9b733579d2f7 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -176,6 +176,33 @@ void Listener::AddEvent(EventSP &event_sp) {
   m_events_condition.notify_all();
 }
 
+void Listener::MoveEvents(
+ListenerSP destination,
+Broadcaster *broadcaster, // nullptr for any broadcaster
+uint32_t event_type_mask) {
+  Log *log = GetLog(LLDBLog::Events);
+
+  std::lock_guard guard(m_events_mutex);
+  auto pos = m_events.begin();
+  while (pos != m_events.end()) {
+EventSP &event_sp = *pos;
+if (event_sp &&
+((broadcaster == nullptr) || event_sp->BroadcasterIs(broadcaster)) &&
+(event_type_mask == 0 || event_type_mask & event_sp->GetType())) {
+  LLDB_LOGF(
+  log, "%p Listener('%s')::MoveEvents moving event %p to %p('%s')",
+ 

[Lldb-commits] [libcxx] [lldb] [libcxx] adds size-based `__split_buffer` representation to unstable ABI (PR #139632)

2025-07-08 Thread Adrian Vogelsgesang via lldb-commits




vogelsgesang wrote:

But at least `std::vector` (i.e. what this commit here is targetting) is 
already ported over to C++. Instead of / In addition to modifying the example 
code, shouldn't this PR also update `LibCxxVector.cpp`?

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


[Lldb-commits] [libcxx] [lldb] [libcxx] adds size-based `__split_buffer` representation to unstable ABI (PR #139632)

2025-07-08 Thread Michael Buch via lldb-commits




Michael137 wrote:

For std::vector this patch didn't actually change anything about the vector 
layout. It just changed some accesses in 
__swap_out_circular_buffer/insert/emplace. LLDB formatters don't rely on those 
functions. They most rely on the data members, which stayed the same.

For std::deque, it has a __split_buffer child, so it's layout did change and 
hence the formatter broke.

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


[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)

2025-07-08 Thread via lldb-commits

athierry-oct wrote:

@JDevlieghere done!

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


[Lldb-commits] [lldb] Draft: [LLDB] Add scalar literal node (PR #147064)

2025-07-08 Thread Augusto Noronha via lldb-commits

augusto2112 wrote:

> Here is the problem with types: initial scalar literal type, all the type 
> promotions and conversions are done using `lldb::BasicType` enumeration 
> types, and later converted to `CompilerType` using the `TypeSystem`. In C++, 
> this works perfectly well, because in 
> [`TypeSystemClang.cpp:5468`](https://github.com/llvm/llvm-project/blob/740da004af5ed402b6ddb0d71759f978bc814f7f/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L5468C1-L5468C41)
>  it is implemented, but in 
> [`TypeSystemSwift:304`](https://github.com/swiftlang/llvm-project/blob/4cbdeee819f3f2ce36d67af493fdd91c708612f4/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h#L304)
>  it is not.
> 
> Do we assume that this was just never needed before, so it can now be 
> implemented and used? Or is there some sort of inherent incompatibility 
> between LLDB's basic type system and Swift type system (talking about 
> primitive types) that this cannot be implemented correctly? If so, what would 
> be an alternative way to abstract the type promotion/conversion from the 
> specific compiler type and type system?

I don't think there's any inherent reason why the Swift type systems can't 
implement `GetBasicTypeEnumeration` and `GetBasicTypeFromAST`, it's most likely 
something that just wasn't needed before.

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


[Lldb-commits] [lldb] [lldb] Change breakpoint interfaces for error handling (PR #146972)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/146972

>From b593c9b4f8791f2b5562ca301f77af72619b9c30 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 8 Jul 2025 15:32:13 -0700
Subject: [PATCH 1/2] [lldb] Change breakpoint interfaces for error handling

This RP changes some Breakpoint-related interfaces to return errors. On
its own these improvements are small, but they encourage better error
handling going forward. There are a bunch of other candidates, but these
were the functions that I touched while working on #146602.
---
 .../lldb/Breakpoint/BreakpointLocation.h  | 14 +---
 lldb/source/API/SBBreakpointLocation.cpp  |  2 +-
 lldb/source/Breakpoint/Breakpoint.cpp | 16 -
 lldb/source/Breakpoint/BreakpointLocation.cpp | 64 ++-
 .../Breakpoint/BreakpointLocationList.cpp | 22 +--
 .../Breakpoint/BreakpointResolverAddress.cpp  |  8 ++-
 lldb/source/Breakpoint/BreakpointSite.cpp |  5 +-
 .../Commands/CommandObjectBreakpoint.cpp  | 17 +++--
 lldb/source/Commands/CommandObjectProcess.cpp | 17 +++--
 9 files changed, 99 insertions(+), 66 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index 66274e8825ee2..ce3a21f92bd46 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -69,7 +69,7 @@ class BreakpointLocation
   // The next section deals with various breakpoint options.
 
   /// If \a enabled is \b true, enable the breakpoint, if \b false disable it.
-  bool SetEnabled(bool enabled);
+  llvm::Error SetEnabled(bool enabled);
 
   /// Check the Enable/Disable state.
   ///
@@ -163,19 +163,11 @@ class BreakpointLocation
   // The next section deals with this location's breakpoint sites.
 
   /// Try to resolve the breakpoint site for this location.
-  ///
-  /// \return
-  /// \b true if we were successful at setting a breakpoint site,
-  /// \b false otherwise.
-  bool ResolveBreakpointSite();
+  llvm::Error ResolveBreakpointSite();
 
   /// Clear this breakpoint location's breakpoint site - for instance when
   /// disabling the breakpoint.
-  ///
-  /// \return
-  /// \b true if there was a breakpoint site to be cleared, \b false
-  /// otherwise.
-  bool ClearBreakpointSite();
+  llvm::Error ClearBreakpointSite();
 
   /// Return whether this breakpoint location has a breakpoint site. \return
   /// \b true if there was a breakpoint site for this breakpoint
diff --git a/lldb/source/API/SBBreakpointLocation.cpp 
b/lldb/source/API/SBBreakpointLocation.cpp
index b2d1da3927c6e..479354a62627d 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -102,7 +102,7 @@ void SBBreakpointLocation::SetEnabled(bool enabled) {
   if (loc_sp) {
 std::lock_guard guard(
 loc_sp->GetTarget().GetAPIMutex());
-loc_sp->SetEnabled(enabled);
+llvm::consumeError(loc_sp->SetEnabled(enabled));
   }
 }
 
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 8fc93cc8e0e51..b569c92ececa9 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -255,6 +255,8 @@ llvm::Error Breakpoint::SetIsHardware(bool is_hardware) {
   if (is_hardware == m_hardware)
 return llvm::Error::success();
 
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
   // Disable all non-hardware breakpoint locations.
   std::vector locations;
   for (BreakpointLocationSP location_sp : m_locations.BreakpointLocations()) {
@@ -268,7 +270,9 @@ llvm::Error Breakpoint::SetIsHardware(bool is_hardware) {
   continue;
 
 locations.push_back(location_sp);
-location_sp->SetEnabled(false);
+if (llvm::Error error = location_sp->SetEnabled(false))
+  LLDB_LOG_ERROR(log, std::move(error),
+ "Failed to disable breakpoint location: {0}");
   }
 
   // Toggle the hardware mode.
@@ -277,8 +281,11 @@ llvm::Error Breakpoint::SetIsHardware(bool is_hardware) {
   // Re-enable all breakpoint locations.
   size_t num_failures = 0;
   for (BreakpointLocationSP location_sp : locations) {
-if (!location_sp->SetEnabled(true))
+if (llvm::Error error = location_sp->SetEnabled(true)) {
+  LLDB_LOG_ERROR(log, std::move(error),
+ "Failed to re-enable breakpoint location: {0}");
   num_failures++;
+}
   }
 
   if (num_failures != 0)
@@ -613,7 +620,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, 
bool load,
 // Remove this breakpoint since the shared library is unloaded, but
 // keep the breakpoint location around so we always get complete
 // hit count and breakpoint lifetime info
-break_loc_sp->ClearBreakpointSite();
+if (llvm::Error error = break_loc_sp->ClearBreakpointSite())
+  LLDB_LOG_ERROR(log, std::move(error),
+   

[Lldb-commits] [lldb] [lldb] Enable SWIG Doxygen Translation (PR #147617)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

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

Enable SWIG support for translating Doxygen comments found in interface and 
header files into a target language's normal documentation language. This 
feature was introduced in SWIG 4.0 and currently only supports Python (and 
Java). Hand-written documentation still takes precedence.

>From f7d52fb75c1224197986f75e08a4201431fc9431 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 8 Jul 2025 16:47:30 -0700
Subject: [PATCH] [lldb] Enable SWIG Doxygen Translation

Enable SWIG support for translating Doxygen comments found in interface
and header files into a target language's normal documentation language.
This feature was introduced in SWIG 4.0 and currently only supports
Python (and Java). Hand-written documentation still takes precedence.
---
 lldb/bindings/python/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 69306a384e0b1..ef6def3f26872 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -14,6 +14,7 @@ add_custom_command(
   DEPENDS lldb-sbapi-dwarf-enums
   COMMAND ${SWIG_EXECUTABLE}
   ${SWIG_COMMON_FLAGS}
+  -doxygen
   -I${CMAKE_CURRENT_SOURCE_DIR}
   ${SWIG_EXTRA_FLAGS}
   -outdir ${CMAKE_CURRENT_BINARY_DIR}

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


[Lldb-commits] [lldb] [lldb] Enable SWIG Doxygen Translation (PR #147617)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Enable SWIG support for translating Doxygen comments found in interface and 
header files into a target language's normal documentation language. This 
feature was introduced in SWIG 4.0 and currently only supports Python (and 
Java). Hand-written documentation still takes precedence.

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


1 Files Affected:

- (modified) lldb/bindings/python/CMakeLists.txt (+1) 


``diff
diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 69306a384e0b1..ef6def3f26872 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -14,6 +14,7 @@ add_custom_command(
   DEPENDS lldb-sbapi-dwarf-enums
   COMMAND ${SWIG_EXECUTABLE}
   ${SWIG_COMMON_FLAGS}
+  -doxygen
   -I${CMAKE_CURRENT_SOURCE_DIR}
   ${SWIG_EXTRA_FLAGS}
   -outdir ${CMAKE_CURRENT_BINARY_DIR}

``




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


[Lldb-commits] [lldb] [lldb] Enable SWIG Doxygen Translation (PR #147617)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From 78533da4cfb0c5d5f9f142cce19609810e630dd7 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Jul 2025 18:36:57 +0100
Subject: [PATCH 1/3] [lldb][test] Combine libstdc++ and libc++ std::string
 tests into generic test

This combines the libc++ and libstdc++ test cases. The main difference was that 
the libstdcpp tests had additional tests for references/pointers to 
std::string. I moved those over.

Split out from https://github.com/llvm/llvm-project/pull/146740
---
 .../{libstdcpp => generic}/string/Makefile|   3 -
 .../string/TestDataFormatterStdString.py} |  54 +++--
 .../generic/string/main.cpp   | 104 ++
 .../data-formatter-stl/libcxx/string/Makefile |   6 -
 .../data-formatter-stl/libcxx/string/main.cpp |  31 --
 .../string/TestDataFormatterStdString.py  |  93 
 .../libstdcpp/string/main.cpp |  16 ---
 7 files changed, 147 insertions(+), 160 deletions(-)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => 
generic}/string/Makefile (53%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/string/TestDataFormatterLibcxxString.py
 => generic/string/TestDataFormatterStdString.py} (80%)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
similarity index 53%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
index c825977b1a5dc..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-CFLAGS_EXTRAS := -O0
-USE_LIBSTDCPP := 1
-
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
similarity index 80%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 2f7fc88e0f449..c19429e67c5c6 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -10,7 +10,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxStringDataFormatterTestCase(TestBase):
+class StdStringDataFormatterTestCase(TestBase):
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -18,17 +18,8 @@ def setUp(self):
 self.main_spec = lldb.SBFileSpec("main.cpp")
 self.namespace = "std"
 
-@add_test_categories(["libc++"])
-@expectedFailureAll(
-bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
-)
-# Inline namespace is randomly ignored as Clang due to broken lookup inside
-# the std namespace.
-@expectedFailureAll(debug_info="gmodules")
-def test_with_run_command(self):
+def do_test(self):
 """Test that that file and class static variables display correctly."""
-self.build()
-
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
 )
@@ -124,6 +115,25 @@ def cleanup():
 ],
 )
 
+# Test references and pointers to std::string.
+var_rq = self.frame().FindVariable("rq")
+var_rQ = self.frame().FindVariable("rQ")
+var_pq = self.frame().FindVariable("pq")
+var_pQ = self.frame().FindVariable("pQ")
+
+self.assertEqual(var_rq.GetSummary(), '"hello world"', "rq summary 
wrong")
+self.assertEqual(
+var_rQ.GetSummary(),
+'"quite a long std::strin with lots of info inside

[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)

2025-07-08 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-win` running 
on `as-builder-10` while building `lldb` at step 8 "test-check-lldb-unit".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/211/builds/321


Here is the relevant piece of the build log for the reference

```
Step 8 (test-check-lldb-unit) failure: Test just built components: 
check-lldb-unit completed (failure)
 TEST 'lldb-unit :: Host/./HostTests.exe/31/87' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Host\.\HostTests.exe-lldb-unit-4664-31-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=31 
C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Host\.\HostTests.exe
--

Script:
--
C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Host\.\HostTests.exe
 --gtest_filter=MainLoopTest.NoSpuriousPipeReads
--
C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\unittests\Host\MainLoopTest.cpp(141):
 error: Expected equality of these values:
  1u
Which is: 1
  callback_count
Which is: 2


C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\unittests\Host\MainLoopTest.cpp:141
Expected equality of these values:
  1u
Which is: 1
  callback_count
Which is: 2






```



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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

Hah i can repro it when i run both libcxx and libstdcxx tests together 
(previously i just ran with `--category libstdcxx`).
Could this be another instance of https://reviews.llvm.org/D66398? Though i 
thought that's fixed now though...

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

Yea I can repro this if I use the same debugger instance to debug a target 
compiled against libc++, then print the typedef, and then debug a libstdc++ 
target.

I think the issue is that the formatter infra caches `typedef name -> 
formatter`. So we would try using the libc++ formatter for a libstdc++ variant 
because the `V1_typedef` is the thing that was cached.

Same reason as https://github.com/llvm/llvm-project/pull/110767

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

For now i think I'll probably i'll reset the formatters in the teardown hook, 
but Jim's comment on https://github.com/llvm/llvm-project/pull/110767 might be 
a good follow-up;

> The narrowest solution is that when you go to cache a type name -> formatter 
> pair, you should  first check whether the type name is generic.  If it is, 
> then you can't guarantee it will resolve to the same base type in the future, 
> so you should not cache it.  IIUC, Michael started down this path but found 
> there wasn't a way to tell straightforwardly whether a type was generic.  
> Since this is just an optimization, we should first prove to ourselves that 
> failing to put one of these type names in the exact matches really makes 
> enough difference to bother with a complex solution.  If the gains are some 
> but not huge, some boneheaded solution like never caching anything where the 
> from type has a '<' and a '>' is probably sufficient.


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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From e592d39c751480838ed90fcaa2b247e96b5bab59 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sun, 6 Jul 2025 09:58:02 +0100
Subject: [PATCH 1/7] [lldb][test] Combine libstdc++ and libc++ std::variant
 tests into generic test

---
 .../{libcxx => generic}/variant/Makefile  |  4 +-
 .../variant/TestDataFormatterStdVariant.py}   | 44 +++--
 .../{libstdcpp => generic}/variant/main.cpp   | 21 ++--
 .../variant/TestDataFormatterLibcxxVariant.py | 88 -
 .../libcxx/variant/main.cpp   | 95 ---
 .../libstdcpp/variant/Makefile|  5 -
 6 files changed, 23 insertions(+), 234 deletions(-)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/variant/Makefile (82%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 => generic/variant/TestDataFormatterStdVariant.py} (59%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => 
generic}/variant/main.cpp (85%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
similarity index 82%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
index 7eeff7407804d..d5f5fec8441b5 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
@@ -1,6 +1,4 @@
 CXX_SOURCES := main.cpp
-
-USE_LIBCPP := 1
-
 CXXFLAGS_EXTRAS := -std=c++17
+
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
similarity index 59%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
index dae9b24fbbcfe..24ae9bfcd1a06 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter for LibStdC++ std::variant.
+Test lldb data formatter subsystem.
 """
 
 import lldb
@@ -8,18 +8,14 @@
 from lldbsuite.test import lldbutil
 
 
-class LibStdcxxVariantDataFormatterTestCase(TestBase):
-@add_test_categories(["libstdcxx"])
-def test_with_run_command(self):
-"""Test LibStdC++ std::variant data formatter works correctly."""
-self.build()
+class StdVariantDataFormatterTestCase(TestBase):
+def do_test(self):
+"""Test that that file and class static variables display correctly."""
 
 (self.target, self.process, _, bkpt) = 
lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp", False)
 )
 
-lldbutil.continue_to_breakpoint(self.process, bkpt)
-
 for name in ["v1", "v1_typedef"]:
 self.expect(
 "frame variable " + name,
@@ -69,28 +65,12 @@ def test_with_run_command(self):
 substrs=["v_many_types_valueless =  No Value"],
 )
 
-@add_test_categories(["libstdcxx"])
-def test_invalid_variant_index(self):
-"""Test LibStdC++ data formatter for std::variant with invalid 
index."""
-self.build()
-
-(self.target, self.process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(
-self, "// break here", lldb.SBFileSpec("main.cpp", False)
-)
-
-lldbutil.continue_to_breakpoint(self.process, bkpt)
-
-self.expect(
-"frame variable v1",
-substrs=["v1 =  Active Type = int  {", "Value = 12", "}"],
-)
-
-var_v1 = thread.frames[0].FindVariable("v1")
-var_v1_raw_obj = var_v1.GetNonSyntheticValue()
-index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
-self.assertTrue(index_obj and index_obj.IsValid())
+@add_test_categories(["libc++"

[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

Bit unfortunate because I personally zoom (i.e., resize) in and out of tmux 
panes a lot to see more of the LLDB output. Now it would clear the screen. But 
I understand why the trade-off was made

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

Confused why the variant tests fail for libstdc++ (they don't locally)

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This combines the libc++ and libstdc++ test cases. The main difference was that 
the libstdcpp tests had additional tests for references/pointers to 
std::string. I moved those over.

The libstdc++ formatters don't support `std::u16string`/`std::u32string` yet, 
so I extracted those into XFAILed test cases.

There were also two test assertions that failed for libstdc++:
1. libstdc++ doesn't obey the capped/uncapped summary options
2. When a summary isn't available for a std::string, libc++ would print 
"Summary Unavailable", whereas libstdc++ just prints "((null))". This may be 
better suited for the STL-specific subdirectories, but left it here for now.

I put those in separate XFAILed test-cases.

Split out from https://github.com/llvm/llvm-project/pull/146740

---

Patch is 29.05 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/147355.diff


7 Files Affected:

- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
 (-3) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
 (+128-52) 
- (added) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 (+104) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
 (-6) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 (-31) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
 (-93) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
 (-16) 


``diff
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
similarity index 53%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
index c825977b1a5dc..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-CFLAGS_EXTRAS := -O0
-USE_LIBSTDCPP := 1
-
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
similarity index 52%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 2f7fc88e0f449..2991cf870dcd2 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -10,7 +10,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxStringDataFormatterTestCase(TestBase):
+class StdStringDataFormatterTestCase(TestBase):
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -18,17 +18,8 @@ def setUp(self):
 self.main_spec = lldb.SBFileSpec("main.cpp")
 self.namespace = "std"
 
-@add_test_categories(["libc++"])
-@expectedFailureAll(
-bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
-)
-# Inline namespace is randomly ignored as Clang due to broken lookup inside
-# the std namespace.
-@expectedFailureAll(debug_info="gmodules")
-def test_with_run_command(self):
+def do_test(self):
 """Test that that file and class static variables display correctly."""
-self.build()
-
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
 )
@@ -47,42 +38,13 @@ def cleanup():
 
 ns = self.namespace
 
-self.expect(
-"frame variable",
-substrs=[
-'(%s::wstring) wempty = L""' % ns,
-'(%s::wstring) s = L"hello world! מזל טוב!"' % ns,
-'(%s::wstring) S = L""' % ns,
-"(const wchar_t *) mazeltov = 0x",
-'L"מזל טוב"',
-'(%s::string) empty = ""' % ns,
-'(%s::string) q = "hello world"' % ns,
-'(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'
-% ns,
- 

[Lldb-commits] [lldb] fd997d8 - [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (#147139)

2025-07-08 Thread via lldb-commits

Author: Michael Buch
Date: 2025-07-08T09:01:10+01:00
New Revision: fd997d86f060c8110a6b5151e8f21c4e4e17ba4a

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

LOG: [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test 
(#147139)

This combines the libc++ and libstdc++ test cases. The main difference
was that the libstdcpp tests had some tuple indexing tests that libc++
didn't have.

The libstdc++ formatter didn't support size summaries for std::tuple. So
I added a `ContainerSizeSummaryProvider` for it (like we do for libc++).
Additionally, the synthetic frontend would only apply to non-empty
tuples, so I adjusted the regex to match empty ones too. We do this for
libc++ already.

Split out from https://github.com/llvm/llvm-project/pull/146740

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp

Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp



diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06412e34eb777..e64b3ebabd740 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1504,6 +1504,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
 "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
 stl_summary_flags, true);
 
+  AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
+"libstdc++ std::tuple summary provider",
+"^std::tuple<.*>(( )?&)?$", stl_summary_flags, true);
+
   cpp_category_sp->AddTypeSummary(
   "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
   eFormatterMatchRegex,
@@ -1546,7 +1550,7 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator,
-  "std::tuple synthetic children", "^std::tuple<.+>(( )?&)?$",
+  "std::tuple synthetic children", "^std::tuple<.*>(( )?&)?$",
   stl_synth_flags, true);
 
   static constexpr const char *const libstdcpp_std_coroutine_handle_regex =

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
index 680e1abfbef58..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
new file mode 100644
index 0..ade502e12b928
--- /dev/null
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
@@ -0,0 +1,76 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestDataFormatterStdTuple(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.line = line_number("main.cpp", "// break here")
+self.namespace = "std"
+
+def do_test(self):
+"""Test that std::tuple is displayed correctly"""
+lldbutil.run_to_source_breakpoint(
+self, "// b

[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969) (PR #147417)

2025-07-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> Relands the commit to upstream the lldb-rpc-gen tool in order to fix a build 
> failure on the linux remote bots.

And changes what when compared to the original PR?

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


[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From dba291d4b0b5ac6e62cfc084340cc0524d15d51c Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Jul 2025 14:45:59 +0100
Subject: [PATCH 1/2] [lldb][Formatters] Consistently unwrap pointer
 element_type in std::shared_ptr formatters

---
 .../lldb/DataFormatters/FormattersHelpers.h|  5 +
 lldb/source/DataFormatters/FormattersHelpers.cpp   | 13 +
 lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp  | 14 +++---
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp   | 12 ++--
 .../shared_ptr/TestDataFormatterStdSharedPtr.py|  4 
 5 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index 6a47cf37eac64..c7ce199452e1d 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -63,6 +63,11 @@ void DumpCxxSmartPtrPointerSummary(Stream &stream, 
ValueObject &ptr,
 bool ContainerSizeSummaryProvider(ValueObject &valobj, Stream &stream,
   const TypeSummaryOptions &options);
 
+/// Return the ValueObjectSP of the underlying pointer member whose type
+/// is a desugared 'std::shared_ptr::element_type *'.
+lldb::ValueObjectSP GetCxxSmartPtrElementPointerType(ValueObject &ptr,
+ ValueObject &container);
+
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 
 time_t GetOSXEpoch();
diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 028fc5da73dc0..104c2ce6f1c0a 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -151,3 +151,16 @@ bool 
lldb_private::formatters::ContainerSizeSummaryProvider(
   return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr,
nullptr, nullptr, &valobj, false, 
false);
 }
+
+ValueObjectSP lldb_private::formatters::GetCxxSmartPtrElementPointerType(
+ValueObject &ptr, ValueObject &container) {
+  auto container_type = container.GetCompilerType().GetNonReferenceType();
+  if (!container_type)
+return nullptr;
+
+  auto arg = container_type.GetTypeTemplateArgument(0);
+  if (!arg)
+return nullptr;
+
+  return ptr.Cast(arg.GetPointerType());
+}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 3079de4936a85..f73a77836034f 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -264,11 +264,7 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
 
   if (idx == 1) {
 Status status;
-auto value_type_sp = valobj_sp->GetCompilerType()
- .GetTypeTemplateArgument(0)
- .GetPointerType();
-ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp);
-ValueObjectSP value_sp = cast_ptr_sp->Dereference(status);
+ValueObjectSP value_sp = m_ptr_obj->Dereference(status);
 if (status.Success())
   return value_sp;
   }
@@ -293,7 +289,11 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
   if (!ptr_obj_sp)
 return lldb::ChildCacheState::eRefetch;
 
-  m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get();
+  auto cast_ptr_sp = GetCxxSmartPtrElementPointerType(*ptr_obj_sp, *valobj_sp);
+  if (!cast_ptr_sp)
+return lldb::ChildCacheState::eRefetch;
+
+  m_ptr_obj = cast_ptr_sp->Clone(ConstString("pointer")).get();
 
   lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_"));
 
@@ -305,7 +305,7 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
 llvm::Expected
 lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  if (name == "__ptr_" || name == "pointer")
+  if (name == "pointer")
 return 0;
 
   if (name == "object" || name == "$$dereference$$")
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 84442273aebd4..d66b8339809be 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -273,11 +273,7 @@ 
LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
   return nullptr;
 
 Status status;
-auto value_type_sp = valobj_sp->GetCompilerType()
- .GetTypeTemplateArgument(0)
- .GetPointerType();
-ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp);
-ValueObjectSP value_sp = cast_ptr_sp->Dereference(status);
+ValueObjectSP value_sp = m_ptr_obj->Dereference(status);
 if (status.S

[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

> I'm not entirely comfortable with putting the (obviously c++ specific) helper 
> function into the DataFormatters) library. There's no reason to call this 
> from outside the c++ language plugin, right? What would you say to putting 
> this into some header inside the plugin (or creating a new one if we have 
> nothing suitable)?

Put it into `Generic.{h,cpp}` in the language plugin. Let me know if there's a 
more suitable place

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From 78533da4cfb0c5d5f9f142cce19609810e630dd7 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Jul 2025 18:36:57 +0100
Subject: [PATCH 1/4] [lldb][test] Combine libstdc++ and libc++ std::string
 tests into generic test

This combines the libc++ and libstdc++ test cases. The main difference was that 
the libstdcpp tests had additional tests for references/pointers to 
std::string. I moved those over.

Split out from https://github.com/llvm/llvm-project/pull/146740
---
 .../{libstdcpp => generic}/string/Makefile|   3 -
 .../string/TestDataFormatterStdString.py} |  54 +++--
 .../generic/string/main.cpp   | 104 ++
 .../data-formatter-stl/libcxx/string/Makefile |   6 -
 .../data-formatter-stl/libcxx/string/main.cpp |  31 --
 .../string/TestDataFormatterStdString.py  |  93 
 .../libstdcpp/string/main.cpp |  16 ---
 7 files changed, 147 insertions(+), 160 deletions(-)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => 
generic}/string/Makefile (53%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/string/TestDataFormatterLibcxxString.py
 => generic/string/TestDataFormatterStdString.py} (80%)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
similarity index 53%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
index c825977b1a5dc..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-CFLAGS_EXTRAS := -O0
-USE_LIBSTDCPP := 1
-
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
similarity index 80%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 2f7fc88e0f449..c19429e67c5c6 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -10,7 +10,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxStringDataFormatterTestCase(TestBase):
+class StdStringDataFormatterTestCase(TestBase):
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -18,17 +18,8 @@ def setUp(self):
 self.main_spec = lldb.SBFileSpec("main.cpp")
 self.namespace = "std"
 
-@add_test_categories(["libc++"])
-@expectedFailureAll(
-bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
-)
-# Inline namespace is randomly ignored as Clang due to broken lookup inside
-# the std namespace.
-@expectedFailureAll(debug_info="gmodules")
-def test_with_run_command(self):
+def do_test(self):
 """Test that that file and class static variables display correctly."""
-self.build()
-
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
 )
@@ -124,6 +115,25 @@ def cleanup():
 ],
 )
 
+# Test references and pointers to std::string.
+var_rq = self.frame().FindVariable("rq")
+var_rQ = self.frame().FindVariable("rQ")
+var_pq = self.frame().FindVariable("pq")
+var_pQ = self.frame().FindVariable("pQ")
+
+self.assertEqual(var_rq.GetSummary(), '"hello world"', "rq summary 
wrong")
+self.assertEqual(
+var_rQ.GetSummary(),
+'"quite a long std::strin with lots of info inside

[Lldb-commits] [lldb] [lldb] Deploy Python DLL on Windows (PR #137467)

2025-07-08 Thread Lawrence Bethlenfalvy via lldb-commits

lbfalvy wrote:

Until this is fixed, how would I determine the specific Python build I need to 
install for LLDB to work? A related issue mentioned 3.10.11 but that no longer 
seems correct so a way to find this info for ourself would be useful.

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


[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 45689b2 - [LLDB] Add type summaries for MSVC STL strings (#143177)

2025-07-08 Thread via lldb-commits

Author: nerix
Date: 2025-07-08T09:55:18+01:00
New Revision: 45689b26eb4bfa619127013dccea8efd8de4d21a

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

LOG: [LLDB] Add type summaries for MSVC STL strings (#143177)

This PR adds type summaries for
`std::{string,wstring,u8string,u16string,u32string}` from the MSVC STL.

See https://github.com/llvm/llvm-project/issues/24834 for the MSVC STL
issue.

The following changes were made:

- `dotest.py` now detects if the MSVC STL is available. It does so by
looking at the target triple, which is an additional argument passed
from Lit. It specifically checks for `windows-msvc` to not match on
`windows-gnu` (i.e. MinGW/Cygwin).
- (The main part): Added support for summarizing `std::(w)string` from
MSVC's STL. Because the type names from the libstdc++ (pre C++ 11)
string types are the same as on MSVC's STL, `CXXCompositeSummaryFormat`
is used with two entries, one for MSVC's STL and one for libstdc++.
With MSVC's STL, `std::u{8,16,32}string` is also handled. These aren't
handled for libstdc++, so I put them in `LoadMsvcStlFormatters`.

Added: 
lldb/source/Plugins/Language/CPlusPlus/MsvcStl.cpp
lldb/source/Plugins/Language/CPlusPlus/MsvcStl.h

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/TestDataFormatterMsvcStlString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/main.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/TestDataFormatterMsvcStlU8String.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/main.cpp

Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/test_categories.py
lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py

lldb/test/API/functionalities/data-formatter/stringprinter/TestStringPrinter.py
lldb/test/API/python_api/sbvalue_persist/TestSBValuePersist.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index d7f274ac4f60e..90c8e32afa507 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -831,6 +831,46 @@ def checkLibstdcxxSupport():
 configuration.skip_categories.append("libstdcxx")
 
 
+def canRunMsvcStlTests():
+from lldbsuite.test import lldbplatformutil
+
+platform = lldbplatformutil.getPlatform()
+if platform != "windows":
+return False, f"Don't know how to build with MSVC's STL on {platform}"
+
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-o", f.name, "-E", "-"]
+p = subprocess.Popen(
+cmd,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+universal_newlines=True,
+)
+_, stderr = p.communicate(
+"""
+#include 
+#ifndef _MSVC_STL_VERSION
+#error _MSVC_STL_VERSION not defined
+#endif
+"""
+)
+if not p.returncode:
+return True, "Compiling with MSVC STL"
+return (False, f"Not compiling with MSVC STL: {stderr}")
+
+
+def checkMsvcStlSupport():
+result, reason = canRunMsvcStlTests()
+if result:
+return  # msvcstl supported
+if "msvcstl" in configuration.categories_list:
+return  # msvcstl category explicitly requested, let it run.
+if configuration.verbose:
+print(f"msvcstl tests will not be run because: {reason}")
+configuration.skip_categories.append("msvcstl")
+
+
 def canRunWatchpointTests():
 from lldbsuite.test import lldbplatformutil
 
@@ -1044,6 +1084,7 @@ def run_suite():
 
 checkLibcxxSupport()
 checkLibstdcxxSupport()
+checkMsvcStlSupport()
 checkWatchpointSupport()
 checkDebugInfoSupport()
 checkDebugServerSupport()

diff  --git a/lldb/packages/Python/lldbsuite/test/test_categories.py 
b/lldb/packages/Python/lldbsuite/test/test_categories.py
index b585f695adeab..1f6e8a78e0c0d 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -33,6 +33,7 @@
 "lldb-server": "Tests related to lldb-server",
 "lldb-dap": "Tests for the Debug Adapter Protocol with lldb-dap",
 "llg

[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From 2fcd6b1084a6cf91c82aef0ebf78208eda868335 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sat, 5 Jul 2025 11:15:23 +0100
Subject: [PATCH 1/6] [lldb][test] Combine libstdc++ and libc++ tuple tests
 into generic test

This combines the libc++ and libstdc++ test cases. The main difference
was that the libstdcpp tests had some tuple indexing tests that libc++ didn't 
have.

Split out from https://github.com/llvm/llvm-project/pull/146740
---
 .../{libcxx => generic}/tuple/Makefile|  1 -
 .../tuple/TestDataFormatterStdTuple.py| 73 +++
 .../{libcxx => generic}/tuple/main.cpp|  3 +-
 .../tuple/TestDataFormatterLibcxxTuple.py | 45 
 .../libstdcpp/tuple/Makefile  |  5 --
 .../tuple/TestDataFormatterStdTuple.py| 47 
 .../libstdcpp/tuple/main.cpp  |  9 ---
 7 files changed, 75 insertions(+), 108 deletions(-)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/tuple/Makefile (75%)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/tuple/main.cpp (80%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
index 680e1abfbef58..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
new file mode 100644
index 0..9e019d328b6b3
--- /dev/null
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
@@ -0,0 +1,73 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestDataFormatterStdTuple(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.line = line_number("main.cpp", "// break here")
+self.namespace = "std"
+
+def do_test(self):
+"""Test that std::tuple is displayed correctly"""
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+tuple_name = self.namespace + "::tuple"
+self.expect("frame variable empty", substrs=[tuple_name, "size=0", 
"{}"])
+
+self.expect(
+"frame variable one_elt",
+substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
+)
+
+self.expect(
+"frame variable three_elts",
+substrs=[
+tuple_name,
+"size=3",
+"{",
+"[0] = 1",
+"[1] = 47",
+'[2] = "foo"',
+"}",
+],
+)
+
+self.assertEqual(
+1, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned()
+)
+self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid())
+
+self.assertEqual(
+'"foobar"', 
frame.GetValueForVariablePath("string_elt[0]").GetSummary()
+)
+
self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid())
+
+self.assertEqual(
+1, 
frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned()
+)
+self.assertEqual(
+'"baz"', 
frame.GetValueForVariablePath("three_elts[1]").GetSummary()
+)
+self.assertEqual(
+2, 
frame.GetValueForVariablePath("three_elts[2]").GetValueAsUnsigned()
+)
+
self.assertFalse(frame.GetValueForVa

[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

> I'm not entirely comfortable with putting the (obviously c++ specific) helper 
> function into the DataFormatters) library. There's no reason to call this 
> from outside the c++ language plugin, right? What would you say to putting 
> this into some header inside the plugin (or creating a new one if we have 
> nothing suitable)?

Yup that makes sense!

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From e592d39c751480838ed90fcaa2b247e96b5bab59 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sun, 6 Jul 2025 09:58:02 +0100
Subject: [PATCH 1/6] [lldb][test] Combine libstdc++ and libc++ std::variant
 tests into generic test

---
 .../{libcxx => generic}/variant/Makefile  |  4 +-
 .../variant/TestDataFormatterStdVariant.py}   | 44 +++--
 .../{libstdcpp => generic}/variant/main.cpp   | 21 ++--
 .../variant/TestDataFormatterLibcxxVariant.py | 88 -
 .../libcxx/variant/main.cpp   | 95 ---
 .../libstdcpp/variant/Makefile|  5 -
 6 files changed, 23 insertions(+), 234 deletions(-)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/variant/Makefile (82%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 => generic/variant/TestDataFormatterStdVariant.py} (59%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => 
generic}/variant/main.cpp (85%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
similarity index 82%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
index 7eeff7407804d..d5f5fec8441b5 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
@@ -1,6 +1,4 @@
 CXX_SOURCES := main.cpp
-
-USE_LIBCPP := 1
-
 CXXFLAGS_EXTRAS := -std=c++17
+
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
similarity index 59%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
index dae9b24fbbcfe..24ae9bfcd1a06 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter for LibStdC++ std::variant.
+Test lldb data formatter subsystem.
 """
 
 import lldb
@@ -8,18 +8,14 @@
 from lldbsuite.test import lldbutil
 
 
-class LibStdcxxVariantDataFormatterTestCase(TestBase):
-@add_test_categories(["libstdcxx"])
-def test_with_run_command(self):
-"""Test LibStdC++ std::variant data formatter works correctly."""
-self.build()
+class StdVariantDataFormatterTestCase(TestBase):
+def do_test(self):
+"""Test that that file and class static variables display correctly."""
 
 (self.target, self.process, _, bkpt) = 
lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp", False)
 )
 
-lldbutil.continue_to_breakpoint(self.process, bkpt)
-
 for name in ["v1", "v1_typedef"]:
 self.expect(
 "frame variable " + name,
@@ -69,28 +65,12 @@ def test_with_run_command(self):
 substrs=["v_many_types_valueless =  No Value"],
 )
 
-@add_test_categories(["libstdcxx"])
-def test_invalid_variant_index(self):
-"""Test LibStdC++ data formatter for std::variant with invalid 
index."""
-self.build()
-
-(self.target, self.process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(
-self, "// break here", lldb.SBFileSpec("main.cpp", False)
-)
-
-lldbutil.continue_to_breakpoint(self.process, bkpt)
-
-self.expect(
-"frame variable v1",
-substrs=["v1 =  Active Type = int  {", "Value = 12", "}"],
-)
-
-var_v1 = thread.frames[0].FindVariable("v1")
-var_v1_raw_obj = var_v1.GetNonSyntheticValue()
-index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
-self.assertTrue(index_obj and index_obj.IsValid())
+@add_test_categories(["libc++"

[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread Pavel Labath via lldb-commits

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

Thanks. I like how this means we no longer create the thread lazily.

I think I see one more race, see inline comment. LGTM assuming you agree with 
my analysis.

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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -110,6 +117,7 @@ class PipeEvent : public MainLoopWindows::IOEvent {
 continue;
   }
 
+  ResetEvent(m_ready);
   SetEvent(m_event);

labath wrote:

I think there's still a race here where if `WillPoll` runs between these two 
calls, it will observe both of them as unset, and trigger another iteration of 
the loop, even though we haven't consumed the previous event.  That next 
iteration could race with the consumption of that event.

I *think* that reversing the order is enough to avoid this.

```suggestion
  // Notify that data is available on the pipe. It's important to set this 
before clearing m_ready to avoid a race with WillPoll.
  SetEvent(m_event);
  // Stop polling until we're told to resume.
  ResetEvent(m_ready);
```

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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -65,15 +66,21 @@ class PipeEvent : public MainLoopWindows::IOEvent {
   }
 
   void WillPoll() override {
-if (!m_monitor_thread.joinable())
-  m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
+// If the m_event is signaled, wait until it is consumed before telling the
+// monitor thread to continue.
+if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) == WAIT_TIMEOUT &&
+WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) == WAIT_TIMEOUT)
+  SetEvent(m_ready);

labath wrote:

This is equivalent. I'm just adding some comments to explain why it is correct.
```suggestion
if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) != WAIT_TIMEOUT) {
  // The thread has already signalled that the data is available. No need 
for further polling until we consume that event.
  return;
}
if (WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) != WAIT_TIMEOUT) {
  // The thread is already waiting for data to become available.
  return;
}
// Start waiting.
SetEvent(m_ready);
```

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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)

2025-07-08 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Use protocol types for modules request and events. (PR #146966)

2025-07-08 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/146966

>From cc0846ca1aa8e302806154b3576698aa1c97dd0d Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 8 Jul 2025 13:57:57 +0100
Subject: [PATCH] [lldb-dap] Use protocol-types for modules request

---
 .../test/tools/lldb-dap/dap_server.py |  14 ++-
 .../module-event/TestDAP_module_event.py  |  19 ++--
 .../tools/lldb-dap/module/TestDAP_module.py   |  15 ++-
 lldb/tools/lldb-dap/DAP.cpp   |  47 
 .../Handler/ModulesRequestHandler.cpp |  76 +
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  95 
 lldb/tools/lldb-dap/JSONUtils.h   |  18 
 .../lldb-dap/Protocol/ProtocolEvents.cpp  |  16 +++
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h |  15 +++
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  14 +++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  21 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  46 
 lldb/tools/lldb-dap/ProtocolUtils.cpp | 102 ++
 lldb/tools/lldb-dap/ProtocolUtils.h   |  30 ++
 lldb/unittests/DAP/CMakeLists.txt |   1 +
 lldb/unittests/DAP/JSONUtilsTest.cpp  |  11 --
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  91 
 lldb/unittests/DAP/ProtocolUtilsTest.cpp  |  24 +
 20 files changed, 476 insertions(+), 215 deletions(-)
 create mode 100644 lldb/unittests/DAP/ProtocolUtilsTest.cpp

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 0fe36cd4bc71f..d227a66a703c1 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -199,8 +199,8 @@ def _read_packet_thread(self):
 finally:
 dump_dap_log(self.log_file)
 
-def get_modules(self):
-module_list = self.request_modules()["body"]["modules"]
+def get_modules(self, startModule: int = 0, moduleCount: int = 0):
+module_list = self.request_modules(startModule, 
moduleCount)["body"]["modules"]
 modules = {}
 for module in module_list:
 modules[module["name"]] = module
@@ -1143,8 +1143,14 @@ def request_completions(self, text, frameId=None):
 }
 return self.send_recv(command_dict)
 
-def request_modules(self):
-return self.send_recv({"command": "modules", "type": "request"})
+def request_modules(self, startModule: int, moduleCount: int):
+return self.send_recv(
+{
+"command": "modules",
+"type": "request",
+"arguments": {"startModule": startModule, "moduleCount": 
moduleCount},
+}
+)
 
 def request_stackTrace(
 self, threadId=None, startFrame=None, levels=None, format=None, 
dump=False
diff --git a/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py 
b/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
index 1ef2f2a8235a4..64ed4154b035d 100644
--- a/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
+++ b/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
@@ -32,7 +32,7 @@ def test_module_event(self):
 
 # Make sure we got a module event for libother.
 event = self.dap_server.wait_for_event("module", 5)
-self.assertTrue(event, "didn't get a module event")
+self.assertIsNotNone(event, "didn't get a module event")
 module_name = event["body"]["module"]["name"]
 module_id = event["body"]["module"]["id"]
 self.assertEqual(event["body"]["reason"], "new")
@@ -43,13 +43,20 @@ def test_module_event(self):
 
 # Make sure we got a module event for libother.
 event = self.dap_server.wait_for_event("module", 5)
-self.assertTrue(event, "didn't get a module event")
+self.assertIsNotNone(event, "didn't get a module event")
 reason = event["body"]["reason"]
-self.assertEqual(event["body"]["reason"], "removed")
+self.assertEqual(reason, "removed")
 self.assertEqual(event["body"]["module"]["id"], module_id)
 
-# The removed module event should omit everything but the module id.
-# Check that there's no module name in the event.
-self.assertNotIn("name", event["body"]["module"])
+# The removed module event should omit everything but the module id 
and name
+# as they are required fields.
+module_data = event["body"]["module"]
+required_keys = ["id", "name"]
+self.assertListEqual(list(module_data.keys()), required_keys)
+self.assertEqual(module_data["name"], "", "expects empty name.")
+
+# Make sure we do not send another event
+even

[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Pavel Labath via lldb-commits

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

This looks good. The problem with caching is not related to this patch.

> For now i think I'll probably i'll reset the formatters in the teardown hook, 
> but @jimingham comment on #110767 might be a good follow-up:
> 
> > Since this is just an optimization, we should first prove to ourselves that 
> > failing to put one of these type names in the exact matches really makes 
> > enough difference to bother with a complex solution.  If the gains are some 
> > but not huge, some boneheaded solution like never caching anything where 
> > the from type has a '<' and a '>' is probably sufficient.

However, I don't see how templates are related to this. I think the same thing 
can happen if I have `using MyType = TypeA;` in one binary and `using MyType = 
TypeB;` in another. If I cache the formatter for TypeA as the formatter for 
`MyType` (because that's correct for one binary) and then use that in the other 
binary, things will blow up. Technically, even `TypeA` in one binary need not 
have anything to do with `TypeA` in the second one, but we currently don't have 
a way to say which version of TypeA we are trying to format.

I think my ideal solution would be to have the formatter cache be per-target. I 
like that because it opens the door to having data formatters be registered 
per-target, which then means you don't have to have uber-formatters which know 
how to format every version of some struct.

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


[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From dba291d4b0b5ac6e62cfc084340cc0524d15d51c Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Jul 2025 14:45:59 +0100
Subject: [PATCH 1/3] [lldb][Formatters] Consistently unwrap pointer
 element_type in std::shared_ptr formatters

---
 .../lldb/DataFormatters/FormattersHelpers.h|  5 +
 lldb/source/DataFormatters/FormattersHelpers.cpp   | 13 +
 lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp  | 14 +++---
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp   | 12 ++--
 .../shared_ptr/TestDataFormatterStdSharedPtr.py|  4 
 5 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index 6a47cf37eac64..c7ce199452e1d 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -63,6 +63,11 @@ void DumpCxxSmartPtrPointerSummary(Stream &stream, 
ValueObject &ptr,
 bool ContainerSizeSummaryProvider(ValueObject &valobj, Stream &stream,
   const TypeSummaryOptions &options);
 
+/// Return the ValueObjectSP of the underlying pointer member whose type
+/// is a desugared 'std::shared_ptr::element_type *'.
+lldb::ValueObjectSP GetCxxSmartPtrElementPointerType(ValueObject &ptr,
+ ValueObject &container);
+
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 
 time_t GetOSXEpoch();
diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 028fc5da73dc0..104c2ce6f1c0a 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -151,3 +151,16 @@ bool 
lldb_private::formatters::ContainerSizeSummaryProvider(
   return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr,
nullptr, nullptr, &valobj, false, 
false);
 }
+
+ValueObjectSP lldb_private::formatters::GetCxxSmartPtrElementPointerType(
+ValueObject &ptr, ValueObject &container) {
+  auto container_type = container.GetCompilerType().GetNonReferenceType();
+  if (!container_type)
+return nullptr;
+
+  auto arg = container_type.GetTypeTemplateArgument(0);
+  if (!arg)
+return nullptr;
+
+  return ptr.Cast(arg.GetPointerType());
+}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 3079de4936a85..f73a77836034f 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -264,11 +264,7 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
 
   if (idx == 1) {
 Status status;
-auto value_type_sp = valobj_sp->GetCompilerType()
- .GetTypeTemplateArgument(0)
- .GetPointerType();
-ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp);
-ValueObjectSP value_sp = cast_ptr_sp->Dereference(status);
+ValueObjectSP value_sp = m_ptr_obj->Dereference(status);
 if (status.Success())
   return value_sp;
   }
@@ -293,7 +289,11 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
   if (!ptr_obj_sp)
 return lldb::ChildCacheState::eRefetch;
 
-  m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get();
+  auto cast_ptr_sp = GetCxxSmartPtrElementPointerType(*ptr_obj_sp, *valobj_sp);
+  if (!cast_ptr_sp)
+return lldb::ChildCacheState::eRefetch;
+
+  m_ptr_obj = cast_ptr_sp->Clone(ConstString("pointer")).get();
 
   lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_"));
 
@@ -305,7 +305,7 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
 llvm::Expected
 lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  if (name == "__ptr_" || name == "pointer")
+  if (name == "pointer")
 return 0;
 
   if (name == "object" || name == "$$dereference$$")
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 84442273aebd4..d66b8339809be 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -273,11 +273,7 @@ 
LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
   return nullptr;
 
 Status status;
-auto value_type_sp = valobj_sp->GetCompilerType()
- .GetTypeTemplateArgument(0)
- .GetPointerType();
-ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp);
-ValueObjectSP value_sp = cast_ptr_sp->Dereference(status);
+ValueObjectSP value_sp = m_ptr_obj->Dereference(status);
 if (status.S

[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -580,17 +564,23 @@ bool AdbClient::SyncService::IsConnected() const {
   return m_conn && m_conn->IsConnected();
 }
 
-AdbClient::SyncService::SyncService(std::unique_ptr &&conn)
-: m_conn(std::move(conn)) {}
+AdbClient::SyncService::SyncService(std::unique_ptr conn, const 
std::string &device_id)
+: m_conn(std::move(conn)), m_device_id(device_id) {}

labath wrote:

Use StringRef or move the string.

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-07-08 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -241,6 +234,10 @@ Status AdbClient::SendDeviceMessage(const std::string 
&packet) {
 Status AdbClient::ReadMessage(std::vector &message) {
   message.clear();
 
+  if (!m_conn) {

labath wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
 here and elsewhere

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -665,3 +655,40 @@ Status 
AdbClient::SyncService::PullFileChunk(std::vector &buffer,
 Status AdbClient::SyncService::ReadAllBytes(void *buffer, size_t size) {
   return ::ReadAllBytes(*m_conn, buffer, size);
 }
+
+Status AdbClient::SyncService::SetupSyncConnection(const std::string 
&device_id) {
+  if (!m_conn) {

labath wrote:

This moving of connections around is very unelegant. Could you at least make it 
so that the connection is moved at most once, e.g. created inside AdbClient and 
then moved into this object.

Though ideally, I would try to avoid using AdbClient here at all by making any 
methods that need to operate on the connection static (something similar to 
ReadAllBytes).

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


[Lldb-commits] [lldb] [lldb-dap] Use protocol types for modules request and events. (PR #146966)

2025-07-08 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread John Harrison via lldb-commits

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

>From 8a60d1cbd3d75e640d5efddf23c717278e7d6b80 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 7 Jul 2025 17:31:25 -0700
Subject: [PATCH 1/2] [lldb] Improving synchronization of MainLoopWindows.

This should improve synchronizing the MainLoopWindows monitor thread with the 
main loop state.

This uses the `m_ready` and `m_event` event handles to manage when the Monitor 
thread continues and adds new tests to cover additional use cases.
---
 lldb/source/Host/windows/MainLoopWindows.cpp |  24 ++--
 lldb/unittests/Host/MainLoopTest.cpp | 141 ++-
 2 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index b3322e8b3ae59..4e2c1d6de894a 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -12,16 +12,16 @@
 #include "lldb/Host/windows/windows.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/WindowsError.h"
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace lldb;
@@ -42,11 +42,12 @@ namespace {
 class PipeEvent : public MainLoopWindows::IOEvent {
 public:
   explicit PipeEvent(HANDLE handle)
-  : IOEvent(CreateEventW(NULL, /*bManualReset=*/FALSE,
+  : IOEvent(CreateEventW(NULL, /*bManualReset=*/TRUE,
  /*bInitialState=*/FALSE, NULL)),
-m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/FALSE,
+m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/TRUE,
/*bInitialState=*/FALSE, NULL)) 
{
 assert(m_event && m_ready);
+m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
   }
 
   ~PipeEvent() override {
@@ -65,15 +66,21 @@ class PipeEvent : public MainLoopWindows::IOEvent {
   }
 
   void WillPoll() override {
-if (!m_monitor_thread.joinable())
-  m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
+// If the m_event is signaled, wait until it is consumed before telling the
+// monitor thread to continue.
+if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) == WAIT_TIMEOUT &&
+WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) == WAIT_TIMEOUT)
+  SetEvent(m_ready);
   }
 
-  void Disarm() override { SetEvent(m_ready); }
+  void Disarm() override { ResetEvent(m_event); }
 
   /// Monitors the handle performing a zero byte read to determine when data is
   /// avaiable.
   void Monitor() {
+// Wait until the MainLoop tells us to start.
+WaitForSingleObject(m_ready, INFINITE);
+
 do {
   char buf[1];
   DWORD bytes_read = 0;
@@ -110,6 +117,7 @@ class PipeEvent : public MainLoopWindows::IOEvent {
 continue;
   }
 
+  ResetEvent(m_ready);
   SetEvent(m_event);
 
   // Wait until the current read is consumed before doing the next read.
diff --git a/lldb/unittests/Host/MainLoopTest.cpp 
b/lldb/unittests/Host/MainLoopTest.cpp
index 502028ae1a343..30585d12fe81d 100644
--- a/lldb/unittests/Host/MainLoopTest.cpp
+++ b/lldb/unittests/Host/MainLoopTest.cpp
@@ -10,6 +10,7 @@
 #include "TestingSupport/SubsystemRAII.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/MainLoopBase.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
@@ -64,7 +65,7 @@ class MainLoopTest : public testing::Test {
 };
 } // namespace
 
-TEST_F(MainLoopTest, ReadObject) {
+TEST_F(MainLoopTest, ReadSocketObject) {
   char X = 'X';
   size_t len = sizeof(X);
   ASSERT_TRUE(socketpair[0]->Write(&X, len).Success());
@@ -101,6 +102,144 @@ TEST_F(MainLoopTest, ReadPipeObject) {
   ASSERT_EQ(1u, callback_count);
 }
 
+TEST_F(MainLoopTest, MultipleReadsPipeObject) {
+  Pipe pipe;
+
+  ASSERT_TRUE(pipe.CreateNew().Success());
+
+  MainLoop loop;
+
+  std::future async_writer = std::async(std::launch::async, [&] {
+for (int i = 0; i < 5; ++i) {
+  std::this_thread::sleep_for(std::chrono::milliseconds(500));
+  char X = 'X';
+  size_t len = sizeof(X);
+  ASSERT_THAT_EXPECTED(pipe.Write(&X, len), llvm::HasValue(1));
+}
+  });
+
+  Status error;
+  lldb::FileSP file = std::make_shared(
+  pipe.GetReadFileDescriptor(), File::eOpenOptionReadOnly, false);
+  auto handle = loop.RegisterReadObject(
+  file,
+  [&](MainLoopBase &loop) {
+callback_count++;
+if (callback_count == 5)
+  loop.RequestTermination();
+
+// Read some data to ensure the handle is not in a readable state.
+char buf[1024] = {0};
+size_t len = sizeof(buf);
+ASSERT_THAT_ERROR(file->Read(buf, len).T

[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
lldb/source/Host/windows/MainLoopWindows.cpp 
lldb/unittests/Host/MainLoopTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index ae3d460aa..a1de895c0 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -67,7 +67,8 @@ public:
 
   void WillPoll() override {
 if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) != WAIT_TIMEOUT) {
-  // The thread has already signalled that the data is available. No need 
for further polling until we consume that event.
+  // The thread has already signalled that the data is available. No need
+  // for further polling until we consume that event.
   return;
 }
 if (WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) != WAIT_TIMEOUT) {
@@ -122,7 +123,8 @@ public:
 continue;
   }
 
-  // Notify that data is available on the pipe. It's important to set this 
before clearing m_ready to avoid a race with WillPoll.
+  // Notify that data is available on the pipe. It's important to set this
+  // before clearing m_ready to avoid a race with WillPoll.
   SetEvent(m_event);
   // Stop polling until we're told to resume.
   ResetEvent(m_ready);

``




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


[Lldb-commits] [lldb] [lldb-dap] Use protocol types for modules request and events. (PR #146966)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread John Harrison via lldb-commits

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

>From 8a60d1cbd3d75e640d5efddf23c717278e7d6b80 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 7 Jul 2025 17:31:25 -0700
Subject: [PATCH 1/4] [lldb] Improving synchronization of MainLoopWindows.

This should improve synchronizing the MainLoopWindows monitor thread with the 
main loop state.

This uses the `m_ready` and `m_event` event handles to manage when the Monitor 
thread continues and adds new tests to cover additional use cases.
---
 lldb/source/Host/windows/MainLoopWindows.cpp |  24 ++--
 lldb/unittests/Host/MainLoopTest.cpp | 141 ++-
 2 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index b3322e8b3ae59..4e2c1d6de894a 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -12,16 +12,16 @@
 #include "lldb/Host/windows/windows.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/WindowsError.h"
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace lldb;
@@ -42,11 +42,12 @@ namespace {
 class PipeEvent : public MainLoopWindows::IOEvent {
 public:
   explicit PipeEvent(HANDLE handle)
-  : IOEvent(CreateEventW(NULL, /*bManualReset=*/FALSE,
+  : IOEvent(CreateEventW(NULL, /*bManualReset=*/TRUE,
  /*bInitialState=*/FALSE, NULL)),
-m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/FALSE,
+m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/TRUE,
/*bInitialState=*/FALSE, NULL)) 
{
 assert(m_event && m_ready);
+m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
   }
 
   ~PipeEvent() override {
@@ -65,15 +66,21 @@ class PipeEvent : public MainLoopWindows::IOEvent {
   }
 
   void WillPoll() override {
-if (!m_monitor_thread.joinable())
-  m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
+// If the m_event is signaled, wait until it is consumed before telling the
+// monitor thread to continue.
+if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) == WAIT_TIMEOUT &&
+WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) == WAIT_TIMEOUT)
+  SetEvent(m_ready);
   }
 
-  void Disarm() override { SetEvent(m_ready); }
+  void Disarm() override { ResetEvent(m_event); }
 
   /// Monitors the handle performing a zero byte read to determine when data is
   /// avaiable.
   void Monitor() {
+// Wait until the MainLoop tells us to start.
+WaitForSingleObject(m_ready, INFINITE);
+
 do {
   char buf[1];
   DWORD bytes_read = 0;
@@ -110,6 +117,7 @@ class PipeEvent : public MainLoopWindows::IOEvent {
 continue;
   }
 
+  ResetEvent(m_ready);
   SetEvent(m_event);
 
   // Wait until the current read is consumed before doing the next read.
diff --git a/lldb/unittests/Host/MainLoopTest.cpp 
b/lldb/unittests/Host/MainLoopTest.cpp
index 502028ae1a343..30585d12fe81d 100644
--- a/lldb/unittests/Host/MainLoopTest.cpp
+++ b/lldb/unittests/Host/MainLoopTest.cpp
@@ -10,6 +10,7 @@
 #include "TestingSupport/SubsystemRAII.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/MainLoopBase.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
@@ -64,7 +65,7 @@ class MainLoopTest : public testing::Test {
 };
 } // namespace
 
-TEST_F(MainLoopTest, ReadObject) {
+TEST_F(MainLoopTest, ReadSocketObject) {
   char X = 'X';
   size_t len = sizeof(X);
   ASSERT_TRUE(socketpair[0]->Write(&X, len).Success());
@@ -101,6 +102,144 @@ TEST_F(MainLoopTest, ReadPipeObject) {
   ASSERT_EQ(1u, callback_count);
 }
 
+TEST_F(MainLoopTest, MultipleReadsPipeObject) {
+  Pipe pipe;
+
+  ASSERT_TRUE(pipe.CreateNew().Success());
+
+  MainLoop loop;
+
+  std::future async_writer = std::async(std::launch::async, [&] {
+for (int i = 0; i < 5; ++i) {
+  std::this_thread::sleep_for(std::chrono::milliseconds(500));
+  char X = 'X';
+  size_t len = sizeof(X);
+  ASSERT_THAT_EXPECTED(pipe.Write(&X, len), llvm::HasValue(1));
+}
+  });
+
+  Status error;
+  lldb::FileSP file = std::make_shared(
+  pipe.GetReadFileDescriptor(), File::eOpenOptionReadOnly, false);
+  auto handle = loop.RegisterReadObject(
+  file,
+  [&](MainLoopBase &loop) {
+callback_count++;
+if (callback_count == 5)
+  loop.RequestTermination();
+
+// Read some data to ensure the handle is not in a readable state.
+char buf[1024] = {0};
+size_t len = sizeof(buf);
+ASSERT_THAT_ERROR(file->Read(buf, len).T

[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread John Harrison via lldb-commits

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

>From 8a60d1cbd3d75e640d5efddf23c717278e7d6b80 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 7 Jul 2025 17:31:25 -0700
Subject: [PATCH 1/3] [lldb] Improving synchronization of MainLoopWindows.

This should improve synchronizing the MainLoopWindows monitor thread with the 
main loop state.

This uses the `m_ready` and `m_event` event handles to manage when the Monitor 
thread continues and adds new tests to cover additional use cases.
---
 lldb/source/Host/windows/MainLoopWindows.cpp |  24 ++--
 lldb/unittests/Host/MainLoopTest.cpp | 141 ++-
 2 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index b3322e8b3ae59..4e2c1d6de894a 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -12,16 +12,16 @@
 #include "lldb/Host/windows/windows.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/WindowsError.h"
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 using namespace lldb;
@@ -42,11 +42,12 @@ namespace {
 class PipeEvent : public MainLoopWindows::IOEvent {
 public:
   explicit PipeEvent(HANDLE handle)
-  : IOEvent(CreateEventW(NULL, /*bManualReset=*/FALSE,
+  : IOEvent(CreateEventW(NULL, /*bManualReset=*/TRUE,
  /*bInitialState=*/FALSE, NULL)),
-m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/FALSE,
+m_handle(handle), m_ready(CreateEventW(NULL, /*bManualReset=*/TRUE,
/*bInitialState=*/FALSE, NULL)) 
{
 assert(m_event && m_ready);
+m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
   }
 
   ~PipeEvent() override {
@@ -65,15 +66,21 @@ class PipeEvent : public MainLoopWindows::IOEvent {
   }
 
   void WillPoll() override {
-if (!m_monitor_thread.joinable())
-  m_monitor_thread = std::thread(&PipeEvent::Monitor, this);
+// If the m_event is signaled, wait until it is consumed before telling the
+// monitor thread to continue.
+if (WaitForSingleObject(m_event, /*dwMilliseconds=*/0) == WAIT_TIMEOUT &&
+WaitForSingleObject(m_ready, /*dwMilliseconds=*/0) == WAIT_TIMEOUT)
+  SetEvent(m_ready);
   }
 
-  void Disarm() override { SetEvent(m_ready); }
+  void Disarm() override { ResetEvent(m_event); }
 
   /// Monitors the handle performing a zero byte read to determine when data is
   /// avaiable.
   void Monitor() {
+// Wait until the MainLoop tells us to start.
+WaitForSingleObject(m_ready, INFINITE);
+
 do {
   char buf[1];
   DWORD bytes_read = 0;
@@ -110,6 +117,7 @@ class PipeEvent : public MainLoopWindows::IOEvent {
 continue;
   }
 
+  ResetEvent(m_ready);
   SetEvent(m_event);
 
   // Wait until the current read is consumed before doing the next read.
diff --git a/lldb/unittests/Host/MainLoopTest.cpp 
b/lldb/unittests/Host/MainLoopTest.cpp
index 502028ae1a343..30585d12fe81d 100644
--- a/lldb/unittests/Host/MainLoopTest.cpp
+++ b/lldb/unittests/Host/MainLoopTest.cpp
@@ -10,6 +10,7 @@
 #include "TestingSupport/SubsystemRAII.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/MainLoopBase.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
@@ -64,7 +65,7 @@ class MainLoopTest : public testing::Test {
 };
 } // namespace
 
-TEST_F(MainLoopTest, ReadObject) {
+TEST_F(MainLoopTest, ReadSocketObject) {
   char X = 'X';
   size_t len = sizeof(X);
   ASSERT_TRUE(socketpair[0]->Write(&X, len).Success());
@@ -101,6 +102,144 @@ TEST_F(MainLoopTest, ReadPipeObject) {
   ASSERT_EQ(1u, callback_count);
 }
 
+TEST_F(MainLoopTest, MultipleReadsPipeObject) {
+  Pipe pipe;
+
+  ASSERT_TRUE(pipe.CreateNew().Success());
+
+  MainLoop loop;
+
+  std::future async_writer = std::async(std::launch::async, [&] {
+for (int i = 0; i < 5; ++i) {
+  std::this_thread::sleep_for(std::chrono::milliseconds(500));
+  char X = 'X';
+  size_t len = sizeof(X);
+  ASSERT_THAT_EXPECTED(pipe.Write(&X, len), llvm::HasValue(1));
+}
+  });
+
+  Status error;
+  lldb::FileSP file = std::make_shared(
+  pipe.GetReadFileDescriptor(), File::eOpenOptionReadOnly, false);
+  auto handle = loop.RegisterReadObject(
+  file,
+  [&](MainLoopBase &loop) {
+callback_count++;
+if (callback_count == 5)
+  loop.RequestTermination();
+
+// Read some data to ensure the handle is not in a readable state.
+char buf[1024] = {0};
+size_t len = sizeof(buf);
+ASSERT_THAT_ERROR(file->Read(buf, len).T

[Lldb-commits] [lldb] d9b208b - [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (#147253)

2025-07-08 Thread via lldb-commits

Author: Michael Buch
Date: 2025-07-08T14:09:32+01:00
New Revision: d9b208b4d31d863c86e27e8889a521a82385f1a7

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

LOG: [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic 
test (#147253)

This combines the libc++ and libstdc++ test cases. The libstdc++ test
had an additional test-case for "reference to typedef". So I added those
to the generic test. The rest of the tests was the same as libc++.

I also moved the test-case for checking invalid variant indexes into a
separate libstdcpp test because it relied on the layout of the libstdc++
type. We should probably rewrite it in the "simulator" style. But for
now I just moved it.

This also removes some redundant checks for libc++ versions and
existence of the `variant` header, which at this point should be
available anywhere these tests are run.

Split out from https://github.com/llvm/llvm-project/pull/146740

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/invalid-variant/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/invalid-variant/TestDataFormatterInvalidStdVariant.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/invalid-variant/main.cpp

Modified: 


Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp



diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
similarity index 82%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
index 7eeff7407804d..d5f5fec8441b5 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile
@@ -1,6 +1,4 @@
 CXX_SOURCES := main.cpp
-
-USE_LIBCPP := 1
-
 CXXFLAGS_EXTRAS := -std=c++17
+
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
similarity index 56%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
index dae9b24fbbcfe..9365cfc96783e 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter for LibStdC++ std::variant.
+Test lldb data formatter subsystem.
 """
 
 import lldb
@@ -8,18 +8,23 @@
 from lldbsuite.test import lldbutil
 
 
-class LibStdcxxVariantDataFormatterTestCase(TestBase):
-@add_test_categories(["libstdcxx"])
-def test_with_run_command(self):
-"""Test LibStdC++ std::variant data formatter works correctly."""
-self.build()
+class StdVariantDataFormatterTestCase(TestBase):
+def do_test(self):
+"""Test that that file and class static variables display correctly."""
+
+def cleanup():
+self.runCmd("type format clear", check=False)
+self.runCmd("type summary clear", check=False)
+self.runCmd("type filter clear", check=False)
+self.runCmd("type synth clear", check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
 
  

[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

> This looks good. The problem with caching is not related to this patch.
> 
> > For now i think I'll probably i'll reset the formatters in the teardown 
> > hook, but @jimingham comment on #110767 might be a good follow-up:
> > > Since this is just an optimization, we should first prove to ourselves 
> > > that failing to put one of these type names in the exact matches really 
> > > makes enough difference to bother with a complex solution.  If the gains 
> > > are some but not huge, some boneheaded solution like never caching 
> > > anything where the from type has a '<' and a '>' is probably sufficient.
> 
> However, I don't see how templates are related to this. I think the same 
> thing can happen if I have `using MyType = TypeA;` in one binary and `using 
> MyType = TypeB;` in another. If I cache the formatter for TypeA as the 
> formatter for `MyType` (because that's correct for one binary) and then use 
> that in the other binary, things will blow up. Technically, even `TypeA` in 
> one binary need not have anything to do with `TypeA` in the second one, but 
> we currently don't have a way to say which version of TypeA we are trying to 
> format.

Yup agreed, it's unrelated to templates. Re. Jim's comment, I meant the part 
about checking whether caching typedefs at all is a good idea. But making the 
cache per-target as you suggest seems like a good solution.

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


[Lldb-commits] [lldb] 1f28da6 - [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (#147355)

2025-07-08 Thread via lldb-commits

Author: Michael Buch
Date: 2025-07-08T14:09:48+01:00
New Revision: 1f28da60d5dfa51b1e623fdd168fbb3ea85f6ac9

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

LOG: [lldb][test] Combine libstdc++ and libc++ std::string tests into generic 
test (#147355)

This combines the libc++ and libstdc++ test cases. The main difference
was that the libstdcpp tests had additional tests for
references/pointers to std::string. I moved those over.

The libstdc++ formatters don't support `std::u16string`/`std::u32string`
yet, so I extracted those into XFAILed test cases.

There were also two test assertions that failed for libstdc++:
1. libstdc++ doesn't obey the capped/uncapped summary options
2. When a summary isn't available for a std::string, libc++ would print
"Summary Unavailable", whereas libstdc++ just prints "((null))". This
may be better suited for the STL-specific subdirectories, but left it
here for now.

I put those in separate XFAILed test-cases.

Split out from https://github.com/llvm/llvm-project/pull/146740

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp

Modified: 


Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp



diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
similarity index 53%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
index c825977b1a5dc..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-CFLAGS_EXTRAS := -O0
-USE_LIBSTDCPP := 1
-
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
similarity index 52%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 2f7fc88e0f449..7ae5687af2cf4 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -10,7 +10,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxStringDataFormatterTestCase(TestBase):
+class StdStringDataFormatterTestCase(TestBase):
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -18,17 +18,8 @@ def setUp(self):
 self.main_spec = lldb.SBFileSpec("main.cpp")
 self.namespace = "std"
 
-@add_test_categories(["libc++"])
-@expectedFailureAll(
-bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
-)
-# Inline namespace is randomly ignored as Clang due to broken lookup inside
-# the std namespace.
-@expectedFailureAll(debug_info="gmodules")
-def test_with_run_command(self):
+def do_test(self):
 """Test that that file and class static variables display correctly."""
-self.build()
-
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
 )
@@ -47,42 +38,13 @@ def cleanup():
 
 ns = self.namespace
 
-self.expect(
-"frame variable",
-substrs=[
-'(%s::wstring) wempty = L""' % ns,
-'(%s::wstring) s = L"hello world! מזל טוב!"' % ns,

[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Pavel Labath via lldb-commits

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

I find `Generic.h` a bit... generic, but it's there, so ship it.

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


[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Pavel Labath via lldb-commits


@@ -19,6 +19,11 @@ namespace formatters {
 bool GenericOptionalSummaryProvider(ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions &options);
 
+/// Return the ValueObjectSP of the underlying pointer member whose type
+/// is a desugared 'std::shared_ptr::element_type *'.
+lldb::ValueObjectSP GetCxxSmartPtrElementPointerType(ValueObject &ptr,

labath wrote:

`GetDesugaredSmartPointerValue` ?

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test (PR #147355)

2025-07-08 Thread Pavel Labath via lldb-commits

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

FWIW, I don't find `(null)` nor `Summary Unavailable` particularly good 
summaries for `(std::string*)NULL`. At least in Python, I believe that 
returning an empty string from the summary provider causes lldb to treat it as 
not present and show the raw value of the object. In case the object is 
corrupted, I think that's the best we can do.

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


[Lldb-commits] [lldb] [lldb][test] Move std::queue from libcxx to generic directory (PR #147529)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This just moves the test from `libcxx` to `generic`. There are currently no 
`std::queue` formatters for libstdc++ so I didn't add a test-case for it.

Split out from https://github.com/llvm/llvm-project/pull/146740

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


3 Files Affected:

- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
 (-1) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
 (+3-4) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
 (+2-2) 


``diff
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
index 680e1abfbef58..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
similarity index 90%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
index 53eaf5a23cc07..ac729c5bacb0f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
@@ -2,14 +2,13 @@
 Test lldb data formatter subsystem.
 """
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class TestDataFormatterLibcxxQueue(TestBase):
+class TestDataFormatterStdQueue(TestBase):
 def setUp(self):
 TestBase.setUp(self)
 self.namespace = "std"
@@ -30,9 +29,9 @@ def check_variable(self, name):
 bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
 )
 @add_test_categories(["libc++"])
-def test(self):
+def test_libcxx(self):
 """Test that std::queue is displayed correctly"""
-self.build()
+self.build(dictionary={"USE_LIBCPP": 1})
 lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp", False)
 )
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
index f3b5f32817970..406b437914932 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
@@ -2,8 +2,8 @@
 #include 
 
 int main() {
-  std::queue q1{{1,2,3,4,5}};
-  std::queue> q2{{1,2,3,4,5}};
+  std::queue q1{{1, 2, 3, 4, 5}};
+  std::queue> q2{{1, 2, 3, 4, 5}};
   int ret = q1.size() + q2.size(); // break here
   return ret;
 }

``




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


[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread Pavel Labath via lldb-commits

labath wrote:

>  But libc++ and libstdc++ print it as "abcd" (which seems like the more 
> correct thing to do?)

I'm not so sure about that. std::string has a separate length field and it can 
contain embedded nul characters, so I can at least understand the idea of 
trusting the length field more than we trust the terminator. It would be an 
interesting experiment to see what happens when you take a corrupted string 
like this and try to e.g. `<<` it to a stream. My guess is it would print 
"abc". (of course, that's undefined, so there's no guarantee all STLs will 
behave the same way)

For libstdc++, I guess this happens because we have the simple summary 
`${var._M_ptr}` (or whatever), but I think this actually shows that this 
summary is wrong it will not print anything that comes after a (perfectly 
legal) internal nul character. I have no idea why this happens for libc++.

Given that the terminator is a part of the std::string contract, I can also 
imagine the formatter flagging this specially in some way (`"abc" 
` ?)

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


[Lldb-commits] [lldb] Implement RISCV function unwinding using instruction emulation (PR #147434)

2025-07-08 Thread via lldb-commits

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


[Lldb-commits] [libcxx] [lldb] [libcxx] adds size-based `__split_buffer` representation to unstable ABI (PR #139632)

2025-07-08 Thread Christopher Di Bella via lldb-commits




cjdb wrote:

@vogelsgesang, this patch is only changing `__split_buffer`. The intention was 
for this patch to be quickly merged, and for the feedback from this patch to 
influence the changes to `vector` (thereby minimising churn and repeated 
comments). Changes to `vector` will be in a follow-up patch, where I'll target 
`vector`'s pretty printers.

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


[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)

2025-07-08 Thread via lldb-commits

YexuanXiao wrote:

The failed tests in CI are allowed to fail. See the 
[comment](https://github.com/llvm/llvm-project/pull/135386#issuecomment-3049426611)
 in another PR #135386.

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-08 Thread Haojian Wu via lldb-commits

hokein wrote:

> Ah, not a problem, the new one is fine. I was just very thrown/wondering why 
> I was reviewing something so similar again.

Sorry for not being clearer about that. I’ll go ahead and close the previous 
review. The new one should already incorporate your review comments from the 
previous one.

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


[Lldb-commits] [lldb] [llvm] [lldb][NFC][MachO] Clean up LC_THREAD reading code, remove i386 corefile (PR #146480)

2025-07-08 Thread Pavel Labath via lldb-commits

labath wrote:

> > Sorry for going off-topic, but what does this say about the support for 
> > `i386-apple-*` as a whole? I find the prospect of dropping that exciting, 
> > as I believe that is the only target where eh_ and debug_frame register 
> > numbers are different.
> 
> I think we can remove i386-macos support, short of booting a seven year old 
> OS on a machine at least that old, and who knows if everything in C++17 we 
> use is even supported by the compilers back then. I know there are sometimes 
> open source people trying to build & use a modern lldb on older 
> configurations, but I think this would be a tough one to have working at this 
> point. I wouldn't feel bad about any patches removing this support. I'll try 
> to start removing these things as I have time/see an opportunity.
> 
> Apple announced that the macOS version being released in a few months (macOS 
> 26) would be the final version that supports Intel machines at all. We'll 
> have a business requirement to keep the 64-bit Intel support for another 
> release cycle or so after that. What open source contributors might be using 
> the llvm.org sources on is a different question, but the entire target 
> support is going to go away before much longer I think.

Got it. Thanks for clarifying.

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-07-08 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

I'm not very fond of the amount of validity checks this PR is adding. What's up 
with that? Is it somehow related to you passing a non-nullptr-but-uninitialized 
Connection object (`std::make_unique()`) into the 
AdbClient? Any chance to get rid of that? Maybe by using a nullptr to mean "no 
connection"? Or by reducing the amount of moving around?

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


[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (PR #147175)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From 24240c7efa951340d7f19e0f74d1075ab100598e Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sun, 6 Jul 2025 07:49:57 +0100
Subject: [PATCH 1/3] [lldb][test] Combine libstdc++ and libc++ iterator tests
 into generic test

---
 .../{libcxx => generic}/iterator/Makefile |  3 -
 .../iterator/TestDataFormatterStdIterator.py} | 19 --
 .../{libcxx => generic}/iterator/main.cpp |  0
 .../libstdcpp/iterator/Makefile   |  6 --
 .../iterator/TestDataFormatterStdIterator.py  | 60 ---
 .../libstdcpp/iterator/main.cpp   | 38 
 6 files changed, 13 insertions(+), 113 deletions(-)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/iterator/Makefile (54%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/iterator/TestDataFormatterLibccIterator.py
 => generic/iterator/TestDataFormatterStdIterator.py} (90%)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/iterator/main.cpp (100%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
index 564cbada74e08..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
@@ -1,6 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
-
-CXXFLAGS_EXTRAS := -O0
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py
similarity index 90%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py
index c43ee46fb658a..9cd1001352def 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py
@@ -2,14 +2,13 @@
 Test lldb data formatter subsystem.
 """
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class LibcxxIteratorDataFormatterTestCase(TestBase):
+class StdIteratorDataFormatterTestCase(TestBase):
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -17,10 +16,8 @@ def setUp(self):
 self.line = line_number("main.cpp", "// Set break point at this line.")
 self.namespace = "std"
 
-@add_test_categories(["libc++"])
-def test_with_run_command(self):
-"""Test that libc++ iterators format properly."""
-self.build()
+def do_test(self):
+"""Test that iterators format properly."""
 self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
 
 lldbutil.run_break_set_by_file_and_line(
@@ -84,3 +81,13 @@ def cleanup():
 self.expect("frame variable siumI.first", substrs=["second"], 
matching=False)
 self.expect("frame variable siumI.second", substrs=["second = 137"])
 self.expect("frame variable siumI.second", substrs=["first"], 
matching=False)
+
+@add_test_categories(["libc++"])
+def test_libcxx(self):
+self.build(dictionary={"USE_LIBCPP": 1})
+self.do_test()
+
+@add_test_categories(["libstdcpp"])
+def test_libstdcxx(self):
+self.build(dictionary={"USE_LIBSTDCPP": 1})
+self.do_test()
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp
similarity index 100%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp
diff 

[Lldb-commits] [lldb] f999918 - [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (#147340)

2025-07-08 Thread via lldb-commits

Author: Michael Buch
Date: 2025-07-08T14:45:15+01:00
New Revision: f184ddde1bc5de1bba0e25780cb25f435909

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

LOG: [lldb][Formatters] Consistently unwrap pointer element_type in 
std::shared_ptr formatters (#147340)

Follow-up to
https://github.com/llvm/llvm-project/pull/147165#pullrequestreview-2992585513

Currently when we explicitly dereference a std::shared_ptr, both the
libstdc++ and libc++ formatters will cast the type of the synthetic
pointer child to whatever the `std::shared_ptr::element_type` is aliased
to. E.g.,
```
(lldb) v p
(std::shared_ptr) p = 10 strong=1 weak=0 {
  pointer = 0x00010016c6a0
}
(lldb) v *p
(int) *p = 10
```

However, when we print (or dereference) `p.pointer`, the type devolves
to something less user-friendly:
```
(lldb) v p.pointer
(std::shared_ptr::element_type *) p.pointer = 0x00010016c6a0
(lldb) v *p.pointer
(std::shared_ptr::element_type) *p.pointer = 10
```

This patch changes both formatters to store the casted type. Then
`GetChildAtIndex` will consistently use the unwrapped type.

Added: 
lldb/source/Plugins/Language/CPlusPlus/Generic.cpp

Modified: 
lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/Generic.h
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index bbfc31a722f27..3ec3cad4b8178 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -12,6 +12,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
   CPlusPlusLanguage.cpp
   CPlusPlusNameParser.cpp
   CxxStringTypes.cpp
+  Generic.cpp
   GenericBitset.cpp
   GenericOptional.cpp
   LibCxx.cpp

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/Generic.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Generic.cpp
new file mode 100644
index 0..b237a8a27090c
--- /dev/null
+++ b/lldb/source/Plugins/Language/CPlusPlus/Generic.cpp
@@ -0,0 +1,22 @@
+//===-- Generic.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 "Generic.h"
+
+lldb::ValueObjectSP lldb_private::formatters::GetDesugaredSmartPointerValue(
+ValueObject &ptr, ValueObject &container) {
+  auto container_type = container.GetCompilerType().GetNonReferenceType();
+  if (!container_type)
+return nullptr;
+
+  auto arg = container_type.GetTypeTemplateArgument(0);
+  if (!arg)
+return nullptr;
+
+  return ptr.Cast(arg.GetPointerType());
+}

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/Generic.h 
b/lldb/source/Plugins/Language/CPlusPlus/Generic.h
index 34efef9e82e5c..f3946225ed48d 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Generic.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/Generic.h
@@ -19,6 +19,11 @@ namespace formatters {
 bool GenericOptionalSummaryProvider(ValueObject &valobj, Stream &stream,
 const TypeSummaryOptions &options);
 
+/// Return the ValueObjectSP of the underlying pointer member whose type
+/// is a desugared 'std::shared_ptr::element_type *'.
+lldb::ValueObjectSP GetDesugaredSmartPointerValue(ValueObject &ptr,
+  ValueObject &container);
+
 } // namespace formatters
 } // namespace lldb_private
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 3079de4936a85..a7874047942c4 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -25,6 +25,7 @@
 #include "lldb/ValueObject/ValueObjectConstResult.h"
 
 #include "Plugins/Language/CPlusPlus/CxxStringTypes.h"
+#include "Plugins/Language/CPlusPlus/Generic.h"
 #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/lldb-enumerations.h"
@@ -264,11 +265,7 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
 
   if (idx == 1) {
 Status status;
-auto value_type_sp = valobj_sp->GetCompilerType()
- .GetTypeTemplateArgument(0)
- .GetPoi

[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/147525

Now that most STL formatter tests have been moved to `generic`. Do the same for 
the MSVC tests (which are currently just for `std::string`). The `std::string` 
test was mostly the same (MSVC just had 1 additional check, which I moved over).

We also only tested `u8string` with MSVC. So i moved those into `generic` 
as-is. I kept it separate from the existing std::string tests since it requires 
c++20.

The tests are currently failing for libc++ and libstdc++ because MSVC had a 
test case which checked that:
```
  std::string overwritten_zero("abc");
  const_cast(overwritten_zero.data())[3] = 'd';
```
prints as `"abc"`. But libc++ and libstdc++ print it as `"abcd"` (which seems 
like the more correct thing to do?)

>From ce9eaf42172580aac1d97e109d8713ba59c3c91a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 8 Jul 2025 15:21:28 +0100
Subject: [PATCH] [lldb][test] Merge MSVC STL std::(u8)string tests into
 generic directory

---
 .../string/TestDataFormatterStdString.py  |  21 +++
 .../generic/string/main.cpp   |   2 +
 .../string => generic/u8string}/Makefile  |   1 +
 .../u8string/TestDataFormatterStdU8String.py} |  29 +++--
 .../{msvcstl => generic}/u8string/main.cpp|  10 +-
 .../string/TestDataFormatterMsvcStlString.py  | 120 --
 .../msvcstl/string/main.cpp   |  40 --
 .../msvcstl/u8string/Makefile |   4 -
 8 files changed, 48 insertions(+), 179 deletions(-)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl/string 
=> generic/u8string}/Makefile (61%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl/u8string/TestDataFormatterMsvcStlU8String.py
 => generic/u8string/TestDataFormatterStdU8String.py} (53%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl => 
generic}/u8string/main.cpp (52%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/TestDataFormatterMsvcStlString.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/Makefile

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 7ae5687af2cf4..ba8a8b32afeb7 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -80,6 +80,7 @@ def cleanup():
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'
 % ns,
 "(%s::string *) null_str = nullptr" % ns,
+'(std::string) overwritten_zero = "abc"',
 ],
 )
 
@@ -124,6 +125,11 @@ def test_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test()
 
+@add_test_categories(["msvcstl"])
+def test_msvc(self):
+self.build()
+self.do_test()
+
 def do_test_multibyte(self):
 lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -157,6 +163,11 @@ def test_multibyte_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_multibyte()
 
+@add_test_categories(["msvcstl"])
+def test_multibyte_msvc(self):
+self.build()
+self.do_test_multibyte()
+
 def do_test_uncapped_summary(self):
 (_, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -187,6 +198,11 @@ def test_uncapped_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_uncapped_summary()
 
+@add_test_categories(["msvcstl"])
+def test_uncapped_msvc(self):
+self.build()
+self.do_test_uncapped_summary()
+
 def do_test_summary_unavailable(self):
 """
 Make sure that if the string is not readable, we give an error.
@@ -212,3 +228,8 @@ def test_unavailable_summary_libcxx(self):
 def test_unavailable_summary_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_summary_unavailable()
+
+@add_test_categories(["msvcstl"])
+def test_unavailable_summary_msvc(self):
+self.build()
+self.do_test_summary_unavailable()
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
index db695ed06f015..f22c890861d

[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

Now that most STL formatter tests have been moved to `generic`. Do the same for 
the MSVC tests (which are currently just for `std::string`). The `std::string` 
test was mostly the same (MSVC just had 1 additional check, which I moved over).

We also only tested `u8string` with MSVC. So i moved those into `generic` 
as-is. I kept it separate from the existing std::string tests since it requires 
c++20.

The tests are currently failing for libc++ and libstdc++ because MSVC had a 
test case which checked that:
```
  std::string overwritten_zero("abc");
  const_cast(overwritten_zero.data())[3] = 'd';
```
prints as `"abc"`. But libc++ and libstdc++ print it as `"abcd"` (which seems 
like the more correct thing to do?)

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


8 Files Affected:

- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
 (+21) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 (+2) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/u8string/Makefile
 (+1) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/u8string/TestDataFormatterStdU8String.py
 (+20-9) 
- (renamed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/u8string/main.cpp
 (+4-6) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/TestDataFormatterMsvcStlString.py
 (-120) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/main.cpp
 (-40) 
- (removed) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/Makefile
 (-4) 


``diff
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 7ae5687af2cf4..ba8a8b32afeb7 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -80,6 +80,7 @@ def cleanup():
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'
 % ns,
 "(%s::string *) null_str = nullptr" % ns,
+'(std::string) overwritten_zero = "abc"',
 ],
 )
 
@@ -124,6 +125,11 @@ def test_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test()
 
+@add_test_categories(["msvcstl"])
+def test_msvc(self):
+self.build()
+self.do_test()
+
 def do_test_multibyte(self):
 lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -157,6 +163,11 @@ def test_multibyte_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_multibyte()
 
+@add_test_categories(["msvcstl"])
+def test_multibyte_msvc(self):
+self.build()
+self.do_test_multibyte()
+
 def do_test_uncapped_summary(self):
 (_, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -187,6 +198,11 @@ def test_uncapped_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_uncapped_summary()
 
+@add_test_categories(["msvcstl"])
+def test_uncapped_msvc(self):
+self.build()
+self.do_test_uncapped_summary()
+
 def do_test_summary_unavailable(self):
 """
 Make sure that if the string is not readable, we give an error.
@@ -212,3 +228,8 @@ def test_unavailable_summary_libcxx(self):
 def test_unavailable_summary_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_summary_unavailable()
+
+@add_test_categories(["msvcstl"])
+def test_unavailable_summary_msvc(self):
+self.build()
+self.do_test_summary_unavailable()
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
index db695ed06f015..f22c890861d01 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
@@ -13,6 +13,8 @@ int main() {
   std::string empty("");
   std::string q("hello world");
   std::string Q("quite a long std::strin with lots of info inside it");
+  std::string overwritten_zero("abc");
+  const_cast(overwritten_zero.data())[3] = 'd';
   std::strin

[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread Michael Buch via lldb-commits

Michael137 wrote:

FYI @Nerixyz 

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


[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread via lldb-commits

Nerixyz wrote:

> prints as `"abc"`. But libc++ and libstdc++ print it as `"abcd"` (which seems 
> like the more correct thing to do?)

This is too MSVC STL/libc++ specific, I think. `std::string` on MSVC's STL 
always has a valid size (regardless of SSO or not) and the test tests that this 
is respected. libc++ should also pass this test, but it currently doesn't, 
because the string is further up in `main.cpp` than expected (you can see that 
it has the expected output before `null_str`, but the check is after 
`null_str`).

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


[Lldb-commits] [lldb] [lldb][test] Move std::queue from libcxx to generic directory (PR #147529)

2025-07-08 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/147529

This just moves the test from `libcxx` to `generic`. There are currently no 
`std::queue` formatters for libstdc++ so I didn't add a test-case for it.

Split out from https://github.com/llvm/llvm-project/pull/146740

>From cbdcb93b7a6488d60efe1194cb3d1c327c106cb0 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 8 Jul 2025 15:50:54 +0100
Subject: [PATCH] [lldb][test] Move std::queue from libcxx to generic directory

This just moves the test from `libcxx` to `generic`. There are currently
no `std::queue` formatters for libstdc++ so I didn't add a test-case for
it.

Split out from https://github.com/llvm/llvm-project/pull/146740
---
 .../data-formatter-stl/{libcxx => generic}/queue/Makefile  | 1 -
 .../queue/TestDataFormatterStdQueue.py}| 7 +++
 .../data-formatter-stl/{libcxx => generic}/queue/main.cpp  | 4 ++--
 3 files changed, 5 insertions(+), 7 deletions(-)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/queue/Makefile (75%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/queue/TestDataFormatterLibcxxQueue.py
 => generic/queue/TestDataFormatterStdQueue.py} (90%)
 rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx 
=> generic}/queue/main.cpp (54%)

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
index 680e1abfbef58..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
similarity index 90%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
index 53eaf5a23cc07..ac729c5bacb0f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
@@ -2,14 +2,13 @@
 Test lldb data formatter subsystem.
 """
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class TestDataFormatterLibcxxQueue(TestBase):
+class TestDataFormatterStdQueue(TestBase):
 def setUp(self):
 TestBase.setUp(self)
 self.namespace = "std"
@@ -30,9 +29,9 @@ def check_variable(self, name):
 bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
 )
 @add_test_categories(["libc++"])
-def test(self):
+def test_libcxx(self):
 """Test that std::queue is displayed correctly"""
-self.build()
+self.build(dictionary={"USE_LIBCPP": 1})
 lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp", False)
 )
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
index f3b5f32817970..406b437914932 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
@@ -2,8 +2,8 @@
 #include 
 
 int main() {
-  std::queue q1{{1,2,3,4,5}};
-  std::queue> q2{{1,2,3,4,5}};
+  std::queue q1{{1, 2, 3, 4, 5}};
+  std::queue> q2{{1, 2, 3, 4, 5}};
   int ret = q1.size() + q2.size(); // break here
   return ret;
 }

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


[Lldb-commits] [lldb] [lldb][test] Move std::queue from libcxx to generic directory (PR #147529)

2025-07-08 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] d338d19 - [lldb][test] Move std::queue from libcxx to generic directory (#147529)

2025-07-08 Thread via lldb-commits

Author: Michael Buch
Date: 2025-07-08T15:22:38+01:00
New Revision: d338d197e7ee6e6f8986e14b2aec9d4c368d8a9e

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

LOG: [lldb][test] Move std::queue from libcxx to generic directory (#147529)

This just moves the test from `libcxx` to `generic`. There are currently
no `std::queue` formatters for libstdc++ so I didn't add a test-case for
it.

Split out from https://github.com/llvm/llvm-project/pull/146740

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp

Modified: 


Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp



diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
index 680e1abfbef58..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
similarity index 90%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
index 53eaf5a23cc07..ac729c5bacb0f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
@@ -2,14 +2,13 @@
 Test lldb data formatter subsystem.
 """
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class TestDataFormatterLibcxxQueue(TestBase):
+class TestDataFormatterStdQueue(TestBase):
 def setUp(self):
 TestBase.setUp(self)
 self.namespace = "std"
@@ -30,9 +29,9 @@ def check_variable(self, name):
 bugnumber="llvm.org/pr36109", debug_info="gmodules", 
triple=".*-android"
 )
 @add_test_categories(["libc++"])
-def test(self):
+def test_libcxx(self):
 """Test that std::queue is displayed correctly"""
-self.build()
+self.build(dictionary={"USE_LIBCPP": 1})
 lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp", False)
 )

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
index f3b5f32817970..406b437914932 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp
@@ -2,8 +2,8 @@
 #include 
 
 int main() {
-  std::queue q1{{1,2,3,4,5}};
-  std::queue> q2{{1,2,3,4,5}};
+  std::queue q1{{1, 2, 3, 4, 5}};
+  std::queue> q2{{1, 2, 3, 4, 5}};
   int ret = q1.size() + q2.size(); // break here
   return ret;
 }



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


[Lldb-commits] [lldb] [lldb][test] Move std::queue from libcxx to generic directory (PR #147529)

2025-07-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add formatters for MSVC STL std::vector (PR #147538)

2025-07-08 Thread via lldb-commits

https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/147538

This adds synthetic child providers for `std::vector` and 
`std::vector` for MSVC's STL.

The structure of a `std::vector` is relatively similar to libc++'s 
implementation that uses `__begin` and `__end`.
`std::vector` is different. It's a `std::vector` wrapper 
instead of `std::vector`. This makes the calculation slightly less 
simple. I put a comment in the `GetChildAtIndex` to make this clear.

- [NatVis for 
`std::vector`](https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/debugger/STL.natvis#L1193-L1205)
- [NatVis for 
`std::vector`](https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/debugger/STL.natvis#L1167-L1179)

Towards #24834.

>From 7d68227afefe36978de890645702cbac857ee41d Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Sat, 21 Jun 2025 17:35:23 +0200
Subject: [PATCH] [LLDB] Add formatters for MSVC STL std::vector

---
 .../Plugins/Language/CPlusPlus/CMakeLists.txt |   1 +
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  36 ++-
 .../Plugins/Language/CPlusPlus/MsvcStl.h  |   3 +
 .../Language/CPlusPlus/MsvcStlVector.cpp  | 295 ++
 .../vbool/TestDataFormatterStdVBool.py|  24 +-
 .../data-formatter-stl/generic/vbool/main.cpp |  39 ++-
 .../vector/TestDataFormatterStdVector.py  |  11 +
 7 files changed, 401 insertions(+), 8 deletions(-)
 create mode 100644 lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index bbfc31a722f27..6869e4b56ebee 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -33,6 +33,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
   LibStdcppTuple.cpp
   LibStdcppUniquePointer.cpp
   MsvcStl.cpp
+  MsvcStlVector.cpp
   MSVCUndecoratedNameParser.cpp
 
   LINK_COMPONENTS
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 17963c0273ba8..5a9fcba05ddbc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1404,7 +1404,7 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   stl_deref_flags.SetFrontEndWantsDereference();
 
   cpp_category_sp->AddTypeSynthetic(
-  "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex,
+  "^std::__debug::vector<.+>(( )?&)?$", eFormatterMatchRegex,
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_synth_flags,
   "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
@@ -1465,10 +1465,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "libstdc++ std::bitset summary provider",
   "^std::(__debug::)?bitset<.+>(( )?&)?$", stl_summary_flags, true);
 
-  AddCXXSummary(
-  cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
-  "libstdc++ std::vector summary provider",
-  "^std::(__debug::)?vector<.+>(( )?&)?$", stl_summary_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::ContainerSizeSummaryProvider,
+"libstdc++ std::__debug::vector summary provider",
+"^std::__debug::vector<.+>(( )?&)?$", stl_summary_flags, true);
 
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
@@ -1611,6 +1611,10 @@ static void 
LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   .SetDontShowValue(false)
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
+  SyntheticChildren::Flags stl_synth_flags;
+  stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
+  false);
+
   using StringElementType = StringPrinter::StringElementType;
 
   RegisterStdStringSummaryProvider(
@@ -1636,6 +1640,28 @@ static void 
LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
 return LibStdcppStringSummaryProvider(valobj, stream, options);
   },
   "MSVC STL/libstdc++ std::wstring summary provider"));
+
+  stl_summary_flags.SetDontShowChildren(false);
+  stl_summary_flags.SetSkipPointers(false);
+
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::ContainerSizeSummaryProvider,
+"MSVC/libstdc++ std::vector summary provider",
+"^std::vector<.+>(( )?&)?$", stl_summary_flags, true);
+  AddCXXSynthetic(
+  cpp_category_sp,
+  [](CXXSyntheticChildren *,
+ ValueObjectSP valobj_sp) -> SyntheticChildrenFrontEnd * {
+if (!valobj_sp)
+  return nullptr;
+if (auto *msvc = MsvcStlVectorSyntheticFrontEndCreator(valobj_sp))
+  return msvc;
+re

[Lldb-commits] [lldb] [lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (PR #147525)

2025-07-08 Thread Michael Buch via lldb-commits

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

>From ce9eaf42172580aac1d97e109d8713ba59c3c91a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 8 Jul 2025 15:21:28 +0100
Subject: [PATCH 1/2] [lldb][test] Merge MSVC STL std::(u8)string tests into
 generic directory

---
 .../string/TestDataFormatterStdString.py  |  21 +++
 .../generic/string/main.cpp   |   2 +
 .../string => generic/u8string}/Makefile  |   1 +
 .../u8string/TestDataFormatterStdU8String.py} |  29 +++--
 .../{msvcstl => generic}/u8string/main.cpp|  10 +-
 .../string/TestDataFormatterMsvcStlString.py  | 120 --
 .../msvcstl/string/main.cpp   |  40 --
 .../msvcstl/u8string/Makefile |   4 -
 8 files changed, 48 insertions(+), 179 deletions(-)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl/string 
=> generic/u8string}/Makefile (61%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl/u8string/TestDataFormatterMsvcStlU8String.py
 => generic/u8string/TestDataFormatterStdU8String.py} (53%)
 rename 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/{msvcstl => 
generic}/u8string/main.cpp (52%)
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/TestDataFormatterMsvcStlString.py
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/string/main.cpp
 delete mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/msvcstl/u8string/Makefile

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 7ae5687af2cf4..ba8a8b32afeb7 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -80,6 +80,7 @@ def cleanup():
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'
 % ns,
 "(%s::string *) null_str = nullptr" % ns,
+'(std::string) overwritten_zero = "abc"',
 ],
 )
 
@@ -124,6 +125,11 @@ def test_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test()
 
+@add_test_categories(["msvcstl"])
+def test_msvc(self):
+self.build()
+self.do_test()
+
 def do_test_multibyte(self):
 lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -157,6 +163,11 @@ def test_multibyte_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_multibyte()
 
+@add_test_categories(["msvcstl"])
+def test_multibyte_msvc(self):
+self.build()
+self.do_test_multibyte()
+
 def do_test_uncapped_summary(self):
 (_, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", self.main_spec
@@ -187,6 +198,11 @@ def test_uncapped_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_uncapped_summary()
 
+@add_test_categories(["msvcstl"])
+def test_uncapped_msvc(self):
+self.build()
+self.do_test_uncapped_summary()
+
 def do_test_summary_unavailable(self):
 """
 Make sure that if the string is not readable, we give an error.
@@ -212,3 +228,8 @@ def test_unavailable_summary_libcxx(self):
 def test_unavailable_summary_libstdcxx(self):
 self.build(dictionary={"USE_LIBSTDCPP": 1})
 self.do_test_summary_unavailable()
+
+@add_test_categories(["msvcstl"])
+def test_unavailable_summary_msvc(self):
+self.build()
+self.do_test_summary_unavailable()
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
index db695ed06f015..f22c890861d01 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp
@@ -13,6 +13,8 @@ int main() {
   std::string empty("");
   std::string q("hello world");
   std::string Q("quite a long std::strin with lots of info inside it");
+  std::string overwritten_zero("abc");
+  const_cast(overwritten_zero.data())[3] = 'd';
   std::string TheVeryLongOne(
   
"123456789012345678901234567890123456789012345678901234567890123456789012"
   
"345678901234567890123456789012345678901234567890123456789012345678901234"
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatte

[Lldb-commits] [lldb] [LLDB] Add formatters for MSVC STL std::vector (PR #147538)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)


Changes

This adds synthetic child providers for `std::vector` and 
`std::vector` for MSVC's STL.

The structure of a `std::vector` is relatively similar to libc++'s 
implementation that uses `__begin` and `__end`.
`std::vector` is different. It's a `std::vector` wrapper instead of `std::vector`. This makes the 
calculation slightly less simple. I put a comment in the `GetChildAtIndex` to 
make this clear.

- [NatVis for 
`std::vector`](https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/debugger/STL.natvis#L1193-L1205)
- [NatVis for 
`std::vector`](https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/debugger/STL.natvis#L1167-L1179)

Towards #24834.

---

Patch is 20.38 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/147538.diff


7 Files Affected:

- (modified) lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(+31-5) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/MsvcStl.h (+3) 
- (added) lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp (+295) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py
 (+22-2) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp
 (+38-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterStdVector.py
 (+11) 


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index bbfc31a722f27..6869e4b56ebee 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -33,6 +33,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
   LibStdcppTuple.cpp
   LibStdcppUniquePointer.cpp
   MsvcStl.cpp
+  MsvcStlVector.cpp
   MSVCUndecoratedNameParser.cpp
 
   LINK_COMPONENTS
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 17963c0273ba8..5a9fcba05ddbc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1404,7 +1404,7 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   stl_deref_flags.SetFrontEndWantsDereference();
 
   cpp_category_sp->AddTypeSynthetic(
-  "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex,
+  "^std::__debug::vector<.+>(( )?&)?$", eFormatterMatchRegex,
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_synth_flags,
   "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
@@ -1465,10 +1465,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "libstdc++ std::bitset summary provider",
   "^std::(__debug::)?bitset<.+>(( )?&)?$", stl_summary_flags, true);
 
-  AddCXXSummary(
-  cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
-  "libstdc++ std::vector summary provider",
-  "^std::(__debug::)?vector<.+>(( )?&)?$", stl_summary_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::ContainerSizeSummaryProvider,
+"libstdc++ std::__debug::vector summary provider",
+"^std::__debug::vector<.+>(( )?&)?$", stl_summary_flags, true);
 
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
@@ -1611,6 +1611,10 @@ static void 
LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   .SetDontShowValue(false)
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
+  SyntheticChildren::Flags stl_synth_flags;
+  stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
+  false);
+
   using StringElementType = StringPrinter::StringElementType;
 
   RegisterStdStringSummaryProvider(
@@ -1636,6 +1640,28 @@ static void 
LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
 return LibStdcppStringSummaryProvider(valobj, stream, options);
   },
   "MSVC STL/libstdc++ std::wstring summary provider"));
+
+  stl_summary_flags.SetDontShowChildren(false);
+  stl_summary_flags.SetSkipPointers(false);
+
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::ContainerSizeSummaryProvider,
+"MSVC/libstdc++ std::vector summary provider",
+"^std::vector<.+>(( )?&)?$", stl_summary_flags, true);
+  AddCXXSynthetic(
+  cpp_category_sp,
+  [](CXXSyntheticChildren *,
+ ValueObjectSP valobj_sp) -> SyntheticChildrenFrontEnd * {
+if (

[Lldb-commits] [lldb] [lldb] Replace PathMappingList::GetPathsAtIndex with thread-safe alternative (PR #147396)

2025-07-08 Thread Alex Langford via lldb-commits


@@ -61,8 +61,10 @@ class PathMappingList {
 return m_pairs.size();
   }
 
-  bool GetPathsAtIndex(uint32_t idx, ConstString &path,
-   ConstString &new_path) const;
+  /// Invokes callback for each pair of paths in the list. The callback can
+  /// return false to immediately stop iteration.
+  void ForEach(std::function

bulbazord wrote:

Only used in one place. I'll look at `LockingAdaptedIterable` and see how bad 
it is.

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


[Lldb-commits] [lldb] [lldb] Improving synchronization of MainLoopWindows. (PR #147438)

2025-07-08 Thread Dmitry Vasilyev via lldb-commits

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

LGTM. 
But I agree that
> it is hard to ensure a race condition is fixed without running the CI on 
> multiple machines/configurations.

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


[Lldb-commits] [lldb] [lldb-dap] Migrate variables request protocol types. (PR #147611)

2025-07-08 Thread John Harrison via lldb-commits

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

This adds new protocol types for the 'variables' request.

While implementing this, I removed the '$__lldb_extension' field we returned on 
the 'variables' request, since I think all the data can be retrieved from other 
DAP requests.

>From 43ca23b7dd715863eb5e2dc7e205a4164cd38647 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 8 Jul 2025 15:44:57 -0700
Subject: [PATCH] [lldb-dap] Migrate variables request protocol types.

This adds new protocol types for the 'variables' request.

While implementing this, I removed the '$__lldb_extension' field we
returned on the 'variables' request, since I think all the data can be
retrieved from other DAP requests.
---
 .../lldb-dap/optimized/TestDAP_optimized.py   |   7 +-
 .../lldb-dap/variables/TestDAP_variables.py   |  17 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../Handler/VariablesRequestHandler.cpp   | 136 +++---
 lldb/tools/lldb-dap/JSONUtils.cpp | 252 --
 lldb/tools/lldb-dap/JSONUtils.h   |  59 
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  35 +++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  48 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  65 +
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  | 131 +
 lldb/tools/lldb-dap/ProtocolUtils.cpp |  70 -
 lldb/tools/lldb-dap/ProtocolUtils.h   |  42 +++
 12 files changed, 430 insertions(+), 441 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/optimized/TestDAP_optimized.py 
b/lldb/test/API/tools/lldb-dap/optimized/TestDAP_optimized.py
index 9cfa9b20f6051..3b769d2dd89ce 100644
--- a/lldb/test/API/tools/lldb-dap/optimized/TestDAP_optimized.py
+++ b/lldb/test/API/tools/lldb-dap/optimized/TestDAP_optimized.py
@@ -28,7 +28,7 @@ def test_stack_frame_name(self):
 parent_frame = self.dap_server.get_stackFrame(frameIndex=1)
 self.assertTrue(parent_frame["name"].endswith(" [opt]"))
 
-@skipIfAsan # On ASAN builds this test intermittently fails 
https://github.com/llvm/llvm-project/issues/111061
+@skipIfAsan  # On ASAN builds this test intermittently fails 
https://github.com/llvm/llvm-project/issues/111061
 @skipIfWindows
 def test_optimized_variable(self):
 """Test optimized variable value contains error."""
@@ -50,9 +50,8 @@ def test_optimized_variable(self):
 value.startswith("> {
 public:
-  using LegacyRequestHandler::LegacyRequestHandler;
+  using RequestHandler::RequestHandler;
   static llvm::StringLiteral GetCommand() { return "variables"; }
-  void operator()(const llvm::json::Object &request) const override;
+  llvm::Expected
+  Run(const protocol::VariablesArguments &) const override;
 };
 
 class LocationsRequestHandler : public LegacyRequestHandler {
diff --git a/lldb/tools/lldb-dap/Handler/VariablesRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/VariablesRequestHandler.cpp
index 19bcca2b22b9b..f80a69a5f5ee5 100644
--- a/lldb/tools/lldb-dap/Handler/VariablesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/VariablesRequestHandler.cpp
@@ -8,107 +8,37 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "Handler/RequestHandler.h"
 #include "JSONUtils.h"
-#include "RequestHandler.h"
+#include "ProtocolUtils.h"
+
+using namespace llvm;
+using namespace lldb_dap::protocol;
 
 namespace lldb_dap {
 
-// "VariablesRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Variables request; value of command field is 
'variables'.
-// Retrieves all child variables for the given variable reference. An
-// optional filter can be used to limit the fetched children to either 
named
-// or indexed children.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "variables" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/VariablesArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "VariablesArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'variables' request.",
-//   "properties": {
-// "variablesReference": {
-//   "type": "integer",
-//   "description": "The Variable reference."
-// },
-// "filter": {
-//   "type": "string",
-//   "enum": [ "indexed", "named" ],
-//   "description": "Optional filter to limit the child variables to either
-//   named or indexed. If ommited, both types are fetched."
-// },
-// "start": {
-//   "type": "integer",
-//   "description": "The index of the first variable to return; if omitted
-//   children start at 0."
-// },
-// "count": {
-//   "type": "integer",
-//   "description": "The number of variables to return. If count is missing
-//   or 0, all variables are returned."
-// },
-// "format": {
-//   "$ref": "#/definiti

[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)

2025-07-08 Thread Andrew Savonichev via lldb-commits

https://github.com/asavonic updated 
https://github.com/llvm/llvm-project/pull/147289

>From a01eb1943afb03d1dc9439e9ae8f3a01b8c15398 Mon Sep 17 00:00:00 2001
From: Andrew Savonichev 
Date: Mon, 7 Jul 2025 17:33:50 +0900
Subject: [PATCH 1/3] [lldb] Clear ModuleList shared modules in
 SBDebugger::Clear

Shared modules are stored in a global ModuleList cache, and it is
intentionally leaked to avoid doing cleanup when lldb exits.

However, when lldb is used as a library, we need a way to manage
opened modules to avoid problems with file locks (on some systems) for
modules that we no longer need.

It should be possible to record all loaded modules and use
ModuleList::RemoveSharedModule and RemoveOrphanSharedModules functions
to clear the cache, but these functions are not available in the API.
This approach is also way too complicated when we just need to cleanup
the library.

The patch adds the following:

  - ModuleList::ClearSharedModules function to clear all shared
modules.

  - SBDebugger::SetClearSharedModules(bool) API to enable clearing
during SBDebugger::Clear().

  - `settings set clear-shared-modules true` command line option
that is equivalent to SetClearSharedModules(true).

This new behaviour is turned off by default: the debugger does not
release these shared modules until the process exits.
---
 lldb/include/lldb/API/SBDebugger.h|   2 +
 lldb/include/lldb/Core/Debugger.h |   4 +
 lldb/include/lldb/Core/ModuleList.h   |   3 +
 lldb/source/API/SBDebugger.cpp|   6 +
 lldb/source/Core/CoreProperties.td|   4 +
 lldb/source/Core/Debugger.cpp |  13 ++
 lldb/source/Core/ModuleList.cpp   |   7 +
 .../python_api/debugger/TestDebuggerAPI.py|  30 +++
 lldb/unittests/Target/CMakeLists.txt  |   1 +
 .../unittests/Target/SharedModuleListTest.cpp | 209 ++
 10 files changed, 279 insertions(+)
 create mode 100644 lldb/unittests/Target/SharedModuleListTest.cpp

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 192fbee9c0c6d..6a2f76f2d5685 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -319,6 +319,8 @@ class LLDB_API SBDebugger {
 
   bool SetShowInlineDiagnostics(bool);
 
+  bool SetClearSharedModules(bool);
+
   bool SetUseSourceCache(bool use_source_cache);
 
   bool GetUseSourceCache() const;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 504f936fe317a..4cf7fc75bafd4 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -373,6 +373,10 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool SetShowInlineDiagnostics(bool);
 
+  bool GetClearSharedModules() const;
+
+  bool SetClearSharedModules(bool);
+
   bool LoadPlugin(const FileSpec &spec, Status &error);
 
   void RunIOHandlers();
diff --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 909ee08f9ba62..587843dd05a4d 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -482,6 +482,9 @@ class ModuleList {
 
   static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr);
 
+  /// Empty global cache of modules to release memory, file locks, etc.
+  static void ClearSharedModules();
+
   /// Applies 'callback' to each module in this ModuleList.
   /// If 'callback' returns false, iteration terminates.
   /// The 'module_sp' passed to 'callback' is guaranteed to
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 603e306497841..221c02cfe66ed 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1466,6 +1466,12 @@ bool SBDebugger::SetShowInlineDiagnostics(bool value) {
   return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false);
 }
 
+bool SBDebugger::SetClearSharedModules(bool value) {
+  LLDB_INSTRUMENT_VA(this, value);
+
+  return (m_opaque_sp ? m_opaque_sp->SetClearSharedModules(value) : false);
+}
+
 bool SBDebugger::SetUseSourceCache(bool value) {
   LLDB_INSTRUMENT_VA(this, value);
 
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 53dd333f045c9..1a6ba1a9af84e 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -268,4 +268,8 @@ let Definition = "debugger" in {
 Global,
 DefaultFalse,
 Desc<"Controls whether diagnostics can refer directly to the command 
input, drawing arrows to it. If false, diagnostics will echo the input.">;
+  def ClearSharedModules: Property<"clear-shared-modules", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"Controls whether the debugger clears internal shared modules as it 
exits.">;
 }
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..fbd2f37960e19 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger

[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)

2025-07-08 Thread Andrew Savonichev via lldb-commits

asavonic wrote:

Updated the patch to [use 
RemoveOrphanSharedModules](https://github.com/llvm/llvm-project/pull/147289/commits/7a27fe962726c3190ce6ad7d635e3ae30a0f52f7)
 instead of force-clearing the cache.
Changed the description as well.

> No one SBDebugger should force-clear the Shared Module Cache. That's a 
> resource shared among all the SBDebuggers, and no SBDebugger can know what 
> the other debugger's intentions are w.r.t. it. That seems wrong to me.

Agree.

> The most an SBDebugger should do on Destroy or Clear is call 
> MemoryPressureDetected or a similar lower-level API to clear all the modules 
> that it is the only owner of. It should not clear the cache out from under 
> other users.

The last revision should do that. The downside is that the program must release 
all shared pointers to modules before calling `Destroy`, or they leak again.

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


[Lldb-commits] [lldb] [lldb] Support specifying a language for breakpoint conditions (PR #147603)

2025-07-08 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

Semi-related: I wonder if we should have a way to set the language from within 
the condition expression itself. E.g. a `\language{C} a + b` prefix. That would 
allow us to also use those conditions from, e.g., lldb-dap where the UI only 
provides a way to enter a single expression for conditional breakpoints, but no 
additional parameters.

We might also want to support something similar, e.g., in the watch panel where 
users can also only enter expressions.

E.g., CodeLLDB (the other DAP implementation besides lldb-dap) provides a 
similar mechanism which also covers breakpoint conditions, documented over 
here: https://github.com/vadimcn/codelldb/blob/master/MANUAL.md#expressions

I wonder if those "expression prefixes" should be part of lldb / the new 
upcoming DIL language itself or layered on top of it by lldb-dap...

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


[Lldb-commits] [lldb] 4647398 - [lldb] Fix a warning

2025-07-08 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2025-07-08T15:00:08-07:00
New Revision: 4647398d6a44d4596c6716875d8d92750f731f90

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

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/tools/lldb-dap/ProtocolUtils.cpp:77:22: error: implicit
  instantiation of undefined template 'std::basic_ostringstream'

Added: 


Modified: 
lldb/tools/lldb-dap/ProtocolUtils.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/ProtocolUtils.cpp 
b/lldb/tools/lldb-dap/ProtocolUtils.cpp
index d13968c98a387..f9e373db74618 100644
--- a/lldb/tools/lldb-dap/ProtocolUtils.cpp
+++ b/lldb/tools/lldb-dap/ProtocolUtils.cpp
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 
 using namespace lldb_dap::protocol;
 namespace lldb_dap {



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


[Lldb-commits] [lldb] [lldb] Support specifying a language for breakpoint conditions (PR #147603)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

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

LLDB breakpoint conditions take an expression that's evaluated using the 
language of the code where the breakpoint is located. Users have asked to have 
an option to tell it to evaluate the expression in a specific language.

This is feature is especially helpful for Swift, for example for a condition 
based on the value in memory at an offset from a register. Such a condition is 
pretty difficult to write in Swift, but easy in C.

This PR adds a new argument (-Y) to specify the language of the condition 
expression. We can't reuse the current -L option, since you might want to break 
on only Swift symbols, but run a C expression there as per the example above.

rdar://146119507

>From fac9c09896d376e23e115590f10240056ccf2097 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 8 Jul 2025 14:55:59 -0700
Subject: [PATCH] [lldb] Support specifying a language for breakpoint
 conditions

LLDB breakpoint conditions take an expression that's evaluated using the
language of the code where the breakpoint is located. Users have asked
to have an option to tell it to evaluate the expression in a specific
language.

This is feature is especially helpful for Swift, for example for a
condition based on the value in memory at an offset from a register.
Such a condition is pretty difficult to write in Swift, but easy in C.

This PR adds a new argument (-Y) to specify the language of the
condition expression. We can't reuse the current -L option, since you
might want to break on only Swift symbols, but run a C expression
there as per the example above.

rdar://146119507
---
 lldb/include/lldb/Breakpoint/Breakpoint.h | 14 ++---
 .../lldb/Breakpoint/BreakpointLocation.h  | 10 +---
 .../lldb/Breakpoint/BreakpointOptions.h   | 20 +++
 lldb/include/lldb/Breakpoint/StopCondition.h  | 53 ++
 lldb/source/API/SBBreakpoint.cpp  |  4 +-
 lldb/source/API/SBBreakpointLocation.cpp  |  4 +-
 lldb/source/API/SBBreakpointName.cpp  |  5 +-
 lldb/source/Breakpoint/Breakpoint.cpp |  8 +--
 lldb/source/Breakpoint/BreakpointLocation.cpp | 37 ++--
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 56 ---
 .../Commands/CommandObjectBreakpoint.cpp  | 10 +++-
 lldb/source/Commands/Options.td   |  6 ++
 lldb/source/Target/StopInfo.cpp   |  4 +-
 .../TestBreakpointConditions.py   | 21 ++-
 14 files changed, 156 insertions(+), 96 deletions(-)
 create mode 100644 lldb/include/lldb/Breakpoint/StopCondition.h

diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index b200a1e4893df..26a5e901a0d7e 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -397,16 +397,12 @@ class Breakpoint : public 
std::enable_shared_from_this,
   /// Set the breakpoint's condition.
   ///
   /// \param[in] condition
-  ///The condition expression to evaluate when the breakpoint is hit.
-  ///Pass in nullptr to clear the condition.
-  void SetCondition(const char *condition);
+  ///The condition to evaluate when the breakpoint is hit.
+  ///Pass in an empty condition to clear the condition.
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText() const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   // The next section are various utility functions.
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index 66274e8825ee2..834d99bd2e0d5 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -129,14 +129,10 @@ class BreakpointLocation
   ///
   /// \param[in] condition
   ///The condition expression to evaluate when the breakpoint is hit.
-  void SetCondition(const char *condition);
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText(size_t *hash = nullptr) const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   bool ConditionSaysStop(ExecutionContext &exe_ctx, Status &error);
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h 
b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index 7bf545717422f..2f73473c07e62 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -12,6 +12,7 @@
 #include 
 #include 
 
+#includ

[Lldb-commits] [lldb] [lldb] Support specifying a language for breakpoint conditions (PR #147603)

2025-07-08 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/147603

>From 67ce4cd81355863ec2b3af43eb5a0e47f420acd2 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 8 Jul 2025 14:55:59 -0700
Subject: [PATCH] [lldb] Support specifying a language for breakpoint
 conditions

LLDB breakpoint conditions take an expression that's evaluated using the
language of the code where the breakpoint is located. Users have asked
to have an option to tell it to evaluate the expression in a specific
language.

This is feature is especially helpful for Swift, for example for a
condition based on the value in memory at an offset from a register.
Such a condition is pretty difficult to write in Swift, but easy in C.

This PR adds a new argument (-Y) to specify the language of the
condition expression. We can't reuse the current -L option, since you
might want to break on only Swift symbols, but run a C expression
there as per the example above.

rdar://146119507
---
 lldb/include/lldb/Breakpoint/Breakpoint.h | 14 ++---
 .../lldb/Breakpoint/BreakpointLocation.h  | 10 +---
 .../lldb/Breakpoint/BreakpointOptions.h   | 20 +++
 lldb/include/lldb/Breakpoint/StopCondition.h  | 53 ++
 lldb/source/API/SBBreakpoint.cpp  |  4 +-
 lldb/source/API/SBBreakpointLocation.cpp  |  4 +-
 lldb/source/API/SBBreakpointName.cpp  |  5 +-
 lldb/source/Breakpoint/Breakpoint.cpp |  8 +--
 lldb/source/Breakpoint/BreakpointLocation.cpp | 37 ++--
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 56 ---
 .../Commands/CommandObjectBreakpoint.cpp  | 10 +++-
 lldb/source/Commands/Options.td   |  6 ++
 lldb/source/Target/StopInfo.cpp   |  4 +-
 .../TestBreakpointConditions.py   | 21 ++-
 14 files changed, 156 insertions(+), 96 deletions(-)
 create mode 100644 lldb/include/lldb/Breakpoint/StopCondition.h

diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index b200a1e4893df..26a5e901a0d7e 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -397,16 +397,12 @@ class Breakpoint : public 
std::enable_shared_from_this,
   /// Set the breakpoint's condition.
   ///
   /// \param[in] condition
-  ///The condition expression to evaluate when the breakpoint is hit.
-  ///Pass in nullptr to clear the condition.
-  void SetCondition(const char *condition);
+  ///The condition to evaluate when the breakpoint is hit.
+  ///Pass in an empty condition to clear the condition.
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText() const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   // The next section are various utility functions.
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index 66274e8825ee2..834d99bd2e0d5 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -129,14 +129,10 @@ class BreakpointLocation
   ///
   /// \param[in] condition
   ///The condition expression to evaluate when the breakpoint is hit.
-  void SetCondition(const char *condition);
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText(size_t *hash = nullptr) const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   bool ConditionSaysStop(ExecutionContext &exe_ctx, Status &error);
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h 
b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index 7bf545717422f..2f73473c07e62 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -12,6 +12,7 @@
 #include 
 #include 
 
+#include "lldb/Breakpoint/StopCondition.h"
 #include "lldb/Utility/Baton.h"
 #include "lldb/Utility/Flags.h"
 #include "lldb/Utility/StringList.h"
@@ -245,18 +246,15 @@ friend class Breakpoint;
   const Baton *GetBaton() const;
 
   // Condition
-  /// Set the breakpoint option's condition.
+  /// Set the breakpoint stop condition.
   ///
   /// \param[in] condition
-  ///The condition expression to evaluate when the breakpoint is hit.
-  void SetCondition(const char *condition);
+  ///The condition to evaluate when the breakpoint is hit.
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///  

[Lldb-commits] [lldb] [lldb] Support specifying a language for breakpoint conditions (PR #147603)

2025-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

LLDB breakpoint conditions take an expression that's evaluated using the 
language of the code where the breakpoint is located. Users have asked to have 
an option to tell it to evaluate the expression in a specific language.

This is feature is especially helpful for Swift, for example for a condition 
based on the value in memory at an offset from a register. Such a condition is 
pretty difficult to write in Swift, but easy in C.

This PR adds a new argument (-Y) to specify the language of the condition 
expression. We can't reuse the current -L option, since you might want to break 
on only Swift symbols, but run a C expression there as per the example above.

rdar://146119507

---

Patch is 23.41 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/147603.diff


14 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/Breakpoint.h (+5-9) 
- (modified) lldb/include/lldb/Breakpoint/BreakpointLocation.h (+3-7) 
- (modified) lldb/include/lldb/Breakpoint/BreakpointOptions.h (+8-12) 
- (added) lldb/include/lldb/Breakpoint/StopCondition.h (+53) 
- (modified) lldb/source/API/SBBreakpoint.cpp (+2-2) 
- (modified) lldb/source/API/SBBreakpointLocation.cpp (+2-2) 
- (modified) lldb/source/API/SBBreakpointName.cpp (+3-2) 
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+4-4) 
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+19-18) 
- (modified) lldb/source/Breakpoint/BreakpointOptions.cpp (+22-34) 
- (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+9-1) 
- (modified) lldb/source/Commands/Options.td (+6) 
- (modified) lldb/source/Target/StopInfo.cpp (+2-2) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
 (+18-3) 


``diff
diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index b200a1e4893df..26a5e901a0d7e 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -397,16 +397,12 @@ class Breakpoint : public 
std::enable_shared_from_this,
   /// Set the breakpoint's condition.
   ///
   /// \param[in] condition
-  ///The condition expression to evaluate when the breakpoint is hit.
-  ///Pass in nullptr to clear the condition.
-  void SetCondition(const char *condition);
+  ///The condition to evaluate when the breakpoint is hit.
+  ///Pass in an empty condition to clear the condition.
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText() const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   // The next section are various utility functions.
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index 66274e8825ee2..834d99bd2e0d5 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -129,14 +129,10 @@ class BreakpointLocation
   ///
   /// \param[in] condition
   ///The condition expression to evaluate when the breakpoint is hit.
-  void SetCondition(const char *condition);
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  // condition has been set.
-  const char *GetConditionText(size_t *hash = nullptr) const;
+  /// Return the breakpoint condition.
+  const StopCondition &GetCondition() const;
 
   bool ConditionSaysStop(ExecutionContext &exe_ctx, Status &error);
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h 
b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index 7bf545717422f..2f73473c07e62 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -12,6 +12,7 @@
 #include 
 #include 
 
+#include "lldb/Breakpoint/StopCondition.h"
 #include "lldb/Utility/Baton.h"
 #include "lldb/Utility/Flags.h"
 #include "lldb/Utility/StringList.h"
@@ -245,18 +246,15 @@ friend class Breakpoint;
   const Baton *GetBaton() const;
 
   // Condition
-  /// Set the breakpoint option's condition.
+  /// Set the breakpoint stop condition.
   ///
   /// \param[in] condition
-  ///The condition expression to evaluate when the breakpoint is hit.
-  void SetCondition(const char *condition);
+  ///The condition to evaluate when the breakpoint is hit.
+  void SetCondition(StopCondition condition);
 
-  /// Return a pointer to the text of the condition expression.
-  ///
-  /// \return
-  ///A pointer to the condition expression text, or nullptr if no
-  //

[Lldb-commits] [lldb] [lldb] Support specifying a language for breakpoint conditions (PR #147603)

2025-07-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
``





View the diff from darker here.


``diff
--- TestBreakpointConditions.py 2025-07-08 22:01:58.00 +
+++ TestBreakpointConditions.py 2025-07-08 22:05:02.802104 +
@@ -250,6 +250,5 @@
 var = frame0.FindValue("val", lldb.eValueTypeVariableArgument)
 self.assertEqual(frame0.GetLineEntry().GetLine(), self.line1)
 
 # The hit count for the breakpoint should be 1.
 self.assertEqual(breakpoint.GetHitCount(), 1)
-

``




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