[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

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

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

Identical code to Linux apart from `/lwp/` in place of `/task/`. Wondered if we 
could share that but as long as it remains identical, we could always do it 
later if we want.

It would be something like `getProcFile(::pid_t pid, ::pid_t tid, const 
llvm::Twine &file, const llvm::Twine &task_folder)`. Then each would implement 
the current call by passing in the right name.

By the time we've done that, we probably have the same number of lines again, 
but with more layers.

So in summary, LGTM :)

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


[Lldb-commits] [lldb] [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (PR #142573)

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

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

LGTM

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


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Hemang Gadhavi (HemangGadhavi)


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

- Added changes to getProcFile() with threadID with testcase for AIX.
- Added support for AIX to get_threadid() from llvm.
@labath @DhruvSrivastavaX 

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


5 Files Affected:

- (added) lldb/include/lldb/Host/aix/Support.h (+23) 
- (modified) lldb/source/Host/CMakeLists.txt (+1) 
- (added) lldb/source/Host/aix/Support.cpp (+24) 
- (modified) lldb/unittests/Host/posix/SupportTest.cpp (+9) 
- (modified) llvm/lib/Support/Unix/Threading.inc (+2) 


``diff
diff --git a/lldb/include/lldb/Host/aix/Support.h 
b/lldb/include/lldb/Host/aix/Support.h
new file mode 100644
index 0..f02a1904b09fa
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Support.h
@@ -0,0 +1,23 @@
+//===-- Support.h ---*- 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
+//
+//===--===//
+
+#ifndef LLDB_HOST_AIX_SUPPORT_H
+#define LLDB_HOST_AIX_SUPPORT_H
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+
+namespace lldb_private {
+
+llvm::ErrorOr>
+getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_AIX_SUPPORT_H
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 90814b1bed4c8..d19e4edd4cf56 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -142,6 +142,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  aix/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Support.cpp b/lldb/source/Host/aix/Support.cpp
new file mode 100644
index 0..afd975565ff2f
--- /dev/null
+++ b/lldb/source/Host/aix/Support.cpp
@@ -0,0 +1,24 @@
+//===-- Support.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/aix/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+llvm::ErrorOr>
+lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
+  Log *log = GetLog(LLDBLog::Host);
+  std::string File =
+  ("/proc/" + llvm::Twine(pid) + "/lwp/" + llvm::Twine(tid) + "/" + file)
+  .str();
+  auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
+  if (!Ret)
+LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
+  return Ret;
+}
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp 
b/lldb/unittests/Host/posix/SupportTest.cpp
index f3976db755943..e4d7ba89fece6 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/posix/Support.h"
+#include "lldb/Host/aix/Support.h"
 #include "llvm/Support/Threading.h"
 #include "gtest/gtest.h"
 
@@ -19,3 +20,11 @@ TEST(Support, getProcFile_Pid) {
   ASSERT_TRUE(*BufferOrError);
 }
 #endif // #ifndef __APPLE__
+
+#if defined(_AIX) && defined(LLVM_ENABLE_THREADING)
+TEST(Support, getProcFile_Tid) {
+  auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), 
"lwpstatus");
+  ASSERT_TRUE(BufferOrError);
+  ASSERT_TRUE(*BufferOrError);
+}
+#endif // #ifdef _AIX && LLVM_ENABLE_THREADING
diff --git a/llvm/lib/Support/Unix/Threading.inc 
b/llvm/lib/Support/Unix/Threading.inc
index 15a5b008604c3..742660d5bea75 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -142,6 +142,8 @@ uint64_t llvm::get_threadid() {
   return uint64_t(gettid());
 #elif defined(__linux__)
   return uint64_t(syscall(__NR_gettid));
+#elif defined(_AIX)
+  return uint64_t(thread_self());
 #else
   return uint64_t(pthread_self());
 #endif

``




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


[Lldb-commits] [lldb] [lldb/cmake] Implicitly pass arguments to llvm_add_library (PR #142583)

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

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/142583

If we're not touching them, we don't need to do anything special to pass them 
along -- with one important caveat: due to how cmake arguments work, the 
implicitly passed arguments need to be specified before arguments that we 
handle.

This isn't particularly nice, but the alternative is enumerating all arguments 
that can be used by llvm_add_library and the macros it calls (it also relies on 
implicit passing of some arguments to llvm_process_sources).

>From 4b2ffbc059e769255d42dbfa937aa2c27de1a650 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 3 Jun 2025 13:18:53 +0200
Subject: [PATCH] [lldb/cmake] Implicitly pass arguments to llvm_add_library

If we're not touching them, we don't need to do anything special to pass
them along -- with one important caveat: due to how cmake arguments
work, the implicitly passed arguments need to be specified before
arguments that we handle.

This isn't particularly nice, but the alternative is enumerating all
arguments that can be used by llvm_add_library and the macros it calls
(it also relies on implicit passing of some arguments to
llvm_process_sources).
---
 lldb/cmake/modules/AddLLDB.cmake  | 20 +++
 lldb/source/API/CMakeLists.txt|  4 ++--
 lldb/source/Breakpoint/CMakeLists.txt |  5 ++---
 lldb/source/Commands/CMakeLists.txt   |  5 ++---
 lldb/source/Core/CMakeLists.txt   | 12 +--
 lldb/source/DataFormatters/CMakeLists.txt |  5 ++---
 lldb/source/Expression/CMakeLists.txt |  9 -
 lldb/source/Host/CMakeLists.txt   |  7 +++
 lldb/source/Host/macosx/objcxx/CMakeLists.txt |  7 +++
 lldb/source/Initialization/CMakeLists.txt |  4 ++--
 lldb/source/Interpreter/CMakeLists.txt|  5 ++---
 .../Interpreter/Interfaces/CMakeLists.txt |  5 ++---
 .../source/Plugins/ABI/AArch64/CMakeLists.txt |  6 +++---
 lldb/source/Plugins/ABI/ARC/CMakeLists.txt|  6 +++---
 lldb/source/Plugins/ABI/ARM/CMakeLists.txt|  6 +++---
 .../source/Plugins/ABI/Hexagon/CMakeLists.txt |  6 +++---
 .../Plugins/ABI/LoongArch/CMakeLists.txt  |  6 +++---
 lldb/source/Plugins/ABI/MSP430/CMakeLists.txt |  6 +++---
 lldb/source/Plugins/ABI/Mips/CMakeLists.txt   |  6 +++---
 .../source/Plugins/ABI/PowerPC/CMakeLists.txt |  6 +++---
 lldb/source/Plugins/ABI/RISCV/CMakeLists.txt  |  6 +++---
 .../source/Plugins/ABI/SystemZ/CMakeLists.txt |  6 +++---
 lldb/source/Plugins/ABI/X86/CMakeLists.txt|  6 +++---
 .../Architecture/AArch64/CMakeLists.txt   |  4 ++--
 .../Plugins/Architecture/Arm/CMakeLists.txt   |  4 ++--
 .../Plugins/Architecture/Mips/CMakeLists.txt  |  4 ++--
 .../Plugins/Architecture/PPC64/CMakeLists.txt |  4 ++--
 .../Plugins/Disassembler/LLVMC/CMakeLists.txt |  8 
 .../DynamicLoader/MacOSX-DYLD/CMakeLists.txt  |  6 +++---
 .../DynamicLoader/POSIX-DYLD/CMakeLists.txt   |  4 ++--
 .../DynamicLoader/Windows-DYLD/CMakeLists.txt |  6 +++---
 .../DynamicLoader/wasm-DYLD/CMakeLists.txt|  4 ++--
 .../ExpressionParser/Clang/CMakeLists.txt | 14 ++---
 .../Plugins/Instruction/ARM/CMakeLists.txt|  4 ++--
 .../Plugins/Instruction/ARM64/CMakeLists.txt  |  4 ++--
 .../Instruction/LoongArch/CMakeLists.txt  |  4 ++--
 .../Plugins/Instruction/MIPS/CMakeLists.txt   |  8 
 .../Plugins/Instruction/MIPS64/CMakeLists.txt |  8 
 .../Plugins/Instruction/PPC64/CMakeLists.txt  |  4 ++--
 .../Plugins/Instruction/RISCV/CMakeLists.txt  |  4 ++--
 .../MainThreadChecker/CMakeLists.txt  |  4 ++--
 .../UBSan/CMakeLists.txt  |  4 ++--
 .../Plugins/JITLoader/GDB/CMakeLists.txt  |  4 ++--
 .../Plugins/Language/CPlusPlus/CMakeLists.txt |  5 ++---
 .../Language/ClangCommon/CMakeLists.txt   |  4 ++--
 .../ObjC/AppleObjCRuntime/CMakeLists.txt  |  4 ++--
 .../ObjC/GNUstepObjCRuntime/CMakeLists.txt|  4 ++--
 .../BSD-Archive/CMakeLists.txt|  4 ++--
 .../ObjectFile/Breakpad/CMakeLists.txt|  6 +++---
 .../Plugins/ObjectFile/COFF/CMakeLists.txt| 10 +-
 .../Plugins/ObjectFile/ELF/CMakeLists.txt |  8 
 .../Plugins/ObjectFile/JSON/CMakeLists.txt|  6 +++---
 .../Plugins/ObjectFile/Mach-O/CMakeLists.txt  |  4 ++--
 .../ObjectFile/Minidump/CMakeLists.txt|  4 ++--
 .../Plugins/ObjectFile/PDB/CMakeLists.txt |  4 ++--
 .../Plugins/ObjectFile/PECOFF/CMakeLists.txt  |  8 
 .../ObjectFile/Placeholder/CMakeLists.txt |  6 +++---
 .../Plugins/ObjectFile/XCOFF/CMakeLists.txt   |  8 
 .../Plugins/ObjectFile/wasm/CMakeLists.txt|  4 ++--
 .../Plugins/Platform/Android/CMakeLists.txt   |  4 ++--
 .../Plugins/Platform/FreeBSD/CMakeLists.txt   |  5 ++---
 .../Plugins/Platform/MacOSX/CMakeLists.txt|  6 +++---
 .../Platform/MacOSX/objcxx/CMakeLists.txt |  7 +++
 .../Plugins/Platform/QemuUser/CMakeLists.txt  |  4 ++--
 .../Plugins/Platform/Win

[Lldb-commits] [lldb] [lldb/cmake] Implicitly pass arguments to llvm_add_library (PR #142583)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-hexagon

Author: Pavel Labath (labath)


Changes

If we're not touching them, we don't need to do anything special to pass them 
along -- with one important caveat: due to how cmake arguments work, the 
implicitly passed arguments need to be specified before arguments that we 
handle.

This isn't particularly nice, but the alternative is enumerating all arguments 
that can be used by llvm_add_library and the macros it calls (it also relies on 
implicit passing of some arguments to llvm_process_sources).

---

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


128 Files Affected:

- (modified) lldb/cmake/modules/AddLLDB.cmake (+3-17) 
- (modified) lldb/source/API/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Breakpoint/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Commands/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Core/CMakeLists.txt (+6-6) 
- (modified) lldb/source/DataFormatters/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Expression/CMakeLists.txt (+4-5) 
- (modified) lldb/source/Host/CMakeLists.txt (+3-4) 
- (modified) lldb/source/Host/macosx/objcxx/CMakeLists.txt (+3-4) 
- (modified) lldb/source/Initialization/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Interpreter/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Interpreter/Interfaces/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Plugins/ABI/AArch64/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/ARC/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/ARM/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/LoongArch/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/MSP430/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/Mips/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/RISCV/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ABI/X86/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/Architecture/AArch64/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Architecture/Arm/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Architecture/Mips/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Architecture/PPC64/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt 
(+3-3) 
- (modified) lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt 
(+3-3) 
- (modified) lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt (+7-7) 
- (modified) lldb/source/Plugins/Instruction/ARM/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Instruction/ARM64/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Instruction/LoongArch/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Instruction/MIPS/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/Instruction/MIPS64/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/Instruction/PPC64/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Instruction/RISCV/CMakeLists.txt (+2-2) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/CMakeLists.txt 
(+2-2) 
- (modified) lldb/source/Plugins/InstrumentationRuntime/UBSan/CMakeLists.txt 
(+2-2) 
- (modified) lldb/source/Plugins/JITLoader/GDB/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt (+2-3) 
- (modified) lldb/source/Plugins/Language/ClangCommon/CMakeLists.txt (+2-2) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt (+2-2) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/CMakeLists.txt 
(+2-2) 
- (modified) lldb/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt 
(+2-2) 
- (modified) lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ObjectFile/COFF/CMakeLists.txt (+5-5) 
- (modified) lldb/source/Plugins/ObjectFile/ELF/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/ObjectFile/JSON/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/ObjectFile/Placeholder/CMakeLists.txt (+3-3) 
- (modified) lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt (+4-4) 
- (modified) lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt (+2-2) 
- (modified) lldb/source/Plugins/Platform/Android/CMa

[Lldb-commits] [lldb] c48c91a - [lldb][test] XFAIL TestThreadJump.py on older Clang versions

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

Author: Michael Buch
Date: 2025-06-03T12:17:50+01:00
New Revision: c48c91a92e50e7e01ab9befa1ff7f3bc9662ecac

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

LOG: [lldb][test] XFAIL TestThreadJump.py on older Clang versions

Failing on the macOS matrix bot for Clang-15 with the following error:
```
07:16:08  FAIL: LLDB 
(/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501_build/bin/clang-arm64)
 :: test_jump_offset_dwarf (TestThreadJump.ThreadJumpTestCase)
07:16:08  UNSUPPORTED: LLDB 
(/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501_build/bin/clang-arm64)
 :: test_jump_offset_dwo (TestThreadJump.ThreadJumpTestCase) (test case does 
not fall in any category of interest for this run)
07:16:08  Restore dir to: 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/lldb-build/tools/lldb/test
07:16:08  ==
07:16:08  FAIL: test_jump_offset_dsym (TestThreadJump.ThreadJumpTestCase)
07:16:08 Test Thread Jump by negative or positive offset
07:16:08  --
07:16:08  Traceback (most recent call last):
07:16:08File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1804, in test_method
07:16:08  return attrvalue(self)
07:16:08File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/functionalities/thread/jump/TestThreadJump.py",
 line 112, in test_jump_offset
07:16:08  self.expect(f"print {var_2}", substrs=[var_2_value])
07:16:08File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2512, in expect
07:16:08  self.fail(log_msg)
07:16:08  AssertionError: Ran command:
07:16:08  "print var_2"
07:16:08
07:16:08  Got output:
07:16:08  (int) 20
07:16:08
07:16:08  Expecting sub string: "40" (was not found)
```

Added: 


Modified: 
lldb/test/API/functionalities/thread/jump/TestThreadJump.py

Removed: 




diff  --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index d603580ac6f36..715846c10f23f 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -65,6 +65,7 @@ def test(self):
 substrs=["error"],
 )
 
+@expectedFailureAll(compiler="clang", compiler_version=["<", "17.0"])
 def test_jump_offset(self):
 """Test Thread Jump by negative or positive offset"""
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] 05547fc - [lldb][test] XFAIL TestClangModulesDeclLookup on Linux

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

Author: Michael Buch
Date: 2025-06-03T12:20:31+01:00
New Revision: 05547fc3ec803b779beefeb52d21ef76cf00413f

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

LOG: [lldb][test] XFAIL TestClangModulesDeclLookup on Linux

Failing on the Linux bots with:
```
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test:56:15:
 error: CHECK-NEXT: expected string not found in input
  ^
:38:26: note: scanning from here
(lldb) expression foo(50)
 ^
:41:34: note: possible intended match here
(lldb) target modules dump ast --filter foo
 ^
```

Added: 


Modified: 
lldb/test/Shell/Expr/TestClangModulesDeclLookup.test

Removed: 




diff  --git a/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test 
b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
index d4f2b3259772e..38954844075f0 100644
--- a/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
+++ b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
@@ -1,4 +1,5 @@
 # XFAIL: target-windows
+# XFAIL: system-linux
 
 # Test that we can successfully locate decls in Clang modules for C++.
 



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


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Hemang Gadhavi (HemangGadhavi)


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

- Added changes to getProcFile() with threadID with testcase for AIX.
- Added support for AIX to get_threadid() from llvm.
@labath @DhruvSrivastavaX 

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


5 Files Affected:

- (added) lldb/include/lldb/Host/aix/Support.h (+23) 
- (modified) lldb/source/Host/CMakeLists.txt (+1) 
- (added) lldb/source/Host/aix/Support.cpp (+24) 
- (modified) lldb/unittests/Host/posix/SupportTest.cpp (+9) 
- (modified) llvm/lib/Support/Unix/Threading.inc (+2) 


``diff
diff --git a/lldb/include/lldb/Host/aix/Support.h 
b/lldb/include/lldb/Host/aix/Support.h
new file mode 100644
index 0..f02a1904b09fa
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Support.h
@@ -0,0 +1,23 @@
+//===-- Support.h ---*- 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
+//
+//===--===//
+
+#ifndef LLDB_HOST_AIX_SUPPORT_H
+#define LLDB_HOST_AIX_SUPPORT_H
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+
+namespace lldb_private {
+
+llvm::ErrorOr>
+getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_AIX_SUPPORT_H
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 90814b1bed4c8..d19e4edd4cf56 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -142,6 +142,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  aix/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Support.cpp b/lldb/source/Host/aix/Support.cpp
new file mode 100644
index 0..afd975565ff2f
--- /dev/null
+++ b/lldb/source/Host/aix/Support.cpp
@@ -0,0 +1,24 @@
+//===-- Support.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/aix/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+llvm::ErrorOr>
+lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
+  Log *log = GetLog(LLDBLog::Host);
+  std::string File =
+  ("/proc/" + llvm::Twine(pid) + "/lwp/" + llvm::Twine(tid) + "/" + file)
+  .str();
+  auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
+  if (!Ret)
+LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
+  return Ret;
+}
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp 
b/lldb/unittests/Host/posix/SupportTest.cpp
index f3976db755943..e4d7ba89fece6 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/posix/Support.h"
+#include "lldb/Host/aix/Support.h"
 #include "llvm/Support/Threading.h"
 #include "gtest/gtest.h"
 
@@ -19,3 +20,11 @@ TEST(Support, getProcFile_Pid) {
   ASSERT_TRUE(*BufferOrError);
 }
 #endif // #ifndef __APPLE__
+
+#if defined(_AIX) && defined(LLVM_ENABLE_THREADING)
+TEST(Support, getProcFile_Tid) {
+  auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), 
"lwpstatus");
+  ASSERT_TRUE(BufferOrError);
+  ASSERT_TRUE(*BufferOrError);
+}
+#endif // #ifdef _AIX && LLVM_ENABLE_THREADING
diff --git a/llvm/lib/Support/Unix/Threading.inc 
b/llvm/lib/Support/Unix/Threading.inc
index 15a5b008604c3..742660d5bea75 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -142,6 +142,8 @@ uint64_t llvm::get_threadid() {
   return uint64_t(gettid());
 #elif defined(__linux__)
   return uint64_t(syscall(__NR_gettid));
+#elif defined(_AIX)
+  return uint64_t(thread_self());
 #else
   return uint64_t(pthread_self());
 #endif

``




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


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-03 Thread Hemang Gadhavi via lldb-commits

https://github.com/HemangGadhavi created 
https://github.com/llvm/llvm-project/pull/142586

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

- Added changes to getProcFile() with threadID with testcase for AIX.
- Added support for AIX to get_threadid() from llvm.
@labath @DhruvSrivastavaX 

>From f556dd52d71cdc3598cd27ab233e034e6355f539 Mon Sep 17 00:00:00 2001
From: HemangGadhavi 
Date: Tue, 3 Jun 2025 06:00:17 -0500
Subject: [PATCH] [lldb][llvm][AIX] Added support for getProcFile with TID

---
 lldb/include/lldb/Host/aix/Support.h  | 23 ++
 lldb/source/Host/CMakeLists.txt   |  1 +
 lldb/source/Host/aix/Support.cpp  | 24 +++
 lldb/unittests/Host/posix/SupportTest.cpp |  9 +
 llvm/lib/Support/Unix/Threading.inc   |  2 ++
 5 files changed, 59 insertions(+)
 create mode 100644 lldb/include/lldb/Host/aix/Support.h
 create mode 100644 lldb/source/Host/aix/Support.cpp

diff --git a/lldb/include/lldb/Host/aix/Support.h 
b/lldb/include/lldb/Host/aix/Support.h
new file mode 100644
index 0..f02a1904b09fa
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Support.h
@@ -0,0 +1,23 @@
+//===-- Support.h ---*- 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
+//
+//===--===//
+
+#ifndef LLDB_HOST_AIX_SUPPORT_H
+#define LLDB_HOST_AIX_SUPPORT_H
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+
+namespace lldb_private {
+
+llvm::ErrorOr>
+getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_AIX_SUPPORT_H
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 90814b1bed4c8..d19e4edd4cf56 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -142,6 +142,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  aix/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Support.cpp b/lldb/source/Host/aix/Support.cpp
new file mode 100644
index 0..afd975565ff2f
--- /dev/null
+++ b/lldb/source/Host/aix/Support.cpp
@@ -0,0 +1,24 @@
+//===-- Support.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/aix/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+llvm::ErrorOr>
+lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
+  Log *log = GetLog(LLDBLog::Host);
+  std::string File =
+  ("/proc/" + llvm::Twine(pid) + "/lwp/" + llvm::Twine(tid) + "/" + file)
+  .str();
+  auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
+  if (!Ret)
+LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
+  return Ret;
+}
diff --git a/lldb/unittests/Host/posix/SupportTest.cpp 
b/lldb/unittests/Host/posix/SupportTest.cpp
index f3976db755943..e4d7ba89fece6 100644
--- a/lldb/unittests/Host/posix/SupportTest.cpp
+++ b/lldb/unittests/Host/posix/SupportTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Host/posix/Support.h"
+#include "lldb/Host/aix/Support.h"
 #include "llvm/Support/Threading.h"
 #include "gtest/gtest.h"
 
@@ -19,3 +20,11 @@ TEST(Support, getProcFile_Pid) {
   ASSERT_TRUE(*BufferOrError);
 }
 #endif // #ifndef __APPLE__
+
+#if defined(_AIX) && defined(LLVM_ENABLE_THREADING)
+TEST(Support, getProcFile_Tid) {
+  auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), 
"lwpstatus");
+  ASSERT_TRUE(BufferOrError);
+  ASSERT_TRUE(*BufferOrError);
+}
+#endif // #ifdef _AIX && LLVM_ENABLE_THREADING
diff --git a/llvm/lib/Support/Unix/Threading.inc 
b/llvm/lib/Support/Unix/Threading.inc
index 15a5b008604c3..742660d5bea75 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -142,6 +142,8 @@ uint64_t llvm::get_threadid() {
   return uint64_t(gettid());
 #elif defined(__linux__)
   return uint64_t(syscall(__NR_gettid));
+#elif defined(_AIX)
+  return uint64_t(thread_self());
 #else
   return uint64_t(p

[Lldb-commits] [lldb] [lldb-dap] Fix disassembled ranges for `disassemble` request (PR #105446)

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

vogelsgesang wrote:

superseded by #140486

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


[Lldb-commits] [lldb] [lldb-dap] Fix disassembled ranges for `disassemble` request (PR #105446)

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

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


[Lldb-commits] [lldb] 75ec944 - [lldb][test] Disable image dump ast test on Windows

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

Author: David Spickett
Date: 2025-06-03T09:33:24Z
New Revision: 75ec944e38eedfc9357171697bceabe98dd9fadb

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

LOG: [lldb][test] Disable image dump ast test on Windows

Again I think this requires DWARF. In theory we could use the PDB
file but I suspect that PDB file is in fact empty, because we
tell clang to produce DWARF.

So on Windows, first thing is we cannot run the expressions:
(lldb) expr A(); A1(); BA1(); AB();
error: :1:1: 'A' has unknown return type; cast the call to 
its declared return type
1 | A(); A1(); BA1(); AB();
  | ^~~
...and so on...

And then the AST is all unknown functions:
(lldb) image dump ast
Dumping clang ast for 4 modules.
TranslationUnitDecl 0x2b3bb591870 <>  

|-FunctionDecl 0x2b3bb592970 <>  mainCRTStartup 
'unsigned long (void *)'
| `-ParmVarDecl 0x2b3bb592a20 <>  'void *'
`-FunctionDecl 0x2b3bb592ad8 <>  
__scrt_common_main_seh 'int ()' static

So I'm just going to disable this test on Windows, it's pretty
clear why it doesn't work and we have no plans to make it work.

Added: 


Modified: 
lldb/test/Shell/Commands/command-image-dump-ast.test

Removed: 




diff  --git a/lldb/test/Shell/Commands/command-image-dump-ast.test 
b/lldb/test/Shell/Commands/command-image-dump-ast.test
index ca57570ab7224..3204022418cb8 100644
--- a/lldb/test/Shell/Commands/command-image-dump-ast.test
+++ b/lldb/test/Shell/Commands/command-image-dump-ast.test
@@ -1,5 +1,9 @@
 # Test `image dump ast` command.
 
+# DWARF is required to properly create the AST, and on Windows that is 
discarded
+# and we only have PDB which doesn't work for this test.
+# UNSUPPORTED: system-windows
+
 # RUN: split-file %s %t
 # RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
 # RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \



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


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-03 Thread Hemang Gadhavi via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-03 Thread Hemang Gadhavi via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (PR #142573)

2025-06-03 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/142573

See #142196 and https://github.com/llvm/llvm-zorg/pull/452 for details.

>From 7f770486b80d0f927f5e4ad16f5e31a771b2ad0a Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 3 Jun 2025 14:28:58 +0400
Subject: [PATCH] [lldb] Disable TestTargetWatchAddress.py on Windows x86_64

See #142196 and https://github.com/llvm/llvm-zorg/pull/452 for details.
---
 .../watchpoint/watchlocation/TestTargetWatchAddress.py   | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
index 7a0e42a4fc278..37fa911b3714c 100644
--- 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -160,6 +160,11 @@ def test_watch_address(self):
 # No size constraint on MIPS for watches
 @skipIf(archs=["mips", "mipsel", "mips64", "mips64el"])
 @skipIf(archs=["s390x"])  # Likewise on SystemZ
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/142196",
+)
 def test_watch_address_with_invalid_watch_size(self):
 """Exercise SBTarget.WatchpointCreateByAddress() API but pass an 
invalid watch_size."""
 self.build()

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


[Lldb-commits] [lldb] [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (PR #142573)

2025-06-03 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-lldb

@llvm/pr-subscribers-platform-windows

Author: Dmitry Vasilyev (slydiman)


Changes

See #142196 and https://github.com/llvm/llvm-zorg/pull/452 for details.

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


1 Files Affected:

- (modified) 
lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py 
(+5) 


``diff
diff --git 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
index 7a0e42a4fc278..37fa911b3714c 100644
--- 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -160,6 +160,11 @@ def test_watch_address(self):
 # No size constraint on MIPS for watches
 @skipIf(archs=["mips", "mipsel", "mips64", "mips64el"])
 @skipIf(archs=["s390x"])  # Likewise on SystemZ
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/142196",
+)
 def test_watch_address_with_invalid_watch_size(self):
 """Exercise SBTarget.WatchpointCreateByAddress() API but pass an 
invalid watch_size."""
 self.build()

``




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


[Lldb-commits] [lldb] 3ddc1e1 - [lldb][test] XFAIL TestClangModulesDeclLookup.test on win-remote-linux

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

Author: Michael Buch
Date: 2025-06-03T13:16:03+01:00
New Revision: 3ddc1e1cf397bd495f5aa42b04630561a9e6bf47

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

LOG: [lldb][test] XFAIL TestClangModulesDeclLookup.test on win-remote-linux

Failing on the `lldb-remote-linux-win` buildbot with:
```
| (lldb) expression foo(50)
|  ^
| :54:34: note: possible intended match here
| (lldb) target modules dump ast --filter foo
|  ^
|
| Input file: 
| Check file: 
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\test\Shell\Expr\TestClangModulesDeclLookup.test
|
| -dump-input=help explains the following input dump.
|
| Input was:
| <<
|.
|.
|.
|   46:  5 foo(10);
|   47: -> 6 return 0;
|   48:  ^
|   49:  7 }
|   50:  8
|   51: (lldb) expression foo(50)
| next:57'0  X error: no match found
|   52:  ^~
| next:57'0 
|   53:  error: 'foo' has unknown return type; cast the call to its 
declared return type
| next:57'0 
~
|   54: (lldb) target modules dump ast --filter foo
| next:57'0 
| next:57'1  ?   possible intended 
match
|   55: Dumping clang ast for 4 modules.
| next:57'0 ~
| >>
`-
error: command failed with exit status: 1
```

Fixes https://github.com/llvm/llvm-project/issues/142590

Added: 


Modified: 
lldb/test/Shell/Expr/TestClangModulesDeclLookup.test

Removed: 




diff  --git a/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test 
b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
index 38954844075f0..a5eb4d626e524 100644
--- a/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
+++ b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
@@ -1,5 +1,6 @@
 # XFAIL: target-windows
 # XFAIL: system-linux
+# XFAIL: system-windows && remote-linux
 
 # Test that we can successfully locate decls in Clang modules for C++.
 



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


[Lldb-commits] [lldb] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (PR #142587)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Replace (questionable) header globs with an explicit argument supported by 
llvm_add_library.

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


17 Files Affected:

- (modified) lldb/CMakeLists.txt (+2) 
- (modified) lldb/cmake/modules/AddLLDB.cmake (+1-7) 
- (modified) lldb/source/API/CMakeLists.txt (+2) 
- (modified) lldb/source/Breakpoint/CMakeLists.txt (+2) 
- (modified) lldb/source/Core/CMakeLists.txt (+3-1) 
- (modified) lldb/source/DataFormatters/CMakeLists.txt (+2) 
- (modified) lldb/source/Expression/CMakeLists.txt (+3-2) 
- (modified) lldb/source/Host/CMakeLists.txt (+2) 
- (modified) lldb/source/Host/macosx/objcxx/CMakeLists.txt (+2) 
- (modified) lldb/source/Initialization/CMakeLists.txt (+2) 
- (modified) lldb/source/Interpreter/CMakeLists.txt (+2) 
- (modified) lldb/source/Interpreter/Interfaces/CMakeLists.txt (+2) 
- (modified) lldb/source/Symbol/CMakeLists.txt (+2) 
- (modified) lldb/source/Target/CMakeLists.txt (+2) 
- (modified) lldb/source/Utility/CMakeLists.txt (+2) 
- (modified) lldb/source/ValueObject/CMakeLists.txt (+2-1) 
- (modified) lldb/source/Version/CMakeLists.txt (+7-8) 


``diff
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 85ba4fde17418..2aaf75dd87bc3 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -38,6 +38,8 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 # Define the LLDB_CONFIGURATION_xxx matching the build type.
 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions(-DLLDB_CONFIGURATION_DEBUG)
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 3a9dcb79629b4..de9243b921745 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -71,12 +71,6 @@ function(add_lldb_library name)
 set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
   endif()
 
-  if (MSVC_IDE OR XCODE)
-string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
-list(GET split_path -1 dir)
-file(GLOB_RECURSE headers
-  ../../include/lldb${dir}/*.h)
-  endif()
   if (PARAM_MODULE)
 set(libkind MODULE)
   elseif (PARAM_SHARED)
@@ -99,7 +93,7 @@ function(add_lldb_library name)
 set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
   endif()
 
-  llvm_add_library(${name} ${libkind} ${headers}
+  llvm_add_library(${name} ${libkind}
 ${PARAM_UNPARSED_ARGUMENTS}
 LINK_LIBS ${PARAM_LINK_LIBS}
 DEPENDS ${PARAM_DEPENDS}
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3bc569608e458..bddcf2f9922d0 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -125,6 +125,8 @@ add_lldb_library(liblldb SHARED ${option_framework}
   ${lldb_python_wrapper}
   ${lldb_lua_wrapper}
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/API
   DEPENDS
 lldb-sbapi-dwarf-enums
 
diff --git a/lldb/source/Breakpoint/CMakeLists.txt 
b/lldb/source/Breakpoint/CMakeLists.txt
index 6cd3c396a2c50..8ef3705750634 100644
--- a/lldb/source/Breakpoint/CMakeLists.txt
+++ b/lldb/source/Breakpoint/CMakeLists.txt
@@ -26,6 +26,8 @@ add_lldb_library(lldbBreakpoint NO_PLUGIN_DEPENDENCIES
   WatchpointOptions.cpp
   WatchpointResource.cpp
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/Breakpoint
   LINK_LIBS
 lldbCore
 lldbExpression
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index c4c442dcb2043..c95c40fb89eef 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -57,9 +57,11 @@ add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
   ThreadedCommunication.cpp
   UserSettingsController.cpp
   Value.cpp
+
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/Core
   DEPENDS
 clang-tablegen-targets
-
   LINK_LIBS
 lldbBreakpoint
 lldbDataFormatters
diff --git a/lldb/source/DataFormatters/CMakeLists.txt 
b/lldb/source/DataFormatters/CMakeLists.txt
index 91b10ba9e0ac8..e2bc5b40d72c0 100644
--- a/lldb/source/DataFormatters/CMakeLists.txt
+++ b/lldb/source/DataFormatters/CMakeLists.txt
@@ -18,6 +18,8 @@ add_lldb_library(lldbDataFormatters NO_PLUGIN_DEPENDENCIES
   ValueObjectPrinter.cpp
   VectorType.cpp
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/DataFormatters
   LINK_LIBS
 lldbCore
 lldbInterpreter
diff --git a/lldb/source/Expression/CMakeLists.txt 
b/lldb/source/Expression/CMakeLists.txt
index 9e1c341947e9d..3a18a83b9a5cd 100644
--- a/lldb/source/Expression/CMakeLists.txt
+++ b/lldb/source/Expression/CMakeLists.txt
@@ -17,9 +17,10 @@ add_lldb_library(lldbExpression NO_PLUGIN_DEPENDENCIES
   UserExpression.cpp
   UtilityFunction.cpp
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/Expression
   DEPENDS
-  intrinsics_gen
-
+intrinsics_gen
   LINK_LIBS
 lldbCore
 lldbHost
diff --git a/lldb/source/Host/CMakeLists.txt b/ll

[Lldb-commits] [lldb] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (PR #142587)

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

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/142587

Replace (questionable) header globs with an explicit argument supported by 
llvm_add_library.

>From 450e714d9eb1a6f15a6b6065cf0c60f120948f65 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 3 Jun 2025 13:45:04 +0200
Subject: [PATCH] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S

Replace (questionable) header globs with an explicit argument supported
by llvm_add_library.
---
 lldb/CMakeLists.txt   |  2 ++
 lldb/cmake/modules/AddLLDB.cmake  |  8 +---
 lldb/source/API/CMakeLists.txt|  2 ++
 lldb/source/Breakpoint/CMakeLists.txt |  2 ++
 lldb/source/Core/CMakeLists.txt   |  4 +++-
 lldb/source/DataFormatters/CMakeLists.txt |  2 ++
 lldb/source/Expression/CMakeLists.txt |  5 +++--
 lldb/source/Host/CMakeLists.txt   |  2 ++
 lldb/source/Host/macosx/objcxx/CMakeLists.txt |  2 ++
 lldb/source/Initialization/CMakeLists.txt |  2 ++
 lldb/source/Interpreter/CMakeLists.txt|  2 ++
 lldb/source/Interpreter/Interfaces/CMakeLists.txt |  2 ++
 lldb/source/Symbol/CMakeLists.txt |  2 ++
 lldb/source/Target/CMakeLists.txt |  2 ++
 lldb/source/Utility/CMakeLists.txt|  2 ++
 lldb/source/ValueObject/CMakeLists.txt|  3 ++-
 lldb/source/Version/CMakeLists.txt| 15 +++
 17 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 85ba4fde17418..2aaf75dd87bc3 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -38,6 +38,8 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 # Define the LLDB_CONFIGURATION_xxx matching the build type.
 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions(-DLLDB_CONFIGURATION_DEBUG)
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 3a9dcb79629b4..de9243b921745 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -71,12 +71,6 @@ function(add_lldb_library name)
 set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
   endif()
 
-  if (MSVC_IDE OR XCODE)
-string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
-list(GET split_path -1 dir)
-file(GLOB_RECURSE headers
-  ../../include/lldb${dir}/*.h)
-  endif()
   if (PARAM_MODULE)
 set(libkind MODULE)
   elseif (PARAM_SHARED)
@@ -99,7 +93,7 @@ function(add_lldb_library name)
 set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
   endif()
 
-  llvm_add_library(${name} ${libkind} ${headers}
+  llvm_add_library(${name} ${libkind}
 ${PARAM_UNPARSED_ARGUMENTS}
 LINK_LIBS ${PARAM_LINK_LIBS}
 DEPENDS ${PARAM_DEPENDS}
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3bc569608e458..bddcf2f9922d0 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -125,6 +125,8 @@ add_lldb_library(liblldb SHARED ${option_framework}
   ${lldb_python_wrapper}
   ${lldb_lua_wrapper}
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/API
   DEPENDS
 lldb-sbapi-dwarf-enums
 
diff --git a/lldb/source/Breakpoint/CMakeLists.txt 
b/lldb/source/Breakpoint/CMakeLists.txt
index 6cd3c396a2c50..8ef3705750634 100644
--- a/lldb/source/Breakpoint/CMakeLists.txt
+++ b/lldb/source/Breakpoint/CMakeLists.txt
@@ -26,6 +26,8 @@ add_lldb_library(lldbBreakpoint NO_PLUGIN_DEPENDENCIES
   WatchpointOptions.cpp
   WatchpointResource.cpp
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/Breakpoint
   LINK_LIBS
 lldbCore
 lldbExpression
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index c4c442dcb2043..c95c40fb89eef 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -57,9 +57,11 @@ add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
   ThreadedCommunication.cpp
   UserSettingsController.cpp
   Value.cpp
+
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/Core
   DEPENDS
 clang-tablegen-targets
-
   LINK_LIBS
 lldbBreakpoint
 lldbDataFormatters
diff --git a/lldb/source/DataFormatters/CMakeLists.txt 
b/lldb/source/DataFormatters/CMakeLists.txt
index 91b10ba9e0ac8..e2bc5b40d72c0 100644
--- a/lldb/source/DataFormatters/CMakeLists.txt
+++ b/lldb/source/DataFormatters/CMakeLists.txt
@@ -18,6 +18,8 @@ add_lldb_library(lldbDataFormatters NO_PLUGIN_DEPENDENCIES
   ValueObjectPrinter.cpp
   VectorType.cpp
 
+  ADDITIONAL_HEADER_DIRS
+${LLDB_INCLUDE_DIR}/lldb/DataFormatters
   LINK_LIBS
 lldbCore
 lldbInterpreter
diff --git a/lldb/source/Expression/CMakeLists.txt 
b/lldb/source/Expression/CMakeLists.txt
index 9e1c341947e9d..3a18a83b9a5cd 100644
--- a/lldb/source/Expression/CMakeLists.txt
+++ b/lldb/source/Expression/CMakeLists.txt
@@ -17,9 +17,10 @@ add_

[Lldb-commits] [lldb] 9c52b17 - [lldb][test] Add test for looking up decls in Clang modules for C++

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

Author: Michael Buch
Date: 2025-06-03T12:10:15+01:00
New Revision: 9c52b177ea27778e904908c974e8113ed637dd69

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

LOG: [lldb][test] Add test for looking up decls in Clang modules for C++

Adds coverage for the code-path where
`ClangExpressionDeclMap::FindExternalVisibleDecls` finds a decl inside
of a Clang module (without explicitly having to import the module on the
LLDB CLI). AFAICT, we had not tests for this.

`LookupFunction` will try to find a `FunctionDecl` in debug-info. But if
no debug-info exists, it will ask the `ClangModulesDeclVendor` to search
for the function with the specified name in any of the Clang modules
that got added to it in `SetupDeclVendor`.

Added: 
lldb/test/Shell/Expr/TestClangModulesDeclLookup.test

Modified: 


Removed: 




diff  --git a/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test 
b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
new file mode 100644
index 0..d4f2b3259772e
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestClangModulesDeclLookup.test
@@ -0,0 +1,60 @@
+# XFAIL: target-windows
+
+# Test that we can successfully locate decls in Clang modules for C++.
+
+# RUN: split-file %s %t
+# RUN: %clang_host -g -gdwarf %t/main.cpp -fmodules -fcxx-modules -o %t.out
+# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
+# RUN:   -x -b -s %t/commands.input %t.out 2>&1 \
+# RUN:   | FileCheck %s
+
+#--- main.cpp
+
+#include "Module.h"
+
+int main() {
+  foo(10);
+  return 0;
+}
+
+#--- module.modulemap
+
+module Module {
+  header "Module.h"
+  export *
+}
+
+#--- Module.h
+
+// We use nodebug here ensures that LLDB tries to pick the decl out of the 
module.
+// If debug-info is available, it would use that to construct the decl instead.
+[[gnu::nodebug]] int foo(int x) { return x; }
+
+int bar(int x, int y) { return x + y; }
+
+#--- commands.input
+
+breakpoint set -n foo
+run
+
+expression foo(5)
+
+# FIXME: when we're stopped in a frame without debug-info, the 
ClangModulesDeclVendor
+# is initialized properly and none of the modules in the CU are compiled (and 
lookup
+# in the DeclVendor is not enabled).
+# CHECK: expression foo(5)
+# CHECK: error: 'foo' has unknown return type; cast the call to its declared 
return type
+
+breakpoint set -p return -X main
+continue
+expression foo(50)
+
+# However, once we're back in a frame with debug-info, the 
ClangModulesDeclVendor infrastructure
+# is back on track.
+
+# CHECK:  expression foo(50)
+# CHECK-NEXT: (int) $0 = 5
+
+target modules dump ast --filter foo
+# CHECK: (lldb) target modules dump ast --filter foo
+# CHECK-NOT: foo



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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  uint64_t id = std::numeric_limits::max();

da-viper wrote:

I changed it to `LLDB_INVALID_ADDRESS` as that is what we are storing

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};

da-viper wrote:

i updated it with the new dynamic capability

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 28 May 2025 14:02:01 +0100
Subject: [PATCH 1/2] [lldb-dap] Use structured types for stepInTargets request

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  16 +-
 .../Handler/StepInTargetsRequestHandler.cpp   | 200 +++---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|   9 +
 .../lldb-dap/Protocol/ProtocolRequests.h  |  15 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  29 +++
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  20 ++
 7 files changed, 186 insertions(+), 130 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr, 

[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 28 May 2025 14:02:01 +0100
Subject: [PATCH 1/3] [lldb-dap] Use structured types for stepInTargets request

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  16 +-
 .../Handler/StepInTargetsRequestHandler.cpp   | 200 +++---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|   9 +
 .../lldb-dap/Protocol/ProtocolRequests.h  |  15 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  29 +++
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  20 ++
 7 files changed, 186 insertions(+), 130 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr, 

[Lldb-commits] [lldb] [lldb-dap] Correct the disconnect helper on server shutdown. (PR #142508)

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

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


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


[Lldb-commits] [lldb] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (PR #142620)

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

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

None

>From bd2788fb6c4ba71c400d615f723d9f8e9522450c Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 3 Jun 2025 15:51:40 +0100
Subject: [PATCH] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters
 by llvm::ArrayRef

---
 .../Clang/ClangExpressionDeclMap.cpp  |  4 +--
 .../Clang/ClangPersistentVariables.cpp|  8 +++---
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  3 ++-
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp  |  7 +++--
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  4 +--
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 17 +---
 .../TypeSystem/Clang/TypeSystemClang.h|  6 ++---
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 27 ---
 10 files changed, 40 insertions(+), 50 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index fec8d29248c20..9f77fbc1d2434 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1978,10 +1978,10 @@ void 
ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
   copied_clang_type.GetCompleteType()) {
 CompilerType void_clang_type =
 m_clang_ast_context->GetBasicType(eBasicTypeVoid);
-CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
+std::array args{void_clang_type.GetPointerType()};
 
 CompilerType method_type = m_clang_ast_context->CreateFunctionType(
-void_clang_type, &void_ptr_clang_type, 1, false, 0);
+void_clang_type, args, false, 0);
 
 const bool is_virtual = false;
 const bool is_static = false;
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index aa0e6e37d63e0..885af26aa35f8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -117,10 +117,10 @@ ClangPersistentVariables::GetClangASTImporter() {
 
 std::shared_ptr
 ClangPersistentVariables::GetClangModulesDeclVendor() {
-  if (!m_modules_decl_vendor_sp) {
-m_modules_decl_vendor_sp.reset(
-ClangModulesDeclVendor::Create(*m_target_sp));
-  }
+  // if (!m_modules_decl_vendor_sp) {
+  //   m_modules_decl_vendor_sp.reset(
+  //   ClangModulesDeclVendor::Create(*m_target_sp));
+  // }
   return m_modules_decl_vendor_sp;
 }
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 87c37e576fad0..9d84af4a85384 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -150,8 +150,9 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
   CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  std::array args{void_type};
   CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
+  /*result_type=*/void_type, args,
   /*is_variadic=*/false, /*qualifiers=*/0);
   CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
   m_resume_ptr_sp = CreateValueObjectFromAddress(
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index c0b931f5c131a..f4d032388a883 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction 
&ctf_function) {
 llvm::inconvertibleErrorCode());
 
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  ctf_function.variadic, 0, clang::CallingConv::CC_C);
+  ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
+  clang::CallingConv::CC_C);
 
   Declaration decl;
   return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
-  arg_types.data(), arg_types.size(), is_variadic, 0,
-  clang::CallingConv::CC_C);
+  arg_types, is_variadic, 0, clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_typ

[Lldb-commits] [lldb] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (PR #142620)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes



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


10 Files Affected:

- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+2-2) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp (+4-4) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp (+2-1) 
- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+3-4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+4-5) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp (+2-2) 
- (modified) lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (+2-3) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+7-10) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+3-3) 
- (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+11-16) 


``diff
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index fec8d29248c20..9f77fbc1d2434 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1978,10 +1978,10 @@ void 
ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
   copied_clang_type.GetCompleteType()) {
 CompilerType void_clang_type =
 m_clang_ast_context->GetBasicType(eBasicTypeVoid);
-CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
+std::array args{void_clang_type.GetPointerType()};
 
 CompilerType method_type = m_clang_ast_context->CreateFunctionType(
-void_clang_type, &void_ptr_clang_type, 1, false, 0);
+void_clang_type, args, false, 0);
 
 const bool is_virtual = false;
 const bool is_static = false;
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index aa0e6e37d63e0..885af26aa35f8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -117,10 +117,10 @@ ClangPersistentVariables::GetClangASTImporter() {
 
 std::shared_ptr
 ClangPersistentVariables::GetClangModulesDeclVendor() {
-  if (!m_modules_decl_vendor_sp) {
-m_modules_decl_vendor_sp.reset(
-ClangModulesDeclVendor::Create(*m_target_sp));
-  }
+  // if (!m_modules_decl_vendor_sp) {
+  //   m_modules_decl_vendor_sp.reset(
+  //   ClangModulesDeclVendor::Create(*m_target_sp));
+  // }
   return m_modules_decl_vendor_sp;
 }
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 87c37e576fad0..9d84af4a85384 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -150,8 +150,9 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
   CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  std::array args{void_type};
   CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
+  /*result_type=*/void_type, args,
   /*is_variadic=*/false, /*qualifiers=*/0);
   CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
   m_resume_ptr_sp = CreateValueObjectFromAddress(
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index c0b931f5c131a..f4d032388a883 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction 
&ctf_function) {
 llvm::inconvertibleErrorCode());
 
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  ctf_function.variadic, 0, clang::CallingConv::CC_C);
+  ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
+  clang::CallingConv::CC_C);
 
   Declaration decl;
   return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
-  arg_types.data(), arg_types.size(), is_variadic, 0,
-  clang::CallingConv::CC_C);
+  arg_types, is_variadic, 0, clang::CallingConv::CC_C);
   lldb::user_id_t functio

[Lldb-commits] [lldb] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (PR #142620)

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

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

>From f69c768795f647d97b85bce5416b2302eb6b5a6d Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 3 Jun 2025 15:51:40 +0100
Subject: [PATCH] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters
 by llvm::ArrayRef

---
 .../Clang/ClangExpressionDeclMap.cpp  |  4 +--
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  3 ++-
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp  |  7 +++--
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  4 +--
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 17 +---
 .../TypeSystem/Clang/TypeSystemClang.h|  6 ++---
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 27 ---
 9 files changed, 36 insertions(+), 46 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index fec8d29248c20..9f77fbc1d2434 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1978,10 +1978,10 @@ void 
ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
   copied_clang_type.GetCompleteType()) {
 CompilerType void_clang_type =
 m_clang_ast_context->GetBasicType(eBasicTypeVoid);
-CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
+std::array args{void_clang_type.GetPointerType()};
 
 CompilerType method_type = m_clang_ast_context->CreateFunctionType(
-void_clang_type, &void_ptr_clang_type, 1, false, 0);
+void_clang_type, args, false, 0);
 
 const bool is_virtual = false;
 const bool is_static = false;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 87c37e576fad0..9d84af4a85384 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -150,8 +150,9 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
   CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  std::array args{void_type};
   CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
+  /*result_type=*/void_type, args,
   /*is_variadic=*/false, /*qualifiers=*/0);
   CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
   m_resume_ptr_sp = CreateValueObjectFromAddress(
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index c0b931f5c131a..f4d032388a883 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction 
&ctf_function) {
 llvm::inconvertibleErrorCode());
 
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  ctf_function.variadic, 0, clang::CallingConv::CC_C);
+  ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
+  clang::CallingConv::CC_C);
 
   Declaration decl;
   return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
-  arg_types.data(), arg_types.size(), is_variadic, 0,
-  clang::CallingConv::CC_C);
+  arg_types, is_variadic, 0, clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0c26c276cc530..620501b304e63 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1309,11 +1309,10 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE 
&die,
 
   // clang_type will get the function prototype clang type after this
   // call
-  CompilerType clang_type =
-  m_ast.CreateFunctionType(return_clang_type, function_param_types.data(),
-   function_param_types.size(), is_variadic,
-   GetCXXMethodCVQuals(die, object_parameter),
-   calling_conve

[Lldb-commits] [lldb] [lldb] switch to CalculateNumChildren where possible (PR #142607)

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

https://github.com/Michael137 commented:

My original idea was that we can just call `CalculateNumChildren` and bubble up 
that error when something goes wrong. But if we're just going to consume it 
anyway, then keeping them as `CalculateNumChildrenIgnoringErrors` seems fine 
(though I would still prefer bubbling up errors, but that brings us back to the 
discussion about how we should be using `llvm::Expected`). CC @adrian-prantl 
@felipepiovezan 

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


[Lldb-commits] [lldb] [lldb] switch to CalculateNumChildren where possible (PR #142607)

2025-06-03 Thread Charles Zablit via lldb-commits

charles-zablit wrote:

> But if we're just going to consume it anyway, then keeping them as 
> `CalculateNumChildrenIgnoringErrors` seems fine (though I would still prefer 
> bubbling up errors, but that brings us back to the discussion about how we 
> should be using `llvm::Expected`)

Agreed, the current changes just feel like moving the logic out of 
`CalculateNumChildrenIgnoringErrors`.

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

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

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/141516

>From 06a2754bfbd434b6a957c6b252be15aac2bf8173 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   6 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 144 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 +++---
 5 files changed, 101 insertions(+), 101 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..33af0ad63077f 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
-  ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+CompilerType type, bool do_deref) {
+  ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(
+  name, address, exe_ctx, type, do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index d3cdb231fbb01..220aa7936af92 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,8 +11,6 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -62,19 +60,23 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
-  Block &block = destroy_func.GetBlock(true);
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function *destroy_func,
+ConstString var_name) {
+  if (!destroy_func)
+return {};
+
+  Block &block = destroy_func->GetBlock(true);
   auto variable_list = block.GetBlockVariableList(true);
 
-  // clang generates an artificial `__promise` variable inside the
-  // `destroy` function. Look for it.
-  auto promise_var = variable_list->FindVariable(ConstString("__promise"));
-  if (!promise_var)
+  auto var = variable_list->FindVariable(var_name);
+  if (!var)
 return {};
-  if (!promise_var->IsArtificial())
+  if (!var->IsArtificial())
 return {};
 
-  Type *promise_type = promise_var->GetType();
+  Type *promise_type = var->GetType();
   if (!promise_type)
 return {};
   return promise_type->GetForwardCompilerType();
@@ -108,30 +110,17 @@ 
lldb_private::formatters::StdlibCoroutineHand

[Lldb-commits] [lldb] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (PR #142620)

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

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

>From f69c768795f647d97b85bce5416b2302eb6b5a6d Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 3 Jun 2025 15:51:40 +0100
Subject: [PATCH 1/2] [lldb][TypeSystem][NFC] CreateFunctionType to take
 parameters by llvm::ArrayRef

---
 .../Clang/ClangExpressionDeclMap.cpp  |  4 +--
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  3 ++-
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp  |  7 +++--
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  4 +--
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 17 +---
 .../TypeSystem/Clang/TypeSystemClang.h|  6 ++---
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 27 ---
 9 files changed, 36 insertions(+), 46 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index fec8d29248c20..9f77fbc1d2434 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1978,10 +1978,10 @@ void 
ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
   copied_clang_type.GetCompleteType()) {
 CompilerType void_clang_type =
 m_clang_ast_context->GetBasicType(eBasicTypeVoid);
-CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
+std::array args{void_clang_type.GetPointerType()};
 
 CompilerType method_type = m_clang_ast_context->CreateFunctionType(
-void_clang_type, &void_ptr_clang_type, 1, false, 0);
+void_clang_type, args, false, 0);
 
 const bool is_virtual = false;
 const bool is_static = false;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 87c37e576fad0..9d84af4a85384 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -150,8 +150,9 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
   CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  std::array args{void_type};
   CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
+  /*result_type=*/void_type, args,
   /*is_variadic=*/false, /*qualifiers=*/0);
   CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
   m_resume_ptr_sp = CreateValueObjectFromAddress(
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index c0b931f5c131a..f4d032388a883 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction 
&ctf_function) {
 llvm::inconvertibleErrorCode());
 
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  ctf_function.variadic, 0, clang::CallingConv::CC_C);
+  ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
+  clang::CallingConv::CC_C);
 
   Declaration decl;
   return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
-  arg_types.data(), arg_types.size(), is_variadic, 0,
-  clang::CallingConv::CC_C);
+  arg_types, is_variadic, 0, clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0c26c276cc530..620501b304e63 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1309,11 +1309,10 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE 
&die,
 
   // clang_type will get the function prototype clang type after this
   // call
-  CompilerType clang_type =
-  m_ast.CreateFunctionType(return_clang_type, function_param_types.data(),
-   function_param_types.size(), is_variadic,
-   GetCXXMethodCVQuals(die, object_parameter),
-   calling_c

[Lldb-commits] [lldb] a90145e - [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (#142573)

2025-06-03 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2025-06-03T20:18:16+04:00
New Revision: a90145e0282fb9eef0ad9ff61f505aff4e30c01d

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

LOG: [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (#142573)

See #142196 and https://github.com/llvm/llvm-zorg/pull/452 for details.

Added: 


Modified: 
lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
index 7a0e42a4fc278..37fa911b3714c 100644
--- 
a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ 
b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -160,6 +160,11 @@ def test_watch_address(self):
 # No size constraint on MIPS for watches
 @skipIf(archs=["mips", "mipsel", "mips64", "mips64el"])
 @skipIf(archs=["s390x"])  # Likewise on SystemZ
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/142196",
+)
 def test_watch_address_with_invalid_watch_size(self):
 """Exercise SBTarget.WatchpointCreateByAddress() API but pass an 
invalid watch_size."""
 self.build()



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


[Lldb-commits] [lldb] [lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (PR #142573)

2025-06-03 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] a903271 - [lldb] Emit an error when using --wait-for without a name or pid (#142424)

2025-06-03 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-06-03T09:19:50-07:00
New Revision: a9032712c453bda70449dedcaf00bead0fea6e88

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

LOG: [lldb] Emit an error when using --wait-for without a name or pid (#142424)

Emit an error when using --wait-for without a name and correct the help
output to specify a name must be provided, rather than a name or PID.

Motivated by
https://discourse.llvm.org/t/why-is-wait-for-not-attaching/86636

Added: 
lldb/test/Shell/Driver/TestWaitFor.test

Modified: 
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Options.td

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestWaitFor.test 
b/lldb/test/Shell/Driver/TestWaitFor.test
new file mode 100644
index 0..dde8e747713ad
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestWaitFor.test
@@ -0,0 +1,2 @@
+# RUN: not %lldb --wait-for 2>&1 | FileCheck %s
+# CHECK: error: --wait-for requires a name (--attach-name)

diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index e19fded051941..16cc736441b59 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name)) {
+  error.SetErrorStringWithFormat(
+  "--wait-for requires a name (--attach-name)");
+  return error;
+}
+
 m_option_data.m_wait_for = true;
   }
 

diff  --git a/lldb/tools/driver/Options.td b/lldb/tools/driver/Options.td
index a24fb3826b909..1d8372c4aa404 100644
--- a/lldb/tools/driver/Options.td
+++ b/lldb/tools/driver/Options.td
@@ -19,9 +19,11 @@ def: Separate<["-"], "n">,
   HelpText<"Alias for --attach-name">,
   Group;
 
-def wait_for: F<"wait-for">,
-  HelpText<"Tells the debugger to wait for a process with the given pid or 
name to launch before attaching.">,
-  Group;
+def wait_for
+: F<"wait-for">,
+  HelpText<"Tells the debugger to wait for the process with the name "
+   "specified by --attach-name to launch before attaching.">,
+  Group;
 def: Flag<["-"], "w">,
   Alias,
   HelpText<"Alias for --wait-for">,



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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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

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


[Lldb-commits] [lldb] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (PR #142587)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -33,6 +33,23 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) 
{
   dap.SendJSON(llvm::json::Value(std::move(event)));
 }
 
+void SendAdditionalCapabilities(DAP &dap) {
+  if (dap.target.IsValid()) {
+// FIXME: stepInTargets request is only supported by the x86 architecture
+// remove when `lldb::InstructionControlFlowKind` is supported by other
+// architectures
+const llvm::StringRef target_triple = dap.target.GetTriple();
+if (!target_triple.starts_with("x86")) {
+  llvm::json::Object event(CreateEventObject("capabilities"));

ashgti wrote:

You could use `protocol::Event event;`

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


[Lldb-commits] [lldb] [lldb/cmake] Implicitly pass arguments to llvm_add_library (PR #142583)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -33,6 +33,23 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) 
{
   dap.SendJSON(llvm::json::Value(std::move(event)));
 }
 
+void SendAdditionalCapabilities(DAP &dap) {

da-viper wrote:

Will update was struggling to think of a good name.

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


[Lldb-commits] [lldb] 20ca895 - [lldb] Add Python properties to SBBreakpoint and similar (#142215)

2025-06-03 Thread via lldb-commits

Author: Dave Lee
Date: 2025-06-03T09:38:22-07:00
New Revision: 20ca8958604dc26d5b480cf9109b861d05341ac8

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

LOG: [lldb] Add Python properties to SBBreakpoint and similar (#142215)

Update `SBBreakpoint`, `SBBreakpointLocation`, and `SBBreakpointName` to
add Python properties for many of their getters/setters.

Added: 


Modified: 
lldb/bindings/interface/SBBreakpointExtensions.i
lldb/bindings/interface/SBBreakpointLocationExtensions.i
lldb/bindings/interface/SBBreakpointNameExtensions.i

lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py

lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py

Removed: 




diff  --git a/lldb/bindings/interface/SBBreakpointExtensions.i 
b/lldb/bindings/interface/SBBreakpointExtensions.i
index 6bc781a327778..82fc3ab0e7c04 100644
--- a/lldb/bindings/interface/SBBreakpointExtensions.i
+++ b/lldb/bindings/interface/SBBreakpointExtensions.i
@@ -50,6 +50,15 @@ STRING_EXTENSION_OUTSIDE(SBBreakpoint)
 enabled = property(IsEnabled, SetEnabled, doc='''A read/write property 
that configures whether this breakpoint is enabled or not.''')
 one_shot = property(IsOneShot, SetOneShot, doc='''A read/write 
property that configures whether this breakpoint is one-shot (deleted when hit) 
or not.''')
 num_locations = property(GetNumLocations, None, doc='''A read only 
property that returns the count of locations of this breakpoint.''')
+auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A 
read/write property that configures the auto-continue property of this 
breakpoint.')
+condition = property(GetCondition, SetCondition, doc='A read/write 
property that configures the condition of this breakpoint.')
+hit_count = property(GetHitCount, doc='A read only property that 
returns the hit count of this breakpoint.')
+ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A 
read/write property that configures the ignore count of this breakpoint.')
+queue_name = property(GetQueueName, SetQueueName, doc='A read/write 
property that configures the queue name criteria of this breakpoint.')
+target = property(GetTarget, doc='A read only property that returns 
the target of this breakpoint.')
+thread_id = property(GetThreadID, SetThreadID, doc='A read/write 
property that configures the thread id criteria of this breakpoint.')
+thread_index = property(GetThreadIndex, SetThreadIndex, doc='A 
read/write property that configures the thread index criteria of this 
breakpoint.')
+thread_name = property(GetThreadName, SetThreadName, doc='A read/write 
property that configures the thread name criteria of this breakpoint.')
 %}
 #endif
 }

diff  --git a/lldb/bindings/interface/SBBreakpointLocationExtensions.i 
b/lldb/bindings/interface/SBBreakpointLocationExtensions.i
index 40027790a5e8d..12c87eb2c0fe6 100644
--- a/lldb/bindings/interface/SBBreakpointLocationExtensions.i
+++ b/lldb/bindings/interface/SBBreakpointLocationExtensions.i
@@ -7,6 +7,19 @@ STRING_EXTENSION_LEVEL_OUTSIDE(SBBreakpointLocation, 
lldb::eDescriptionLevelFull
 # our own equality operator here
 def __eq__(self, other):
   return not self.__ne__(other)
+
+addr = property(GetAddress, doc='A read only property that returns the 
address of this breakpoint location.')
+auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A 
read/write property that configures the auto-continue property of this 
breakpoint location.')
+breakpoint = property(GetBreakpoint, doc='A read only property that 
returns the parent breakpoint of this breakpoint location.')
+condition = property(GetCondition, SetCondition, doc='A read/write 
property that configures the condition of this breakpoint location.')
+hit_count = property(GetHitCount, doc='A read only property that returns 
the hit count of this breakpoint location.')
+id = property(GetID, doc='A read only property that returns the id of this 
breakpoint location.')
+ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A read/write 
property that configures the ignore count of this breakpoint location.')
+load_addr = property(GetLoadAddress, doc='A read only property that 
returns the load address of this breakpoint location.')
+queue_name = property(GetQueueName, SetQueueName, doc='A read/write 
property that configures the queue name criteria of this breakpoint location.')
+thread_id = property(GetThreadID, SetThreadID, doc='A read/write property 
that configures the thread id 

[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  uint64_t id = LLDB_INVALID_ADDRESS;
+
+  /// The name of the step-in target (shown in the UI).
+  std::string label;
+
+  /// The line of the step-in target.
+  std::optional line;
+
+  /// Start position of the range covered by the step in target. It is measured
+  /// in UTF-16 code units and the client capability `columnsStartAt1`
+  /// determines whether it is 0- or 1-based.
+  std::optional column;
+
+  /// The end line of the range covered by the step-in target.
+  std::optional endLine;
+
+  /// End position of the range covered by the step in target. It is measured 
in
+  /// UTF-16 code units and the client capability `columnsStartAt1` determines
+  /// whether it is 0- or 1-based.
+  std::optional endColumn;

da-viper wrote:

I think it is better, to not send any line or column if we don't have one, as 
some DAP client may interpret it as a valid position. 

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -33,6 +33,23 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) 
{
   dap.SendJSON(llvm::json::Value(std::move(event)));
 }
 
+void SendAdditionalCapabilities(DAP &dap) {
+  if (dap.target.IsValid()) {

da-viper wrote:

I wanted to do it like that but I was thinking if we add more check for other 
capability, we would have to refactor it. 

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -78,3 +78,31 @@ def test_basic(self):
 leaf_frame = self.dap_server.get_stackFrame()
 self.assertIsNotNone(leaf_frame, "expect a leaf frame")
 self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"])
+
+def test_supported_capability(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+bp_lines = [line_number(source, "// set breakpoint here")]
+breakpoint_ids = self.set_source_breakpoints(source, bp_lines)
+self.assertEqual(
+len(breakpoint_ids), len(bp_lines), "expect correct number of 
breakpoints"
+)
+is_supported = self.dap_server.get_initialize_value(
+"supportsStepInTargetsRequest"
+)
+arch: str = self.getArchitecture()
+if arch.startswith("x86"):
+self.assertTrue(
+is_supported,
+f"expect capability `stepInTarget` is supported with 
architecture {arch}",
+)
+else:
+self.assertFalse(
+is_supported,
+f"expect capability `stepInTarget` is not supported with 
architecture {arch}",
+)

da-viper wrote:

Just to confirm, the architecture in the decorator `@skipif(arch=[..])` is it 
the target/ platform architecture as it may not match correctly if it is 
remote. 

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -78,3 +78,31 @@ def test_basic(self):
 leaf_frame = self.dap_server.get_stackFrame()
 self.assertIsNotNone(leaf_frame, "expect a leaf frame")
 self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"])
+
+def test_supported_capability(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+bp_lines = [line_number(source, "// set breakpoint here")]
+breakpoint_ids = self.set_source_breakpoints(source, bp_lines)
+self.assertEqual(
+len(breakpoint_ids), len(bp_lines), "expect correct number of 
breakpoints"
+)
+is_supported = self.dap_server.get_initialize_value(
+"supportsStepInTargetsRequest"
+)
+arch: str = self.getArchitecture()
+if arch.startswith("x86"):
+self.assertTrue(
+is_supported,
+f"expect capability `stepInTarget` is supported with 
architecture {arch}",
+)
+else:
+self.assertFalse(
+is_supported,
+f"expect capability `stepInTarget` is not supported with 
architecture {arch}",
+)

ashgti wrote:

Yea, basically, we'd expect all the functional tests to only work on x86 
targets and the non-x86 targets should only be checking that the capability 
isn't set after we launch/attach/configurationDone.

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -33,6 +33,23 @@ static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) 
{
   dap.SendJSON(llvm::json::Value(std::move(event)));
 }
 
+void SendAdditionalCapabilities(DAP &dap) {
+  if (dap.target.IsValid()) {

ashgti wrote:

We can always update it in the future if we need to adjust the flow

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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-03 Thread Chelsea Cassanova via lldb-commits

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

>From b47eaa64397da7ea5d2a7ca46bea4513a37755f0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 28 May 2025 15:45:45 -0700
Subject: [PATCH 1/2] [lldb][headers] Create Python script to fix up framework
 headers

This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
---
 lldb/cmake/modules/LLDBFramework.cmake|  34 ++---
 lldb/scripts/framework-header-fix.py  | 129 ++
 lldb/scripts/framework-header-fix.sh  |  17 ---
 .../Shell/Scripts/Inputs/Main/SBAddress.h |  13 ++
 .../Shell/Scripts/Inputs/RPC/RPCSBAddress.h   |   9 ++
 .../Shell/Scripts/TestFrameworkFixScript.test |  16 +++
 .../Scripts/TestRPCFrameworkFixScript.test|  14 ++
 7 files changed, 196 insertions(+), 36 deletions(-)
 create mode 100755 lldb/scripts/framework-header-fix.py
 delete mode 100755 lldb/scripts/framework-header-fix.sh
 create mode 100644 lldb/test/Shell/Scripts/Inputs/Main/SBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/Inputs/RPC/RPCSBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScript.test
 create mode 100644 lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..9c2ad4ea6f0d6 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -68,24 +68,16 @@ if(NOT APPLE_EMBEDDED)
   )
 endif()
 
-# At configuration time, collect headers for the framework bundle and copy them
-# into a staging directory. Later we can copy over the entire folder.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
 find_program(unifdef_EXECUTABLE unifdef)
 
-set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
-foreach(header
-${public_headers}
-${generated_public_headers}
-${root_public_headers})
+# All necessary header files will be staged in the include directory in the 
build directory,
+# so just copy the files from there into the framework's staging directory.
+set(lldb_build_dir_header_staging ${CMAKE_BINARY_DIR}/include/lldb)
+set(lldb_framework_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
+foreach(header ${lldb_build_dir_header_staging})
 
   get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging}/${basename})
+  set(staged_header ${lldb_framework_header_staging}/${basename})
 
   if(unifdef_EXECUTABLE)
 # unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
@@ -107,14 +99,18 @@ endforeach()
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
+
+# We're taking the header files from where they've been staged in the build 
directory's include folder,
+# so create a dependency on the build step that creates that directory.
+add_dependencies(liblldb-resource-headers liblldb-header-staging)
 add_dependencies(liblldb liblldb-resource-headers)
 
-# At build time, copy the staged headers into the framework bundle (and do
-# some post-processing in-place).
+# Take the headers from the staging directory and fix up their includes for 
the framework.
+# Then write them to the output directory.
+# Also, run unifdef to remove any specified guards from the header files.
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
-  COMMENT "LLDB.framework: copy framework headers"
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i 
${lldb_framework_header_staging} -o $/Headers -p 
${unifdef_EXECUTABLE} USWIG
+  COMMENT "LLDB.framework: Fix up and copy framework headers"
 )
 
 # Copy vendor-specific headers from clang (without staging).
diff --git a/lldb/scripts/framework-header-fix.py 
b/lldb/scripts/framework-header-fix.py
new file mode 100755
index 0..e6ea4e9bf917f
--- /dev/null
+++ b/lldb/scripts/framework-header-fix.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+
+"""
+Usage:  
+
+This script is used when building LLDB.framework or LLDBRPC.framework. For 
each framework, local includes are converted to their respective framework 
includes.
+
+This script is used in 2 ways:
+1. It is used on header

[Lldb-commits] [lldb] [lldb/cmake] Implicitly pass arguments to llvm_add_library (PR #142583)

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

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


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


[Lldb-commits] [lldb] [lldb][headers] Create script to fix up versioning (PR #141116)

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

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

LGTM

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


[Lldb-commits] [lldb] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (PR #142587)

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

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


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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

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

https://github.com/JDevlieghere commented:

I think this could benefit from following the pattern of the other scripts, 
which is running on a single file and having CMake doing the globbing, 
presumably that means the build system can do all of this in parallel instead 
of making this a single-threaded operation. 

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


[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread via lldb-commits

jimingham wrote:

This also seems like an awkward way to do what we've wanted for a while, which 
is the equivalent of stop hooks for "launch", "attach" and "module loaded", 
since you have to do all three, even if you only wanted to do one of the set.

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


[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread via lldb-commits

jimingham wrote:

I changed the stop-hooks recently so they optionally fire when lldb first gets 
control of the process, so you can already write python code that intervenes 
when your "did_attach" and "did_launch" callbacks fire.

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 28 May 2025 14:02:01 +0100
Subject: [PATCH 1/4] [lldb-dap] Use structured types for stepInTargets request

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  16 +-
 .../Handler/StepInTargetsRequestHandler.cpp   | 200 +++---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|   9 +
 .../lldb-dap/Protocol/ProtocolRequests.h  |  15 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  29 +++
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  20 ++
 7 files changed, 186 insertions(+), 130 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr, 

[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  uint64_t id = LLDB_INVALID_ADDRESS;
+
+  /// The name of the step-in target (shown in the UI).
+  std::string label;
+
+  /// The line of the step-in target.
+  std::optional line;
+
+  /// Start position of the range covered by the step in target. It is measured
+  /// in UTF-16 code units and the client capability `columnsStartAt1`
+  /// determines whether it is 0- or 1-based.
+  std::optional column;
+
+  /// The end line of the range covered by the step-in target.
+  std::optional endLine;
+
+  /// End position of the range covered by the step in target. It is measured 
in
+  /// UTF-16 code units and the client capability `columnsStartAt1` determines
+  /// whether it is 0- or 1-based.
+  std::optional endColumn;

da-viper wrote:

i used `uint32_t`  for column as it does not have a consistent type in the code 
base and no `toJSON` over load for `uint16_t`  

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

LGTM!

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 28 May 2025 14:02:01 +0100
Subject: [PATCH 1/5] [lldb-dap] Use structured types for stepInTargets request

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  16 +-
 .../Handler/StepInTargetsRequestHandler.cpp   | 200 +++---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|   9 +
 .../lldb-dap/Protocol/ProtocolRequests.h  |  15 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  29 +++
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  20 ++
 7 files changed, 186 insertions(+), 130 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr, 

[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread via lldb-commits

jimingham wrote:

But if you don't care so much about shared state, then I think a better way of 
doing what you want is just to add `target module-hook add`...

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


[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread via lldb-commits

jimingham wrote:

One thing that's nicer about this approach than independent callbacks for each 
of the hooks is that it allows you to group the three callbacks in the same 
class, so that you can more easily keep shared state.

But that's a general problem with these affordances.  For instance, it's super 
inconvenient that the summary providers and synthetic child providers produce 
separate objects to handle the callbacks.  You end up computing the sizes of 
container classes twice, once for the summary and once because you need it to 
present the type...  If the summary & child provider could share state, you'd 
only need to do that once per stop.  

And as we are adding more of these callbacks for "lifecycle events" it would be 
really convenient, as you have done here, to be able to get one object to 
manage multiple different types of callback hits.

For the case of hooks, I wonder if we could augment the -C options we currently 
use to add affordances backed by a Python class with a `__call__` method so you 
could say:

`target stop-hook add -C my_python_class --shared-instance 1 --call_method 
stop_hook_handler
`
And that would tell lldb to make a single object instance (one for each target 
in this case).   Allowing you to specify the method name means you don't have 
to do the discrimination in `__call__`...  

That way as we add more of these callbacks (which I agree we really need to do) 
then people could mix and match them as the wish, we wouldn't have to figure 
out what the right combination are for everybody's uses.

Note for summary & synthetic child providers you wouldn't need to specify the 
methods as those are pre-determined.  So the `--call-method` would not be 
necessary.

It might also be handy to be able to define several commands that share state, 
so you could do the same thing for command classes (though in that case the 
shared instance would be held by the debugger not the target...)

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

https://github.com/da-viper created 
https://github.com/llvm/llvm-project/pull/142652

The current implementation hides any possible error from performing a step 
command.

>From 7e940dcb0cfde1bc9be73c7cf2a40ba7f08d12e5 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 2 Jun 2025 17:07:50 +0100
Subject: [PATCH] [lldb-dap] Forward any error from stepping.

---
 lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp|  9 ++---
 lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp  | 11 +++
 lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp |  6 --
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..02fd77470fa08 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -33,13 +34,15 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/true);
+thread.StepInstruction(/*step_over=*/true, error);
   } else {
-thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+error);
   }
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..1a70be7d220c5 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
@@ -39,9 +40,10 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
 
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/false);
-return Error::success();
+thread.StepInstruction(/*step_over=*/false, error);
+return ToError(error);
   }
 
   std::string step_in_target;
@@ -50,8 +52,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
 step_in_target = it->second;
 
   RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
-  thread.StepInto(step_in_target.c_str(), run_mode);
-  return Error::success();
+  thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
+  run_mode);
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
index 6b98582262a68..e31b38cb68bfd 100644
--- a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -35,9 +36,10 @@ Error StepOutRequestHandler::Run(const StepOutArguments 
&arguments) const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
-  thread.StepOut();
+  lldb::SBError error;
+  thread.StepOut(error);
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  lldb::addr_t id = LLDB_INVALID_ADDRESS;
+
+  /// The name of the step-in target (shown in the UI).
+  std::string label;
+
+  /// The line of the step-in target.
+  std::optional line = LLDB_INVALID_LINE_NUMBER;

ashgti wrote:

Since this has a default, you can drop the `std::optional`.

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-03 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

> I think this could benefit from following the pattern of the other scripts, 
> which is running on a single file and having CMake doing the globbing, 
> presumably that means the build system can do all of this in parallel instead 
> of making this a single-threaded operation.

I was actually wondering if file-level operations should be done in the script 
or by the build system. With the other scripts we do this in the build system 
so this can be changed to match that.

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


[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread Med Ismail Bennani via lldb-commits

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

Hey @clayborg, this is pretty cool. I'm glad you were able to use and extend 
the ScriptedPythonInterface to implement this, hopefully it wasn't too 
complicated. LGTM!

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


[Lldb-commits] [lldb] [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (PR #142620)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

The current implementation hides any possible error from performing a step 
command.

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


3 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp (+6-3) 
- (modified) lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp (+7-4) 
- (modified) lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp (+4-2) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..02fd77470fa08 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -33,13 +34,15 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/true);
+thread.StepInstruction(/*step_over=*/true, error);
   } else {
-thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+error);
   }
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..1a70be7d220c5 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
@@ -39,9 +40,10 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
 
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/false);
-return Error::success();
+thread.StepInstruction(/*step_over=*/false, error);
+return ToError(error);
   }
 
   std::string step_in_target;
@@ -50,8 +52,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
 step_in_target = it->second;
 
   RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
-  thread.StepInto(step_in_target.c_str(), run_mode);
-  return Error::success();
+  thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
+  run_mode);
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
index 6b98582262a68..e31b38cb68bfd 100644
--- a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -35,9 +36,10 @@ Error StepOutRequestHandler::Run(const StepOutArguments 
&arguments) const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
-  thread.StepOut();
+  lldb::SBError error;
+  thread.StepOut(error);
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap

``




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


[Lldb-commits] [lldb] Add a python JIT loader class. (PR #142514)

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

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


[Lldb-commits] [lldb] [lldb][headers] Create script to fix up versioning (PR #141116)

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

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


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


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-03 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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

For these three request handlers, should we also add a sanity check of:

```
  if (!SBDebugger::StateIsStoppedState(process.GetState()))
return make_error();
```

To the `Run(...)` so we can get a specific error if the process isn't stopped?

In normal debugging flows we shouldn't be in that situation, but our tests may 
incorrectly try to step when the process isn't stopped.

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-03 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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

>From 7e940dcb0cfde1bc9be73c7cf2a40ba7f08d12e5 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 2 Jun 2025 17:07:50 +0100
Subject: [PATCH 1/2] [lldb-dap] Forward any error from stepping.

---
 lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp|  9 ++---
 lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp  | 11 +++
 lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp |  6 --
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..02fd77470fa08 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -33,13 +34,15 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/true);
+thread.StepInstruction(/*step_over=*/true, error);
   } else {
-thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+error);
   }
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..1a70be7d220c5 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
@@ -39,9 +40,10 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
 
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/false);
-return Error::success();
+thread.StepInstruction(/*step_over=*/false, error);
+return ToError(error);
   }
 
   std::string step_in_target;
@@ -50,8 +52,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
 step_in_target = it->second;
 
   RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
-  thread.StepInto(step_in_target.c_str(), run_mode);
-  return Error::success();
+  thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
+  run_mode);
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
index 6b98582262a68..e31b38cb68bfd 100644
--- a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -35,9 +36,10 @@ Error StepOutRequestHandler::Run(const StepOutArguments 
&arguments) const {
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
-  thread.StepOut();
+  lldb::SBError error;
+  thread.StepOut(error);
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap

>From 89d2bb588e2f880d6818fe45061a0f9db0a3fdd1 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 3 Jun 2025 19:34:59 +0100
Subject: [PATCH 2/2] [lldb][lldb-dap] add review changes

---
 lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp| 3 +++
 lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp  | 3 +++
 lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp | 4 
 3 files changed, 10 insertions(+)

diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 02fd77470fa08..2b48350dfba1b 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -31,6 +31,9 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   if (!thread.IsValid())
 return make_error("invalid thread");
 
+  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+return m

[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

>From 6076f7778f3f10d7360d8f0b156992809de73094 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 3 Jun 2025 10:44:43 -0700
Subject: [PATCH] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h | 12 
 lldb/include/lldb/Core/FormatEntity.h |  4 ++-
 lldb/include/lldb/Interpreter/OptionValue.h   | 12 
 lldb/include/lldb/Target/Language.h   |  4 +--
 lldb/source/Core/Debugger.cpp | 30 ++-
 lldb/source/Core/Disassembler.cpp |  7 +++--
 lldb/source/Core/FormatEntity.cpp |  4 +--
 lldb/source/Core/Statusline.cpp   |  8 ++---
 lldb/source/Interpreter/OptionValue.cpp   |  6 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  8 ++---
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  6 ++--
 lldb/source/Target/StackFrame.cpp |  7 +++--
 lldb/source/Target/Thread.cpp | 12 +---
 lldb/source/Target/ThreadPlanTracer.cpp   |  4 +--
 lldb/unittests/Core/DebuggerTest.cpp  |  2 +-
 15 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 1aed3c6ff9e9d..18257161eec7b 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -205,6 +205,8 @@ struct Entry {
 return true;
   }
 
+  operator bool() const { return type != Type::Invalid; }
+
   std::vector &GetChildren();
 
   std::string string;
@@ -217,7 +219,7 @@ struct Entry {
   size_t level = 0;
   /// @}
 
-  Type type;
+  Type type = Type::Invalid;
   lldb::Format fmt = lldb::eFormatDefault;
   lldb::addr_t number = 0;
   bool deref = false;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..f293a3a33bfa0 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntityValue();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,11 +297,9 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
-if constexpr (std::is_same_v)
-  return GetRegexValue();
-return {};
+static_assert(std::is_same_v,
+  "only for RegularExpression");
+return GetRegexValue();
   }
 
   bool SetValueAs(bool v) { return SetBooleanValue(v); }
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntityValue() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index d6

[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

2025-06-03 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 h,cpp -- 
lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/FormatEntity.h 
lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Target/Language.h 
lldb/source/Core/Debugger.cpp lldb/source/Core/Disassembler.cpp 
lldb/source/Core/FormatEntity.cpp lldb/source/Core/Statusline.cpp 
lldb/source/Interpreter/OptionValue.cpp 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h 
lldb/source/Target/StackFrame.cpp lldb/source/Target/Thread.cpp 
lldb/source/Target/ThreadPlanTracer.cpp lldb/unittests/Core/DebuggerTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index de60d25b9..81037d3de 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1537,7 +1537,8 @@ bool Debugger::FormatDisassemblerAddress(const 
FormatEntity::Entry *format,
 
   if (format == nullptr) {
 if (exe_ctx != nullptr && exe_ctx->HasTargetScope()) {
-  format_entry = 
exe_ctx->GetTargetRef().GetDebugger().GetDisassemblyFormat();
+  format_entry =
+  exe_ctx->GetTargetRef().GetDebugger().GetDisassemblyFormat();
   format = &format_entry;
 }
 if (format == nullptr) {
diff --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 6ecbd1f69..833e32757 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -1037,8 +1037,7 @@ void InstructionList::Dump(Stream *s, bool show_address, 
bool show_bytes,
   const FormatEntity::Entry *disassembly_format = nullptr;
   FormatEntity::Entry format;
   if (exe_ctx && exe_ctx->HasTargetScope()) {
-format =
-exe_ctx->GetTargetRef().GetDebugger().GetDisassemblyFormat();
+format = exe_ctx->GetTargetRef().GetDebugger().GetDisassemblyFormat();
 disassembly_format = &format;
   } else {
 FormatEntity::Parse("${addr}: ", format);

``




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


[Lldb-commits] [lldb] Add a python JIT loader class. (PR #142514)

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

bulbazord wrote:

> This seems like a generic module loading observer. I don't see anything JIT 
> specific about it. Not saying a generic module loading observer is not a good 
> idea. But calling it a JITLoader seems pretty confusing to me.

+1 on the name. The design seems very general, so maybe calling it something 
like ModuleObserver or something would make more sense.

Your PR summary describes what users can do, but why might they want to do it? 
Do you have a motivation for this change?

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


[Lldb-commits] [lldb] Add a python JIT loader class. (PR #142514)

2025-06-03 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> Hey @clayborg, this is pretty cool. I'm glad you were able to use and extend 
> the ScriptedPythonInterface to implement this, hopefully it wasn't too 
> complicated. LGTM!

I meant LGTM on the scripting side of things. I still thing we should address 
Jim's comments:

> For the case of hooks, I wonder if we could augment the -C options we 
> currently use to add affordances backed by a Python class with a __call__ 
> method so you could say:
> 
> `target stop-hook add -C my_python_class --shared-instance 1 --call_method 
> stop_hook_handler `
> 

If you use a `OptionGroupPythonClassWithDict`, you automatically get `-C` 
option to specify either a class or a function to a CommandObject.

I like the idea of being able to create or share instances between scripted 
affordances but I think we need a way to list the existing instances (and what 
scripted affordance are they driving), otherwise, how would the user be able to 
tell what number to pass to `--shared-instance` ?

Suggestion: if you make this more generic, you could implement a template 
that's included in the lldb python module like we do for other scripted 
affordances (ScriptedProcess, ScriptedThread, ScriptedThreadPlan ...) with a 
base implementation for every function the script should implement. That would 
make it easier to write new scripts for this.

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


[Lldb-commits] [lldb] [lldb-dap] Forward any error from stepping. (PR #142652)

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

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

Nice

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


[Lldb-commits] [lldb] [lldb][headers] Create script to fix up versioning (PR #141116)

2025-06-03 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] d204aa9 - [lldb][headers] Create script to fix up versioning (#141116)

2025-06-03 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2025-06-03T13:06:46-07:00
New Revision: d204aa9deb72b8dcaf5e5b5550871d0ebe982825

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

LOG: [lldb][headers] Create script to fix up versioning (#141116)

This commit creates a Python script that fixes up the versioning
information in lldb-defines.h. It also moves the build logic for fixing
up the lldb headers from being in the framework only to being in the
same location that we create the liblldb target.

Added: 
lldb/scripts/version-header-fix.py
lldb/test/Shell/Scripts/Inputs/lldb-defines.h
lldb/test/Shell/Scripts/TestVersionFixScript.test

Modified: 
lldb/scripts/framework-header-fix.sh
lldb/source/API/CMakeLists.txt

Removed: 




diff  --git a/lldb/scripts/framework-header-fix.sh 
b/lldb/scripts/framework-header-fix.sh
index 3459dd91c9ec1..345579c80cdf5 100755
--- a/lldb/scripts/framework-header-fix.sh
+++ b/lldb/scripts/framework-header-fix.sh
@@ -7,11 +7,5 @@ for file in `find $1 -name "*.h"`
 do
   /usr/bin/sed -i.bak 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 
/1' "$file"
   /usr/bin/sed -i.bak 's|  LLDB_MAJOR_VERSION 
LLDB_MINOR_VERSION LLDB_PATCH_VERSION
+
+This script uncomments and populates the versioning information in 
lldb-defines.h
+"""
+
+import argparse
+import os
+import re
+
+LLDB_VERSION_REGEX = re.compile(r"//\s*#define LLDB_VERSION\s*$", re.M)
+LLDB_REVISION_REGEX = re.compile(r"//\s*#define LLDB_REVISION\s*$", re.M)
+LLDB_VERSION_STRING_REGEX = re.compile(r"//\s*#define 
LLDB_VERSION_STRING\s*$", re.M)
+
+
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument("input_path")
+parser.add_argument("output_path")
+parser.add_argument("lldb_version_major")
+parser.add_argument("lldb_version_minor")
+parser.add_argument("lldb_version_patch")
+args = parser.parse_args()
+input_path = str(args.input_path)
+output_path = str(args.output_path)
+lldb_version_major = args.lldb_version_major
+lldb_version_minor = args.lldb_version_minor
+lldb_version_patch = args.lldb_version_patch
+
+with open(input_path, "r") as input_file:
+lines = input_file.readlines()
+file_buffer = "".join(lines)
+
+with open(output_path, "w") as output_file:
+# For the defines in lldb-defines.h that define the major, minor and 
version string
+# uncomment each define and populate its value using the arguments 
passed in.
+# e.g. //#define LLDB_VERSION -> #define LLDB_VERSION 

+file_buffer = re.sub(
+LLDB_VERSION_REGEX,
+r"#define LLDB_VERSION " + lldb_version_major,
+file_buffer,
+)
+
+file_buffer = re.sub(
+LLDB_REVISION_REGEX,
+r"#define LLDB_REVISION " + lldb_version_patch,
+file_buffer,
+)
+file_buffer = re.sub(
+LLDB_VERSION_STRING_REGEX,
+r'#define LLDB_VERSION_STRING "{0}.{1}.{2}"'.format(
+lldb_version_major, lldb_version_minor, lldb_version_patch
+),
+file_buffer,
+)
+output_file.write(file_buffer)
+
+
+if __name__ == "__main__":
+main()

diff  --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3bc569608e458..4139f8a9c7821 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,6 +290,45 @@ else()
   endif()
 endif()
 
+# Stage all headers in the include directory in the build dir.
+file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
+set(lldb_header_staging_dir ${CMAKE_BINARY_DIR}/include/lldb)
+file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
+file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
+list(REMOVE_ITEM root_public_headers ${root_private_headers})
+
+find_program(unifdef_EXECUTABLE unifdef)
+
+foreach(header
+${public_headers}
+${generated_public_headers}
+${root_public_headers})
+  get_filename_component(basename ${header} NAME)
+  set(staged_header ${lldb_header_staging_dir}/${basename})
+
+  if(unifdef_EXECUTABLE)
+# unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
+# That means if we successfully remove SWIG code, the build system believes
+# that the command has failed and stops. This is undesirable.
+set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} 
${header} || (exit 0))
+  else()
+set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header})
+  endif()
+
+  add_custom_command(
+DEPENDS ${header} OUTPUT ${staged_header}
+COMMAND ${copy_command}
+COMMENT "LLDB headers: stage LLDB headers in include directory")
+
+  list(APPEND lldb_staged_headers 

[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

>From 6076f7778f3f10d7360d8f0b156992809de73094 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 3 Jun 2025 10:44:43 -0700
Subject: [PATCH 1/2] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h | 12 
 lldb/include/lldb/Core/FormatEntity.h |  4 ++-
 lldb/include/lldb/Interpreter/OptionValue.h   | 12 
 lldb/include/lldb/Target/Language.h   |  4 +--
 lldb/source/Core/Debugger.cpp | 30 ++-
 lldb/source/Core/Disassembler.cpp |  7 +++--
 lldb/source/Core/FormatEntity.cpp |  4 +--
 lldb/source/Core/Statusline.cpp   |  8 ++---
 lldb/source/Interpreter/OptionValue.cpp   |  6 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  8 ++---
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  6 ++--
 lldb/source/Target/StackFrame.cpp |  7 +++--
 lldb/source/Target/Thread.cpp | 12 +---
 lldb/source/Target/ThreadPlanTracer.cpp   |  4 +--
 lldb/unittests/Core/DebuggerTest.cpp  |  2 +-
 15 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 1aed3c6ff9e9d..18257161eec7b 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -205,6 +205,8 @@ struct Entry {
 return true;
   }
 
+  operator bool() const { return type != Type::Invalid; }
+
   std::vector &GetChildren();
 
   std::string string;
@@ -217,7 +219,7 @@ struct Entry {
   size_t level = 0;
   /// @}
 
-  Type type;
+  Type type = Type::Invalid;
   lldb::Format fmt = lldb::eFormatDefault;
   lldb::addr_t number = 0;
   bool deref = false;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..f293a3a33bfa0 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntityValue();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,11 +297,9 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
-if constexpr (std::is_same_v)
-  return GetRegexValue();
-return {};
+static_assert(std::is_same_v,
+  "only for RegularExpression");
+return GetRegexValue();
   }
 
   bool SetValueAs(bool v) { return SetBooleanValue(v); }
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntityValue() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
inde

[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

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

https://github.com/JDevlieghere commented:

Can you add a `Thread` serialization/deserialization unit test?

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

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

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


[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint and similar (PR #142215)

2025-06-03 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

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


@@ -8,72 +8,43 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "ProtocolUtils.h"
 #include "RequestHandler.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDefines.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+using namespace lldb_dap::protocol;
 
 namespace lldb_dap {
 
-// "ThreadsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Thread request; value of command field is 'threads'. The
-// request retrieves a list of all threads.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "threads" ]
-//   }
-// },
-// "required": [ "command" ]
-//   }]
-// },
-// "ThreadsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'threads' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "threads": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/Thread"
-// },
-// "description": "All threads."
-//   }
-// },
-// "required": [ "threads" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void ThreadsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
+/// The request retrieves a list of all threads.
+Expected
+ThreadsRequestHandler::Run(const ThreadsArguments &) const {
+  lldb::SBProcess process = dap.target.GetProcess();
+  std::vector threads;
 
-  llvm::json::Array threads;
   // Client requests the baseline of currently existing threads after
   // a successful launch or attach by sending a 'threads' request
   // right after receiving the configurationDone response.
   // If no thread has reported to the client, it prevents something
   // like the pause request from working in the running state.
   // Return the cache of initial threads as the process might have resumed
   if (dap.initial_thread_list) {
-threads = dap.initial_thread_list.value();
+threads = *dap.initial_thread_list;
 dap.initial_thread_list.reset();
-  } else {
-threads = GetThreads(dap.target.GetProcess(), dap.thread_format);
-  }
+  } else if (!lldb::SBDebugger::StateIsStoppedState(process.GetState()))
+return make_error();
+  else
+threads = GetThreads(process, dap.thread_format);

JDevlieghere wrote:

Nit: if one case has braces, all of them should according to the style guide.
```suggestion
  } else if (!lldb::SBDebugger::StateIsStoppedState(process.GetState())) {
return make_error();
  } else {
threads = GetThreads(process, dap.thread_format);
  }
```

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

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


@@ -116,77 +116,79 @@ void SendProcessEvent(DAP &dap, LaunchMethod 
launch_method) {
 
 // Send a thread stopped event for all threads as long as the process
 // is stopped.
-void SendThreadStoppedEvent(DAP &dap) {
+void SendThreadStoppedEvent(DAP &dap, bool on_entry) {

JDevlieghere wrote:

Can this return an `llvm::Error` and have the error percolated up instead of 
logging it here?

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  uint64_t id = LLDB_INVALID_ADDRESS;
+
+  /// The name of the step-in target (shown in the UI).
+  std::string label;
+
+  /// The line of the step-in target.
+  std::optional line;
+
+  /// Start position of the range covered by the step in target. It is measured
+  /// in UTF-16 code units and the client capability `columnsStartAt1`
+  /// determines whether it is 0- or 1-based.
+  std::optional column;
+
+  /// The end line of the range covered by the step-in target.
+  std::optional endLine;
+
+  /// End position of the range covered by the step in target. It is measured 
in
+  /// UTF-16 code units and the client capability `columnsStartAt1` determines
+  /// whether it is 0- or 1-based.
+  std::optional endColumn;

ashgti wrote:

Sorry, I didn't fully finish the thought. When we convert this into json in the 
`toJSON` we can check if they're equal to the invalid value and not send the 
value.

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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-03 Thread Chelsea Cassanova via lldb-commits

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

>From b47eaa64397da7ea5d2a7ca46bea4513a37755f0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 28 May 2025 15:45:45 -0700
Subject: [PATCH 1/2] [lldb][headers] Create Python script to fix up framework
 headers

This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
---
 lldb/cmake/modules/LLDBFramework.cmake|  34 ++---
 lldb/scripts/framework-header-fix.py  | 129 ++
 lldb/scripts/framework-header-fix.sh  |  17 ---
 .../Shell/Scripts/Inputs/Main/SBAddress.h |  13 ++
 .../Shell/Scripts/Inputs/RPC/RPCSBAddress.h   |   9 ++
 .../Shell/Scripts/TestFrameworkFixScript.test |  16 +++
 .../Scripts/TestRPCFrameworkFixScript.test|  14 ++
 7 files changed, 196 insertions(+), 36 deletions(-)
 create mode 100755 lldb/scripts/framework-header-fix.py
 delete mode 100755 lldb/scripts/framework-header-fix.sh
 create mode 100644 lldb/test/Shell/Scripts/Inputs/Main/SBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/Inputs/RPC/RPCSBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScript.test
 create mode 100644 lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..9c2ad4ea6f0d6 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -68,24 +68,16 @@ if(NOT APPLE_EMBEDDED)
   )
 endif()
 
-# At configuration time, collect headers for the framework bundle and copy them
-# into a staging directory. Later we can copy over the entire folder.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
 find_program(unifdef_EXECUTABLE unifdef)
 
-set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
-foreach(header
-${public_headers}
-${generated_public_headers}
-${root_public_headers})
+# All necessary header files will be staged in the include directory in the 
build directory,
+# so just copy the files from there into the framework's staging directory.
+set(lldb_build_dir_header_staging ${CMAKE_BINARY_DIR}/include/lldb)
+set(lldb_framework_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
+foreach(header ${lldb_build_dir_header_staging})
 
   get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging}/${basename})
+  set(staged_header ${lldb_framework_header_staging}/${basename})
 
   if(unifdef_EXECUTABLE)
 # unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
@@ -107,14 +99,18 @@ endforeach()
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
+
+# We're taking the header files from where they've been staged in the build 
directory's include folder,
+# so create a dependency on the build step that creates that directory.
+add_dependencies(liblldb-resource-headers liblldb-header-staging)
 add_dependencies(liblldb liblldb-resource-headers)
 
-# At build time, copy the staged headers into the framework bundle (and do
-# some post-processing in-place).
+# Take the headers from the staging directory and fix up their includes for 
the framework.
+# Then write them to the output directory.
+# Also, run unifdef to remove any specified guards from the header files.
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
-  COMMENT "LLDB.framework: copy framework headers"
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i 
${lldb_framework_header_staging} -o $/Headers -p 
${unifdef_EXECUTABLE} USWIG
+  COMMENT "LLDB.framework: Fix up and copy framework headers"
 )
 
 # Copy vendor-specific headers from clang (without staging).
diff --git a/lldb/scripts/framework-header-fix.py 
b/lldb/scripts/framework-header-fix.py
new file mode 100755
index 0..e6ea4e9bf917f
--- /dev/null
+++ b/lldb/scripts/framework-header-fix.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+
+"""
+Usage:  
+
+This script is used when building LLDB.framework or LLDBRPC.framework. For 
each framework, local includes are converted to their respective framework 
includes.
+
+This script is used in 2 ways:
+1. It is used on header

[Lldb-commits] [lldb] [lldb][RPC] Upstream LLDB to RPC converstion Python script (PR #138028)

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

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

LGTM. Might be worth making this match the other scripts and doing this once 
instead of line-by-line.

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][lldb-dap] explicitly set the expr as an alias for expression. (PR #134562)

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

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


[Lldb-commits] [lldb] Add a pythin JIT loader class. (PR #142514)

2025-06-03 Thread via lldb-commits

jimingham wrote:

This seems like a generic module loading observer.  I don't see anything JIT 
specific about it.  Not saying a generic module loading observer is not a good 
idea.  But calling it a JITLoader seems pretty confusing to me.

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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


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


[Lldb-commits] [lldb] [lldb][test] Free buffers in demangling tests to avoid leaks (PR #142676)

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

https://github.com/rupprecht created 
https://github.com/llvm/llvm-project/pull/142676

Test case added by f669b9c3eca9438d33259aefb8156f977f1df382 / #137793. Note 
that the `DemanglingParts` case above also frees the buffer; this new test case 
is inconsistent.

>From 270b38ccfe58011c2b22e89e5b5757df3a17c35c Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Tue, 3 Jun 2025 14:56:35 -0700
Subject: [PATCH] [lldb][test] Free buffers in demangling tests to avoid leaks

---
 lldb/unittests/Core/MangledTest.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/unittests/Core/MangledTest.cpp 
b/lldb/unittests/Core/MangledTest.cpp
index dfdc026521379..e9dfd05459642 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -642,8 +642,10 @@ TEST_P(DemanglingInfoCorrectnessTestFixutre, Correctness) {
   // function names.
   if (Root->getKind() !=
   llvm::itanium_demangle::Node::Kind::KFunctionEncoding &&
-  Root->getKind() != llvm::itanium_demangle::Node::Kind::KDotSuffix)
+  Root->getKind() != llvm::itanium_demangle::Node::Kind::KDotSuffix) {
+std::free(OB.getBuffer());
 return;
+  }
 
   ASSERT_TRUE(OB.NameInfo.hasBasename());
 
@@ -670,6 +672,7 @@ TEST_P(DemanglingInfoCorrectnessTestFixutre, Correctness) {
return_right, qualifiers, suffix);
 
   EXPECT_EQ(reconstructed_name, demangled);
+  std::free(OB.getBuffer());
 }
 
 INSTANTIATE_TEST_SUITE_P(

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


[Lldb-commits] [lldb] [lldb][test] Free buffers in demangling tests to avoid leaks (PR #142676)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jordan Rupprecht (rupprecht)


Changes

Test case added by f669b9c3eca9438d33259aefb8156f977f1df382 / #137793. 
Note that the `DemanglingParts` case above also frees the buffer; this new test 
case is inconsistent.

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


1 Files Affected:

- (modified) lldb/unittests/Core/MangledTest.cpp (+4-1) 


``diff
diff --git a/lldb/unittests/Core/MangledTest.cpp 
b/lldb/unittests/Core/MangledTest.cpp
index dfdc026521379..e9dfd05459642 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -642,8 +642,10 @@ TEST_P(DemanglingInfoCorrectnessTestFixutre, Correctness) {
   // function names.
   if (Root->getKind() !=
   llvm::itanium_demangle::Node::Kind::KFunctionEncoding &&
-  Root->getKind() != llvm::itanium_demangle::Node::Kind::KDotSuffix)
+  Root->getKind() != llvm::itanium_demangle::Node::Kind::KDotSuffix) {
+std::free(OB.getBuffer());
 return;
+  }
 
   ASSERT_TRUE(OB.NameInfo.hasBasename());
 
@@ -670,6 +672,7 @@ TEST_P(DemanglingInfoCorrectnessTestFixutre, Correctness) {
return_right, qualifiers, suffix);
 
   EXPECT_EQ(reconstructed_name, demangled);
+  std::free(OB.getBuffer());
 }
 
 INSTANTIATE_TEST_SUITE_P(

``




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


[Lldb-commits] [lldb] [lldb][test] Free buffers in demangling tests to avoid leaks (PR #142676)

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

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

LGTM. Maybe an opportunity to use a unique_ptr with a custom deleter? Something 
like:

```
struct TrackingOutputBufferDeleter {
  void operator()(TrackingOutputBuffer* TOB) {
if (!TOB)
  return;
std::free(TOB->getBuffer());
std::free(TOB);
  }
};
```

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


[Lldb-commits] [lldb] [lldb-dap][test] Fix DAP disassemble test (PR #142129)

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

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


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


[Lldb-commits] [lldb] [lldb] Do not accept invalid `process save-core` plugins (PR #142684)

2025-06-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes


Fixes #142581

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


6 Files Affected:

- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+1-1) 
- (modified) lldb/source/Symbol/SaveCoreOptions.cpp (-1) 
- (added) lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test 
(+19) 
- (modified) lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp (+9-3) 
- (modified) lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp (+10-4) 
- (modified) lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp (+8-2) 


``diff
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index d0f5eaf2dfd9a..b1f243c9e2777 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1303,7 +1303,7 @@ class CommandObjectProcessSaveCore : public 
CommandObjectParsed {
 llvm_unreachable("Unimplemented option");
   }
 
-  return {};
+  return error;
 }
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index e51ae27954934..d884b00a47b00 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -24,7 +24,6 @@ Status SaveCoreOptions::SetPluginName(const char *name) {
   if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
 return Status::FromErrorStringWithFormat(
 "plugin name '%s' is not a valid ObjectFile plugin name", name);
-return error;
   }
 
   m_plugin_name = name;
diff --git 
a/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test 
b/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test
new file mode 100644
index 0..c034c8ebbf87d
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test
@@ -0,0 +1,19 @@
+# This checks that lldb returns an error if process save-core is called
+# with a plugin that does not exist.
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -s %s -o exit 2>&1 | FileCheck %s
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Breakpoint 1: where = {{.*}}`main
+
+run
+# CHECK-LABEL: run
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = breakpoint 1
+# CHECK:   frame #0: {{.*}}`main at main.c
+
+process save-core --plugin-name=notaplugin dump
+# CHECK-LABEL: process save-core --plugin-name=notaplugin dump
+# CHECK: error: plugin name 'notaplugin' is not a valid ObjectFile plugin name
diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..2b48350dfba1b 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -30,16 +31,21 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   if (!thread.IsValid())
 return make_error("invalid thread");
 
+  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+return make_error();
+
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/true);
+thread.StepInstruction(/*step_over=*/true, error);
   } else {
-thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+error);
   }
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..6742c791a5486 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
@@ -39,9 +40,13 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
 
+  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+return make_error();
+
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/false);
-return Error::success();
+thread.StepIns

[Lldb-commits] [lldb] cb56e15 - [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (#142620)

2025-06-03 Thread via lldb-commits

Author: Michael Buch
Date: 2025-06-03T23:37:39+01:00
New Revision: cb56e15bb3e92c8aab2b7fd74a7683ffd83ac10b

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

LOG: [lldb][TypeSystem][NFC] CreateFunctionType to take parameters by 
llvm::ArrayRef (#142620)

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index fec8d29248c20..9f77fbc1d2434 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1978,10 +1978,10 @@ void 
ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
   copied_clang_type.GetCompleteType()) {
 CompilerType void_clang_type =
 m_clang_ast_context->GetBasicType(eBasicTypeVoid);
-CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
+std::array args{void_clang_type.GetPointerType()};
 
 CompilerType method_type = m_clang_ast_context->CreateFunctionType(
-void_clang_type, &void_ptr_clang_type, 1, false, 0);
+void_clang_type, args, false, 0);
 
 const bool is_virtual = false;
 const bool is_static = false;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 87c37e576fad0..9d84af4a85384 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -150,8 +150,9 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
   CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  std::array args{void_type};
   CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
+  /*result_type=*/void_type, args,
   /*is_variadic=*/false, /*qualifiers=*/0);
   CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
   m_resume_ptr_sp = CreateValueObjectFromAddress(

diff  --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index c0b931f5c131a..f4d032388a883 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction 
&ctf_function) {
 llvm::inconvertibleErrorCode());
 
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  ctf_function.variadic, 0, clang::CallingConv::CC_C);
+  ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
+  clang::CallingConv::CC_C);
 
   Declaration decl;
   return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
   ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
-  arg_types.data(), arg_types.size(), is_variadic, 0,
-  clang::CallingConv::CC_C);
+  arg_types, is_variadic, 0, clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0c26c276cc530..620501b304e63 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1309,11 +1309,10 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE 
&die,
 
   // clang_type will get the function prototype clang type after this
   // call
-  CompilerType clang_type =
-  m_ast.CreateFunctionType(return_clang_type, function_param_types.data(),
-   functi

[Lldb-commits] [lldb] 33fae08 - [lldb-dap] Forward any error from stepping. (#142652)

2025-06-03 Thread via lldb-commits

Author: Ebuka Ezike
Date: 2025-06-03T23:40:00+01:00
New Revision: 33fae0840562ae7e93dd7b4bc6dd4a41150eee01

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

LOG: [lldb-dap] Forward any error from stepping. (#142652)

The current implementation hides any possible error from performing a
step command.

It makes it easier to know where an issue is from.

Added: 


Modified: 
lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..2b48350dfba1b 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -30,16 +31,21 @@ Error NextRequestHandler::Run(const NextArguments &args) 
const {
   if (!thread.IsValid())
 return make_error("invalid thread");
 
+  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+return make_error();
+
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/true);
+thread.StepInstruction(/*step_over=*/true, error);
   } else {
-thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+error);
   }
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap

diff  --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..6742c791a5486 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
@@ -39,9 +40,13 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
 
+  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+return make_error();
+
+  lldb::SBError error;
   if (args.granularity == eSteppingGranularityInstruction) {
-thread.StepInstruction(/*step_over=*/false);
-return Error::success();
+thread.StepInstruction(/*step_over=*/false, error);
+return ToError(error);
   }
 
   std::string step_in_target;
@@ -50,8 +55,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) 
const {
 step_in_target = it->second;
 
   RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
-  thread.StepInto(step_in_target.c_str(), run_mode);
-  return Error::success();
+  thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
+  run_mode);
+  return ToError(error);
 }
 
 } // namespace lldb_dap

diff  --git a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
index 6b98582262a68..e896e03720b6b 100644
--- a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
+#include "LLDBUtils.h"
 #include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "llvm/Support/Error.h"
@@ -32,12 +33,17 @@ Error StepOutRequestHandler::Run(const StepOutArguments 
&arguments) const {
   if (!thread.IsValid())
 return make_error("invalid thread");
 
+  if (!lldb::SBDebugger::StateIsStoppedState(
+  dap.target.GetProcess().GetState()))
+return make_error();
+
   // Remember the thread ID that caused the resume so we can set the
   // "threadCausedFocus" boolean value in the "stopped" events.
   dap.focus_tid = thread.GetThreadID();
-  thread.StepOut();
+  lldb::SBError error;
+  thread.StepOut(error);
 
-  return Error::success();
+  return ToError(error);
 }
 
 } // namespace lldb_dap



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


  1   2   >