[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

This is a very simple case that currently only validates we can create a DAP 
instance and send a message over the transport layer. More in-depth tests will 
require additional helpers and possibly refactors of DAP to make it more 
testable, however this is some ground work to have basic support for unit tests.

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


3 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.h (+2-1) 
- (modified) lldb/unittests/DAP/CMakeLists.txt (+1) 
- (added) lldb/unittests/DAP/DAPTest.cpp (+63) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..2ff66d1cd0182 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -226,7 +226,8 @@ struct DAP {
   /// \param[in] default_repl_mode
   /// Default repl mode behavior, as configured by the binary.
   /// \param[in] pre_init_commands
-  /// LLDB commands to execute as soon as the debugger instance is 
allocaed.
+  /// LLDB commands to execute as soon as the debugger instance is
+  /// allocated.
   /// \param[in] transport
   /// Transport for this debug session.
   DAP(Log *log, const ReplMode default_repl_mode,
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 110733e93b192..6074e9b872c49 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests
   LLDBUtilsTest.cpp
   TransportTest.cpp
   ProtocolTypesTest.cpp
+  DAPTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
new file mode 100644
index 0..9d2a9b944678e
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -0,0 +1,63 @@
+//===-- DAPTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "Transport.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+using lldb_private::File;
+using lldb_private::NativeFile;
+using lldb_private::Pipe;
+
+class DAPTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr toDAP;
+  std::unique_ptr fromDAP;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded());
+toDAP = std::make_unique(
+"toDAP", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+fromDAP = std::make_unique(
+"fromDAP", nullptr,
+std::make_shared(output.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(input.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+};
+
+TEST_F(DAPTest, SendProtocolMessages) {
+  DAP dap{nullptr, ReplMode::Auto, {}, *toDAP};
+  dap.Send(Event{"my-event", std::nullopt});
+  ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(testing::FieldsAre(
+   /*event=*/"my-event", /*body=*/std::nullopt;
+}

``




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


[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

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

Very excited to see more unit testing!

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


[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)

2025-05-14 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -1510,6 +1510,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t 
watch_id,
 }
 
 ModuleSP Target::GetExecutableModule() {
+  std::lock_guard guard(m_images.GetMutex());

JDevlieghere wrote:

Let's use the `Modules()` iterable which allows us to use a for-based loop and 
does the locking for us:

```
  // Search for the first executable in the module list.
  for (ModuleSP module_sp : m_images.Modules()) {
lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
```

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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Should I rename `toDAP`/`fromDAP` to `to_dap`/`from_dap`? I think thats more 
> inline with how lldb names variables, right?

Yes, good point. Currently we have a weird mix of styles. Once everything has 
been migrated to use the protocol classes, we should go through the code and 
fix the remaining inconsistencies. 

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


[Lldb-commits] [lldb] 28d732a - [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (#138020)

2025-05-14 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2025-05-14T10:46:01-07:00
New Revision: 28d732a24ef06bab3a2cd6c17975281155f63cd6

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

LOG: [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 
4 (#138020)

CMake 4 no longer sets the `CMAKE_OSX_SYSROOT` variable by default. If
you've updated to CMake 4 on macOS (e.g. with brew) and try building
LLDB with CMake/ninja, this will yield an error when building
debugserver that clang is unable to run since it tries to compile files
that don't exist.

These files are supposed to be generated by the `mig` process. `mig`
needs the `CMAKE_OSX_SYSROOT` variable in order to work and without it,
it silently fails to generate the files that later on need to be
compiled.

This commit sets this SDK path for mig and will fatal error out of config
when building debugserver without having set CMAKE_OSX_SYSROOT.

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index f7ff76c3e8e84..8340b5ad8948d 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -154,6 +154,21 @@ endif()
 
 add_definitions(-DLLDB_USE_OS_LOG)
 
+# Make sure we have the macOS SDK root as mig needs it and will silently
+# fail to generate its output files without it.
+if(CMAKE_OSX_SYSROOT)
+  set(MIG_SYSROOT ${CMAKE_OSX_SYSROOT})
+else()
+  execute_process(COMMAND xcrun --show-sdk-path
+OUTPUT_VARIABLE MIG_SYSROOT
+ERROR_QUIET
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
+if(NOT MIG_SYSROOT)
+  message(FATAL_ERROR "Unable to obtain sysroot required by mig (Mach 
Interface Generator). Set CMAKE_OSX_SYSROOT to explicitly specify a sysroot.")
+endif()
+
 if(${CMAKE_OSX_SYSROOT} MATCHES ".Internal.sdk$")
   message(STATUS "LLDB debugserver energy support is enabled")
   add_definitions(-DLLDB_ENERGY)
@@ -177,7 +192,7 @@ endif()
 separate_arguments(MIG_ARCH_FLAGS_SEPARTED NATIVE_COMMAND "${MIG_ARCH_FLAGS}")
 
 add_custom_command(OUTPUT ${generated_mach_interfaces}
-  VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot 
${CMAKE_OSX_SYSROOT} ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+  VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot ${MIG_SYSROOT} 
${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
   )
 



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


[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)

2025-05-14 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)

2025-05-14 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

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

>From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:31:40 -0700
Subject: [PATCH 1/2] [lldb-dap] Setup DAP for unit testing.

This is a very simple case that currently only validates we can create a DAP 
instance and send a message over the transport layer. More in-depth tests will 
require additional helpers and possibly refactors of DAP to make it more 
testable, however this is some ground work to have basic support for unit tests.
---
 lldb/tools/lldb-dap/DAP.h |  3 +-
 lldb/unittests/DAP/CMakeLists.txt |  1 +
 lldb/unittests/DAP/DAPTest.cpp| 63 +++
 3 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 lldb/unittests/DAP/DAPTest.cpp

diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..2ff66d1cd0182 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -226,7 +226,8 @@ struct DAP {
   /// \param[in] default_repl_mode
   /// Default repl mode behavior, as configured by the binary.
   /// \param[in] pre_init_commands
-  /// LLDB commands to execute as soon as the debugger instance is 
allocaed.
+  /// LLDB commands to execute as soon as the debugger instance is
+  /// allocated.
   /// \param[in] transport
   /// Transport for this debug session.
   DAP(Log *log, const ReplMode default_repl_mode,
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 110733e93b192..6074e9b872c49 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests
   LLDBUtilsTest.cpp
   TransportTest.cpp
   ProtocolTypesTest.cpp
+  DAPTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
new file mode 100644
index 0..9d2a9b944678e
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -0,0 +1,63 @@
+//===-- DAPTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "Transport.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+using lldb_private::File;
+using lldb_private::NativeFile;
+using lldb_private::Pipe;
+
+class DAPTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr toDAP;
+  std::unique_ptr fromDAP;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded());
+toDAP = std::make_unique(
+"toDAP", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+fromDAP = std::make_unique(
+"fromDAP", nullptr,
+std::make_shared(output.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(input.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+};
+
+TEST_F(DAPTest, SendProtocolMessages) {
+  DAP dap{nullptr, ReplMode::Auto, {}, *toDAP};
+  dap.Send(Event{"my-event", std::nullopt});
+  ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(testing::FieldsAre(
+   /*event=*/"my-event", /*body=*/std::nullopt;
+}

>From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:46:51 -0700
Subject: [PATCH 2/2] Adjusting the naming of variables.

---
 lldb/unittests/DAP/DAPTest.cpp | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
index 9d2a9b944678e..8e8c2ea3ccbb0 100644
--- a/lldb/unittests/DAP/DAPTest.cpp
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -29,22 +29,22 @@ class DAPTest : public testing::Test {
 protected:
   Pipe input;
   Pipe output;
-

[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

ashgti wrote:

Should I rename `toDAP`/`fromDAP` to `to_dap`/`from_dap`? I think thats more 
inline with how lldb names variables, right?

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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

ashgti wrote:

Yea, thats my mistake. I made the protocol classes to match the names of the 
spec, but we don't really have to do that as long as the `toJSON`/`fromJSON` 
adjusts the names, they can be different.

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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

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

>From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:31:40 -0700
Subject: [PATCH 1/3] [lldb-dap] Setup DAP for unit testing.

This is a very simple case that currently only validates we can create a DAP 
instance and send a message over the transport layer. More in-depth tests will 
require additional helpers and possibly refactors of DAP to make it more 
testable, however this is some ground work to have basic support for unit tests.
---
 lldb/tools/lldb-dap/DAP.h |  3 +-
 lldb/unittests/DAP/CMakeLists.txt |  1 +
 lldb/unittests/DAP/DAPTest.cpp| 63 +++
 3 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 lldb/unittests/DAP/DAPTest.cpp

diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..2ff66d1cd0182 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -226,7 +226,8 @@ struct DAP {
   /// \param[in] default_repl_mode
   /// Default repl mode behavior, as configured by the binary.
   /// \param[in] pre_init_commands
-  /// LLDB commands to execute as soon as the debugger instance is 
allocaed.
+  /// LLDB commands to execute as soon as the debugger instance is
+  /// allocated.
   /// \param[in] transport
   /// Transport for this debug session.
   DAP(Log *log, const ReplMode default_repl_mode,
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 110733e93b192..6074e9b872c49 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests
   LLDBUtilsTest.cpp
   TransportTest.cpp
   ProtocolTypesTest.cpp
+  DAPTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
new file mode 100644
index 0..9d2a9b944678e
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -0,0 +1,63 @@
+//===-- DAPTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "Transport.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+using lldb_private::File;
+using lldb_private::NativeFile;
+using lldb_private::Pipe;
+
+class DAPTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr toDAP;
+  std::unique_ptr fromDAP;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded());
+toDAP = std::make_unique(
+"toDAP", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+fromDAP = std::make_unique(
+"fromDAP", nullptr,
+std::make_shared(output.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(input.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+};
+
+TEST_F(DAPTest, SendProtocolMessages) {
+  DAP dap{nullptr, ReplMode::Auto, {}, *toDAP};
+  dap.Send(Event{"my-event", std::nullopt});
+  ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(testing::FieldsAre(
+   /*event=*/"my-event", /*body=*/std::nullopt;
+}

>From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:46:51 -0700
Subject: [PATCH 2/3] Adjusting the naming of variables.

---
 lldb/unittests/DAP/DAPTest.cpp | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
index 9d2a9b944678e..8e8c2ea3ccbb0 100644
--- a/lldb/unittests/DAP/DAPTest.cpp
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -29,22 +29,22 @@ class DAPTest : public testing::Test {
 protected:
   Pipe input;
   Pipe output;
-

[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+# Usage: convert-lldb-header-to-rpc-header.py  

+# This scripts takes common LLDB headers (such as lldb-defines.h) and replaces 
references to LLDB
+# with those for RPC. This happens for:
+# - namespace definitions
+# - namespace usage
+# - version string macros
+# - ifdef/ifndef lines

JDevlieghere wrote:

Python has a PEP that describes how to document files/modules. We should use 
that here too. 
```suggestion
"""
Usage: convert-lldb-header-to-rpc-header.py  

This scripts takes common LLDB headers (such as lldb-defines.h) and replaces 
references to LLDB
with those for RPC. This happens for:
- namespace definitions
- namespace usage
- version string macros
- ifdef/ifndef lines
"""
```

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


[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,16 @@
+// Copy lldb-rpc-defines.h from source.
+# RUN: mkdir -p %t/input
+# RUN: mkdir -p %t/output
+# RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input

JDevlieghere wrote:

Is the goal to run this on the sources to catch regressions, or are we just 
using the source file as a meaningful input? If it's the latter, I would 
recommend copying the file into the Inputs directory and reducing it to the 
bare minimum needed for the test. 

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


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-14 Thread via lldb-commits

https://github.com/ita-sc updated 
https://github.com/llvm/llvm-project/pull/139916



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)

2025-05-14 Thread Kazu Hirata via lldb-commits

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


[Lldb-commits] [lldb] 539265b - [lldb] Simplify a string comparison (NFC) (#139932)

2025-05-14 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-14T11:21:42-07:00
New Revision: 539265b9044f8cda513e5e65d11f2630a32176cf

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

LOG: [lldb] Simplify a string comparison (NFC) (#139932)

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index a2722db5d24a0..451cf40e2818d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -123,8 +123,7 @@ void ASTStructExtractor::ExtractFromTopLevelDecl(Decl *D) {
   FunctionDecl *function_decl = dyn_cast(D);
 
   if (m_ast_context && function_decl &&
-  !m_function.m_wrapper_function_name.compare(
-  function_decl->getNameAsString())) {
+  m_function.m_wrapper_function_name == function_decl->getNameAsString()) {
 ExtractFromFunctionDecl(function_decl);
   }
 }



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


[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-05-14 Thread Alex Langford via lldb-commits

bulbazord wrote:

> Pushed again to address David's comments and remove most of the FIXMEs. 
> There's one FIXME I've kept in for now:
> 
> ```
> // FIXME: SB class server references are stored as non-const references so
> // that we can actually change them as needed. If a parameter is marked
> // const, we will fail to compile because we cannot make an
> // SBFooServerReference from a `const SBFoo &`.
> // To work around this issue, we'll apply a `const_cast` if needed so we
> // can continue to generate callbacks for now, but we really should
> // rethink the way we store object IDs server-side to support
> // const-qualified parameters.
> ```
> 
> @bulbazord This is referring to how we emit storage for const SB parameters 
> in callback functions. Currently it looks like it only gets applied to one 
> function that gets generated. Any thoughts here?

Given it only applies to one function, it's probably okay to keep it around for 
now. The fact that we need a `const_cast` at all is concerning but I think 
we've done a reasonably alright job at explaining why it exists (though I am a 
partial author, so maybe my perspective is biased).

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


[Lldb-commits] [lldb] [lldb][RPC] Upstream Python scripts (PR #138028)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,20 @@
+// Copy lldb-defines.h from source.
+# RUN: mkdir -p %t/input
+# RUN: mkdir -p %t/output
+# RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input

JDevlieghere wrote:

You're mixing two comment styles here, and lit doesn't actually treat these any 
differently (it just look for RUN lines). So let's settle on one and drop them 
everywhere else. 

```suggestion
// Copy lldb-defines.h from source.
RUN: mkdir -p %t/input
RUN: mkdir -p %t/output
RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input
```

or 

```suggestion
# Copy lldb-defines.h from source.
RUN: mkdir -p %t/input
RUN: mkdir -p %t/output
RUN: cp %p/../../../../../include/lldb/lldb-defines.h %t/input
```

I think the latter is slightly more common.

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


[Lldb-commits] [lldb] [lldb][AIX] Added 32-bit XCOFF Executable support (PR #139875)

2025-05-14 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/139875



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)

2025-05-14 Thread John Harrison via lldb-commits

ashgti wrote:

> Yeah, that should be possible, and it may make more sense in a world where 
> the MainLoop cannot listen on all FD types (since you need the forwarding 
> thread anyway). It's unfortunate that there's no synchronization operation 
> (at least, not a portable one, FUTEX_FD seems kinda nice) that allows you do 
> wait for condition variables and FDs, necessitating these forwarding threads. 
> Since forwarding would add a bit of latency, one of the factors would be 
> which kinds of operations do we want to make slower.

We could adjust the lldb-dap VSCode extension to launch lldb-dap using a named 
pipe or local tcp port on Windows. Then we'd uniformly be able to support 
reading the input using the existing lldb NativeFile/Socket helpers. See 
https://code.visualstudio.com/api/references/vscode-api#DebugAdapterNamedPipeServer
 

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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Yea, thats my mistake. I made the protocol classes to match the names of the 
> spec, but we don't really have to do that as long as the `toJSON`/`fromJSON` 
> adjusts the names, they can be different.

I think we discussed this at some point in the past and I'm personally okay 
with saying that everything outside the protocol dir should follow the LLDB 
style and the Protocol dir matches the spec (although we're already diverging 
from that for the enums). 

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


[Lldb-commits] [lldb] [lldb][Formatters] Add --pointer-match-depth option to `type summary add` command. (PR #138209)

2025-05-14 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

Ping.

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


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-14 Thread Ely Ronnen via lldb-commits

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


[Lldb-commits] [lldb] Lldb dap assembly breakpoint (PR #139969)

2025-05-14 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen created 
https://github.com/llvm/llvm-project/pull/139969

Enable breakpints from assembly sources



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-14 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen edited 
https://github.com/llvm/llvm-project/pull/139969
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread via lldb-commits

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

The clang parts look like a nice improvement, thanks!

Please wait for a few other people to review it though.

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.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 "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+return "";
+  const psinfo_t *psinfo =
+  reinterpret_cast(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}

labath wrote:

>  In that case, shall I go ahead with this?

I think we can say it's up to you, but so far I haven't seen anything that 
would make me thing this is necessary. You're right that it causes the name 
field to disappear, but the usefulness of that field comes from the fact that 
it's different for every thread:
```
lldb) thread list
Process 6708 stopped
* thread #1: tid = 6708, 0x7fffee7201ac libc.so.6`__select + 332, name = 
'lldb', stop reason = signal SIGSTOP
  thread #2: tid = 6759, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'er.alarm-thread'
  thread #3: tid = 6760, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'dbg.evt-handler'
  thread #4: tid = 6765, 0x7fffee70b15a libc.so.6`wait4 + 90, name = 
'ait4(pid=6764)>'
  thread #5: tid = 6766, 0x7fffee7201ac libc.so.6`__select + 332, name = 
'b-remote.async>'
  thread #6: tid = 6771, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'intern-state'
  thread #7: tid = 6772, 0x7fffee7201ac libc.so.6`__select + 332, name = 
'.process.stdio>'
  thread #8: tid = 6773, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-0'
  thread #9: tid = 6774, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-1'
  thread #10: tid = 6775, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-2'
  thread #11: tid = 6776, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-3'
  thread #12: tid = 6777, 0x7fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-4'
```

If all of these said `name='lldb'`, would the result be useful? I think not. 
And I think the same goes for the single-threaded use case: if there is just a 
single thread, then you don't need names as there's nothing to distinguish.

https://github.com/llvm/llvm-project/pull/139537
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread via lldb-commits


@@ -107,6 +107,7 @@ class ASTUnit {
 
 private:
   std::unique_ptr LangOpts;
+  std::shared_ptr DiagOpts;

cor3ntin wrote:

Can that be unique_ptr ?

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.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 "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+return "";
+  const psinfo_t *psinfo =
+  reinterpret_cast(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}

labath wrote:

You also shouldn't expect that the "process stopped" output will contain the 
name of the process. That really is the name of the thread -- it just happens 
that on linux the main thread gets the name of the process. On macos for 
instance, this output doesn't contain the name of the process, even for the 
main thread:
```
(lldb) Process 6668 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x000185cf1b6c libsystem_kernel.dylib`__read_nocancel + 8
```

https://github.com/llvm/llvm-project/pull/139537
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Oliver Hunt via lldb-commits


@@ -2032,6 +2032,7 @@ class SourceManagerForFile {
   // as they are created in `createSourceManagerForFile` so that they can be
   // deleted in the reverse order as they are created.
   std::unique_ptr FileMgr;
+  std::unique_ptr DiagOpts;

ojhunt wrote:

I don't like that in some cases we have a unique_ptr and 
later (ATSUnit) we use a shared_ptr<>. It leaves an author unable to know given 
some arbitrary DiagnosticOptions* what the lifetime and/or ownership rules are.

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


[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -1243,303 +1243,285 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol(
   return false;
 }
 
-// Answer the question: Where did THIS frame save the CALLER frame ("previous"
-// frame)'s register value?
-
-enum UnwindLLDB::RegisterSearchResult
-RegisterContextUnwind::SavedLocationForRegister(
-uint32_t lldb_regnum,
-lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc) {
+/// Search this stack frame's UnwindPlans for the AbstractRegisterLocation

labath wrote:

The docstring should go in the header. If there are details you think are only 
relevant for the implementation (not the interface), they can stay here.

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


[Lldb-commits] [lldb] Extending LLDB to work on AIX (PR #102601)

2025-05-14 Thread Hemang Gadhavi via lldb-commits

https://github.com/HemangGadhavi updated 
https://github.com/llvm/llvm-project/pull/102601



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

> I think our tests are not fully specifying their expected state. For example, 
> lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
> `TestDAP_console.test_diagnositcs` was performing an evaluate and then using 
> `get_important` to fetch output events with category 'important'.
> 
> With the change, the `important` output was always coming after the request 
> was handled. I updated the test to use a `self.collect_important` instead of 
> `get_important`. Previously, this could have been emitted while the request 
> was being handled, but now the output would only ever be emitted after the 
> request handler is finished.

Okay, so it's kind of what I said, right? The "important" output was coming 
before the message was handled most of the time, although it wasn't guaranteed, 
and the test could fail if that happens. Now, it *always* comes too late.

If that's true, then the test change to use `self.collect_important` could be 
made before the functionality change, right?


> Thinking about this some more, would it be possible to treat everything as an 
> `SBEvent`? We could use the `DAP::broadcaster` to create events for the DAP 
> protocol messages we receive, right? Then when we listen for events we'd just 
> need to check if the event was a 
> `DAPBroadcasterBits::eBroadcastBitProtocolMessage` as the event type and 
> handle protocol messages in the same loop we're handling events.
> 
> This would have a similar effect as using a MainLoop but unifies the event 
> thread with the DAP handler. We'd still need to transport thread to parse 
> messages and add events to the broadcaster.

Yeah, that should be possible, and it may make more sense in a world where the 
MainLoop cannot listen on all FD types (since you need the forwarding thread 
anyway). It's unfortunate that there's no synchronization operation (at least, 
not a portable one, FUTEX_FD seems kinda nice) that allows you do wait for 
condition variables and FDs, necessitating these forwarding threads. Since 
forwarding would add a bit of latency, one of the factors would be which kinds 
of operations do we want to make slower.

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-14 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-14 Thread via lldb-commits

https://github.com/nd created https://github.com/llvm/llvm-project/pull/139862

Lock ensures modules don't change during iteration.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (nd)


Changes

Lock ensures modules don't change during iteration.

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


1 Files Affected:

- (modified) lldb/source/Target/Target.cpp (+1) 


``diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7f61f8689fb95..485b49aeb64b4 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1510,6 +1510,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t 
watch_id,
 }
 
 ModuleSP Target::GetExecutableModule() {
+  std::lock_guard guard(m_images.GetMutex());
   // search for the first executable in the module list
   for (size_t i = 0; i < m_images.GetSize(); ++i) {
 ModuleSP module_sp = m_images.GetModuleAtIndex(i);

``




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


[Lldb-commits] [lldb] 97aa01b - [lldb] Call Target::ClearAllLoadedSections earlier (#138892)

2025-05-14 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-14T11:16:55+02:00
New Revision: 97aa01bef770ec651c86978d137933e09221dd00

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

LOG: [lldb] Call Target::ClearAllLoadedSections earlier (#138892)

Minidump files contain explicit information about load addresses of
modules, so it can load them itself. This works on other platforms, but
fails on darwin because DynamicLoaderDarwin nukes the loaded module list
on initialization (which happens after the core file plugin has done its
work).

This used to work until #109477, which enabled the dynamic loader
plugins for minidump files in order to get them to provide access to
TLS.

Clearing the load list makes sense, but I think we could do it earlier
in the process, so that both Process and DynamicLoader plugins get a
chance to load modules. This patch does that by calling the function
early in the launch/attach/load core flows.

This fixes TestDynamicValue.py:test_from_core_file on darwin.

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Target/Process.cpp
lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 578ab12268ea3..1270d57423c7b 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -872,7 +872,6 @@ void DynamicLoaderDarwin::PrivateInitialize(Process 
*process) {
StateAsCString(m_process->GetState()));
   Clear(true);
   m_process = process;
-  m_process->GetTarget().ClearAllLoadedSections();
 }
 
 // Member function that gets called when the process state changes.

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 13ff12b4ff953..7c5512598bbb6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2763,6 +2763,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo 
&launch_info, StateType &state,
   }
 
   if (state == eStateStopped || state == eStateCrashed) {
+GetTarget().ClearAllLoadedSections();
 DidLaunch();
 
 // Now that we know the process type, update its signal responses from the
@@ -2799,6 +2800,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo 
&launch_info, StateType &state,
 }
 
 Status Process::LoadCore() {
+  GetTarget().ClearAllLoadedSections();
   Status error = DoLoadCore();
   if (error.Success()) {
 ListenerSP listener_sp(
@@ -3094,6 +3096,8 @@ void Process::CompleteAttach() {
   Log *log(GetLog(LLDBLog::Process | LLDBLog::Target));
   LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
 
+  GetTarget().ClearAllLoadedSections();
+
   // Let the process subclass figure out at much as it can about the process
   // before we go looking for a dynamic loader plug-in.
   ArchSpec process_arch;

diff  --git a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py 
b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
index cd95a9ff3fe8c..faa35421ff60b 100644
--- a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
+++ b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
@@ -282,7 +282,6 @@ def test_from_forward_decl(self):
 
 @no_debug_info_test
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")
-@expectedFailureDarwin  # dynamic loader unloads modules
 @expectedFailureAll(archs=["arm"]) # Minidump saving not implemented
 def test_from_core_file(self):
 """Test fetching C++ dynamic values from core files. Specifically, test



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


[Lldb-commits] [lldb] [lldb] Fix ForwardListFrontEnd::CalculateNumChildren (PR #139805)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

I'm very much in favor of removing this dependence on the setting value, as I 
think it should be handled at a higher level. *However*, I fear this is going 
to make printing large std::forward_list very slow. Since computing the size of 
the list requires iterating through all the elements, which is a lot of pointer 
chasing, printing of large lists (like, 10k elements or more) could take a very 
long time (and I think that's the reason this limit was originally introduced).

Fortunately, we already have a mechanism to prevent this -- we mave 
`GetNumChildren` overload with the `max` argument which basically says "if the 
number of children is larger than this, don't bother giving me the exact 
value". The general printing logic (in frame var and lldb-dap) should already 
know how to make use of this (I've made sure of that because I was supporting 
some formatters like this), but for std::forward_list, its summary provider 
will force the calculation of the size (because it prints the size in the 
summary).

For this, I think the fix is to change the formatter to *not* print the exact 
size (all the time). For example, it could call `GetNumChildren(X)` and if the 
result is smaller than `X`, it can print the exact size (`size=x`). Otherwise 
it can just print the lower bound (`size>=X` ?).

The value of `X` might be derived from the setting, but I think it'd also make 
sense have an independent constant, because not every client has to display the 
values according to this setting (for example, VSCode always prints the first 
100 values).

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


[Lldb-commits] [lldb] [lldb] Call Target::ClearAllLoadedSections earlier (PR #138892)

2025-05-14 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Call Target::ClearAllLoadedSections earlier (PR #138892)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

> Looks good to me, we should clear them on both attach & launch which is what 
> the Darwin DynamicLoader plugin was doing.
> 
> I was a little surprised that Minidump is picking up the host native 
> DyanmicLoader plugin at all - seems like the static dynamic loader might make 
> more sense, so it can say what binaries are loaded & where they're loaded - 
> but I've never looked at the Minidump code, I'm sure there are reasons why it 
> works this way.

It originally did that, but then this changed last year in order to get access 
to thread-local data, which is also a responsibility of the dynamic loader 
class. At least for posix systems (I'm not sure about Darwin, as the dynamic 
loader is more tightly integrated into the OS) it also kind of makes sense 
because the dynamic loader can work off of an (elf) core file (if it contains 
enough information). For minidumps, some of that work is wasted though, because 
the minidump contains explicit load addresses of all modules. So, it would kind 
of make sense to separate the logic for loading the modules from "loading of 
TLS", but it's not quite clear how to do that as two are quite intertwined.

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


[Lldb-commits] [lldb] adabc83 - [lldb] Merge/unify ABI-provided AArch64 unwind plans (#139545)

2025-05-14 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-14T11:29:56+02:00
New Revision: adabc83a92130e556d4d16adaee6e81e09fdf570

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

LOG: [lldb] Merge/unify ABI-provided AArch64 unwind plans (#139545)

The macos and sysv ABIs return functionally equivalent unwind plans, so
they can be implemented in the base AArch64 class. The only difference
between them was that the macos plan provided a "pc=lr" rule whereas the
sysv plan called SetReturnAddressRegister (which causes the unwind
machinery to act as if that rule was present). This difference was
enough to cause `CompareUnwindPlansForIdenticalInitialPCLocation` to
return a different value and break the (temporarily reverted)
TestUnwindFramelessFaulted test.

While merging the two functions, I couldn't stop myself from simplifying
them to use the generic register number schemes -- which exposed another
bug in CompareUnwindPlansForIdenticalInitialPCLocation, namely that it
was expecting all unwind plans to use the LLDB numbering scheme. This
patch fixes that as well.

Added: 


Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
lldb/source/Symbol/FuncUnwinders.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 7d8d0a4d3d671..3bafb21f7c33a 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -19,6 +19,7 @@
 #include 
 
 using namespace lldb;
+using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE(ABIAArch64)
 
@@ -200,3 +201,44 @@ void ABIAArch64::AugmentRegisterInfo(
 lldb::eEncodingIEEE754, lldb::eFormatFloat);
   }
 }
+
+UnwindPlanSP ABIAArch64::CreateFunctionEntryUnwindPlan() {
+  UnwindPlan::Row row;
+
+  // Our previous Call Frame Address is the stack pointer
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_SP, 0);
+
+  // Our previous PC is in the LR, all other registers are the same.
+  row.SetRegisterLocationToRegister(LLDB_REGNUM_GENERIC_PC,
+LLDB_REGNUM_GENERIC_RA, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 at-func-entry default");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}
+
+UnwindPlanSP ABIAArch64::CreateDefaultUnwindPlan() {
+  UnwindPlan::Row row;
+  const int32_t ptr_size = 8;
+
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_FP,
+2 * ptr_size);
+  row.SetUnspecifiedRegistersAreUndefined(true);
+
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_FP,
+   ptr_size * -2, true);
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_PC,
+   ptr_size * -1, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 default unwind plan");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 52e42f1260a83..53702f4da580d 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -19,6 +19,9 @@ class ABIAArch64 : public lldb_private::MCBasedABI {
   lldb::addr_t FixCodeAddress(lldb::addr_t pc) override;
   lldb::addr_t FixDataAddress(lldb::addr_t pc) override;
 
+  lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan() override;
+  lldb::UnwindPlanSP CreateDefaultUnwindPlan() override;
+
 protected:
   virtual lldb::addr_t FixAddress(lldb::addr_t pc, lldb::addr_t mask) {
 return pc;

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index f86ab8cbb1195..094e0523a4edf 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -17,7 +17,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Value.h"
-#include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/Process.h"
 #i

[Lldb-commits] [lldb] [lldb] Merge/unify ABI-provided AArch64 unwind plans (PR #139545)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

> Nice unification, thanks. I'm sure the pc=lr rule was me not trusting the 
> algorithms over in RegisterContextUnwind to do the right thing if the rule 
> wasn't listed. Having just pushed all that code around for a day, I know this 
> kind of thing is unneeded, but harmless if it's present.

Well.. as it stands now, it's kind of needed because without it, your test 
would break in CompareUnwindPlansForIdenticalInitialPCLocation, as it doesn't 
recognise that `SetReturnAddressRegister(LR)` is equivalent to 
`SetRegisterLocationToRegister(PC, LR)`. 

This is kind of why I have suggested in 
https://discourse.llvm.org/t/unhappiness-with-the-lldb-unwinder-register-passing-up-the-stack-interrup-trap-sigtramp-frames/86058/3
 to standardise on the `pc=lr` rules. I wrote that before I encountered this 
problem, but seeing we had plans which employed both of these strategies (and 
they both mostly worked) has made me more confident this could work.


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


[Lldb-commits] [lldb] [lldb] Merge/unify ABI-provided AArch64 unwind plans (PR #139545)

2025-05-14 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Call Target::ClearAllLoadedSections earlier (PR #138892)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

Yeah, this is kind of my fault as I introduced this way back when. I think at 
that point we didn't have test-specific headers, which made this option more 
appealing.

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


[Lldb-commits] [lldb] [lldb][AIX] Added 32-bit XCOFF Executable support (PR #139875)

2025-05-14 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX created 
https://github.com/llvm/llvm-project/pull/139875

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:
1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

**Description:**
Adding support for XCOFF 32 bit file format as well in lldb, up to the point 
where 64-bit support is implemented. 
Added a new test case for the same. 
This is an incremental PR on top of the previous couple of XCOFF support 
commits.




  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -111,7 +111,42 @@ ASTNodeUP DILParser::ParseUnaryExpression() {
   llvm_unreachable("invalid token kind");
 }
   }
-  return ParsePrimaryExpression();
+  return ParsePostfixExpression();
+}
+
+// Parse a postfix_expression.
+//
+//  postfix_expression:
+//primary_expression
+//postfix_expression "[" integer_literal "]"
+//
+ASTNodeUP DILParser::ParsePostfixExpression() {
+  ASTNodeUP lhs = ParsePrimaryExpression();
+  while (CurToken().Is(Token::l_square)) {
+uint32_t loc = CurToken().GetLocation();
+Token token = CurToken();
+switch (token.GetKind()) {
+case Token::l_square: {
+  m_dil_lexer.Advance();
+  auto rhs = ParseIntegerConstant();

labath wrote:

make type explicit

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

I'm sorry, I put this off because it wasn't clear how to respond immediately -- 
and then it dropped off my radar.

I have a bunch of comments, but overall, I think this could work.

My main objection is to the use of the APInt class. If you want to use it 
(which I'm fine with, but I also think a plain (u)int64_t would work for this 
purpose as well), then I think you should use it properly: using the operations 
defined on the class itself (e.g. `slt`/`ult`) -- instead of converting it to 
an plain integer first chance you get. As it stands now your parser will 
happily accept an incredibly long integer, but then you'll assert when 
`getZExtValue` cannot convert that to an uint64_t. There's also some confusion 
about whether the value is signed or unsigned. You can't just switch between 
`getZExtValue` and `getSExtValue` and expect the result to make sense (hint: 
`getSExtValue` of "0x80" parsed into an APInt is -128)

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {
+  uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();
+  // Verify that the 'index' is not out-of-range for the declared type.
+  if (child_idx >= num_children) {
+auto message = llvm::formatv(

labath wrote:

I'm not sure this is actually correct, or expected. The type of message here is 
going to be `formatv_object`, and I wouldn't be surprised if it holds 
references to objects to objects that get destroyed at the full statement. 
Better explicitly make this a std::string.

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {
+  uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();
+  // Verify that the 'index' is not out-of-range for the declared type.
+  if (child_idx >= num_children) {
+auto message = llvm::formatv(
+"array index {0} is not valid for \"({1}) {2}\"", child_idx,
+base->GetTypeName().AsCString(""),
+base->GetName().AsCString());
+return llvm::make_error(m_expr, message,
+node->GetLocation());
+  }
+
+  if (static_cast(child_idx) <
+  synthetic->GetNumChildrenIgnoringErrors()) {
+lldb::ValueObjectSP child_valobj_sp =
+synthetic->GetChildAtIndex(child_idx);
+if (child_valobj_sp) {
+  return child_valobj_sp;
+}
+  }
+}
+  }
+
+  auto base_type = base->GetCompilerType();
+  if (!base_type.IsPointerType() && !base_type.IsArrayType())

labath wrote:

This is one of the (few) type checks that I think make sense, but I think this 
would read better if it was structured like:
```
if (pointer) ...
else if (array) ...
else  /*not pointer or array*/
```

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -108,6 +110,26 @@ class UnaryOpNode : public ASTNode {
   ASTNodeUP m_operand;
 };
 
+class ArraySubscriptNode : public ASTNode {
+public:
+  ArraySubscriptNode(uint32_t location, ASTNodeUP base, llvm::APInt index)
+  : ASTNode(location, NodeKind::eArraySubscriptNode),
+m_base(std::move(base)), m_index(std::move(index)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *GetBase() const { return m_base.get(); }
+  const llvm::APInt *GetIndex() const { return &m_index; }

labath wrote:

I think this should return a (const) reference to make it clear it can't be 
null.

(I know the same can be said about the GetBase, and I'd actually do that there 
as well, but it's less of a surprise there since the object is already stored 
as a pointer)

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {

labath wrote:

Can we simplify this? AFAICT, GetSyntheticValue should return null if there's 
no synthtic value, and it should never the same object, so could this be just 
`if (lldb::ValueObjectSP synthetic = base->GetSyntheticValue())` ?

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }

labath wrote:

```suggestion
  if (!lhs_or_err)
return lhs_or_err;
```

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -81,21 +100,28 @@ llvm::Expected DILLexer::Lex(llvm::StringRef expr,
 return Token(Token::eof, "", (uint32_t)expr.size());
 
   uint32_t position = cur_pos - expr.begin();
+  std::optional maybe_number = IsNumber(expr, remainder);
+  if (maybe_number) {
+std::string number = (*maybe_number).str();
+return Token(Token::numeric_constant, number, position);
+  }

labath wrote:

```suggestion
  if (maybe_number)
return Token(Token::numeric_constant, maybe_number->str(), position);
```

mainly because it avoids making a copy of the std::string object (without 
resorting to std::move)

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {
+  uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();

labath wrote:

GetNumChildren can actually be an expensive operation (see 
https://github.com/llvm/llvm-project/pull/139805#issuecomment-2879353718). Just 
ask for the child with the given index and then deal with the error.

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -111,7 +111,36 @@ ASTNodeUP DILParser::ParseUnaryExpression() {
   llvm_unreachable("invalid token kind");
 }
   }
-  return ParsePrimaryExpression();
+  return ParsePostfixExpression();
+}
+
+// Parse a postfix_expression.
+//
+//  postfix_expression:
+//primary_expression
+//postfix_expression "[" expression "]"
+//
+ASTNodeUP DILParser::ParsePostfixExpression() {
+  ASTNodeUP lhs = ParsePrimaryExpression();
+  while (CurToken().Is(Token::l_square)) {
+uint32_t loc = CurToken().GetLocation();
+Token token = CurToken();
+switch (token.GetKind()) {
+case Token::l_square: {

labath wrote:

Okay... I *guess* that makes sense...

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] Added 32-bit XCOFF Executable support (PR #139875)

2025-05-14 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/139875



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits

labath wrote:

> Okay, I see the problem, I didn't really think that retrieving the type 
> system when debugging Swift code would return C type system. Why is it like 
> this though?

It depends on how you retrieve the type system. You were iterating through the 
type systems of the target, which will return all of them because C and swift 
(and other languages) can coexist within the same process. There isn't such a 
thing as a "pure swift" application, so we should have a story for how the two 
will interact. Maybe story can be "we don't let the two interact", but it 
should be an explicit choice and we should thing through the consequences.

> Is there a reliable way to get a type system of the main language?

I don't think "main language" makes sense as a concept. The fact that Swift 
makes up 99% of your binary is not going to help you if what you really want to 
do is debug that 1% written in C. It *might* make sense to use the language of 
the currently selected frame but even there we need to be careful. The fact 
that you can access global variables means you can end up with non-local types 
even in this case.

> I also found now that the function TypeSystem::GetBasicTypeFromAST that the 
> code in Eval relies on is not even implemented in 
> [TypeSystemSwift](https://github.com/swiftlang/llvm-project/blob/a5b0b3daf26fd41b2caf61551b72f74b0e2a4ab7/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h#L296).

I don't know why is that the case, but it wouldn't surprise me if that's 
somehow related to the fact that the BasicType enum is already very C specific.

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


[Lldb-commits] [lldb] [lldb][test] Fix beginning/end of file test failed on Windows (PR #139278)

2025-05-14 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/139278

>From 30318b28b158950b0f8d6c2732831eceb7cefc41 Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Fri, 9 May 2025 22:53:03 +0800
Subject: [PATCH] [lldb][test] Fix beginning/end of file test failed on Windows

---
 lldb/test/Shell/Commands/Inputs/cross_platform.c  | 15 +++
 .../command-list-reach-beginning-of-file.test | 15 ---
 .../Commands/command-list-reach-end-of-file.test  | 10 +-
 3 files changed, 20 insertions(+), 20 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/Inputs/cross_platform.c

diff --git a/lldb/test/Shell/Commands/Inputs/cross_platform.c 
b/lldb/test/Shell/Commands/Inputs/cross_platform.c
new file mode 100644
index 0..9349a94e0257f
--- /dev/null
+++ b/lldb/test/Shell/Commands/Inputs/cross_platform.c
@@ -0,0 +1,15 @@
+#include 
+void doNothing() { printf("doNothing\n"); }
+
+void doSomethiing() {
+  doNothing();
+  doNothing();
+  doNothing();
+}
+
+int main() {
+  doSomethiing();
+  doNothing();
+  doSomethiing();
+  return 0;
+}
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
index fa4a93e5904aa..aa27813bbc056 100644
--- a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -9,17 +7,12 @@ list
 b main
 # CHECK: Breakpoint 1:
 
+
 r
 # CHECK: int main()
 
-list
-# CHECK: if (child_pid == 0)
-
 list -
-# CHECK: int main()
-
-list -10
-# CHECK: #include 
+# CHECK: #include 
 
 list -
 # CHECK: note: Reached beginning of the file, no more to page
@@ -28,4 +21,4 @@ list -
 # CHECK: note: Reached beginning of the file, no more to page
 
 list
-# CHECK: int main()
+# CHECK: doNothing();
diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
index edf4c521a9e76..3b6b144640921 100644
--- a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -12,12 +10,6 @@ b main
 r
 # CHECK: int main()
 
-list
-# CHECK: if (child_pid == 0)
-
-list
-# CHECK: printf("signo = %d\n", SIGCHLD);
-
 list
 # CHECK: return 0;
 

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


[Lldb-commits] [lldb] [lldb][test] Fix beginning/end of file test failed on Windows (PR #139278)

2025-05-14 Thread via lldb-commits

hapee wrote:

> Seems fine, my only question is does the source actually need to be doing 
> this much?
> 
> Or in other words: the example should be as complex as it needs to be to show 
> the bug. If that means just calling the same do-nothing function over and 
> over to create more lines, that would be preferable.

I have removed unnecessary code to ensure that the file used in the test case 
is as simple as possible.


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


[Lldb-commits] [lldb] [lldb][test] Fix beginning/end of file test failed on Windows (PR #139278)

2025-05-14 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/139278

>From d1b295748d5bb4666140f37ec6896d8503239cf6 Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Fri, 9 May 2025 22:53:03 +0800
Subject: [PATCH] [lldb][test] Fix beginning/end of file test failed on Windows

---
 lldb/test/Shell/Commands/Inputs/cross_platform.c  | 15 +++
 .../command-list-reach-beginning-of-file.test | 14 +++---
 .../Commands/command-list-reach-end-of-file.test  | 10 +-
 3 files changed, 19 insertions(+), 20 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/Inputs/cross_platform.c

diff --git a/lldb/test/Shell/Commands/Inputs/cross_platform.c 
b/lldb/test/Shell/Commands/Inputs/cross_platform.c
new file mode 100644
index 0..9349a94e0257f
--- /dev/null
+++ b/lldb/test/Shell/Commands/Inputs/cross_platform.c
@@ -0,0 +1,15 @@
+#include 
+void doNothing() { printf("doNothing\n"); }
+
+void doSomethiing() {
+  doNothing();
+  doNothing();
+  doNothing();
+}
+
+int main() {
+  doSomethiing();
+  doNothing();
+  doSomethiing();
+  return 0;
+}
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
index fa4a93e5904aa..daa3a94892d63 100644
--- a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -12,14 +10,8 @@ b main
 r
 # CHECK: int main()
 
-list
-# CHECK: if (child_pid == 0)
-
 list -
-# CHECK: int main()
-
-list -10
-# CHECK: #include 
+# CHECK: #include 
 
 list -
 # CHECK: note: Reached beginning of the file, no more to page
@@ -28,4 +20,4 @@ list -
 # CHECK: note: Reached beginning of the file, no more to page
 
 list
-# CHECK: int main()
+# CHECK: doNothing();
diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
index edf4c521a9e76..3b6b144640921 100644
--- a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -12,12 +10,6 @@ b main
 r
 # CHECK: int main()
 
-list
-# CHECK: if (child_pid == 0)
-
-list
-# CHECK: printf("signo = %d\n", SIGCHLD);
-
 list
 # CHECK: return 0;
 

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }

labath wrote:

What's the purpose of that ?  GetChildAtIndex, GetChildMemberWithName, etc. 
work fine on reference types.

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


[Lldb-commits] [lldb] 7e7871d - [lldb] Clear loaded sections even earlier

2025-05-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2025-05-14T15:38:10+02:00
New Revision: 7e7871d3f58b9da72ca180fcd7f0d2da3f92ec4a

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

LOG: [lldb] Clear loaded sections even earlier

Follow-up to #138892 fixing breakage on windows. Calling
ClearAllLoadedSections earlier is necessary to avoid throwing out the
work done by the windows process plugin.

Added: 


Modified: 
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 7c5512598bbb6..f136271a3b8a8 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2675,6 +2675,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo 
&launch_info, StateType &state,
   m_jit_loaders_up.reset();
   m_system_runtime_up.reset();
   m_os_up.reset();
+  GetTarget().ClearAllLoadedSections();
 
   {
 std::lock_guard guard(m_process_input_reader_mutex);
@@ -2763,7 +2764,6 @@ Status Process::LaunchPrivate(ProcessLaunchInfo 
&launch_info, StateType &state,
   }
 
   if (state == eStateStopped || state == eStateCrashed) {
-GetTarget().ClearAllLoadedSections();
 DidLaunch();
 
 // Now that we know the process type, update its signal responses from the



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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-14 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

@labath Hi, do you have any other comment on this? thanks!

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


[Lldb-commits] [lldb] [lldb][AIX] Added 32-bit XCOFF Executable support (PR #139875)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)


Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:
1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

**Description:**
Adding support for XCOFF 32 bit file format as well in lldb, up to the point 
where 64-bit support is implemented. 
Added a new test case for the same. 
This is an incremental PR on top of the previous couple of XCOFF support 
commits.


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


3 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp (+37-17) 
- (modified) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h (+13-1) 
- (added) lldb/test/Shell/ObjectFile/XCOFF/basic-info32.yaml (+110) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 177c360ba..1ad488ff20c24 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -39,7 +39,6 @@ using namespace lldb;
 using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE(ObjectFileXCOFF)
-
 // FIXME: target 64bit at this moment.
 
 // Static methods.
@@ -95,10 +94,11 @@ bool ObjectFileXCOFF::CreateBinary() {
 
   Log *log = GetLog(LLDBLog::Object);
 
-  auto binary = llvm::object::ObjectFile::createObjectFile(
-  llvm::MemoryBufferRef(toStringRef(m_data.GetData()),
-m_file.GetFilename().GetStringRef()),
-  file_magic::xcoff_object_64);
+  auto memory_ref = llvm::MemoryBufferRef(toStringRef(m_data.GetData()),
+  m_file.GetFilename().GetStringRef());
+  llvm::file_magic magic = llvm::identify_magic(memory_ref.getBuffer());
+
+  auto binary = llvm::object::ObjectFile::createObjectFile(memory_ref, magic);
   if (!binary) {
 LLDB_LOG_ERROR(log, binary.takeError(),
"Failed to create binary for file ({1}): {0}", m_file);
@@ -143,9 +143,9 @@ size_t ObjectFileXCOFF::GetModuleSpecifications(
 
 static uint32_t XCOFFHeaderSizeFromMagic(uint32_t magic) {
   switch (magic) {
-// TODO: 32bit not supported.
-// case XCOFF::XCOFF32:
-//  return sizeof(struct llvm::object::XCOFFFileHeader32);
+  case XCOFF::XCOFF32:
+return sizeof(struct llvm::object::XCOFFFileHeader32);
+break;
   case XCOFF::XCOFF64:
 return sizeof(struct llvm::object::XCOFFFileHeader64);
 break;
@@ -169,8 +169,9 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP &data_sp,
 }
 
 bool ObjectFileXCOFF::ParseHeader() {
-  // Only 64-bit is supported for now
-  return m_binary->fileHeader64()->Magic == XCOFF::XCOFF64;
+  if (m_binary->is64Bit())
+return m_binary->fileHeader64()->Magic == XCOFF::XCOFF64;
+  return m_binary->fileHeader64()->Magic == XCOFF::XCOFF32;
 }
 
 ByteOrder ObjectFileXCOFF::GetByteOrder() const { return eByteOrderBig; }
@@ -178,8 +179,9 @@ ByteOrder ObjectFileXCOFF::GetByteOrder() const { return 
eByteOrderBig; }
 bool ObjectFileXCOFF::IsExecutable() const { return true; }
 
 uint32_t ObjectFileXCOFF::GetAddressByteSize() const {
-  // 32-bit not supported. return 8 for 64-bit XCOFF::XCOFF64
-  return 8;
+  if (m_binary->is64Bit())
+return 8;
+  return 4;
 }
 
 AddressClass ObjectFileXCOFF::GetAddressClass(addr_t file_addr) {
@@ -191,20 +193,36 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
 void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+
   if (m_sections_up)
 return;
 
   m_sections_up = std::make_unique();
-  ModuleSP module_sp(GetModule());
+  if (m_binary->is64Bit())
+CreateSectionsWithBitness(unified_section_list);
+  else
+CreateSectionsWithBitness(unified_section_list);
+}
+
+template  auto GetSections(llvm::object::XCOFFObjectFile *binary) {
+  if constexpr (T::Is64Bit)
+return binary->sections64();
+  else
+return binary->sections32();
+}
 
+template 
+void ObjectFileXCOFF::CreateSectionsWithBitness(
+SectionList &unified_section_list) {
+  ModuleSP module_sp(GetModule());
   if (!module_sp)
 return;
 
   std::lock_guard guard(module_sp->GetMutex());
 
   int idx = 0;
-  for (const llvm::object::XCOFFSectionHeader64 §ion :
-   m_binary->sections64()) {
+  for (const typename T::SectionHeader §ion :
+   GetSections(m_binary.get())) {
 
 ConstString const_sect_name(section.Name);
 
@@ -253,9 +271,11 @@ UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
 uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; 
}
 
 ObjectFile::Type ObjectFileXCOFF::CalculateType() {
-  if (m_binary->fileHeader64()->Flags & XCOFF::F_EXEC)
+ 

[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

2025-05-14 Thread Pavel Labath via lldb-commits

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


https://github.com/llvm/llvm-project/pull/139817
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread via lldb-commits


@@ -837,6 +838,7 @@ class ASTUnit {
   static std::unique_ptr LoadFromCommandLine(
   const char **ArgBegin, const char **ArgEnd,
   std::shared_ptr PCHContainerOps,
+  std::shared_ptr DiagOpts,

cor3ntin wrote:

We probably can pass by reference here

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-14 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

2025-05-14 Thread Pavel Labath via lldb-commits


@@ -1243,303 +1243,285 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol(
   return false;
 }
 
-// Answer the question: Where did THIS frame save the CALLER frame ("previous"
-// frame)'s register value?
-
-enum UnwindLLDB::RegisterSearchResult
-RegisterContextUnwind::SavedLocationForRegister(
-uint32_t lldb_regnum,
-lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc) {
+/// Search this stack frame's UnwindPlans for the AbstractRegisterLocation
+/// for this register.
+///
+/// \param[out] kind
+/// Set to the RegisterKind of the UnwindPlan which is the basis for
+/// the returned AbstractRegisterLocation; if the location is in terms
+/// of another register number, this Kind is needed to interpret it
+/// correctly.
+///
+/// \return
+/// An empty optional indicaTes that there was an error in processing
+/// the request.
+///
+/// If there is no unwind rule for a volatile (caller-preserved) register,
+/// the returned AbstractRegisterLocation will be IsUndefined,
+/// indicating that we should stop searching.
+///
+/// If there is no unwind rule for a non-volatile (callee-preserved)
+/// register, the returned AbstractRegisterLocation will be IsSame.
+/// In frame 0, IsSame means get the value from the live register context.
+/// Else it means to continue descending down the stack to more-live frames
+/// looking for a location/value.
+///
+/// If an AbstractRegisterLocation is found in an UnwindPlan, that will
+/// be returned, with no consideration of the current ABI rules for
+/// registers.  Functions using an alternate ABI calling convention
+/// will work as long as the UnwindPlans are exhaustive about what
+/// registers are volatile/non-volatile.
+std::optional
+RegisterContextUnwind::GetAbstractRegisterLocation(uint32_t lldb_regnum,
+   lldb::RegisterKind &kind) {
   RegisterNumber regnum(m_thread, eRegisterKindLLDB, lldb_regnum);
   Log *log = GetLog(LLDBLog::Unwind);
 
-  // Have we already found this register location?
-  if (!m_registers.empty()) {
-std::map::const_iterator
-iterator;
-iterator = m_registers.find(regnum.GetAsKind(eRegisterKindLLDB));
-if (iterator != m_registers.end()) {
-  regloc = iterator->second;
-  UnwindLogMsg("supplying caller's saved %s (%d)'s location, cached",
-   regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
-  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
-}
-  }
-
-  // Look through the available UnwindPlans for the register location.
-
   UnwindPlan::Row::AbstractRegisterLocation unwindplan_regloc;
-  bool have_unwindplan_regloc = false;
-  RegisterKind unwindplan_registerkind = kNumRegisterKinds;
 
+  // First, try to find a register location via the FastUnwindPlan
   if (m_fast_unwind_plan_sp) {
 const UnwindPlan::Row *active_row =
 m_fast_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
-unwindplan_registerkind = m_fast_unwind_plan_sp->GetRegisterKind();
-if (regnum.GetAsKind(unwindplan_registerkind) == LLDB_INVALID_REGNUM) {
+kind = m_fast_unwind_plan_sp->GetRegisterKind();
+if (regnum.GetAsKind(kind) == LLDB_INVALID_REGNUM) {
   UnwindLogMsg("could not convert lldb regnum %s (%d) into %d RegisterKind 
"
"reg numbering scheme",
regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
-   (int)unwindplan_registerkind);
-  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
+   (int)kind);
+  return {};
 }
 // The architecture default unwind plan marks unknown registers as
 // Undefined so that we don't forward them up the stack when a
 // jitted stack frame may have overwritten them.  But when the
 // arch default unwind plan is used as the Fast Unwind Plan, we
 // need to recognize this & switch over to the Full Unwind Plan
-// to see what unwind rule that (more knoweldgeable, probably)
-// UnwindPlan has.  If the full UnwindPlan says the register
-// location is Undefined, then it really is.
-if (active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
+// to see what unwind rule that (more knowledgeable, probably)
+// UnwindPlan has.
+if (active_row->GetRegisterInfo(regnum.GetAsKind(kind),
 unwindplan_regloc) &&
 !unwindplan_regloc.IsUndefined()) {
   UnwindLogMsg(
   "supplying caller's saved %s (%d)'s location using FastUnwindPlan",
   regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
-  have_unwindplan_regloc = true;
+  return unwindplan_regloc;
 }
   }
 
-  if (!have_unwindplan_regloc) {
-// m_full_unwind_plan_sp being NULL means that we haven't tried to find a
-// full UnwindPlan yet
-bool got_new_full_unwindplan = false;
-if (!m_full_unwi

[Lldb-commits] [lldb] [lldb] Provide lr value in faulting frame on arm64 (PR #138805)

2025-05-14 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> I also needed to remove the brk #0xf000 instruction because lldb is not able 
> to step over it -- it just ends up spinning forever. FWICS, it's not actually 
> necessary now that you're stepping through the test. Nonetheless, this is a 
> bug -- one that @DavidSpickett might be interested in :)

Yes I've been asked a few times about it. GDB also has problems with it, but 
probably does something slightly more useful. I'll speak to folks on that side 
and see how we could handle this.


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


[Lldb-commits] [lldb] [lldb] Use llvm::unique (NFC) (PR #139910)

2025-05-14 Thread Kazu Hirata via lldb-commits

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

While I am at it, this patch removes the "if" statement.
std::vector::erase(first, last) doesn't do anything when
first == last.




  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Use llvm::unique (NFC) (PR #139910)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes

While I am at it, this patch removes the "if" statement.
std::vector::erase(first, last) doesn't do anything when
first == last.


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


1 Files Affected:

- (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+1-4) 


``diff
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 9ad98a41c688c..b964dc5877a97 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -497,10 +497,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
pos != end; ++pos) {
 if (pos->second.size() > 1) {
   llvm::sort(pos->second);
-  reg_num_collection::iterator unique_end =
-  std::unique(pos->second.begin(), pos->second.end());
-  if (unique_end != pos->second.end())
-pos->second.erase(unique_end, pos->second.end());
+  pos->second.erase(llvm::unique(pos->second), pos->second.end());
 }
 assert(!pos->second.empty());
 if (pos->second.back() != LLDB_INVALID_REGNUM)

``




https://github.com/llvm/llvm-project/pull/139910
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Jan Svoboda via lldb-commits


@@ -2032,6 +2032,7 @@ class SourceManagerForFile {
   // as they are created in `createSourceManagerForFile` so that they can be
   // deleted in the reverse order as they are created.
   std::unique_ptr FileMgr;
+  std::unique_ptr DiagOpts;

jansvoboda11 wrote:

I don't think I understand. Now that `DiagnosticOptions` are not intrusively 
reference-counted, raw pointers have clearer semantics than before (typically 
nullable non-owning borrow), no? I'd also argue that using values, references, 
raw pointers, `unique_ptr` and `shared_ptr` depending on the context is the 
clearest way to communicate lifetimes and ownership. Regardless, there's only 
one raw pointer to `DiagnosticOptions` remaining after my patch in 
`clang::tooling::ToolInvocation`, and that has exactly the semantics you'd 
expect: optional borrow where the owner is someone else and you expect them to 
keep the object alive long enough.

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


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-14 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/common/TCPSocket.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 4148ad67b..b6e0f1117 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -169,8 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) {
 return error;
   }
 
-  error = Status::FromErrorStringWithFormatv("Failed to connect {0}:{1}",
-  host_port->hostname, host_port->port);
+  error = Status::FromErrorStringWithFormatv(
+  "Failed to connect {0}:{1}", host_port->hostname, host_port->port);
   return error;
 }
 

``




https://github.com/llvm/llvm-project/pull/139916
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Jan Svoboda via lldb-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/139584



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] 998dca4 - [lldb-dap] Add unit test for protocol enum types (#139848)

2025-05-14 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-14T09:10:49-07:00
New Revision: 998dca42351f3292512af56207b603dc2fef565b

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

LOG: [lldb-dap] Add unit test for protocol enum types (#139848)

Add dedicated unit tests for the protocol enum types.

Added: 


Modified: 
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
lldb/unittests/DAP/ProtocolTypesTest.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
index fafd061334bc9..857503b3a0084 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
@@ -105,7 +105,7 @@ bool fromJSON(const json::Value &Params, ColumnType &CT, 
json::Path P) {
   .Case("string", eColumnTypeString)
   .Case("number", eColumnTypeNumber)
   .Case("boolean", eColumnTypeBoolean)
-  .Case("unixTimestampUTC ", eColumnTypeTimestamp)
+  .Case("unixTimestampUTC", eColumnTypeTimestamp)
   .Default(std::nullopt);
   if (!columnType) {
 P.report("unexpected value, expected 'string', 'number',  'boolean', or "
@@ -482,6 +482,18 @@ bool fromJSON(const llvm::json::Value &Params, 
SteppingGranularity &SG,
   return true;
 }
 
+llvm::json::Value toJSON(const SteppingGranularity &SG) {
+  switch (SG) {
+  case eSteppingGranularityStatement:
+return "statement";
+  case eSteppingGranularityLine:
+return "line";
+  case eSteppingGranularityInstruction:
+return "instruction";
+  }
+  llvm_unreachable("unhandled stepping granularity.");
+}
+
 bool fromJSON(const llvm::json::Value &Params, ValueFormat &VF,
   llvm::json::Path P) {
   json::ObjectMapper O(Params, P);

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index f8d2b35ce3e14..757037a7b6ed2 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -339,6 +339,7 @@ enum SteppingGranularity : unsigned {
 };
 bool fromJSON(const llvm::json::Value &, SteppingGranularity &,
   llvm::json::Path);
+llvm::json::Value toJSON(const SteppingGranularity &);
 
 /// Provides formatting information for a value.
 struct ValueFormat {

diff  --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
index fd3e3be073183..d97bbaffa2bc0 100644
--- a/lldb/unittests/DAP/ProtocolTypesTest.cpp
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -291,3 +291,201 @@ TEST(ProtocolTypesTest, Capabilities) {
   EXPECT_EQ(capabilities.lldbExtVersion,
 deserialized_capabilities->lldbExtVersion);
 }
+
+TEST(ProtocolTypesTest, PresentationHint) {
+  // Test all PresentationHint values.
+  std::vector> test_cases = {
+  {ePresentationHintNormal, "normal"},
+  {ePresentationHintEmphasize, "emphasize"},
+  {ePresentationHintDeemphasize, "deemphasize"}};
+
+  for (const auto &test_case : test_cases) {
+// Serialize the PresentationHint to JSON.
+llvm::json::Value serialized = toJSON(test_case.first);
+ASSERT_EQ(serialized.kind(), llvm::json::Value::Kind::String);
+EXPECT_EQ(serialized.getAsString(), test_case.second);
+
+// Deserialize the JSON back to PresentationHint.
+PresentationHint deserialized;
+llvm::json::Path::Root root;
+ASSERT_TRUE(fromJSON(serialized, deserialized, root))
+<< llvm::toString(root.getError());
+EXPECT_EQ(deserialized, test_case.first);
+  }
+
+  // Test invalid value.
+  llvm::json::Value invalid_value = "invalid_hint";
+  PresentationHint deserialized_invalid;
+  llvm::json::Path::Root root;
+  EXPECT_FALSE(fromJSON(invalid_value, deserialized_invalid, root));
+}
+
+TEST(ProtocolTypesTest, SteppingGranularity) {
+  // Test all SteppingGranularity values.
+  std::vector> test_cases = {
+  {eSteppingGranularityStatement, "statement"},
+  {eSteppingGranularityLine, "line"},
+  {eSteppingGranularityInstruction, "instruction"}};
+
+  for (const auto &test_case : test_cases) {
+// Serialize the SteppingGranularity to JSON.
+llvm::json::Value serialized = toJSON(test_case.first);
+ASSERT_EQ(serialized.kind(), llvm::json::Value::Kind::String);
+EXPECT_EQ(serialized.getAsString(), test_case.second);
+
+// Deserialize the JSON back to SteppingGranularity.
+SteppingGranularity deserialized;
+llvm::json::Path::Root root;
+ASSERT_TRUE(fromJSON(serialized, deserialized, root))
+<< llvm::toString(root.getError());
+EXPECT_EQ(deserialized, test_case.first);
+  }
+
+  // Test invalid value.
+  llvm::json::Value invalid_value = "invalid_granularity";
+  SteppingGranularity deser

[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)

2025-05-14 Thread John Harrison via lldb-commits

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

This adds basic support for testing the Transport class and includes tests for 
'Read'.

>From 506e8107a397e2ae88d8b952c0a5351cda9fa161 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 09:13:32 -0700
Subject: [PATCH] [lldb-dap] Adding unittests for Transport.

This adds basic support for testing the Transport class and includes tests for 
'Read'.
---
 lldb/unittests/DAP/CMakeLists.txt|  1 +
 lldb/unittests/DAP/TransportTest.cpp | 81 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/unittests/DAP/TransportTest.cpp

diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 8b240654046e2..110733e93b192 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(DAPTests
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
+  TransportTest.cpp
   ProtocolTypesTest.cpp
 
   LINK_LIBS
diff --git a/lldb/unittests/DAP/TransportTest.cpp 
b/lldb/unittests/DAP/TransportTest.cpp
new file mode 100644
index 0..d27167cf9da61
--- /dev/null
+++ b/lldb/unittests/DAP/TransportTest.cpp
@@ -0,0 +1,81 @@
+//===-- LLDBUtilsTest.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 "Transport.h"
+#include "Protocol/ProtocolBase.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+class TransportTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr transport;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded());
+transport = std::make_unique(
+"stdio", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+
+  void Write(StringRef json) {
+std::string message =
+formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str();
+ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()),
+ Succeeded());
+  }
+};
+
+TEST_F(TransportTest, MalformedRequests) {
+  std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn";
+  ASSERT_THAT_EXPECTED(
+  input.Write(malformed_header.data(), malformed_header.size()),
+  Succeeded());
+  ASSERT_THAT_EXPECTED(
+  transport->Read(std::chrono::milliseconds(1)),
+  FailedWithMessage(
+  "expected 'Content-Length: ' and got 'COnTent-LenGth: '"));
+}
+
+TEST_F(TransportTest, Read) {
+  Write(R"json({"seq": 1, "type": "request", "command": "abc"})json");
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(
+   testing::FieldsAre(1, "abc", std::nullopt;
+}
+
+TEST_F(TransportTest, ReadWithTimeout) {
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}
+
+TEST_F(TransportTest, ReadWithEOF) {
+  input.CloseWriteFileDescriptor();
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}

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


[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

This adds basic support for testing the Transport class and includes tests for 
'Read'.

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


2 Files Affected:

- (modified) lldb/unittests/DAP/CMakeLists.txt (+1) 
- (added) lldb/unittests/DAP/TransportTest.cpp (+81) 


``diff
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 8b240654046e2..110733e93b192 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(DAPTests
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
+  TransportTest.cpp
   ProtocolTypesTest.cpp
 
   LINK_LIBS
diff --git a/lldb/unittests/DAP/TransportTest.cpp 
b/lldb/unittests/DAP/TransportTest.cpp
new file mode 100644
index 0..d27167cf9da61
--- /dev/null
+++ b/lldb/unittests/DAP/TransportTest.cpp
@@ -0,0 +1,81 @@
+//===-- LLDBUtilsTest.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 "Transport.h"
+#include "Protocol/ProtocolBase.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+class TransportTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr transport;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded());
+transport = std::make_unique(
+"stdio", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+
+  void Write(StringRef json) {
+std::string message =
+formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str();
+ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()),
+ Succeeded());
+  }
+};
+
+TEST_F(TransportTest, MalformedRequests) {
+  std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn";
+  ASSERT_THAT_EXPECTED(
+  input.Write(malformed_header.data(), malformed_header.size()),
+  Succeeded());
+  ASSERT_THAT_EXPECTED(
+  transport->Read(std::chrono::milliseconds(1)),
+  FailedWithMessage(
+  "expected 'Content-Length: ' and got 'COnTent-LenGth: '"));
+}
+
+TEST_F(TransportTest, Read) {
+  Write(R"json({"seq": 1, "type": "request", "command": "abc"})json");
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(
+   testing::FieldsAre(1, "abc", std::nullopt;
+}
+
+TEST_F(TransportTest, ReadWithTimeout) {
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}
+
+TEST_F(TransportTest, ReadWithEOF) {
+  input.CloseWriteFileDescriptor();
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}

``




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


[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-05-14 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/138032



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Adding unit tests for Transport. (PR #139926)

2025-05-14 Thread John Harrison via lldb-commits

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

>From 506e8107a397e2ae88d8b952c0a5351cda9fa161 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 09:13:32 -0700
Subject: [PATCH 1/2] [lldb-dap] Adding unittests for Transport.

This adds basic support for testing the Transport class and includes tests for 
'Read'.
---
 lldb/unittests/DAP/CMakeLists.txt|  1 +
 lldb/unittests/DAP/TransportTest.cpp | 81 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/unittests/DAP/TransportTest.cpp

diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 8b240654046e2..110733e93b192 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(DAPTests
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
+  TransportTest.cpp
   ProtocolTypesTest.cpp
 
   LINK_LIBS
diff --git a/lldb/unittests/DAP/TransportTest.cpp 
b/lldb/unittests/DAP/TransportTest.cpp
new file mode 100644
index 0..d27167cf9da61
--- /dev/null
+++ b/lldb/unittests/DAP/TransportTest.cpp
@@ -0,0 +1,81 @@
+//===-- LLDBUtilsTest.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 "Transport.h"
+#include "Protocol/ProtocolBase.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+class TransportTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr transport;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), llvm::Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), llvm::Succeeded());
+transport = std::make_unique(
+"stdio", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+
+  void Write(StringRef json) {
+std::string message =
+formatv("Content-Length: {0}\r\n\r\n{1}", json.size(), json).str();
+ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()),
+ Succeeded());
+  }
+};
+
+TEST_F(TransportTest, MalformedRequests) {
+  std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn";
+  ASSERT_THAT_EXPECTED(
+  input.Write(malformed_header.data(), malformed_header.size()),
+  Succeeded());
+  ASSERT_THAT_EXPECTED(
+  transport->Read(std::chrono::milliseconds(1)),
+  FailedWithMessage(
+  "expected 'Content-Length: ' and got 'COnTent-LenGth: '"));
+}
+
+TEST_F(TransportTest, Read) {
+  Write(R"json({"seq": 1, "type": "request", "command": "abc"})json");
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(
+   testing::FieldsAre(1, "abc", std::nullopt;
+}
+
+TEST_F(TransportTest, ReadWithTimeout) {
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}
+
+TEST_F(TransportTest, ReadWithEOF) {
+  input.CloseWriteFileDescriptor();
+  ASSERT_THAT_EXPECTED(transport->Read(std::chrono::milliseconds(1)),
+   Failed());
+}

>From 8d5ffc83c6fce70a3fe66fb726781e7bd2b08d77 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 09:16:34 -0700
Subject: [PATCH 2/2] Fixing the filename in the top comment.

---
 lldb/unittests/DAP/TransportTest.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/unittests/DAP/TransportTest.cpp 
b/lldb/unittests/DAP/TransportTest.cpp
index d27167cf9da61..b8eade5442814 100644
--- a/lldb/unittests/DAP/TransportTest.cpp
+++ b/lldb/unittests/DAP/TransportTest.cpp
@@ -1,4 +1,4 @@
-//===-- LLDBUtilsTest.cpp 
-===//
+//===-- TransportTest.cpp 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/

[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-05-14 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/138032



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)

2025-05-14 Thread Kazu Hirata via lldb-commits

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

None



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Simplify a string comparison (NFC) (PR #139932)

2025-05-14 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp 
(+1-2) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index a2722db5d24a0..451cf40e2818d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -123,8 +123,7 @@ void ASTStructExtractor::ExtractFromTopLevelDecl(Decl *D) {
   FunctionDecl *function_decl = dyn_cast(D);
 
   if (m_ast_context && function_decl &&
-  !m_function.m_wrapper_function_name.compare(
-  function_decl->getNameAsString())) {
+  m_function.m_wrapper_function_name == function_decl->getNameAsString()) {
 ExtractFromFunctionDecl(function_decl);
   }
 }

``




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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

ashgti wrote:

I added a few extra tests here and some extra base classes to help setup tests.

LMKWYT

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


[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)

2025-05-14 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

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

>From 6f947e38ad4f744754cf13c1094c4e5e3fd249b6 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:31:40 -0700
Subject: [PATCH 1/5] [lldb-dap] Setup DAP for unit testing.

This is a very simple case that currently only validates we can create a DAP 
instance and send a message over the transport layer. More in-depth tests will 
require additional helpers and possibly refactors of DAP to make it more 
testable, however this is some ground work to have basic support for unit tests.
---
 lldb/tools/lldb-dap/DAP.h |  3 +-
 lldb/unittests/DAP/CMakeLists.txt |  1 +
 lldb/unittests/DAP/DAPTest.cpp| 63 +++
 3 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 lldb/unittests/DAP/DAPTest.cpp

diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..2ff66d1cd0182 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -226,7 +226,8 @@ struct DAP {
   /// \param[in] default_repl_mode
   /// Default repl mode behavior, as configured by the binary.
   /// \param[in] pre_init_commands
-  /// LLDB commands to execute as soon as the debugger instance is 
allocaed.
+  /// LLDB commands to execute as soon as the debugger instance is
+  /// allocated.
   /// \param[in] transport
   /// Transport for this debug session.
   DAP(Log *log, const ReplMode default_repl_mode,
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 110733e93b192..6074e9b872c49 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -3,6 +3,7 @@ add_lldb_unittest(DAPTests
   LLDBUtilsTest.cpp
   TransportTest.cpp
   ProtocolTypesTest.cpp
+  DAPTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
new file mode 100644
index 0..9d2a9b944678e
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -0,0 +1,63 @@
+//===-- DAPTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "Transport.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/Pipe.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+using lldb_private::File;
+using lldb_private::NativeFile;
+using lldb_private::Pipe;
+
+class DAPTest : public testing::Test {
+protected:
+  Pipe input;
+  Pipe output;
+  std::unique_ptr toDAP;
+  std::unique_ptr fromDAP;
+
+  void SetUp() override {
+ASSERT_THAT_ERROR(input.CreateNew(false).ToError(), Succeeded());
+ASSERT_THAT_ERROR(output.CreateNew(false).ToError(), Succeeded());
+toDAP = std::make_unique(
+"toDAP", nullptr,
+std::make_shared(input.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(output.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+fromDAP = std::make_unique(
+"fromDAP", nullptr,
+std::make_shared(output.GetReadFileDescriptor(),
+ File::eOpenOptionReadOnly,
+ NativeFile::Unowned),
+std::make_shared(input.GetWriteFileDescriptor(),
+ File::eOpenOptionWriteOnly,
+ NativeFile::Unowned));
+  }
+};
+
+TEST_F(DAPTest, SendProtocolMessages) {
+  DAP dap{nullptr, ReplMode::Auto, {}, *toDAP};
+  dap.Send(Event{"my-event", std::nullopt});
+  ASSERT_THAT_EXPECTED(fromDAP->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(testing::FieldsAre(
+   /*event=*/"my-event", /*body=*/std::nullopt;
+}

>From 8bc4880a338dd0d0f2daa64b77c8bdbf567270b2 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 14 May 2025 10:46:51 -0700
Subject: [PATCH 2/5] Adjusting the naming of variables.

---
 lldb/unittests/DAP/DAPTest.cpp | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
index 9d2a9b944678e..8e8c2ea3ccbb0 100644
--- a/lldb/unittests/DAP/DAPTest.cpp
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -29,22 +29,22 @@ class DAPTest : public testing::Test {
 protected:
   Pipe input;
   Pipe output;
-

[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)

2025-05-14 Thread Ebuka Ezike via lldb-commits

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

>From 7dbd5f7467cf1ab31caf935633062a7a66a49757 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 14 May 2025 17:32:47 +0100
Subject: [PATCH 1/4] [lldb][lldb-dap] clarify the todo.

---
 lldb/tools/lldb-dap/package.json  | 14 +++
 lldb/tools/lldb-dap/src-ts/extension.ts   | 10 +-
 .../src-ts/ui/modules-data-provider.ts| 98 ---
 3 files changed, 85 insertions(+), 37 deletions(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index e3e46526f379f..3c73534fd3180 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -244,6 +244,20 @@
 }
   }
 ],
+"commands": [
+  {
+"command": "lldb-dap.modules.copyProperty",
+"title": "Copy Value"
+  }
+],
+"menus": {
+  "view/item/context": [
+{
+  "command": "lldb-dap.modules.copyProperty",
+  "when": "view == lldb-dap.modules && viewItem == property"
+}
+  ]
+},
 "breakpoints": [
   {
 "language": "ada"
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts 
b/lldb/tools/lldb-dap/src-ts/extension.ts
index a5c0a09ae60cf..c8e5146e29cea 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -6,7 +6,10 @@ import { LaunchUriHandler } from "./uri-launch-handler";
 import { LLDBDapConfigurationProvider } from "./debug-configuration-provider";
 import { LLDBDapServer } from "./lldb-dap-server";
 import { DebugSessionTracker } from "./debug-session-tracker";
-import { ModulesDataProvider } from "./ui/modules-data-provider";
+import {
+  ModulesDataProvider,
+  ModuleProperty,
+} from "./ui/modules-data-provider";
 
 /**
  * This class represents the extension and manages its life cycle. Other 
extensions
@@ -40,6 +43,11 @@ export class LLDBDapExtension extends DisposableContext {
   ),
   vscode.window.registerUriHandler(new LaunchUriHandler()),
 );
+
+vscode.commands.registerCommand(
+  "lldb-dap.modules.copyProperty",
+  (node: ModuleProperty) => vscode.env.clipboard.writeText(node.value),
+);
   }
 }
 
diff --git a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts 
b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
index 478c162de8878..da527b04ba509 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
@@ -2,60 +2,86 @@ import * as vscode from "vscode";
 import { DebugProtocol } from "@vscode/debugprotocol";
 import { DebugSessionTracker } from "../debug-session-tracker";
 
-/** A tree data provider for listing loaded modules for the active debug 
session. */
-export class ModulesDataProvider
-  implements vscode.TreeDataProvider
-{
-  private changeTreeData = new vscode.EventEmitter();
-  readonly onDidChangeTreeData = this.changeTreeData.event;
+export interface ModuleProperty {
+  key: string;
+  value: string;
+}
 
-  constructor(private readonly tracker: DebugSessionTracker) {
-tracker.onDidChangeModules(() => this.changeTreeData.fire());
-vscode.debug.onDidChangeActiveDebugSession(() =>
-  this.changeTreeData.fire(),
-);
+/** Type to represent both Module and ModuleProperty since TreeDataProvider
+ * expects one concrete type */
+type TreeData = DebugProtocol.Module | ModuleProperty;
+
+function isModule(type: TreeData): type is DebugProtocol.Module {
+  return (type as DebugProtocol.Module).id !== undefined;
+}
+
+class ModuleItem extends vscode.TreeItem {
+  constructor(module: DebugProtocol.Module) {
+super(module.name, vscode.TreeItemCollapsibleState.Collapsed);
+this.description = module.symbolStatus;
   }
 
-  getTreeItem(module: DebugProtocol.Module): vscode.TreeItem {
-let treeItem = new vscode.TreeItem(/*label=*/ module.name);
-if (module.path) {
-  treeItem.description = `${module.id} -- ${module.path}`;
-} else {
-  treeItem.description = `${module.id}`;
-}
+  static getProperties(module: DebugProtocol.Module): ModuleProperty[] {
+// does not include the name and symbol status as it is show in the parent.
+let children: ModuleProperty[] = [];
+children.push({ key: "id:", value: module.id.toString() });
 
-const tooltip = new vscode.MarkdownString();
-tooltip.appendMarkdown(`# ${module.name}\n\n`);
-tooltip.appendMarkdown(`- **ID**: ${module.id}\n`);
 if (module.addressRange) {
-  tooltip.appendMarkdown(
-`- **Load address**: 0x${Number(module.addressRange).toString(16)}\n`,
-  );
+  children.push({
+key: "load address:",
+value: `0x${Number(module.addressRange).toString(16)}`,
+  });
 }
 if (module.path) {
-  tooltip.appendMarkdown(`- **Path**: ${module.path}\n`);
+  children.push({ key: "path:", value: module.path });
 }
 if (module.version) {
-  tooltip.app

[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

2025-05-14 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/139817

>From e63e53adc0909f481a165eca958a3ac2ca4374ee Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 13 May 2025 17:11:08 -0700
Subject: [PATCH 1/7] [lldb][NFC] Split
 RegisterContextUnwind::SavedLocationForRegister

RegisterContextUnwind::SavedLocationForRegister is around 450 lines
that first find an abstract register location (e.g. "CFA-8") for a
register by looking in the UnwindPlans.  Then it evaluates the
abstract register location to create a concrete register location
(e.g. "stored at address 0x...", "live in register at frame 0").
There are some complicated cases in the first half of the method
to handle return address register architectures correctly, in
particular.

Looking at the two halves, they're both exactly 226 lines long and
there's little involvement between them except for passing an
abstract register location along.

(there were some parts in the "abstract register location" code
that would set the concrete register location, unnecessarily)

It's also a complex enough method that there are some bits of code
that aren't actually doing anything at this point.

This patch adds a RegisterContextUnwind::GetAbstractRegisterLocation
method, which does the first half, and has a clearly defined return
values.

The code to convert an AbstractRegisterLocation into a
ConcreteRegisterLocation remains in SavedLocationForRegister.

It's a bit of a tricky patch to visually inspect, despite it not
changing functionality, the reorganizations and rewrites make the
diff unreadable.  Nearly all the real changes are in the
"find the abstract register location" first half of the method.
I think reading the new code in its new form is the easiest way
to inspect this PR.  With a defined interface between the two of
what is expected, it's pretty easy to look at the code and reason
about whether it is written correctly.

(whereas before, that was very difficult, for me at least.)
---
 .../lldb/Target/RegisterContextUnwind.h   |   3 +
 lldb/source/Target/RegisterContextUnwind.cpp  | 530 +-
 lldb/source/Target/RegisterNumber.cpp |   1 +
 3 files changed, 259 insertions(+), 275 deletions(-)

diff --git a/lldb/include/lldb/Target/RegisterContextUnwind.h 
b/lldb/include/lldb/Target/RegisterContextUnwind.h
index 044a387fe5aa2..b10a364823b83 100644
--- a/lldb/include/lldb/Target/RegisterContextUnwind.h
+++ b/lldb/include/lldb/Target/RegisterContextUnwind.h
@@ -151,6 +151,9 @@ class RegisterContextUnwind : public 
lldb_private::RegisterContext {
   uint32_t lldb_regnum,
   lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc);
 
+  std::optional
+  GetAbstractRegisterLocation(uint32_t lldb_regnum, lldb::RegisterKind &kind);
+
   bool ReadRegisterValueFromRegisterLocation(
   lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc,
   const lldb_private::RegisterInfo *reg_info,
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index cf4b96c6eda9f..a3931abefb054 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1243,247 +1243,194 @@ bool RegisterContextUnwind::IsTrapHandlerSymbol(
   return false;
 }
 
-// Answer the question: Where did THIS frame save the CALLER frame ("previous"
-// frame)'s register value?
-
-enum UnwindLLDB::RegisterSearchResult
-RegisterContextUnwind::SavedLocationForRegister(
-uint32_t lldb_regnum,
-lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc) {
+// Search this stack frame's UnwindPlans for the AbstractRegisterLocation
+// for this register.
+//
+// When an AbstractRegisterLocation is found in an UnwindPlan, that is
+// returned, regardless of the ABI rules for volatile/non-volatile registers
+// in effect.
+//
+// If there is no unwind rule for a volatile (caller-preserved) register
+// the returned AbstractRegisterLocation will be IsUndefined,
+// indicating that we should stop searching.
+//
+// If there is no unwind rule for a non-volatile (callee-preserved)
+// register, the returned AbstractRegisterLocation will be IsSame.
+// In frame 0, IsSame means get the  value from the live register context.
+// Else it means to continue descending down the stack to more-live frames
+// looking for a location/value.
+//
+// An empty optional indicates that there was an error in processing.
+std::optional
+RegisterContextUnwind::GetAbstractRegisterLocation(uint32_t lldb_regnum,
+   lldb::RegisterKind &kind) {
   RegisterNumber regnum(m_thread, eRegisterKindLLDB, lldb_regnum);
   Log *log = GetLog(LLDBLog::Unwind);
 
-  // Have we already found this register location?
-  if (!m_registers.empty()) {
-std::map::const_iterator
-iterator;
-iterator = m_registers.find(regnum.GetAsKind(eRegisterKindLLDB));
-if (iterator != m_registers.end()) {
-  regloc = iterator

[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,35 @@
+//===-- DisconnectRequestHandlerTest.cpp 
--===//

JDevlieghere wrote:

```suggestion
//===-- DisconnectTest.cpp ===//
```

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


[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

2025-05-14 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/139817



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-14 Thread Ely Ronnen via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

2025-05-14 Thread John Harrison via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Jan Svoboda via lldb-commits


@@ -107,6 +107,7 @@ class ASTUnit {
 
 private:
   std::unique_ptr LangOpts;
+  std::shared_ptr DiagOpts;

jansvoboda11 wrote:

I was hoping it could be, but the situation is a bit weird. The documentation 
for `ASTUnit::LoadFromCommandLine()` says the `DiagnosticsEngine` parameter is 
expected to outlive the returned value. However, it's being passed in 
`IntrusiveRefCntPtr`, so the lifetime is not enforced, and of course some 
clients started to rely on `ASTUnit` taking shared ownership of that object. 
And the clients also use the `DiagnosticsEngine` object themselves after 
passing it to that function, so the ownership is indeed shared. And since 
`DiagnosticsEngine` now relies on `DiagnosticOptions` to live long enough, 
sharing ownership in `ASTUnit` was the best fit. Does that make sense?

In general `ASTUnit` is a big pile of lifetime hacks which I'd like to clean up 
one day, but today is not the day.

https://github.com/llvm/llvm-project/pull/139584
___
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] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Jan Svoboda via lldb-commits


@@ -837,6 +838,7 @@ class ASTUnit {
   static std::unique_ptr LoadFromCommandLine(
   const char **ArgBegin, const char **ArgEnd,
   std::shared_ptr PCHContainerOps,
+  std::shared_ptr DiagOpts,

jansvoboda11 wrote:

Explained above.

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


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

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

LGTM modulo (pre-existing) typo.

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


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-14 Thread Jonas Devlieghere via lldb-commits


@@ -169,7 +169,8 @@ Status TCPSocket::Connect(llvm::StringRef name) {
 return error;
   }
 
-  error = Status::FromErrorString("Failed to connect port");
+  error = Status::FromErrorStringWithFormatv(
+  "Failed to connect {0}:{1}", host_port->hostname, host_port->port);

JDevlieghere wrote:

```suggestion
  error = Status::FromErrorStringWithFormatv(
  "Failed to connect to {0}:{1}", host_port->hostname, host_port->port);
```

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


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-14 Thread Jonas Devlieghere via lldb-commits

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


  1   2   >