[Lldb-commits] [lldb] 48a814c - Don't run TestUnwindFramelessFaulted.py on Linux

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

Author: Jason Molenda
Date: 2025-05-11T23:57:53-07:00
New Revision: 48a814c7112d8d79f23ab18de7b2b80dee2c08bc

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

LOG: Don't run TestUnwindFramelessFaulted.py on Linux
There's something still wrong with how it's building
the test file.

Added: 


Modified: 

lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py
 
b/lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py
index 03af87fcf32f6..483a487d76899 100644
--- 
a/lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py
+++ 
b/lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py
@@ -10,7 +10,7 @@
 class TestUnwindFramelessFaulted(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
-@skipIf(oslist=no_match([lldbplatformutil.getDarwinOSTriples(), "linux"]))
+@skipIf(oslist=no_match([lldbplatformutil.getDarwinOSTriples()]))
 @skipIf(archs=no_match(["aarch64", "arm64", "arm64e"]))
 
 # The static linker in Xcode 15.0-15.2 on macOS 14 will mislink



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


[Lldb-commits] [lldb] 9e44f0d - Reapply "[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on windows (#137978)" (#138896)

2025-05-11 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-12T07:57:43+02:00
New Revision: 9e44f0d669c116e896845d08ca603ca4f46be1db

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

LOG: Reapply "[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on 
windows (#137978)" (#138896)

This reverts commit
https://github.com/llvm/llvm-project/commit/a0260a95ece74733ada00b19d8b1930dde462a66,
reapplying

https://github.com/llvm/llvm-project/commit/7c5f5f3ef83b1d1d43d63862a8431af3dded15bb,
with a fix that makes *both*
pipe handles inheritable.

The original commit description was:

This is a follow-up to https://github.com/llvm/llvm-project/pull/126935,
which enables passing handles to a child
process on windows systems. Unlike on unix-like systems, the handles
need to be created with the "inheritable" flag because there's to way to
change the flag value after it has been created. This is why I don't
respect the child_process_inherit flag but rather always set the flag to
true. (My next step is to delete the flag entirely.)

This does mean that pipe may be created as inheritable even if its not
necessary, but I think this is offset by the fact that windows (unlike
unixes, which pass all ~O_CLOEXEC descriptors through execve and *all*
descriptors through fork) has a way to specify the precise set of
handles to pass to a specific child process.

If this turns out to be insufficient, instead of a constructor flag, I'd
rather go with creating a separate api to create an inheritable copy of
a handle (as typically, you only want to inherit one end of the pipe).

Added: 


Modified: 
lldb/source/Host/windows/PipeWindows.cpp
lldb/source/Host/windows/ProcessLauncherWindows.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/tools/lldb-server/lldb-platform.cpp
lldb/unittests/Host/HostTest.cpp

Removed: 




diff  --git a/lldb/source/Host/windows/PipeWindows.cpp 
b/lldb/source/Host/windows/PipeWindows.cpp
index e3f5b629a0590..30b9d1c41695b 100644
--- a/lldb/source/Host/windows/PipeWindows.cpp
+++ b/lldb/source/Host/windows/PipeWindows.cpp
@@ -88,8 +88,9 @@ Status PipeWindows::CreateNew(llvm::StringRef name,
   std::string pipe_path = g_pipe_name_prefix.str();
   pipe_path.append(name.str());
 
-  SECURITY_ATTRIBUTES sa{sizeof(SECURITY_ATTRIBUTES), 0,
- child_process_inherit ? TRUE : FALSE};
+  // We always create inheritable handles, but we won't pass them to a child
+  // process unless explicitly requested (cf. ProcessLauncherWindows.cpp).
+  SECURITY_ATTRIBUTES sa{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
 
   // Always open for overlapped i/o.  We implement blocking manually in Read
   // and Write.
@@ -165,8 +166,9 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name,
 
   assert(is_read ? !CanRead() : !CanWrite());
 
-  SECURITY_ATTRIBUTES attributes{sizeof(SECURITY_ATTRIBUTES), 0,
- child_process_inherit ? TRUE : FALSE};
+  // We always create inheritable handles, but we won't pass them to a child
+  // process unless explicitly requested (cf. ProcessLauncherWindows.cpp).
+  SECURITY_ATTRIBUTES attributes{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
 
   std::string pipe_path = g_pipe_name_prefix.str();
   pipe_path.append(name.str());

diff  --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 065ba9271ad0d..bc35667ea9a23 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -10,6 +10,7 @@
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
 
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Program.h"
@@ -65,14 +66,23 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
 
   std::string executable;
   std::vector environment;
-  STARTUPINFO startupinfo = {};
+  STARTUPINFOEX startupinfoex = {};
+  STARTUPINFO &startupinfo = startupinfoex.StartupInfo;
   PROCESS_INFORMATION pi = {};
 
   HANDLE stdin_handle = GetStdioHandle(launch_info, STDIN_FILENO);
   HANDLE stdout_handle = GetStdioHandle(launch_info, STDOUT_FILENO);
   HANDLE stderr_handle = GetStdioHandle(launch_info, STDERR_FILENO);
-
-  startupinfo.cb = sizeof(startupinfo);
+  auto close_handles = llvm::make_scope_exit([&] {
+if (stdin_handle)
+  ::CloseHandle(stdin_handle);
+if (stdout_handle)
+  ::CloseHandle(stdout_handle);
+if (stderr_handle)
+  ::CloseHandle(stderr_handle);
+  });
+
+  startupinfo.cb = sizeof(startupinfoex);
   startupinfo.dwFlags |= STARTF_USESTDHANDLES;
   startupinfo.hStdError =
   stderr_handle ? stderr_handle : ::GetStdHandle(STD_ERROR_HA

[Lldb-commits] [lldb] Reapply "[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on windows (#137978)" (PR #138896)

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

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-11 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/2] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/2] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

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


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

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

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

Add unit tests for serializing and deserializing protocol types.

>From 5fdd0d606262254f7363a55fd5ad38fe726b2dab Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sun, 11 May 2025 23:28:21 -0700
Subject: [PATCH] [lldb-dap] Add unit tests for protocol types

Add unit tests for serializing and deserializing protocol types.
---
 lldb/unittests/DAP/CMakeLists.txt|   1 +
 lldb/unittests/DAP/ProtocolTypesTest.cpp | 268 +++
 2 files changed, 269 insertions(+)
 create mode 100644 lldb/unittests/DAP/ProtocolTypesTest.cpp

diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 4bbb552be9f34..62318d2ecbad3 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
+  ProtocolTypesTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
new file mode 100644
index 0..b64810dc713af
--- /dev/null
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -0,0 +1,268 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// 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 "Protocol/ProtocolTypes.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::json::Value value = toJSON(filter);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("filter"), "testFilter");
+  EXPECT_EQ(obj->getString("label"), "Test Filter");
+  EXPECT_EQ(obj->getString("description"), "This is a test filter");
+  EXPECT_EQ(obj->getBoolean("default"), true);
+  EXPECT_EQ(obj->getBoolean("supportsCondition"), true);
+  EXPECT_EQ(obj->getString("conditionDescription"),
+"Condition for test filter");
+}
+
+TEST(ProtocolTypesTest, ColumnDescriptor) {
+  ColumnDescriptor column;
+  column.attributeName = "testAttribute";
+  column.label = "Test Label";
+  column.format = "testFormat";
+  column.type = eColumnTypeString;
+  column.width = 20;
+
+  llvm::json::Value value = toJSON(column);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("attributeName"), "testAttribute");
+  EXPECT_EQ(obj->getString("label"), "Test Label");
+  EXPECT_EQ(obj->getString("format"), "testFormat");
+  EXPECT_EQ(obj->getString("type"), "string");
+  EXPECT_EQ(obj->getInteger("width"), 20);
+}
+
+TEST(ProtocolTypesTest, BreakpointMode) {
+  BreakpointMode mode;
+  mode.mode = "testMode";
+  mode.label = "Test Label";
+  mode.description = "This is a test description";
+  mode.appliesTo = {eBreakpointModeApplicabilitySource,
+eBreakpointModeApplicabilityException};
+
+  llvm::json::Value value = toJSON(mode);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("mode"), "testMode");
+  EXPECT_EQ(obj->getString("label"), "Test Label");
+  EXPECT_EQ(obj->getString("description"), "This is a test description");
+
+  const auto *appliesToArray = obj->getArray("appliesTo");
+  ASSERT_NE(appliesToArray, nullptr);
+  ASSERT_EQ(appliesToArray->size(), 2UL);
+  EXPECT_EQ(appliesToArray->front().getAsString(), "source");
+  EXPECT_EQ(appliesToArray->back().getAsString(), "exception");
+}
+
+TEST(ProtocolTypesTest, Capabilities) {
+  Capabilities capabilities;
+  capabilities.supportedFeatures = {eAdapterFeatureANSIStyling,
+eAdapterFeatureTerminateRequest};
+  capabilities.exceptionBreakpointFilters = {
+  {"filter1", "Filter 1", "Description 1", true, true, "Condition 1"},
+  {"filter2", "Filter 2", "Description 2", false, false, "Condition 2"}};
+  capabilities.completionTriggerCharacters = {"."};
+  capabilities.additionalModuleColumns = {
+  {"attribute1", "Label 1", "Format 1", eColumnTypeString, 10},
+  {"attribute2", "Label 2", "Format 2", eColumnTypeNumber, 20}};
+  capabilities.supportedChecksumAlgorithms = {eChecksumAlgorithmMD5,
+  eChecksumAlgorithmSHA256};
+  capabilities.breakpointModes = {{"mode1",
+   

[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Add unit tests for serializing and deserializing protocol types.

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


2 Files Affected:

- (modified) lldb/unittests/DAP/CMakeLists.txt (+1) 
- (added) lldb/unittests/DAP/ProtocolTypesTest.cpp (+268) 


``diff
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 4bbb552be9f34..62318d2ecbad3 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
+  ProtocolTypesTest.cpp
 
   LINK_LIBS
 lldbDAP
diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
new file mode 100644
index 0..b64810dc713af
--- /dev/null
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -0,0 +1,268 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// 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 "Protocol/ProtocolTypes.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::json::Value value = toJSON(filter);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("filter"), "testFilter");
+  EXPECT_EQ(obj->getString("label"), "Test Filter");
+  EXPECT_EQ(obj->getString("description"), "This is a test filter");
+  EXPECT_EQ(obj->getBoolean("default"), true);
+  EXPECT_EQ(obj->getBoolean("supportsCondition"), true);
+  EXPECT_EQ(obj->getString("conditionDescription"),
+"Condition for test filter");
+}
+
+TEST(ProtocolTypesTest, ColumnDescriptor) {
+  ColumnDescriptor column;
+  column.attributeName = "testAttribute";
+  column.label = "Test Label";
+  column.format = "testFormat";
+  column.type = eColumnTypeString;
+  column.width = 20;
+
+  llvm::json::Value value = toJSON(column);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("attributeName"), "testAttribute");
+  EXPECT_EQ(obj->getString("label"), "Test Label");
+  EXPECT_EQ(obj->getString("format"), "testFormat");
+  EXPECT_EQ(obj->getString("type"), "string");
+  EXPECT_EQ(obj->getInteger("width"), 20);
+}
+
+TEST(ProtocolTypesTest, BreakpointMode) {
+  BreakpointMode mode;
+  mode.mode = "testMode";
+  mode.label = "Test Label";
+  mode.description = "This is a test description";
+  mode.appliesTo = {eBreakpointModeApplicabilitySource,
+eBreakpointModeApplicabilityException};
+
+  llvm::json::Value value = toJSON(mode);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("mode"), "testMode");
+  EXPECT_EQ(obj->getString("label"), "Test Label");
+  EXPECT_EQ(obj->getString("description"), "This is a test description");
+
+  const auto *appliesToArray = obj->getArray("appliesTo");
+  ASSERT_NE(appliesToArray, nullptr);
+  ASSERT_EQ(appliesToArray->size(), 2UL);
+  EXPECT_EQ(appliesToArray->front().getAsString(), "source");
+  EXPECT_EQ(appliesToArray->back().getAsString(), "exception");
+}
+
+TEST(ProtocolTypesTest, Capabilities) {
+  Capabilities capabilities;
+  capabilities.supportedFeatures = {eAdapterFeatureANSIStyling,
+eAdapterFeatureTerminateRequest};
+  capabilities.exceptionBreakpointFilters = {
+  {"filter1", "Filter 1", "Description 1", true, true, "Condition 1"},
+  {"filter2", "Filter 2", "Description 2", false, false, "Condition 2"}};
+  capabilities.completionTriggerCharacters = {"."};
+  capabilities.additionalModuleColumns = {
+  {"attribute1", "Label 1", "Format 1", eColumnTypeString, 10},
+  {"attribute2", "Label 2", "Format 2", eColumnTypeNumber, 20}};
+  capabilities.supportedChecksumAlgorithms = {eChecksumAlgorithmMD5,
+  eChecksumAlgorithmSHA256};
+  capabilities.breakpointModes = {{"mode1",
+   "Mode 1",
+   "Description 1",
+   {eBreakpointModeApplicabilitySource}},
+  {"mode2",
+   "Mode 2",
+   

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

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

Author: Jason Molenda
Date: 2025-05-11T23:39:35-07:00
New Revision: b957cc0c7e8eb5895ca519c9cc09e099878f5fbb

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

LOG: [lldb] Provide lr value in faulting frame on arm64 (#138805)

Re-landing this patch with small tweaks to address CI bot failures
as it was run on many different configurations.  I think the test
may run on aarch64 Linux systems now.

When a frameless function faults or is interrupted asynchronously, the
UnwindPlan MAY have no register location rule for the return address
register (lr on arm64); the value is simply live in the lr register when
it was interrupted, and the frame below this on the stack -- e.g.
sigtramp on a Unix system -- has the full register context, including
that register.

RegisterContextUnwind::SavedLocationForRegister, when asked to find the
caller's pc value, will first see if there is a pc register location. If
there isn't, on a Return Address Register architecture like
arm/mips/riscv, we rewrite the register request from "pc" to "RA
register", and search for a location.

On frame 0 (the live frame) and an interrupted frame, the UnwindPlan may
have no register location rule for the RA Reg, that is valid. A
frameless function that never calls another may simply keep the return
address in the live register the whole way. Our instruction emulation
unwind plans explicitly add a rule (see Pavel's May 2024 change
https://github.com/llvm/llvm-project/pull/91321 ), but an UnwindPlan
sourced from debug_frame may not.

I've got a case where this exactly happens - clang debug_frame for arm64
where there is no register location for the lr in a frameless function.
There is a fault in the middle of this frameless function and we only
get the lr value from the fault handler below this frame if lr has a
register location of `IsSame`, in line with Pavel's 2024 change.

Similar to how we see a request of the RA Reg from frame 0 after failing
to find an unwind location for the pc register, the same style of
special casing is needed when this is a function that was interrupted.

Without this change, we can find the pc of the frame that was executing
when it was interrupted, but we need $lr to find its caller, and we
don't descend down to the trap handler to get that value, truncating the
stack.

rdar://145614545

Added: 
lldb/test/API/functionalities/unwind/frameless-faulted/Makefile

lldb/test/API/functionalities/unwind/frameless-faulted/TestUnwindFramelessFaulted.py

lldb/test/API/functionalities/unwind/frameless-faulted/interrupt-and-trap-funcs.s
lldb/test/API/functionalities/unwind/frameless-faulted/main.c

Modified: 
lldb/source/Target/RegisterContextUnwind.cpp

Removed: 




diff  --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index f56dda187e12a..cf4b96c6eda9f 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -248,6 +248,7 @@ void RegisterContextUnwind::InitializeZerothFrame() {
 active_row =
 m_full_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
 row_register_kind = m_full_unwind_plan_sp->GetRegisterKind();
+PropagateTrapHandlerFlagFromUnwindPlan(m_full_unwind_plan_sp);
 if (active_row && log) {
   StreamString active_row_strm;
   active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread,
@@ -279,7 +280,7 @@ void RegisterContextUnwind::InitializeZerothFrame() {
   call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
   process->GetTarget(), m_thread);
 
-if (call_site_unwind_plan != nullptr) {
+if (call_site_unwind_plan.get() != nullptr) {
   m_fallback_unwind_plan_sp = call_site_unwind_plan;
   if (TryFallbackUnwindPlan())
 cfa_status = true;
@@ -1375,6 +1376,7 @@ RegisterContextUnwind::SavedLocationForRegister(
 }
   }
 
+  // Check if the active_row has a register location listed.
   if (regnum.IsValid() && active_row &&
   
active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
   unwindplan_regloc)) {
@@ -1388,11 +1390,10 @@ RegisterContextUnwind::SavedLocationForRegister(
   // This is frame 0 and we're retrieving the PC and it's saved in a Return
   // Address register and it hasn't been saved anywhere yet -- that is,
   // it's still live in the actual register. Handle this specially.
-
   if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
-  IsFrameZero()) {
-if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
-LLDB_INVALID_REGNUM) {
+  return_address_reg.GetAsKind(eRegisterKindLLDB) !=
+  LLDB_INVALID_REGNU

[Lldb-commits] [lldb] c1ecd0a - [lldb-dap] Don't build the unit tests on Windows

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:14:03-07:00
New Revision: c1ecd0a92e51be383bc48eef06bfcba3ffdd413f

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

LOG: [lldb-dap] Don't build the unit tests on Windows

Added: 


Modified: 
lldb/unittests/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index fa59c00a3f0c8..d8f9cc747986e 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -48,13 +48,13 @@ endfunction()
 
 add_subdirectory(TestingSupport)
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # FIXME: APITests.exe is not a valid googletest binary.
+  # FIXME: Tests linking against libLLDB don't work on Windows.
   add_subdirectory(API)
+  add_subdirectory(DAP)
 endif()
 add_subdirectory(Breakpoint)
 add_subdirectory(Callback)
 add_subdirectory(Core)
-add_subdirectory(DAP)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
 add_subdirectory(Editline)



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


[Lldb-commits] [lldb] 5b97a5b - [lldb-dap] Add unit tests for GetString and GetBoolean

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:20:30-07:00
New Revision: 5b97a5b2ae6368a9c1ad220d3b1d94c545578bed

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

LOG: [lldb-dap] Add unit tests for GetString and GetBoolean

These are simple functions but they're used a lot. Add some simple unit
tests for them.

Added: 


Modified: 
lldb/unittests/DAP/JSONUtilsTest.cpp

Removed: 




diff  --git a/lldb/unittests/DAP/JSONUtilsTest.cpp 
b/lldb/unittests/DAP/JSONUtilsTest.cpp
index 0cf42a1c08870..2dbd1de899ece 100644
--- a/lldb/unittests/DAP/JSONUtilsTest.cpp
+++ b/lldb/unittests/DAP/JSONUtilsTest.cpp
@@ -16,9 +16,72 @@ using namespace lldb;
 using namespace lldb_dap;
 
 TEST(JSONUtilsTest, GetAsString) {
-  StringRef str = "foo";
-  json::Value value("foo");
-  EXPECT_EQ(str, GetAsString(value));
+  json::Value string_value("foo");
+  EXPECT_EQ(GetAsString(string_value), "foo");
+
+  json::Value int_value(42);
+  EXPECT_EQ(GetAsString(int_value), "");
+
+  json::Value null_value(nullptr);
+  EXPECT_EQ(GetAsString(null_value), "");
+}
+
+TEST(JSONUtilsTest, GetString_Ref) {
+  json::Object obj;
+  obj.try_emplace("key", "value");
+
+  auto result = GetString(obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), "value");
+
+  result = GetString(obj, "nonexistent_key");
+  EXPECT_FALSE(result.has_value());
+}
+
+TEST(JSONUtilsTest, GetString_Pointer) {
+  json::Object obj;
+  obj.try_emplace("key", "value");
+
+  auto result = GetString(&obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), "value");
+
+  result = GetString(nullptr, "key");
+  EXPECT_FALSE(result.has_value());
+}
+
+TEST(JSONUtilsTest, GetBoolean_Ref) {
+  json::Object obj;
+  obj.try_emplace("key_true", true);
+  obj.try_emplace("key_false", false);
+  obj.try_emplace("key_int", 1);
+
+  auto result = GetBoolean(obj, "key_true");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_TRUE(result.value());
+
+  result = GetBoolean(obj, "key_false");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_FALSE(result.value());
+
+  result = GetBoolean(obj, "key_int");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_TRUE(result.value());
+
+  result = GetBoolean(obj, "nonexistent_key");
+  EXPECT_FALSE(result.has_value());
+}
+
+TEST(JSONUtilsTest, GetBoolean_Pointer) {
+  json::Object obj;
+  obj.try_emplace("key", true);
+
+  auto result = GetBoolean(&obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_TRUE(result.value());
+
+  result = GetBoolean(nullptr, "key");
+  EXPECT_FALSE(result.has_value());
 }
 
 TEST(JSONUtilsTest, CreateModule) {



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


[Lldb-commits] [lldb] 8757aa0 - [lldb-dap] Add unit tests for GetInteger

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:22:21-07:00
New Revision: 8757aa0a7ec1ef1ca79e1ff2ff63d246e6215ba4

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

LOG: [lldb-dap] Add unit tests for GetInteger

Added: 


Modified: 
lldb/unittests/DAP/JSONUtilsTest.cpp

Removed: 




diff  --git a/lldb/unittests/DAP/JSONUtilsTest.cpp 
b/lldb/unittests/DAP/JSONUtilsTest.cpp
index 2dbd1de899ece..648aef106caa6 100644
--- a/lldb/unittests/DAP/JSONUtilsTest.cpp
+++ b/lldb/unittests/DAP/JSONUtilsTest.cpp
@@ -9,7 +9,9 @@
 #include "JSONUtils.h"
 #include "lldb/API/SBModule.h"
 #include "lldb/API/SBTarget.h"
+#include "llvm/Support/JSON.h"
 #include "gtest/gtest.h"
+#include 
 
 using namespace llvm;
 using namespace lldb;
@@ -84,6 +86,59 @@ TEST(JSONUtilsTest, GetBoolean_Pointer) {
   EXPECT_FALSE(result.has_value());
 }
 
+TEST(JSONUtilsTest, GetInteger_Ref) {
+  json::Object obj;
+  obj.try_emplace("key", 123);
+
+  auto result = GetInteger(obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), 123);
+
+  result = GetInteger(obj, "nonexistent_key");
+  EXPECT_FALSE(result.has_value());
+
+  obj.try_emplace("key_float", 123.45);
+  result = GetInteger(obj, "key_float");
+  EXPECT_FALSE(result.has_value());
+
+  obj.try_emplace("key_string", "123");
+  result = GetInteger(obj, "key_string");
+  EXPECT_FALSE(result.has_value());
+}
+
+TEST(JSONUtilsTest, GetInteger_Pointer) {
+  json::Object obj;
+  obj.try_emplace("key", 456);
+
+  auto result = GetInteger(&obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), 456);
+
+  result = GetInteger(nullptr, "key");
+  EXPECT_FALSE(result.has_value());
+
+  obj.try_emplace("key_invalid", "not_an_integer");
+  result = GetInteger(&obj, "key_invalid");
+  EXPECT_FALSE(result.has_value());
+}
+
+TEST(JSONUtilsTest, GetInteger_DifferentTypes) {
+  json::Object obj;
+  obj.try_emplace("key", 789);
+
+  auto result = GetInteger(obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), 789);
+
+  result = GetInteger(obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), 789U);
+
+  result = GetInteger(obj, "key");
+  ASSERT_TRUE(result.has_value());
+  EXPECT_EQ(result.value(), static_cast(789));
+}
+
 TEST(JSONUtilsTest, CreateModule) {
   SBTarget target;
   SBModule module;



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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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

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

>From b0996a236d9eaf70de562ae2cf0e1900417cae93 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sat, 10 May 2025 12:08:29 -0700
Subject: [PATCH 1/3] [lldb-dap] Split lldb-dap into library and tool (NFC)

Split lldb-dap into a library (lldbDAP) and a tool (lldb-dap). The
motivation is being able to link parts of lldb-dap separately, for
example to support unit testing and fizzing.
---
 lldb/tools/lldb-dap/CMakeLists.txt| 22 ++-
 lldb/tools/lldb-dap/tool/CMakeLists.txt   | 28 +++
 .../{ => tool}/lldb-dap-Info.plist.in |  0
 lldb/tools/lldb-dap/{ => tool}/lldb-dap.cpp   |  0
 4 files changed, 36 insertions(+), 14 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/tool/CMakeLists.txt
 rename lldb/tools/lldb-dap/{ => tool}/lldb-dap-Info.plist.in (100%)
 rename lldb/tools/lldb-dap/{ => tool}/lldb-dap.cpp (100%)

diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index a9dc19006293b..25bacd91fe581 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -1,20 +1,14 @@
-if(APPLE)
-  configure_file(
-${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
-${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
-)
-  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
-endif()
-
 # We need to include the llvm components we depend on manually, as liblldb does
 # not re-export those.
 set(LLVM_LINK_COMPONENTS Support)
 set(LLVM_TARGET_DEFINITIONS Options.td)
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(LLDBDAPOptionsTableGen)
-add_lldb_tool(lldb-dap
-  lldb-dap.cpp
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+add_lldb_library(lldbDAP
   Breakpoint.cpp
   BreakpointBase.cpp
   DAP.cpp
@@ -85,10 +79,8 @@ add_lldb_tool(lldb-dap
 Support
   )
 
-target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-
 if(LLDB_DAP_WELCOME_MESSAGE)
-  target_compile_definitions(lldb-dap
+  target_compile_definitions(lldbDAP
 PRIVATE
 -DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
 endif()
@@ -105,3 +97,5 @@ if(LLDB_BUILD_FRAMEWORK)
   "@loader_path/../../Library/PrivateFrameworks"
   )
 endif()
+
+add_subdirectory(tool)
diff --git a/lldb/tools/lldb-dap/tool/CMakeLists.txt 
b/lldb/tools/lldb-dap/tool/CMakeLists.txt
new file mode 100644
index 0..e418737bc05b1
--- /dev/null
+++ b/lldb/tools/lldb-dap/tool/CMakeLists.txt
@@ -0,0 +1,28 @@
+if(APPLE)
+  configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+)
+  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
+endif()
+
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+lldbDAP
+  )
+
+if(LLDB_BUILD_FRAMEWORK)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  lldb_setup_rpaths(lldb-dap
+BUILD_RPATH
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
+INSTALL_RPATH
+  "@loader_path/../../../SharedFrameworks"
+  "@loader_path/../../System/Library/PrivateFrameworks"
+  "@loader_path/../../Library/PrivateFrameworks"
+  )
+endif()
diff --git a/lldb/tools/lldb-dap/lldb-dap-Info.plist.in 
b/lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap-Info.plist.in
rename to lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap.cpp
rename to lldb/tools/lldb-dap/tool/lldb-dap.cpp

>From 6f0768f467b3991069ae6c35e5bb9f612340444d Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sat, 10 May 2025 12:32:07 -0700
Subject: [PATCH 2/3] Add simple unit tests as an example

---
 lldb/tools/lldb-dap/CMakeLists.txt   |  6 ++---
 lldb/unittests/CMakeLists.txt|  1 +
 lldb/unittests/DAP/CMakeLists.txt|  8 +++
 lldb/unittests/DAP/JSONUtilsTest.cpp | 33 
 4 files changed, 45 insertions(+), 3 deletions(-)
 create mode 100644 lldb/unittests/DAP/CMakeLists.txt
 create mode 100644 lldb/unittests/DAP/JSONUtilsTest.cpp

diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index 25bacd91fe581..cdca4a0d62e8a 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -5,9 +5,6 @@ set(LLVM_TARGET

[Lldb-commits] [lldb] 6f84ec3 - [lldb-dap] Split lldb-dap into library and tool (NFC) (#139402)

2025-05-11 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-11T14:48:40-07:00
New Revision: 6f84ec3496f5ec9038a59c11d2ea495f1e601049

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

LOG: [lldb-dap] Split lldb-dap into library and tool (NFC) (#139402)

Split lldb-dap into a library (lldbDAP) and a tool (lldb-dap). The
motivation is being able to link parts of lldb-dap separately, for
example to support unit testing and fuzzing.

Added: 
lldb/tools/lldb-dap/tool/CMakeLists.txt
lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
lldb/tools/lldb-dap/tool/lldb-dap.cpp
lldb/unittests/DAP/CMakeLists.txt
lldb/unittests/DAP/JSONUtilsTest.cpp

Modified: 
lldb/tools/lldb-dap/CMakeLists.txt
lldb/unittests/CMakeLists.txt

Removed: 
lldb/tools/lldb-dap/lldb-dap-Info.plist.in
lldb/tools/lldb-dap/lldb-dap.cpp



diff  --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index a9dc19006293b..608166bf0e0dd 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -1,20 +1,11 @@
-if(APPLE)
-  configure_file(
-${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
-${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
-)
-  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
-endif()
-
 # We need to include the llvm components we depend on manually, as liblldb does
 # not re-export those.
 set(LLVM_LINK_COMPONENTS Support)
 set(LLVM_TARGET_DEFINITIONS Options.td)
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(LLDBDAPOptionsTableGen)
-add_lldb_tool(lldb-dap
-  lldb-dap.cpp
+
+add_lldb_library(lldbDAP
   Breakpoint.cpp
   BreakpointBase.cpp
   DAP.cpp
@@ -85,10 +76,11 @@ add_lldb_tool(lldb-dap
 Support
   )
 
-target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(lldbDAP
+  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 
 if(LLDB_DAP_WELCOME_MESSAGE)
-  target_compile_definitions(lldb-dap
+  target_compile_definitions(lldbDAP
 PRIVATE
 -DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
 endif()
@@ -105,3 +97,5 @@ if(LLDB_BUILD_FRAMEWORK)
   "@loader_path/../../Library/PrivateFrameworks"
   )
 endif()
+
+add_subdirectory(tool)

diff  --git a/lldb/tools/lldb-dap/tool/CMakeLists.txt 
b/lldb/tools/lldb-dap/tool/CMakeLists.txt
new file mode 100644
index 0..b39a4ed9c40e7
--- /dev/null
+++ b/lldb/tools/lldb-dap/tool/CMakeLists.txt
@@ -0,0 +1,28 @@
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+lldbDAP
+  )
+
+if(APPLE)
+  configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+)
+  target_link_options(lldb-dap
+PRIVATE 
LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist)
+endif()
+
+if(LLDB_BUILD_FRAMEWORK)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in 
diff erent locations.
+  lldb_setup_rpaths(lldb-dap
+BUILD_RPATH
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
+INSTALL_RPATH
+  "@loader_path/../../../SharedFrameworks"
+  "@loader_path/../../System/Library/PrivateFrameworks"
+  "@loader_path/../../Library/PrivateFrameworks"
+  )
+endif()

diff  --git a/lldb/tools/lldb-dap/lldb-dap-Info.plist.in 
b/lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap-Info.plist.in
rename to lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in

diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap.cpp
rename to lldb/tools/lldb-dap/tool/lldb-dap.cpp

diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index cc9d45ebf981d..fa59c00a3f0c8 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -54,6 +54,7 @@ endif()
 add_subdirectory(Breakpoint)
 add_subdirectory(Callback)
 add_subdirectory(Core)
+add_subdirectory(DAP)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
 add_subdirectory(Editline)

diff  --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
new file mode 100644
index 0..f61c4006072a3
--- /dev/null
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_lldb_unittest(DAPTests
+  JSONUtilsTest.cpp
+
+  LINK_LIBS
+lldbDAP
+  LINK_COMPONENTS
+Support
+  )

diff  --git a/lldb/unittests/DAP/JSONUtilsTest.cpp 
b/lldb/unittests/DAP/JSONUtilsTest.cpp
new file mode 1006

[Lldb-commits] [lldb] 2ccfb99 - [lldb] Fix term settings completion tests (#139447)

2025-05-11 Thread via lldb-commits

Author: Emmanuel Ferdman
Date: 2025-05-11T14:47:21-07:00
New Revision: 2ccfb99d81d9fa9be6b0be02649d987106797979

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

LOG: [lldb] Fix term settings completion tests (#139447)

# PR Summary
Small PR - Several test functions for `term-width/height` completions
had identical names, causing silent overriding. This gives them distinct
_width/_height suffixes to ensure all tests run.

Signed-off-by: Emmanuel Ferdman 

Added: 


Modified: 
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index bf043c795fac6..e7c53729f2090 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -334,22 +334,22 @@ def test_settings_replace_target_ru(self):
 "settings replace target.ru", "settings replace target.run-args"
 )
 
-def test_settings_show_term(self):
+def test_settings_show_term_width(self):
 self.complete_from_to("settings show term-w", "settings show 
term-width")
 
-def test_settings_list_term(self):
+def test_settings_list_term_width(self):
 self.complete_from_to("settings list term-w", "settings list 
term-width")
 
-def test_settings_show_term(self):
+def test_settings_show_term_height(self):
 self.complete_from_to("settings show term-h", "settings show 
term-height")
 
-def test_settings_list_term(self):
+def test_settings_list_term_height(self):
 self.complete_from_to("settings list term-h", "settings list 
term-height")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_width(self):
 self.complete_from_to("settings remove term-w", "settings remove 
term-width")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_height(self):
 self.complete_from_to("settings remove term-h", "settings remove 
term-height")
 
 def test_settings_s(self):



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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

2025-05-11 Thread via lldb-commits

github-actions[bot] wrote:



@emmanuel-ferdman Congratulations on having your first Pull Request (PR) merged 
into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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

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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

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

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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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


@@ -85,10 +76,11 @@ add_lldb_tool(lldb-dap
 Support
   )
 
-target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(lldbDAP
+  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR_DIR})

da-viper wrote:

```suggestion
  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
```

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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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

https://github.com/da-viper requested changes to this pull request.


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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

2025-05-11 Thread Emmanuel Ferdman via lldb-commits

https://github.com/emmanuel-ferdman created 
https://github.com/llvm/llvm-project/pull/139447

# PR Summary
Small PR - Several test functions for `term-width/height` completions had 
identical names, causing silent overriding. This gives them distinct 
_width/_height suffixes to ensure all tests run.

>From f11437930874cd55b80b3f486c1dc6c19afeee9b Mon Sep 17 00:00:00 2001
From: Emmanuel Ferdman 
Date: Sun, 11 May 2025 05:30:16 -0700
Subject: [PATCH] [lldb] Fix term settings completion tests

Signed-off-by: Emmanuel Ferdman 
---
 .../API/functionalities/completion/TestCompletion.py | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index bf043c795fac6..e7c53729f2090 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -334,22 +334,22 @@ def test_settings_replace_target_ru(self):
 "settings replace target.ru", "settings replace target.run-args"
 )
 
-def test_settings_show_term(self):
+def test_settings_show_term_width(self):
 self.complete_from_to("settings show term-w", "settings show 
term-width")
 
-def test_settings_list_term(self):
+def test_settings_list_term_width(self):
 self.complete_from_to("settings list term-w", "settings list 
term-width")
 
-def test_settings_show_term(self):
+def test_settings_show_term_height(self):
 self.complete_from_to("settings show term-h", "settings show 
term-height")
 
-def test_settings_list_term(self):
+def test_settings_list_term_height(self):
 self.complete_from_to("settings list term-h", "settings list 
term-height")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_width(self):
 self.complete_from_to("settings remove term-w", "settings remove 
term-width")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_height(self):
 self.complete_from_to("settings remove term-h", "settings remove 
term-height")
 
 def test_settings_s(self):

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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

2025-05-11 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Emmanuel Ferdman (emmanuel-ferdman)


Changes

# PR Summary
Small PR - Several test functions for `term-width/height` completions had 
identical names, causing silent overriding. This gives them distinct 
_width/_height suffixes to ensure all tests run.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+6-6) 


``diff
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index bf043c795fac6..e7c53729f2090 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -334,22 +334,22 @@ def test_settings_replace_target_ru(self):
 "settings replace target.ru", "settings replace target.run-args"
 )
 
-def test_settings_show_term(self):
+def test_settings_show_term_width(self):
 self.complete_from_to("settings show term-w", "settings show 
term-width")
 
-def test_settings_list_term(self):
+def test_settings_list_term_width(self):
 self.complete_from_to("settings list term-w", "settings list 
term-width")
 
-def test_settings_show_term(self):
+def test_settings_show_term_height(self):
 self.complete_from_to("settings show term-h", "settings show 
term-height")
 
-def test_settings_list_term(self):
+def test_settings_list_term_height(self):
 self.complete_from_to("settings list term-h", "settings list 
term-height")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_width(self):
 self.complete_from_to("settings remove term-w", "settings remove 
term-width")
 
-def test_settings_remove_term(self):
+def test_settings_remove_term_height(self):
 self.complete_from_to("settings remove term-h", "settings remove 
term-height")
 
 def test_settings_s(self):

``




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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

2025-05-11 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/139447
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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


@@ -0,0 +1,28 @@
+if(APPLE)
+  configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+)
+  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
+endif()
+
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+lldbDAP
+  )
+

da-viper wrote:

```suggestion
add_lldb_tool(lldb-dap
  lldb-dap.cpp

  LINK_LIBS
lldbDAP
  )
  
if(APPLE)
  configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
  ${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
  )
  target_link_options(lldb-dap PRIVATE 
LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist)
endif()
```

use 
[target_link_option](https://cmake.org/cmake/help/latest/prop_tgt/LINK_OPTIONS.html#prop_tgt:LINK_OPTIONS)
 .

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


[Lldb-commits] [lldb] [lldb] Fix term settings completion tests (PR #139447)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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

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



  



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] Split lldb-dap into library and tool (NFC) (PR #139402)

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


@@ -0,0 +1,28 @@
+if(APPLE)
+  configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+)
+  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
+endif()
+
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+lldbDAP
+  )
+

JDevlieghere wrote:

I'm just moving the code, but since we're on CMake 3.20 now is as good a time 
as any to address the fixme. 

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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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


@@ -85,10 +76,11 @@ add_lldb_tool(lldb-dap
 Support
   )
 
-target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(lldbDAP
+  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR_DIR})

JDevlieghere wrote:

Good catch, I added `CMAKE_CURRENT_BINARY_DIR` just to be future proof but as 
nothing relies on this yet I didn't notice it wasn't working.

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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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

https://github.com/da-viper approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

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


@@ -0,0 +1,28 @@
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+lldbDAP
+  )
+
+if(APPLE)
+  configure_file(
+${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+)
+  target_link_options(lldb-dap
+PRIVATE 
LINKER:-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist)

da-viper wrote:

I don't think we need the `-Wl` flag

> For example, "LINKER:-z,defs" becomes -Xlinker -z -Xlinker defs for Clang and 
> -Wl,-z,defs for GNU GCC.

>From 
>https://cmake.org/cmake/help/latest/prop_tgt/LINK_OPTIONS.html#handling-compiler-driver-differences

you can use `otool -s __TEXT __info_plist /path/to/lldb-dap` to confirm it was 
added. Cannot confirm since I do not have a mac. 

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


[Lldb-commits] [lldb] d129790 - [lldb-dap] Remove GetSigned from JSONUtils (NFC)

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:29:53-07:00
New Revision: d129790ae89a106597e19475b6332e73cea663c2

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

LOG: [lldb-dap] Remove GetSigned from JSONUtils (NFC)

This function was replaced by GetInteger which can handle both signed
and unsigned values. It currently had one caller in JSONUtils, which
this patch updates.

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index bd2e6630a126e..279e6d3d93814 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -99,19 +99,6 @@ std::optional GetBoolean(const llvm::json::Object *obj,
   return std::nullopt;
 }
 
-std::optional GetSigned(const llvm::json::Object &obj,
- llvm::StringRef key) {
-  return obj.getInteger(key);
-}
-
-std::optional GetSigned(const llvm::json::Object *obj,
- llvm::StringRef key) {
-  if (obj == nullptr)
-return std::nullopt;
-
-  return GetSigned(*obj, key);
-}
-
 bool ObjectContainsKey(const llvm::json::Object &obj, llvm::StringRef key) {
   return obj.find(key) != obj.end();
 }
@@ -263,7 +250,7 @@ void FillResponse(const llvm::json::Object &request,
   response.try_emplace("seq", (int64_t)0);
   EmplaceSafeString(response, "command",
 GetString(request, "command").value_or(""));
-  const int64_t seq = GetSigned(request, "seq").value_or(0);
+  const uint64_t seq = GetInteger(request, "seq").value_or(0);
   response.try_emplace("request_seq", seq);
   response.try_emplace("success", true);
 }



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


[Lldb-commits] [lldb] 79fbef1 - [lldb-dap] Add unit tests for LLDBUtils (NFC)

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:42:42-07:00
New Revision: 79fbef17128340923be177f8c4e841fc2cc8a9e9

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

LOG: [lldb-dap] Add unit tests for LLDBUtils (NFC)

Added: 
lldb/unittests/DAP/LLDBUtilsTest.cpp

Modified: 
lldb/unittests/DAP/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index f61c4006072a3..4bbb552be9f34 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_unittest(DAPTests
   JSONUtilsTest.cpp
+  LLDBUtilsTest.cpp
 
   LINK_LIBS
 lldbDAP

diff  --git a/lldb/unittests/DAP/LLDBUtilsTest.cpp 
b/lldb/unittests/DAP/LLDBUtilsTest.cpp
new file mode 100644
index 0..37c21bdef8abc
--- /dev/null
+++ b/lldb/unittests/DAP/LLDBUtilsTest.cpp
@@ -0,0 +1,46 @@
+//===-- 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 "LLDBUtils.h"
+#include "lldb/API/SBStructuredData.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+
+TEST(LLDBUtilsTest, GetStringValue) {
+  // Create an SBStructuredData object from JSON.
+  const char *json_data = R"("test_string")";
+  SBStructuredData data;
+  SBError error = data.SetFromJSON(json_data);
+
+  // Ensure the JSON was parsed successfully.
+  ASSERT_TRUE(error.Success());
+  ASSERT_TRUE(data.IsValid());
+
+  // Call GetStringValue and verify the result.
+  std::string result = GetStringValue(data);
+  EXPECT_EQ(result, "test_string");
+
+  // Test with invalid SBStructuredData.
+  SBStructuredData invalid_data;
+  result = GetStringValue(invalid_data);
+  EXPECT_EQ(result, "");
+
+  // Test with empty JSON.
+  const char *empty_json = R"("")";
+  SBStructuredData empty_data;
+  error = empty_data.SetFromJSON(empty_json);
+
+  ASSERT_TRUE(error.Success());
+  ASSERT_TRUE(empty_data.IsValid());
+
+  result = GetStringValue(empty_data);
+  EXPECT_EQ(result, "");
+}



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


[Lldb-commits] [lldb] e584af5 - [lldb-dap] Add unit tests for ToError

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:51:32-07:00
New Revision: e584af5861cec9ff8989487694f78855bee950dc

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

LOG: [lldb-dap] Add unit tests for ToError

Added: 


Modified: 
lldb/unittests/DAP/LLDBUtilsTest.cpp

Removed: 




diff  --git a/lldb/unittests/DAP/LLDBUtilsTest.cpp 
b/lldb/unittests/DAP/LLDBUtilsTest.cpp
index 37c21bdef8abc..4f619af2b136e 100644
--- a/lldb/unittests/DAP/LLDBUtilsTest.cpp
+++ b/lldb/unittests/DAP/LLDBUtilsTest.cpp
@@ -7,7 +7,9 @@
 
//===--===//
 
 #include "LLDBUtils.h"
+#include "lldb/API/SBError.h"
 #include "lldb/API/SBStructuredData.h"
+#include "llvm/Support/Error.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -44,3 +46,20 @@ TEST(LLDBUtilsTest, GetStringValue) {
   result = GetStringValue(empty_data);
   EXPECT_EQ(result, "");
 }
+
+TEST(LLDBUtilsTest, ToError) {
+  // Test with a successful SBError.
+  SBError success_error;
+  ASSERT_TRUE(success_error.Success());
+  llvm::Error llvm_error = ToError(success_error);
+  EXPECT_FALSE(llvm_error);
+
+  // Test with a failing SBError.
+  SBError fail_error;
+  fail_error.SetErrorString("Test error message");
+  ASSERT_TRUE(fail_error.Fail());
+  llvm_error = ToError(fail_error);
+
+  std::string error_message = toString(std::move(llvm_error));
+  EXPECT_EQ(error_message, "Test error message");
+}



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


[Lldb-commits] [lldb] e62fc14 - [lldb-dap] Add unit tests for GetStrings

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

Author: Jonas Devlieghere
Date: 2025-05-11T16:32:43-07:00
New Revision: e62fc14a5d214f801758b35bdcad0c8efc65e8b8

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

LOG: [lldb-dap] Add unit tests for GetStrings

Added: 


Modified: 
lldb/unittests/DAP/JSONUtilsTest.cpp

Removed: 




diff  --git a/lldb/unittests/DAP/JSONUtilsTest.cpp 
b/lldb/unittests/DAP/JSONUtilsTest.cpp
index 648aef106caa6..ce4be085965d5 100644
--- a/lldb/unittests/DAP/JSONUtilsTest.cpp
+++ b/lldb/unittests/DAP/JSONUtilsTest.cpp
@@ -149,3 +149,47 @@ TEST(JSONUtilsTest, CreateModule) {
   ASSERT_NE(object, nullptr);
   EXPECT_EQ(object->size(), 0UL);
 }
+
+TEST(JSONUtilsTest, GetStrings_EmptyArray) {
+  llvm::json::Object obj;
+  obj.try_emplace("key", llvm::json::Array());
+  auto result = GetStrings(&obj, "key");
+  EXPECT_TRUE(result.empty());
+}
+
+TEST(JSONUtilsTest, GetStrings_NullKey) {
+  llvm::json::Object obj;
+  auto result = GetStrings(&obj, "nonexistent_key");
+  EXPECT_TRUE(result.empty());
+}
+
+TEST(JSONUtilsTest, GetStrings_StringValues) {
+  llvm::json::Object obj;
+  llvm::json::Array arr{"value1", "value2", "value3"};
+  obj.try_emplace("key", std::move(arr));
+  auto result = GetStrings(&obj, "key");
+  ASSERT_EQ(result.size(), 3UL);
+  EXPECT_EQ(result[0], "value1");
+  EXPECT_EQ(result[1], "value2");
+  EXPECT_EQ(result[2], "value3");
+}
+
+TEST(JSONUtilsTest, GetStrings_MixedValues) {
+  llvm::json::Object obj;
+  llvm::json::Array arr{"string", 42, true, nullptr};
+  obj.try_emplace("key", std::move(arr));
+  auto result = GetStrings(&obj, "key");
+  ASSERT_EQ(result.size(), 3UL);
+  EXPECT_EQ(result[0], "string");
+  EXPECT_EQ(result[1], "42");
+  EXPECT_EQ(result[2], "true");
+}
+
+TEST(JSONUtilsTest, GetStrings_NestedArray) {
+  llvm::json::Object obj;
+  llvm::json::Array nested_array{"string", llvm::json::Array{"nested"}};
+  obj.try_emplace("key", std::move(nested_array));
+  auto result = GetStrings(&obj, "key");
+  ASSERT_EQ(result.size(), 1UL);
+  EXPECT_EQ(result[0], "string");
+}



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


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

2025-05-11 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

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

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


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

```
Step 16 (test-check-lldb-unit) failure: Test just built components: 
check-lldb-unit completed (failure)
 TEST 'lldb-unit :: 
DAP/./DAPTests.exe/failed_to_discover_tests_from_gtest' FAILED 





```



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