[Lldb-commits] [lldb] [lldb/cmake] Remove a no-op statement (PR #141063)

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

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


[Lldb-commits] [lldb] f1cf168 - [lldb/cmake] Remove a no-op statement (#141063)

2025-05-23 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-23T09:23:53+02:00
New Revision: f1cf168a6fbfa28eca2bebb4493966dc63c925c5

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

LOG: [lldb/cmake] Remove a no-op statement (#141063)

Like the comment says, this really is a no-op and has no effect on the
generated build commands.

Added: 


Modified: 
lldb/cmake/modules/AddLLDB.cmake

Removed: 




diff  --git a/lldb/cmake/modules/AddLLDB.cmake 
b/lldb/cmake/modules/AddLLDB.cmake
index 0a81ec5092185..41f9b28a0ab39 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -93,13 +93,6 @@ function(add_lldb_library name)
 set(libkind STATIC)
   endif()
 
-  #PIC not needed on Win
-  # FIXME: Setting CMAKE_CXX_FLAGS here is a no-op, use target_compile_options
-  # or omit this logic instead.
-  if (NOT WIN32)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
-  endif()
-
   if (PARAM_OBJECT)
 add_library(${name} ${libkind} ${srcs})
   else()



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


[Lldb-commits] [lldb] [lldb/cmake] Remove special handling of OBJECT libraries (PR #141066)

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

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/141066

>From 498052aef6ae24353bb50771bac773908da51b5d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 22 May 2025 15:50:01 +0200
Subject: [PATCH] [lldb/cmake] Remove special handling of OBJECT libraries

Nothing in lldb sets this. And even if they did, llvm_add_library should
know how to handle that.
---
 lldb/cmake/modules/AddLLDB.cmake | 36 ++--
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 41f9b28a0ab39..2956cdb7f9c8a 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -93,29 +93,25 @@ function(add_lldb_library name)
 set(libkind STATIC)
   endif()
 
-  if (PARAM_OBJECT)
-add_library(${name} ${libkind} ${srcs})
-  else()
-if(PARAM_ENTITLEMENTS)
-  set(pass_ENTITLEMENTS ENTITLEMENTS ${PARAM_ENTITLEMENTS})
-endif()
+  if(PARAM_ENTITLEMENTS)
+set(pass_ENTITLEMENTS ENTITLEMENTS ${PARAM_ENTITLEMENTS})
+  endif()
 
-if(LLDB_NO_INSTALL_DEFAULT_RPATH)
-  set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
-endif()
+  if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+  endif()
 
-llvm_add_library(${name} ${libkind} ${srcs}
-  LINK_LIBS ${PARAM_LINK_LIBS}
-  DEPENDS ${PARAM_DEPENDS}
-  ${pass_ENTITLEMENTS}
-  ${pass_NO_INSTALL_RPATH}
-)
+  llvm_add_library(${name} ${libkind} ${srcs}
+LINK_LIBS ${PARAM_LINK_LIBS}
+DEPENDS ${PARAM_DEPENDS}
+${pass_ENTITLEMENTS}
+${pass_NO_INSTALL_RPATH}
+  )
 
-if(CLANG_LINK_CLANG_DYLIB)
-  target_link_libraries(${name} PRIVATE clang-cpp)
-else()
-  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
-endif()
+  if(CLANG_LINK_CLANG_DYLIB)
+target_link_libraries(${name} PRIVATE clang-cpp)
+  else()
+target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
   endif()
 
   # A target cannot be changed to a FRAMEWORK after calling install() because

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

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

https://github.com/labath commented:

> One area that I couldn't decide is if the ValueObj should be constructed in 
> Platform or not. Because Thread calls out to platform I just decided to call 
> the existing method, but I wanted your feedback on this because it does feel 
> somewhat split purpose. It might make sense to move the code into platform 
> and have thread call platform to create the SP, the issue is that the value 
> object needs a target reference.

I'm not sure about that myself. I think it would make sense, but it's hard to 
say without seeing how it would look like. I don't think it needs to be done 
here, but I would encourage you to give it a shot afterwards.

Now for tests. The tests for the UnixSignals part are great, but I'm not sure 
if there's a test for the end-to-end flow. It possible this automatically code 
is tested by one of the existing core file. Could you check if anything breaks 
if you e.g. change `GetDescriptionFromSiginfo` to return an empty string? If it 
does, then it's probably fine. If not, could you check if one of our existing 
core files has the siginfo stuff we'd need to write a test for this?

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

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


@@ -480,3 +481,111 @@ CompilerType PlatformLinux::GetSiginfoType(const 
llvm::Triple &triple) {
   ast->CompleteTagDeclarationDefinition(siginfo_type);
   return siginfo_type;
 }
+
+static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) {
+  if (!siginfo_sp)
+return "";
+
+  lldb_private::LinuxSignals linux_signals;
+  int code = 
siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0);
+  int signo =
+  siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1);
+  // si_code = 0 is SI_NOINFO, we just want the description with nothing

labath wrote:

I don't think it is. The only reference I can find is 
https://github.com/torvalds/linux/blob/94305e83eccb3120c921cd3a015cd74731140bac/arch/sparc/include/uapi/asm/siginfo.h#L14
 and there it's set to 32767.

0 is 
[SI_USER](https://github.com/torvalds/linux/blob/94305e83eccb3120c921cd3a015cd74731140bac/include/uapi/asm-generic/siginfo.h#L174),
 which is used by `kill`, so in theory uid/pid should be set. However, it's 
also used as a default value, so maybe not printing the uid/pid in this case is 
actually correct:
https://github.com/torvalds/linux/blob/94305e83eccb3120c921cd3a015cd74731140bac/kernel/signal.c#L589-L599

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

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

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


[Lldb-commits] [lldb] [lldb] Adding a new decorator for CMAKE_BUILD_TYPE. (PR #141159)

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

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


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


[Lldb-commits] [lldb] [lldb/cmake] Don't call llvm_process_sources (PR #141217)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

It's already called in llvm_add_library.

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


1 Files Affected:

- (modified) lldb/cmake/modules/AddLLDB.cmake (+2-3) 


``diff
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 2956cdb7f9c8a..3a9dcb79629b4 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -45,7 +45,6 @@ function(add_lldb_library name)
 "INSTALL_PREFIX;ENTITLEMENTS"
 "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
 ${ARGN})
-  llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
 
   if(PARAM_NO_INTERNAL_DEPENDENCIES)
@@ -77,7 +76,6 @@ function(add_lldb_library name)
 list(GET split_path -1 dir)
 file(GLOB_RECURSE headers
   ../../include/lldb${dir}/*.h)
-set(srcs ${srcs} ${headers})
   endif()
   if (PARAM_MODULE)
 set(libkind MODULE)
@@ -101,7 +99,8 @@ function(add_lldb_library name)
 set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
   endif()
 
-  llvm_add_library(${name} ${libkind} ${srcs}
+  llvm_add_library(${name} ${libkind} ${headers}
+${PARAM_UNPARSED_ARGUMENTS}
 LINK_LIBS ${PARAM_LINK_LIBS}
 DEPENDS ${PARAM_DEPENDS}
 ${pass_ENTITLEMENTS}

``




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


[Lldb-commits] [lldb] [lldb/cmake] Don't call llvm_process_sources (PR #141217)

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

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

It's already called in llvm_add_library.

>From 1da42847de2c438ae726b9800843f6449fede41a Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 23 May 2025 11:22:40 +0200
Subject: [PATCH] [lldb/cmake] Don't call llvm_process_sources

It's already called in llvm_add_library.
---
 lldb/cmake/modules/AddLLDB.cmake | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 2956cdb7f9c8a..3a9dcb79629b4 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -45,7 +45,6 @@ function(add_lldb_library name)
 "INSTALL_PREFIX;ENTITLEMENTS"
 "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS;CLANG_LIBS"
 ${ARGN})
-  llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
 
   if(PARAM_NO_INTERNAL_DEPENDENCIES)
@@ -77,7 +76,6 @@ function(add_lldb_library name)
 list(GET split_path -1 dir)
 file(GLOB_RECURSE headers
   ../../include/lldb${dir}/*.h)
-set(srcs ${srcs} ${headers})
   endif()
   if (PARAM_MODULE)
 set(libkind MODULE)
@@ -101,7 +99,8 @@ function(add_lldb_library name)
 set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
   endif()
 
-  llvm_add_library(${name} ${libkind} ${srcs}
+  llvm_add_library(${name} ${libkind} ${headers}
+${PARAM_UNPARSED_ARGUMENTS}
 LINK_LIBS ${PARAM_LINK_LIBS}
 DEPENDS ${PARAM_DEPENDS}
 ${pass_ENTITLEMENTS}

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


[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on windows (PR #141212)

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

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

https://lab.llvm.org/buildbot/#/builders/141/builds/8927/steps/6/logs/stdio

>From 660eeaef30c2d99f0ed571029f4f7d6783a36789 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Fri, 23 May 2025 10:44:09 +0200
Subject: [PATCH] [lldb] skip unnamed symbol test on windows

---
 .../unnamed_symbol_lookup/TestUnnamedSymbolLookup.py   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py 
b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
index 09d43a34c7e30..c0438f77fb1d1 100644
--- a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
+++ b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
@@ -8,7 +8,8 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
+# --keep-symbol causes error on Windows: llvm-strip.exe: error: option is not 
supported for COFF
+@skipIfWindows
 class TestUnnamedSymbolLookup(TestBase):
 def test_unnamed_symbol_lookup(self):
 """Test looking up unnamed symbol synthetic name"""

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


[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on windows (PR #141212)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ely Ronnen (eronnen)


Changes

https://lab.llvm.org/buildbot/#/builders/141/builds/8927/steps/6/logs/stdio

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


1 Files Affected:

- (modified) 
lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py 
(+2-1) 


``diff
diff --git 
a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py 
b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
index 09d43a34c7e30..c0438f77fb1d1 100644
--- a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
+++ b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
@@ -8,7 +8,8 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
+# --keep-symbol causes error on Windows: llvm-strip.exe: error: option is not 
supported for COFF
+@skipIfWindows
 class TestUnnamedSymbolLookup(TestBase):
 def test_unnamed_symbol_lookup(self):
 """Test looking up unnamed symbol synthetic name"""

``




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


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

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

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


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

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

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

I think it's fine. the std::vector formatter tests are not running currently on 
windows, so it's likely that formatter is just broken there. Since this is test 
for the DIL and not std::vector, we could write our own formatter to test this 
functionality, but I think that would be overkill. We can keep the test here, 
and once the new implementation is enabled, we can move the relevant part to 
the test for std::vector.

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


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

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


@@ -0,0 +1,119 @@
+"""
+Test DIL array subscript.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+
+class TestFrameVarDILArraySubscript(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def expect_var_path(self, expr, compare_to_framevar=False, value=None, 
type=None):
+value_dil = super().expect_var_path(expr, value=value, type=type)
+if compare_to_framevar:
+self.runCmd("settings set target.experimental.use-DIL false")
+value_frv = super().expect_var_path(expr, value=value, type=type)
+self.runCmd("settings set target.experimental.use-DIL true")
+self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
+
+def test_subscript(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+
+self.runCmd("settings set target.experimental.use-DIL true")
+
+# Test int[] and int*
+self.expect_var_path("int_arr[0]", True, value="1")
+self.expect_var_path("int_ptr[1]", True, value="2")
+self.expect("frame var 'int_arr[enum_one]'", error=True)
+
+# Test when base and index are references.
+self.expect_var_path("int_arr[0]", True, value="1")
+self.expect("frame var 'int_arr[idx_1_ref]'", error=True)
+self.expect("frame var 'int_arr[enum_ref]'", error=True)
+self.expect_var_path("int_arr_ref[0]", value="1")
+self.expect("frame var 'int_arr_ref[idx_1_ref]'", error=True)
+self.expect("frame var 'int_arr_ref[enum_ref]'", error=True)
+
+# Test when base and index are typedefs.
+self.expect_var_path("td_int_arr[0]", True, value="1")
+self.expect("frame var 'td_int_arr[td_int_idx_1]'", error=True)
+self.expect("frame var 'td_int_arr[td_td_int_idx_2]'", error=True)
+self.expect_var_path("td_int_ptr[0]", True, value="1")
+self.expect("frame var 'td_int_ptr[td_int_idx_1]'", error=True)
+self.expect("frame var 'td_int_ptr[td_td_int_idx_2]'", error=True)
+
+# Both typedefs and refs
+self.expect("frame var 'td_int_arr_ref[td_int_idx_1_ref]'", error=True)
+
+# Test for index out of bounds.
+self.expect_var_path("int_arr[42]", True, type="int")
+self.expect_var_path("int_arr[100]", True, type="int")
+
+# Test address-of of the subscripted value.
+self.expect_var_path("*(&int_arr[1])", value="2")
+
+# Test for negative index.
+self.expect(
+"frame var 'int_arr[-1]'",
+error=True,
+substrs=["unrecognized token"],
+)
+
+# Test for floating point index
+self.expect(
+"frame var 'int_arr[1.0]'",
+error=True,
+substrs=["unrecognized token"],
+)
+
+# Base should be a "pointer to T" and index should be of an integral 
type.
+self.expect(
+"frame var 'idx_1[0]'",
+error=True,
+substrs=["subscripted value is not an array or pointer"],
+)
+self.expect(
+"frame var 'idx_1_ref[0]'",
+error=True,
+substrs=["subscripted value is not an array or pointer"],
+)
+self.expect(
+"frame var 'int_arr[int_ptr]'",
+error=True,
+substrs=["failed to parse integer constant"],
+)
+self.expect(
+"frame var '1[2]'",
+error=True,
+substrs=["Unexpected token"],
+)
+
+# Base should not be a pointer to void
+self.expect(
+"frame var 'p_void[0]'",
+error=True,
+substrs=["subscript of pointer to incomplete type 'void'"],
+)
+
+@skipIf(oslist=["windows"], archs=["aarch64"])

labath wrote:

```suggestion
@expectedFailureAll(oslist=["windows"])
```

I doubt this is specific to aarch64. It just happens we have no other bot 
around. And lets use xfail so we know to re-enable this when it gets fixed.

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

labath wrote:

> I don't know if this is the source of the problem, but one thing I noticed is 
> that you're missing some sort of synchronization to make sure the child 
> process doesn't exit before you're able to observe it. A slightly lame but 
> probably sufficient method to do that would be to put a long (say, 1 minute, 
> it's there just to ensure the process exits if something goes wrong) sleep 
> into the child, and then have the parent kill it when it is done with it.

The code looks good, but you still need to do something to ensure there's no 
race in retrieving the process info.

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

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


@@ -480,3 +481,111 @@ CompilerType PlatformLinux::GetSiginfoType(const 
llvm::Triple &triple) {
   ast->CompleteTagDeclarationDefinition(siginfo_type);
   return siginfo_type;
 }
+
+static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) {
+  if (!siginfo_sp)
+return "";
+
+  lldb_private::LinuxSignals linux_signals;
+  int code = 
siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0);
+  int signo =
+  siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1);
+  // si_code = 0 is SI_NOINFO, we just want the description with nothing
+  // important
+  if (code == 0)
+return linux_signals.GetSignalDescription(signo, code);
+
+  auto sifields = siginfo_sp->GetChildMemberWithName("_sifields");
+  if (!sifields)
+return linux_signals.GetSignalDescription(signo, code);
+
+  // declare everything that we can populate later.
+  std::optional addr;
+  std::optional upper;
+  std::optional lower;
+  std::optional pid;
+  std::optional uid;
+
+  // The negative si_codes are special and mean this signal was sent from user
+  // space not the kernel. These take precedence because they break some of the
+  // invariants around kernel sent signals. Such as SIGSEGV won't have an
+  // address.
+  if (code < 0) {
+auto sikill = sifields->GetChildMemberWithName("_kill");
+if (sikill) {
+  auto pid_sp = sikill->GetChildMemberWithName("si_pid");
+  if (pid_sp)
+pid = pid_sp->GetValueAsUnsigned(-1);
+  auto uid_sp = sikill->GetChildMemberWithName("si_uid");
+  if (uid_sp)
+uid = uid_sp->GetValueAsUnsigned(-1);
+}
+  } else {
+
+switch (signo) {
+case SIGILL:
+case SIGFPE:
+case SIGBUS: {
+  auto sigfault = sifields->GetChildMemberWithName("_sigfault");
+  if (!sigfault)
+break;
+
+  auto addr_sp = sigfault->GetChildMemberWithName("si_addr");
+  if (addr_sp)
+addr = addr_sp->GetValueAsUnsigned(-1);
+  break;
+}
+case SIGSEGV: {
+  auto sigfault = sifields->GetChildMemberWithName("_sigfault");
+  if (!sigfault)
+break;
+
+  auto addr_sp = sigfault->GetChildMemberWithName("si_addr");
+  if (addr_sp)
+addr = addr_sp->GetValueAsUnsigned(-1);
+
+  auto bounds_sp = sigfault->GetChildMemberWithName("_bounds");
+  if (!bounds_sp)
+break;
+
+  auto addr_bnds_sp = bounds_sp->GetChildMemberWithName("_addr_bnd");
+  if (!addr_bnds_sp)
+break;
+
+  auto lower_sp = addr_bnds_sp->GetChildMemberWithName("_lower");
+  if (lower_sp)
+lower = lower_sp->GetValueAsUnsigned(-1);
+
+  auto upper_sp = addr_bnds_sp->GetChildMemberWithName("_upper");
+  if (upper_sp)
+upper = upper_sp->GetValueAsUnsigned(-1);
+
+  break;
+}
+default:
+  break;
+}
+  }
+
+  return linux_signals.GetSignalDescription(signo, code, addr, lower, upper,
+uid, pid);
+}
+
+lldb::StopInfoSP PlatformLinux::GetStopInfoFromSiginfo(Thread &thread) {
+  ValueObjectSP siginfo_sp = thread.GetSiginfoValue();
+  if (!siginfo_sp)
+return {};
+  auto signo_sp = siginfo_sp->GetChildMemberWithName("si_signo");
+  auto sicode_sp = siginfo_sp->GetChildMemberWithName("si_code");
+  if (!signo_sp || !sicode_sp)
+return {};
+
+  std::string siginfo_description = GetDescriptionFromSiginfo(siginfo_sp);
+  if (siginfo_description.empty())
+return StopInfo::CreateStopReasonWithSignal(
+thread, signo_sp->GetValueAsUnsigned(-1));
+  else

labath wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

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


[Lldb-commits] [lldb] a4380fe - [lldb/cmake] Remove special handling of OBJECT libraries (#141066)

2025-05-23 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-23T10:22:59+02:00
New Revision: a4380fe5f99978f49c2d119aee412a6bd734e9fd

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

LOG: [lldb/cmake] Remove special handling of OBJECT libraries (#141066)

Nothing in lldb sets this. And even if they did, llvm_add_library should
know how to handle that.

Added: 


Modified: 
lldb/cmake/modules/AddLLDB.cmake

Removed: 




diff  --git a/lldb/cmake/modules/AddLLDB.cmake 
b/lldb/cmake/modules/AddLLDB.cmake
index 41f9b28a0ab39..2956cdb7f9c8a 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -93,29 +93,25 @@ function(add_lldb_library name)
 set(libkind STATIC)
   endif()
 
-  if (PARAM_OBJECT)
-add_library(${name} ${libkind} ${srcs})
-  else()
-if(PARAM_ENTITLEMENTS)
-  set(pass_ENTITLEMENTS ENTITLEMENTS ${PARAM_ENTITLEMENTS})
-endif()
+  if(PARAM_ENTITLEMENTS)
+set(pass_ENTITLEMENTS ENTITLEMENTS ${PARAM_ENTITLEMENTS})
+  endif()
 
-if(LLDB_NO_INSTALL_DEFAULT_RPATH)
-  set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
-endif()
+  if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+  endif()
 
-llvm_add_library(${name} ${libkind} ${srcs}
-  LINK_LIBS ${PARAM_LINK_LIBS}
-  DEPENDS ${PARAM_DEPENDS}
-  ${pass_ENTITLEMENTS}
-  ${pass_NO_INSTALL_RPATH}
-)
+  llvm_add_library(${name} ${libkind} ${srcs}
+LINK_LIBS ${PARAM_LINK_LIBS}
+DEPENDS ${PARAM_DEPENDS}
+${pass_ENTITLEMENTS}
+${pass_NO_INSTALL_RPATH}
+  )
 
-if(CLANG_LINK_CLANG_DYLIB)
-  target_link_libraries(${name} PRIVATE clang-cpp)
-else()
-  target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
-endif()
+  if(CLANG_LINK_CLANG_DYLIB)
+target_link_libraries(${name} PRIVATE clang-cpp)
+  else()
+target_link_libraries(${name} PRIVATE ${PARAM_CLANG_LIBS})
   endif()
 
   # A target cannot be changed to a FRAMEWORK after calling install() because



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


[Lldb-commits] [lldb] [lldb/cmake] Remove special handling of OBJECT libraries (PR #141066)

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

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


[Lldb-commits] [lldb] [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (PR #141220)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

`parseAndLoadModuleMapFile` returns `true` on error. This seems to have always 
been an issue? This is now preventing me from fixing a different modules 
related issue. So this patch checks the return value correctly.

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


1 Files Affected:

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


``diff
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index eb62cb618f254..c99ed9dd0a68d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -330,7 +330,7 @@ bool ClangModulesDeclVendorImpl::AddModule(const 
SourceModule &module,
   auto file = HS.lookupModuleMapFile(*dir, is_framework);
   if (!file)
 return error();
-  if (!HS.parseAndLoadModuleMapFile(*file, is_system))
+  if (HS.parseAndLoadModuleMapFile(*file, is_system))
 return error();
 }
   }

``




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


[Lldb-commits] [lldb] [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (PR #141220)

2025-05-23 Thread Michael Buch via lldb-commits

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

`parseAndLoadModuleMapFile` returns `true` on error. This seems to have always 
been an issue? This is now preventing me from fixing a different modules 
related issue. So this patch checks the return value correctly.

>From eeb97c3ad4fc761323b7033481a37dfb942a64bf Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 23 May 2025 10:42:21 +0100
Subject: [PATCH] [lldb][Modules] Fix error handling of
 parseAndLoadModuleMapFile

`parseAndLoadModuleMapFile` returns `true` on error. This seems to have
always been an issue? This is now preventing me from fixing a different
modules related issue. So this patch checks the return value correctly.
---
 .../Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index eb62cb618f254..c99ed9dd0a68d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -330,7 +330,7 @@ bool ClangModulesDeclVendorImpl::AddModule(const 
SourceModule &module,
   auto file = HS.lookupModuleMapFile(*dir, is_framework);
   if (!file)
 return error();
-  if (!HS.parseAndLoadModuleMapFile(*file, is_system))
+  if (HS.parseAndLoadModuleMapFile(*file, is_system))
 return error();
 }
   }

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

HemangGadhavi wrote:

> > I don't know if this is the source of the problem, but one thing I noticed 
> > is that you're missing some sort of synchronization to make sure the child 
> > process doesn't exit before you're able to observe it. A slightly lame but 
> > probably sufficient method to do that would be to put a long (say, 1 
> > minute, it's there just to ensure the process exits if something goes 
> > wrong) sleep into the child, and then have the parent kill it when it is 
> > done with it.
> 
> The code looks good, but you still need to do something to ensure there's no 
> race in retrieving the process info.

Hi @labath Added some delay which gives some time before retrieving the process 
info. 
Please review once. 

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

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

>From a47e4642e6ebcbe6b5466ff118968bac83ccf1e9 Mon Sep 17 00:00:00 2001
From: HemangGadhavi 
Date: Tue, 6 May 2025 07:59:45 -0500
Subject: [PATCH 1/3] [lldb][AIX] get host info for AIX (cont..)

---
 lldb/source/Host/aix/Host.cpp| 49 +++-
 lldb/source/Host/aix/HostInfoAIX.cpp | 15 +
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index a812e061ccae2..ead8202cbbdef 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/BinaryFormat/XCOFF.h"
+#include 
 #include 
 #include 
 
@@ -41,6 +42,14 @@ static ProcessInstanceInfo::timespec 
convert(pr_timestruc64_t t) {
   return ts;
 }
 
+static bool IsDirNumeric(const char *dname) {
+  for (; *dname; dname++) {
+if (!isdigit(*dname))
+  return false;
+  }
+  return true;
+}
+
 static bool GetStatusInfo(::pid_t pid, ProcessInstanceInfo &processInfo,
   ProcessState &State) {
   struct pstatus pstatusData;
@@ -133,7 +142,45 @@ static bool GetProcessAndStatInfo(::pid_t pid,
 
 uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
  ProcessInstanceInfoList &process_infos) {
-  return 0;
+  static const char procdir[] = "/proc/";
+
+  DIR *dirproc = opendir(procdir);
+  if (dirproc) {
+struct dirent *direntry = nullptr;
+const uid_t our_uid = getuid();
+const lldb::pid_t our_pid = getpid();
+bool all_users = match_info.GetMatchAllUsers();
+
+while ((direntry = readdir(dirproc)) != nullptr) {
+  if (!IsDirNumeric(direntry->d_name))
+continue;
+
+  lldb::pid_t pid = atoi(direntry->d_name);
+  // Skip this process.
+  if (pid == our_pid)
+continue;
+
+  ProcessState State;
+  ProcessInstanceInfo process_info;
+  if (!GetProcessAndStatInfo(pid, process_info, State))
+continue;
+
+  if (State == ProcessState::Zombie ||
+  State == ProcessState::TracedOrStopped)
+continue;
+
+  // Check for user match if we're not matching all users and not running
+  // as root.
+  if (!all_users && (our_uid != 0) && (process_info.GetUserID() != 
our_uid))
+continue;
+
+  if (match_info.Matches(process_info)) {
+process_infos.push_back(process_info);
+  }
+}
+closedir(dirproc);
+  }
+  return process_infos.size();
 }
 
 bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
diff --git a/lldb/source/Host/aix/HostInfoAIX.cpp 
b/lldb/source/Host/aix/HostInfoAIX.cpp
index 61b47462dd647..d720f5c52d3b1 100644
--- a/lldb/source/Host/aix/HostInfoAIX.cpp
+++ b/lldb/source/Host/aix/HostInfoAIX.cpp
@@ -7,6 +7,8 @@
 
//===--===//
 
 #include "lldb/Host/aix/HostInfoAIX.h"
+#include "lldb/Host/posix/Support.h"
+#include 
 
 using namespace lldb_private;
 
@@ -18,5 +20,18 @@ void HostInfoAIX::Terminate() { HostInfoBase::Terminate(); }
 
 FileSpec HostInfoAIX::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
+  struct psinfo psinfoData;
+  auto BufferOrError = getProcFile(getpid(), "psinfo");
+  if (BufferOrError) {
+std::unique_ptr PsinfoBuffer =
+std::move(*BufferOrError);
+memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
+llvm::StringRef exe_path(
+psinfoData.pr_psargs,
+strnlen(psinfoData.pr_psargs, sizeof(psinfoData.pr_psargs)));
+if (!exe_path.empty()) {
+  g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
+}
+  }
   return g_program_filespec;
 }

>From adf7708a50e781c31e2bccc1eff484499977f064 Mon Sep 17 00:00:00 2001
From: HemangGadhavi 
Date: Wed, 21 May 2025 05:22:07 -0400
Subject: [PATCH 2/3] Added testcase for GetProgramFileSpec & FindProcesses

---
 lldb/source/Host/aix/Host.cpp| 17 -
 lldb/source/Host/aix/HostInfoAIX.cpp |  3 +--
 lldb/unittests/Host/HostInfoTest.cpp |  5 +
 lldb/unittests/Host/HostTest.cpp | 24 
 4 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index ead8202cbbdef..b5572b93d93a9 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -42,14 +42,6 @@ static ProcessInstanceInfo::timespec 
convert(pr_timestruc64_t t) {
   return ts;
 }
 
-static bool IsDirNumeric(const char *dname) {
-  for (; *dname; dname++) {
-if (!isdigit(*dname))
-  return false;
-  }
-  return true;
-}
-
 static bool GetStatusInfo(::pid_t pid, ProcessInstanceInfo &processInfo,
   ProcessState &State) {
   struct pstatus pstatusData;
@@ -152,10 +144,10 @@ uint32_t Host::FindProc

[Lldb-commits] [lldb] 53d7b1d - [LLDB] Add field member operators to DIL (#138093)

2025-05-23 Thread via lldb-commits

Author: cmtice
Date: 2025-05-23T07:30:10-07:00
New Revision: 53d7b1d9e00d8cc3189808bbc26e2ee4577766e7

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

LOG: [LLDB] Add field member operators to DIL (#138093)

Add the arrow and period operators, allowing DIL to find and access
member fields.

Added: 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/Makefile

lldb/test/API/commands/frame/var-dil/basics/MemberOf/TestFrameVarDILMemberOf.py
lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/Makefile

lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/Makefile

lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/TestFrameVarDILMemberOfInheritance.py
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp

Modified: 
lldb/docs/dil-expr-lang.ebnf
lldb/include/lldb/ValueObject/DILAST.h
lldb/include/lldb/ValueObject/DILEval.h
lldb/include/lldb/ValueObject/DILLexer.h
lldb/include/lldb/ValueObject/DILParser.h
lldb/source/Target/StackFrame.cpp
lldb/source/ValueObject/DILAST.cpp
lldb/source/ValueObject/DILEval.cpp
lldb/source/ValueObject/DILLexer.cpp
lldb/source/ValueObject/DILParser.cpp

Removed: 




diff  --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..580626862c005 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -5,13 +5,17 @@
 
 expression = unary_expression ;
 
-unary_expression = unary_operator expression
- | primary_expression ;
+unary_expression = postfix_expression
+ | unary_operator expression ;
 
 unary_operator = "*" | "&" ;
 
+postfix_expresson = primary_expression
+  | postfix_expression "." id_expression
+  | postfix_expression "->" id_expression ;
+
 primary_expression = id_expression
-   | "(" expression ")";
+   | "(" expression ")"  ;
 
 id_expression = unqualified_id
   | qualified_id

diff  --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..8687316657ca9 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
 enum class NodeKind {
   eErrorNode,
   eIdentifierNode,
+  eMemberOfNode,
   eUnaryOpNode,
 };
 
@@ -88,6 +89,29 @@ class IdentifierNode : public ASTNode {
   std::string m_name;
 };
 
+class MemberOfNode : public ASTNode {
+public:
+  MemberOfNode(uint32_t location, ASTNodeUP base, bool is_arrow,
+   std::string name)
+  : ASTNode(location, NodeKind::eMemberOfNode), m_base(std::move(base)),
+m_is_arrow(is_arrow), m_field_name(std::move(name)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *GetBase() const { return m_base.get(); }
+  bool GetIsArrow() const { return m_is_arrow; }
+  llvm::StringRef GetFieldName() const { return llvm::StringRef(m_field_name); 
}
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eMemberOfNode;
+  }
+
+private:
+  ASTNodeUP m_base;
+  bool m_is_arrow;
+  std::string m_field_name;
+};
+
 class UnaryOpNode : public ASTNode {
 public:
   UnaryOpNode(uint32_t location, UnaryOpKind kind, ASTNodeUP operand)
@@ -118,6 +142,8 @@ class Visitor {
   virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
+  Visit(const MemberOfNode *node) = 0;
+  virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
 };
 

diff  --git a/lldb/include/lldb/ValueObject/DILEval.h 
b/lldb/include/lldb/ValueObject/DILEval.h
index b1dd3fdb49739..266b6fb1a63eb 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -41,22 +41,27 @@ lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef 
name_ref,
 class Interpreter : Visitor {
 public:
   Interpreter(lldb::TargetSP target, llvm::StringRef expr,
-  lldb::DynamicValueType use_dynamic,
-  std::shared_ptr frame_sp);
+  std::shared_ptr frame_sp,
+  lldb::DynamicValueType use_dynamic, bool use_synthetic,
+  bool fragile_ivar, bool check_ptr_vs_member);
 
   llvm::Expected Evaluate(const ASTNode *node);
 
 private:
   llvm::Expected
   Visit(const IdentifierNode *node) override;
+  llvm::Expected Visit(const MemberOfNode *node) override;
   llvm::Expected Visit(const UnaryOpNode *node) overrid

[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

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

kazutakahirata wrote:

@cmtice I'm getting:

```
lldb/include/lldb/ValueObject/DILParser.h:121:8: error: private field 
'm_fragile_ivar' is not used [-Werror,-Wunused-private-field]
  121 |   bool m_fragile_ivar;
  |^
lldb/include/lldb/ValueObject/DILParser.h:122:8: error: private field 
'm_check_ptr_vs_member' is not used [-Werror,-Wunused-private-field]
  122 |   bool m_check_ptr_vs_member;
  |^
2 errors generated.
```

Would you mind taking a look?  Should I just remove these variables, adjust the 
constructor, and the callers of the constructor?  Thanks!


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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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


@@ -54,6 +54,12 @@ TEST_F(HostInfoTest, GetHostname) {
   EXPECT_TRUE(HostInfo::GetHostname(s));
 }
 
+TEST_F(HostInfoTest, GetProgramFileSpec) {
+  // Test GetProgramFileSpec()
+  FileSpec filespec = HostInfo::GetProgramFileSpec();
+  EXPECT_FALSE(filespec.GetFilename().IsEmpty());

DhruvSrivastavaX wrote:

@labath Do we need to make it like more like a step-by-step/combination check?
Like checking if the Path validity, then checking if it exists or something 
like that?
Or just one strong check like above is enough?

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

DhruvSrivastavaX wrote:

Side-Note: @HemangGadhavi Please verify that these pass on our AIX setup as 
well.

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

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

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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-23 Thread via lldb-commits

cmtice wrote:

> @cmtice I'm getting:
> 
> ```
> lldb/include/lldb/ValueObject/DILParser.h:121:8: error: private field 
> 'm_fragile_ivar' is not used [-Werror,-Wunused-private-field]
>   121 |   bool m_fragile_ivar;
>   |^
> lldb/include/lldb/ValueObject/DILParser.h:122:8: error: private field 
> 'm_check_ptr_vs_member' is not used [-Werror,-Wunused-private-field]
>   122 |   bool m_check_ptr_vs_member;
>   |^
> 2 errors generated.
> ```
> 
> Would you mind taking a look? Should I just remove these variables, adjust 
> the constructor, and the callers of the constructor? Thanks!

I'll try to get a fix for this asap.

https://github.com/llvm/llvm-project/pull/138093
___
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-05-23 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+"""
+Usage:   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'^//#define LLDB_VERSION$')
+LLDB_REVISION_REGEX = re.compile(r'^//#define LLDB_REVISION$')
+LLDB_VERSION_STRING_REGEX = re.compile(r'^//#define LLDB_VERSION_STRING$')
+
+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()
+
+with open(output_path, "w") as output_file:
+for line in lines:
+version_match = LLDB_VERSION_REGEX.match(line)
+revision_match = LLDB_REVISION_REGEX.match(line)
+version_string_match = LLDB_VERSION_STRING_REGEX.match(line)
+
+# 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 

+if version_match:
+output_file.write(re.sub(LLDB_VERSION_REGEX, r'#define 
LLDB_VERSION ' + lldb_version_major, line))
+elif revision_match:
+output_file.write(re.sub(LLDB_REVISION_REGEX, r'#define 
LLDB_REVISION ' + lldb_version_patch, line))
+elif version_string_match:
+output_file.write(re.sub(LLDB_VERSION_STRING_REGEX, r'#define 
LLDB_VERSION_STRING "{0}.{1}.{2}"'.format(lldb_version_major, 
lldb_version_minor, lldb_version_patch), line))
+else:
+output_file.write(line)

chelcassanova wrote:

> Unless that's intentional?

Not really, this is more of a holdover from how I set up the regex matching for 
other Python scripts that do this kind of thing. I can try passing in the 
buffer here instead of going line by line.

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][headers] Create script to fix up versioning (PR #141116)

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


@@ -0,0 +1,17 @@
+// Run the convert script on it, then run the framework include fix on it. The 
framework version fix script
+// expects that all lldb references have been renamed to lldb-rpc in order for 
it to modify the includes
+// to go into the framework.

chelcassanova wrote:

This can be removed, this comment is referring to lldb-rpc and the "it" 
would've been from when I was copying a file in from source.

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] 6087854 - [lldb] skip unnamed symbol test on windows (#141212)

2025-05-23 Thread via lldb-commits

Author: Ely Ronnen
Date: 2025-05-23T18:52:42+02:00
New Revision: 6087854472a97e9a1b33933a0694cf4210c90b93

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

LOG: [lldb] skip unnamed symbol test on windows (#141212)

https://lab.llvm.org/buildbot/#/builders/141/builds/8927/steps/6/logs/stdio

Added: 


Modified: 
lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py 
b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
index 09d43a34c7e30..c0438f77fb1d1 100644
--- a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
+++ b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py
@@ -8,7 +8,8 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
+# --keep-symbol causes error on Windows: llvm-strip.exe: error: option is not 
supported for COFF
+@skipIfWindows
 class TestUnnamedSymbolLookup(TestBase):
 def test_unnamed_symbol_lookup(self):
 """Test looking up unnamed symbol synthetic name"""



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


[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on windows (PR #141212)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `lldb` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-shell :: Recognizer/assert.test (2948 of 2959)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Python/Crashlog/no-args.test (2949 
of 2959)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/lua-python.test (2950 of 2959)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test (2951 of 
2959)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test (2952 
of 2959)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/no_threadState.test (2953 of 2959)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test 
(2954 of 2959)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/lua.test (2955 of 2959)
PASS: lldb-api :: terminal/TestEditlineCompletions.py (2956 of 2959)
UNRESOLVED: lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py (2957 of 2959)
 TEST 'lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py' 
FAILED 
Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make 
/usr/bin/gmake --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/launch
 -p TestDAP_launch.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
6087854472a97e9a1b33933a0694cf4210c90b93)
  clang revision 6087854472a97e9a1b33933a0694cf4210c90b93
  llvm revision 6087854472a97e9a1b33933a0694cf4210c90b93
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/launch
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

runCmd: settings set target.auto-apply-fixits false

```



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


[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on windows (PR #141212)

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

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-23 Thread Jacob Lalonde via lldb-commits


@@ -480,3 +481,111 @@ CompilerType PlatformLinux::GetSiginfoType(const 
llvm::Triple &triple) {
   ast->CompleteTagDeclarationDefinition(siginfo_type);
   return siginfo_type;
 }
+
+static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) {
+  if (!siginfo_sp)
+return "";
+
+  lldb_private::LinuxSignals linux_signals;
+  int code = 
siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0);
+  int signo =
+  siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1);
+  // si_code = 0 is SI_NOINFO, we just want the description with nothing

Jlalond wrote:

I'm not sure where I got this information, but it shouldn't matter because the 
code is not defined. Good eye.

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-23 Thread Jacob Lalonde via lldb-commits

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

>From 94d78d5ea7866fe896381319c875d6b9c3d34c90 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 15 May 2025 13:57:11 -0700
Subject: [PATCH 01/12] Update ThreadElfCore

---
 lldb/include/lldb/Target/UnixSignals.h  |  6 --
 .../Plugins/Process/Utility/LinuxSignals.cpp| 17 ++---
 .../Plugins/Process/elf-core/ThreadElfCore.cpp  | 10 +++---
 .../Plugins/Process/elf-core/ThreadElfCore.h|  6 ++
 lldb/source/Target/UnixSignals.cpp  |  9 +++--
 5 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..a1807d69f329b 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -36,7 +36,9 @@ class UnixSignals {
std::optional code = std::nullopt,
std::optional addr = std::nullopt,
std::optional lower = std::nullopt,
-   std::optional upper = std::nullopt) const;
+   std::optional upper = std::nullopt,
+   std::optional pid = std::nullopt,
+   std::optional uid = std::nullopt) const;
 
   bool SignalIsValid(int32_t signo) const;
 
@@ -105,7 +107,7 @@ class UnixSignals {
  llvm::StringRef description,
  llvm::StringRef alias = llvm::StringRef());
 
-  enum SignalCodePrintOption { None, Address, Bounds };
+  enum SignalCodePrintOption { None, Address, Bounds, Sender };
 
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 9c4fe55147a28..25d4e4609bbb8 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -38,6 +38,17 @@
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) 
\
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
 #endif /* if defined(__linux__) && !defined(__mips__) */
+// See siginfo.h in the Linux Kernel, these codes can be sent for any signal.
+#define ADD_LINUX_SIGNAL(signo, name, ...) \
+  AddSignal(signo, name, __VA_ARGS__); \
+  ADD_SIGCODE(signo, signo, SI_QUEUE, -1, "sent by sigqueue"); \
+  ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration"); \
+  ADD_SIGCODE(signo, signo, SI_MESGQ, -3, "sent by real time mesq state 
change"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCIO, -4, "sent by AIO completion"); \
+  ADD_SIGCODE(signo, signo, SI_SIGIO, -5, "sent by queued SIGIO"); \
+  ADD_SIGCODE(signo, signo, SI_TKILL, -6, "sent by tkill system call"); \
+  ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, "sent by execve() killing 
subsidiary threads"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCNL, -60, "sent by glibc async name lookup 
completion"); 
 
 using namespace lldb_private;
 
@@ -46,9 +57,9 @@ LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
 void LinuxSignals::Reset() {
   m_signals.clear();
   // clang-format off
-  //SIGNO   NAMESUPPRESS  STOPNOTIFY  DESCRIPTION
-  //==  ==    ==  ==  
===
-  AddSignal(1,  "SIGHUP",   false,true,   true,   "hangup");
+  //   SIGNO   NAMESUPPRESS  STOPNOTIFY  
DESCRIPTION
+  //   ==  ==    ==  ==  
===
+  ADD_LINUX_SIGNAL(1,  "SIGHUP",   false,true,   true,   "hangup");
   AddSignal(2,  "SIGINT",   true, true,   true,   "interrupt");
   AddSignal(3,  "SIGQUIT",  false,true,   true,   "quit");
 
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index e1c28e2edc20b..195d1798b0783 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -590,9 +590,13 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch,
   // 64b ELF have a 4 byte pad.
   if (data.GetAddressByteSize() == 8)
 offset += 4;
-  // Not every stop signal has a valid address, but that will get resolved in
-  // the unix_signals.GetSignalDescription() call below.
-  if (unix_signals.GetShouldStop(si_signo)) {
+
+ if (si_code < 0) {
+  sigfault.kill._pid = data.GetU32(&offset);
+  sigfault.kill._uid = data.GetU32(&offset);
+ } else if (unix_signals.GetShouldStop(si_signo)) {
+// Not every stop signal has a valid address, but that will get resolved in
+// the unix_signals.GetSignalDescription() call below.
 // Instead of memcpy we call all these indivi

[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;

ashgti wrote:

`lldb::addr_t load_addr` ? 

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {

ashgti wrote:

style nit: no `{}`

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {
+return llvm::make_error(
+llvm::formatv("address {:x} does not exist in the debuggee", 
load_addr),
+llvm::inconvertibleErrorCode(), false);
+  }
+
+  const uint32_t byte_size =
+  args.bytes.value_or(dap.target.GetAddressByteSize());
+
+  protocol::DataBreakpointInfoResponseBody response;
+  response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size);
+
+  lldb::SBMemoryRegionInfo region;
+  lldb::SBError err =
+  dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region);
+  // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this
+  // request if SBProcess::GetMemoryRegionInfo returns error.
+  if (err.Success() && !(region.IsReadable() || region.IsWritable())) {
+response.description = llvm::formatv(
+"memory region for address {} has no read or write permissions",
+load_addr);
+
+  } else {
+response.description =
+llvm::formatv("{} bytes at {:x}", byte_size, load_addr);
+response.accessTypes = {protocol::eDataBreakpointAccessTypeRead,

ashgti wrote:

Shouldn't we check the regionInfo for setting these access types?

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -1042,16 +1042,30 @@ def request_setFunctionBreakpoints(self, names, 
condition=None, hitCondition=Non
 return self.send_recv(command_dict)
 
 def request_dataBreakpointInfo(
-self, variablesReference, name, frameIndex=0, threadId=None
+self,
+name: str,
+variablesReference: int = None,
+frameIndex: int = 0,
+bytes_: int = None,
+asAddress: bool = None,
 ):
-stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)
-if stackFrame is None:
-return []
-args_dict = {
-"variablesReference": variablesReference,
-"name": name,
-"frameId": stackFrame["id"],
-}
+args_dict = {}
+if asAddress is not None:
+args_dict = {
+"name": name,
+"asAddress": asAddress,
+"bytes": bytes_,
+}
+else:
+stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=None)
+if stackFrame is None:
+return []

ashgti wrote:

If we have a frameIndex and its not found, should we raise an error? I think 
that might be better than silently returning an empty value.

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {
+return llvm::make_error(
+llvm::formatv("address {:x} does not exist in the debuggee", 
load_addr),
+llvm::inconvertibleErrorCode(), false);
+  }
+
+  const uint32_t byte_size =
+  args.bytes.value_or(dap.target.GetAddressByteSize());
+
+  protocol::DataBreakpointInfoResponseBody response;
+  response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size);
+
+  lldb::SBMemoryRegionInfo region;
+  lldb::SBError err =
+  dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region);
+  // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this
+  // request if SBProcess::GetMemoryRegionInfo returns error.
+  if (err.Success() && !(region.IsReadable() || region.IsWritable())) {

ashgti wrote:

Can we handle `err` separately?

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);

ashgti wrote:

nit: Could we rename `address` above to `raw_address` or remove the variable? 
Its only used on line 24, which could use `args.name` as the first param 
instead. Then we can use `addr` or `address` here.

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {
+return llvm::make_error(
+llvm::formatv("address {:x} does not exist in the debuggee", 
load_addr),
+llvm::inconvertibleErrorCode(), false);
+  }
+
+  const uint32_t byte_size =
+  args.bytes.value_or(dap.target.GetAddressByteSize());
+
+  protocol::DataBreakpointInfoResponseBody response;
+  response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size);
+
+  lldb::SBMemoryRegionInfo region;
+  lldb::SBError err =
+  dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region);
+  // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this

ashgti wrote:

I think debugserver also implements this 
https://github.com/llvm/llvm-project/blob/b878e0d11874a898bbaa1daf58007dfd232005f2/lldb/tools/debugserver/source/RNBRemote.cpp#L4242-L4329
 I'm not sure if this comment is correct.

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


[Lldb-commits] [lldb] [lldb-dap] Minor change to stdio client name. (PR #141266)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Update the stdin <-> stdout client name to `stdio`. I noticed on macOS if 
I get a crash report from lldb-dap the `/` in the client name causes some 
thread names to be reported without the full name. For example `Thread 6 
Crashed:: */stdout.event_handler`. Switching to `stdio` I think is still clear 
and not truncated in the macOS crash reports.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/tool/lldb-dap.cpp (+1-1) 


``diff
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 7a4cc70902a56..9b9de5e21a742 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -542,7 +542,7 @@ int main(int argc, char *argv[]) {
   lldb::IOObjectSP output = std::make_shared(
   stdout_fd, File::eOpenOptionWriteOnly, NativeFile::Unowned);
 
-  constexpr llvm::StringLiteral client_name = "stdin/stdout";
+  constexpr llvm::StringLiteral client_name = "stdio";
   Transport transport(client_name, log.get(), input, output);
   DAP dap(log.get(), default_repl_mode, pre_init_commands, transport);
 

``




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


[Lldb-commits] [lldb] 7dc7c15 - [lldb] Adding a new decorator for CMAKE_BUILD_TYPE. (#141159)

2025-05-23 Thread via lldb-commits

Author: John Harrison
Date: 2025-05-23T08:46:23-07:00
New Revision: 7dc7c155251c0008d5d59b84f0c9056365740f11

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

LOG: [lldb] Adding a new decorator for CMAKE_BUILD_TYPE. (#141159)

In lldb-dap, we have existing tests that are known to be unstable when
lldb and lldb-dap are built in the Debug configuration.

This decorator lets us skip those tests in CI jobs that are to slow with
those configurations.

This was split out from #140777 to make the patches smaller.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/configuration.py
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/test/API/lit.cfg.py
lldb/test/API/lit.site.cfg.py.in

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index 18c1566176331..b2d91fd211477 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -137,6 +137,9 @@
 # A plugin whose tests will be enabled, like intel-pt.
 enabled_plugins = []
 
+# the build type of lldb
+# Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
+cmake_build_type = None
 
 def shouldSkipBecauseOfCategories(test_categories):
 if use_categories:

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 895f2a82547a9..868e9f7e5eca0 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1102,3 +1102,15 @@ def is_feature_enabled():
 return "%s is not supported on this system." % feature
 
 return skipTestIfFn(is_feature_enabled)
+
+
+def skipIfBuildType(types: list[str]):
+"""Skip tests if built in a specific CMAKE_BUILD_TYPE.
+
+Supported types include 'Release', 'RelWithDebInfo', 'Debug', 'MinSizeRel'.
+"""
+types = [name.lower() for name in types]
+return unittest.skipIf(
+configuration.cmake_build_type.lower() in types,
+"skip on {} build type(s)".format(", ".join(types)),
+)

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 7cc8f2985043e..d7f274ac4f60e 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -297,6 +297,7 @@ def parseOptionsAndInitTestdirs():
 configuration.libcxx_include_dir = args.libcxx_include_dir
 configuration.libcxx_include_target_dir = args.libcxx_include_target_dir
 configuration.libcxx_library_dir = args.libcxx_library_dir
+configuration.cmake_build_type = args.cmake_build_type.lower()
 
 if args.channels:
 lldbtest_config.channels = args.channels

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 98210b7102e1b..e9c21388bc213 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -300,6 +300,12 @@ def create_parser():
 metavar="platform-available-ports",
 help="Ports available for connection to a lldb server on the remote 
platform",
 )
+group.add_argument(
+"--cmake-build-type",
+dest="cmake_build_type",
+metavar="cmake-build-type",
+help="Specifies the build type on single-configuration",
+)
 
 # Test-suite behaviour
 group = parser.add_argument_group("Runtime behaviour options")

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 08cf11c8a68db..646a446c86fdb 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -271,6 +271,9 @@ def delete_module_cache(path):
 if is_configured("lldb_framework_dir"):
 dotest_cmd += ["--framework", config.lldb_framework_dir]
 
+if is_configured("cmake_build_type"):
+dotest_cmd += ["--cmake-build-type", config.cmake_build_type]
+
 if "lldb-simulator-ios" in config.available_features:
 dotest_cmd += ["--apple-sdk", "iphonesimulator", "--platform-name", 
"ios-simulator"]
 elif "lldb-simulator-watchos" in config.available_features:

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index 54807de8819d2..8552d17d66631 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -27,6 +27,7 @@ config.dotest_common_args_str = 
lit_config.substitute("@LLDB_TEST_COMMON_ARGS@")
 config.dotest_user_args_str = lit_config.substitute("@LLDB_TEST_USER_ARGS@")
 config.lldb_platform_url = lit_config.substitute("@LLDB_TEST_PLATFORM_URL@

[Lldb-commits] [lldb] [lldb] Adding a new decorator for CMAKE_BUILD_TYPE. (PR #141159)

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

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


[Lldb-commits] [lldb] [lldb] skip unnamed symbol test on windows (PR #141212)

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

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


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


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

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

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

>From 01e35b2635b3727be7f7ab6f2389086c6e86b776 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 30 Apr 2025 13:37:15 -0700
Subject: [PATCH] [lldb][RPC] Upstream Python scripts

As part of upstreaming LLDB RPC, this commit adds python scripts that
are used by LLDB RPC to modify the public lldb header files for use with
RPC.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
---
 .../convert-lldb-header-to-rpc-header.py  | 71 +++
 lldb/scripts/framework-header-include-fix.py  | 46 
 .../TestConvertScript/CheckLLDBDefines.test   | 23 ++
 .../CheckLLDBEnumerations.test| 21 ++
 .../TestConvertScript/CheckLLDBTypes.test | 25 +++
 .../TestConvertScript/CheckSBDefines.test | 23 ++
 .../TestConvertScript/Inputs/SBDefines.h  | 22 ++
 .../TestConvertScript/Inputs/lldb-defines.h   | 23 ++
 .../Inputs/lldb-enumerations.h| 17 +
 .../TestConvertScript/Inputs/lldb-types.h | 23 ++
 .../CheckLLDBDefines.test |  9 +++
 .../CheckLLDBTypes.test   |  9 +++
 .../CheckSBClass.test | 11 +++
 .../CheckSBDefines.test   | 12 
 .../Inputs/SBDefines.h|  9 +++
 .../Inputs/SBRPC-FrameworkFix.h   | 10 +++
 .../Inputs/lldb-rpc-defines.h |  7 ++
 .../Inputs/lldb-rpc-types.h   |  7 ++
 18 files changed, 368 insertions(+)
 create mode 100755 lldb/scripts/convert-lldb-header-to-rpc-header.py
 create mode 100755 lldb/scripts/framework-header-include-fix.py
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBEnumerations.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckLLDBTypes.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/CheckSBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/SBDefines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-defines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-enumerations.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestConvertScript/Inputs/lldb-types.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckLLDBTypes.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBClass.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/CheckSBDefines.test
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBDefines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/SBRPC-FrameworkFix.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-defines.h
 create mode 100644 
lldb/test/Shell/RPC/Scripts/TestFrameworkIncludeFixScript/Inputs/lldb-rpc-types.h

diff --git a/lldb/scripts/convert-lldb-header-to-rpc-header.py 
b/lldb/scripts/convert-lldb-header-to-rpc-header.py
new file mode 100755
index 0..a7fd4733af56f
--- /dev/null
+++ b/lldb/scripts/convert-lldb-header-to-rpc-header.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+"""
+Usage: convert-lldb-header-to-rpc-header.py  

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

+
+import argparse
+import os
+import re
+
+
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument("input")
+parser.add_argument("output")
+args = parser.parse_args()
+input_path = str(args.input)
+output_path = str(args.output)
+with open(input_path, "r") as input_file:
+lines = input_file.readlines()
+
+with open(output_path, "w") as output_file:
+for line in lines:
+# NOTE: We do not use lldb-forward.h or lldb-versioning.h in RPC, 
so remove
+# all includes that are found for these files.
+if re.match(
+r'#include "lldb/lldb-forward|#include "lldb/lldb-versioning', 
line
+):
+continue
+# For lldb-rpc-defines.h, replace the ifndef LLDB_LLDB_ portion 
with LLDB_RPC_ as we're not
+# using LLDB private definitions in RPC.
+elif re.match(r".+LLDB_LLDB_", line):
+output_file.write(re.sub(r"LLDB_LLDB_", r"LLDB_RPC_", line))
+# Similarly to lldb-rpc-defines.h, replace the ifndef for LLDB_API 
in SBDefines.h to LLDB_

[Lldb-commits] [lldb] [LLDB] Fix warning about unused private members. (PR #141259)

2025-05-23 Thread via lldb-commits

https://github.com/cmtice created 
https://github.com/llvm/llvm-project/pull/141259

None

>From 589d44d2924ca149bfbf0b4b4cdb37f7dfe4c99f Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Fri, 23 May 2025 10:07:59 -0700
Subject: [PATCH] [LLDB] Fix warning about unused private members.

---
 lldb/include/lldb/ValueObject/DILParser.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/include/lldb/ValueObject/DILParser.h 
b/lldb/include/lldb/ValueObject/DILParser.h
index bd152940d28f6..485d84d27162e 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -71,6 +71,10 @@ class DILParser {
 
   bool UseSynthetic() { return m_use_synthetic; }
 
+  bool UseFragileIvar() { return m_fragile_ivar; }
+
+  bool CheckPtrVsMember() { return m_check_ptr_vs_member; }
+
   lldb::DynamicValueType UseDynamic() { return m_use_dynamic; }
 
 private:

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


[Lldb-commits] [lldb] [LLDB] Fix warning about unused private members. (PR #141259)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (cmtice)


Changes



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


1 Files Affected:

- (modified) lldb/include/lldb/ValueObject/DILParser.h (+4) 


``diff
diff --git a/lldb/include/lldb/ValueObject/DILParser.h 
b/lldb/include/lldb/ValueObject/DILParser.h
index bd152940d28f6..485d84d27162e 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -71,6 +71,10 @@ class DILParser {
 
   bool UseSynthetic() { return m_use_synthetic; }
 
+  bool UseFragileIvar() { return m_fragile_ivar; }
+
+  bool CheckPtrVsMember() { return m_check_ptr_vs_member; }
+
   lldb::DynamicValueType UseDynamic() { return m_use_dynamic; }
 
 private:

``




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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-23 Thread via lldb-commits

cmtice wrote:

> > @cmtice I'm getting:
> > ```
> > lldb/include/lldb/ValueObject/DILParser.h:121:8: error: private field 
> > 'm_fragile_ivar' is not used [-Werror,-Wunused-private-field]
> >   121 |   bool m_fragile_ivar;
> >   |^
> > lldb/include/lldb/ValueObject/DILParser.h:122:8: error: private field 
> > 'm_check_ptr_vs_member' is not used [-Werror,-Wunused-private-field]
> >   122 |   bool m_check_ptr_vs_member;
> >   |^
> > 2 errors generated.
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > Would you mind taking a look? Should I just remove these variables, adjust 
> > the constructor, and the callers of the constructor? Thanks!
> 
> I'll try to get a fix for this asap.

I think this should fix the problem: 
https://github.com/llvm/llvm-project/pull/141259 . Kazu, could you verify that 
it does please?

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


[Lldb-commits] [lldb] [LLDB] Fix warning about unused private members. (PR #141259)

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

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

LGTM.  I've verified that your patch fixes the warning.  Thanks!  I suppose 
you're going to use these accessors in the near future !?

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


[Lldb-commits] [lldb] [LLDB] Fix warning about unused private members. (PR #141259)

2025-05-23 Thread via lldb-commits

cmtice wrote:

> LGTM. I've verified that your patch fixes the warning. Thanks! I suppose 
> you're going to use these accessors in the near future !?

Yes, that is the plan.

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


[Lldb-commits] [lldb] b878e0d - [LLDB] Fix warning about unused private members. (#141259)

2025-05-23 Thread via lldb-commits

Author: cmtice
Date: 2025-05-23T10:18:05-07:00
New Revision: b878e0d11874a898bbaa1daf58007dfd232005f2

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

LOG: [LLDB] Fix warning about unused private members. (#141259)

Added: 


Modified: 
lldb/include/lldb/ValueObject/DILParser.h

Removed: 




diff  --git a/lldb/include/lldb/ValueObject/DILParser.h 
b/lldb/include/lldb/ValueObject/DILParser.h
index bd152940d28f6..485d84d27162e 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -71,6 +71,10 @@ class DILParser {
 
   bool UseSynthetic() { return m_use_synthetic; }
 
+  bool UseFragileIvar() { return m_fragile_ivar; }
+
+  bool CheckPtrVsMember() { return m_check_ptr_vs_member; }
+
   lldb::DynamicValueType UseDynamic() { return m_use_dynamic; }
 
 private:



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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

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

kazutakahirata wrote:

> I think this should fix the problem: #141259 . Kazu, could you verify that it 
> does please?

@cmtice Yes, it does.  I've LGTMed #141259.  Thank you for fixing this quickly!


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


[Lldb-commits] [lldb] [LLDB] Fix warning about unused private members. (PR #141259)

2025-05-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Minor change to stdio client name. (PR #141266)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Minor change to stdio client name. (PR #141266)

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

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -131,9 +133,10 @@ def verify_breakpoint_hit(self, breakpoint_ids, 
timeout=DEFAULT_TIMEOUT):
 # So when looking at the description we just want to make sure
 # the right breakpoint matches and not worry about the actual
 # location.
+type_name = "watchpoint" if is_watchpoint else "breakpoint"

ashgti wrote:

I think according to the spec, the 'reason' on line 122 should be `data 
breakpoint`, which maybe means our stopped event handler isn't handling data 
breakpoints correctly.

On that note, in the DAP this would be a `data breakpoint` not a 'watchpoint', 
can we update the description accordingly?

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


[Lldb-commits] [lldb] [lldb/cmake] Don't call llvm_process_sources (PR #141217)

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

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


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


[Lldb-commits] [lldb] [lldb][Modules] Fix error handling of parseAndLoadModuleMapFile (PR #141220)

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

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


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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-23 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

> Now for tests. The tests for the UnixSignals part are great, but I'm not sure 
> if there's a test for the end-to-end flow. It possible this automatically 
> code is tested by one of the existing core file. Could you check if anything 
> breaks if you e.g. change GetDescriptionFromSiginfo to return an empty 
> string? If it does, then it's probably fine. If not, could you check if one 
> of our existing core files has the siginfo stuff we'd need to write a test 
> for this?

Yep! I broke basically every core test on my 5th commit, plenty of shell tests 
that cover this and I ensured I maintained the existing behavior.

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


[Lldb-commits] [lldb] b2bb0f9 - [lldb-dap] Minor change to stdio client name. (#141266)

2025-05-23 Thread via lldb-commits

Author: John Harrison
Date: 2025-05-23T11:09:19-07:00
New Revision: b2bb0f9764681b15d7813e1dfba3b2877cce1b42

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

LOG: [lldb-dap] Minor change to stdio client name. (#141266)

Update the stdin <-> stdout client name to `stdio`. I noticed on macOS
if I get a crash report from lldb-dap the `/` in the client name causes
some thread names to be reported without the full name. For example
`Thread 6 Crashed:: */stdout.event_handler`. Switching to `stdio` I
think is still clear and not truncated in the macOS crash reports.

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 7a4cc70902a56..9b9de5e21a742 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -542,7 +542,7 @@ int main(int argc, char *argv[]) {
   lldb::IOObjectSP output = std::make_shared(
   stdout_fd, File::eOpenOptionWriteOnly, NativeFile::Unowned);
 
-  constexpr llvm::StringLiteral client_name = "stdin/stdout";
+  constexpr llvm::StringLiteral client_name = "stdio";
   Transport transport(client_name, log.get(), input, output);
   DAP dap(log.get(), default_repl_mode, pre_init_commands, transport);
 



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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;

da-viper wrote:

`llvm::getAsUnsignedInteger` accepts on `unsigned long long` and the type of 
`lldb::addr_t` is `unsigned long int` on my machine 

Did a bit digging and found `llvm::StringRef::getAsInteger`

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {

da-viper wrote:

do you want me to change the initialisation of sb_addr to `{}` initialisation ?

https://github.com/llvm/llvm-project/pull/141122
___
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 address comparison in DisassembleRequestHandler (PR #140975)

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

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


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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -104,7 +104,9 @@ def waitUntil(self, condition_callback):
 time.sleep(0.5)
 return False
 
-def verify_breakpoint_hit(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
+def verify_breakpoint_hit(
+self, breakpoint_ids, timeout=DEFAULT_TIMEOUT, is_watchpoint=False

ashgti wrote:

Instead of `is_watchpoint` could we take a `reason: Optional[str] = None` and 
use that to match the `body['reason']`? Then we can catch specific kinds of 
stop reasons (e.g. `breakpoint` vs `instruction breakpoint` vs `data 
breakpoint` etc...).

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {
+return llvm::make_error(
+llvm::formatv("address {:x} does not exist in the debuggee", 
load_addr),
+llvm::inconvertibleErrorCode(), false);
+  }
+
+  const uint32_t byte_size =
+  args.bytes.value_or(dap.target.GetAddressByteSize());
+
+  protocol::DataBreakpointInfoResponseBody response;
+  response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size);
+
+  lldb::SBMemoryRegionInfo region;
+  lldb::SBError err =
+  dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region);
+  // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this

da-viper wrote:

I also wasn't 100% sure  would check if the region is memory mapped suffice ? 

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -16,12 +15,61 @@
 
 namespace lldb_dap {
 
+static llvm::Expected
+HandleDataBreakpointBytes(DAP &dap,
+  const protocol::DataBreakpointInfoArguments &args) {
+  llvm::StringRef address = args.name;
+
+  unsigned long long load_addr = LLDB_INVALID_ADDRESS;
+  if (llvm::getAsUnsignedInteger(address, 0, load_addr)) {
+return llvm::make_error(llvm::formatv("invalid address"),
+  llvm::inconvertibleErrorCode(), false);
+  }
+
+  lldb::SBAddress sb_addr(load_addr, dap.target);
+  if (!sb_addr.IsValid()) {
+return llvm::make_error(
+llvm::formatv("address {:x} does not exist in the debuggee", 
load_addr),
+llvm::inconvertibleErrorCode(), false);
+  }
+
+  const uint32_t byte_size =
+  args.bytes.value_or(dap.target.GetAddressByteSize());
+
+  protocol::DataBreakpointInfoResponseBody response;
+  response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size);
+
+  lldb::SBMemoryRegionInfo region;
+  lldb::SBError err =
+  dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region);
+  // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this
+  // request if SBProcess::GetMemoryRegionInfo returns error.
+  if (err.Success() && !(region.IsReadable() || region.IsWritable())) {
+response.description = llvm::formatv(
+"memory region for address {} has no read or write permissions",
+load_addr);
+
+  } else {
+response.description =
+llvm::formatv("{} bytes at {:x}", byte_size, load_addr);
+response.accessTypes = {protocol::eDataBreakpointAccessTypeRead,

da-viper wrote:

I did not check since I was not sure if the information from memoryRegion info 
is accurate. 

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


[Lldb-commits] [lldb] Support breakpoint info bytes (PR #141122)

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


@@ -131,9 +133,10 @@ def verify_breakpoint_hit(self, breakpoint_ids, 
timeout=DEFAULT_TIMEOUT):
 # So when looking at the description we just want to make sure
 # the right breakpoint matches and not worry about the actual
 # location.
+type_name = "watchpoint" if is_watchpoint else "breakpoint"

da-viper wrote:

I assume we also have to change the reason for stop in the DAP stop event 
handler ?.


https://github.com/llvm/llvm-project/blob/afd31339458967d3da9a04379f46f5e9ec1bb587/lldb/tools/lldb-dap/JSONUtils.cpp#L895-L900


https://github.com/llvm/llvm-project/pull/141122
___
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-05-23 Thread Chelsea Cassanova via lldb-commits

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

>From b9930c61eff81d3b0c84357d1af86b110ce60ebf Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 22 May 2025 11:00:06 -0700
Subject: [PATCH] [lldb][headers] Create script to fix up versioning

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.
---
 lldb/scripts/version-header-fix.py| 46 +++
 lldb/source/API/CMakeLists.txt| 34 ++
 lldb/test/Shell/Scripts/Inputs/lldb-defines.h |  7 +++
 .../TestFrameworkFixScriptIncludes.test   | 17 +++
 .../Shell/Scripts/TestVersionFixScript.test   | 11 +
 5 files changed, 115 insertions(+)
 create mode 100755 lldb/scripts/version-header-fix.py
 create mode 100644 lldb/test/Shell/Scripts/Inputs/lldb-defines.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScriptIncludes.test
 create mode 100644 lldb/test/Shell/Scripts/TestVersionFixScript.test

diff --git a/lldb/scripts/version-header-fix.py 
b/lldb/scripts/version-header-fix.py
new file mode 100755
index 0..cf5b525d9a2e8
--- /dev/null
+++ b/lldb/scripts/version-header-fix.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+"""
+Usage:   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..a1f2d4fee82c8 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,6 +290,40 @@ 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 ${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})
+foreach(header
+${public_headers}
+${generated_public_headers}
+${root_public_headers})
+  get_filename_component(basename ${header} NAME)
+  set(staged_header ${lldb_header_staging}/${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 ${staged_header})
+endforeach()
+
+add_custom_command(TARGET liblldb POST_BUILD
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/version-header-fix.

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

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

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

>From fcb4a366d9f4659273480f49c491fc50a179cfff Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 22 May 2025 11:00:06 -0700
Subject: [PATCH] [lldb][headers] Create script to fix up versioning

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.
---
 lldb/scripts/framework-header-fix.sh  |  6 ---
 lldb/scripts/version-header-fix.py| 46 +++
 lldb/source/API/CMakeLists.txt| 34 ++
 lldb/test/Shell/Scripts/Inputs/lldb-defines.h |  7 +++
 .../TestFrameworkFixScriptIncludes.test   | 17 +++
 .../Shell/Scripts/TestVersionFixScript.test   | 11 +
 6 files changed, 115 insertions(+), 6 deletions(-)
 create mode 100755 lldb/scripts/version-header-fix.py
 create mode 100644 lldb/test/Shell/Scripts/Inputs/lldb-defines.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScriptIncludes.test
 create mode 100644 lldb/test/Shell/Scripts/TestVersionFixScript.test

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..a1f2d4fee82c8 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,6 +290,40 @@ 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 ${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})
+foreach(header
+${public_headers}
+${generated_public_headers}
+${root_public_headers})
+  get_filename_component(basename ${header} NAME)
+  set(staged_header ${lldb_header_staging}/${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 L

[Lldb-commits] [lldb] [lldb-dap] Minor change to stdio client name. (PR #141266)

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

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

Update the stdin <-> stdout client name to `stdio`. I noticed on macOS if I get 
a crash report from lldb-dap the `/` in the client name causes some thread 
names to be reported without the full name. For example `Thread 6 Crashed:: 
*/stdout.event_handler`. Switching to `stdio` I think is still clear and not 
truncated in the macOS crash reports.

>From 6a25ac8be9d030d73872a9a1c3b2469425a868ae Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 May 2025 10:56:59 -0700
Subject: [PATCH] [lldb-dap] Minor change to stdio client name.

Update the stdin <-> stdout client name to `stdio`. I noticed on macOS if I get 
a crash report from lldb-dap the `/` in the client name causes some thread 
names to be reported without the full name. For example `Thread 6 Crashed:: 
*/stdout.event_handler`. Switching to `stdio` I think is still clear and not 
truncated in the macOS crash reports.
---
 lldb/tools/lldb-dap/tool/lldb-dap.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 7a4cc70902a56..9b9de5e21a742 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -542,7 +542,7 @@ int main(int argc, char *argv[]) {
   lldb::IOObjectSP output = std::make_shared(
   stdout_fd, File::eOpenOptionWriteOnly, NativeFile::Unowned);
 
-  constexpr llvm::StringLiteral client_name = "stdin/stdout";
+  constexpr llvm::StringLiteral client_name = "stdio";
   Transport transport(client_name, log.get(), input, output);
   DAP dap(log.get(), default_repl_mode, pre_init_commands, transport);
 

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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

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

Use the if statement with an initializer pattern that's very common in LLVM in 
SBTarget. Every time someone adds a new method to SBTarget, I want to encourage 
using this pattern, but I don't because it would be inconsistent with the rest 
of the file. This solves that problem by switching over the whole file.

>From 619cbf2836462e06aee1d3a43ff9c3a48482d9c8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 23 May 2025 12:20:52 -0700
Subject: [PATCH] [lldb] Use if-with-initializer pattern in SBTarget (NFC)

Use the if statement with an initializer pattern that's very common in
LLVM in SBTarget. Every time someone adds a new method to SBTarget, I
want to encourage using this pattern, but I don't because it would be
inconsistent with the rest of the file. This solves that problem by
switching over the whole file.
---
 lldb/source/API/SBTarget.cpp | 944 ---
 1 file changed, 436 insertions(+), 508 deletions(-)

diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..6363677bedf6e 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -166,8 +166,7 @@ SBProcess SBTarget::GetProcess() {
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 process_sp = target_sp->GetProcessSP();
 sb_process.SetSP(process_sp);
   }
@@ -178,22 +177,19 @@ SBProcess SBTarget::GetProcess() {
 SBPlatform SBTarget::GetPlatform() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return SBPlatform();
-
-  SBPlatform platform;
-  platform.m_opaque_sp = target_sp->GetPlatform();
-
-  return platform;
+  if (TargetSP target_sp = GetSP()) {
+SBPlatform platform;
+platform.m_opaque_sp = target_sp->GetPlatform();
+return platform;
+  }
+  return SBPlatform();
 }
 
 SBDebugger SBTarget::GetDebugger() const {
   LLDB_INSTRUMENT_VA(this);
 
   SBDebugger debugger;
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 debugger.reset(target_sp->GetDebugger().shared_from_this());
   return debugger;
 }
@@ -208,41 +204,37 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;
-  std::string json_str =
-  llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
- target_sp->GetDebugger(), target_sp.get(),
- options.ref()))
-  .str();
-  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  }
   return data;
 }
 
 void SBTarget::ResetStatistics() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
 }
 
 void SBTarget::SetCollectingStats(bool v) {
   LLDB_INSTRUMENT_VA(this, v);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return;
-  return DebuggerStats::SetCollectingStats(v);
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::SetCollectingStats(v);
 }
 
 bool SBTarget::GetCollectingStats() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return false;
-  return DebuggerStats::GetCollectingStats();
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::GetCollectingStats();
+  return false;
 }
 
 SBProcess SBTarget::LoadCore(const char *core_file) {
@@ -256,8 +248,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, 
lldb::SBError &error) {
   LLDB_INSTRUMENT_VA(this, core_file, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 FileSpec filespec(core_file);
 FileSystem::Instance().Resolve(filespec);
 ProcessSP process_sp(target_sp->CreateProcess(
@@ -303,8 +294,7 @@ SBError SBTarget::Install() {
   LLDB_INSTRUMENT_VA(this);
 
   SBError sb_error;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 sb_error.ref() = target_sp->Install(nullptr);
   }
@@ -323,9 +313,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const 
**argv,
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::loc

[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Use the if statement with an initializer pattern that's very common in LLVM in 
SBTarget. Every time someone adds a new method to SBTarget, I want to encourage 
using this pattern, but I don't because it would be inconsistent with the rest 
of the file. This solves that problem by switching over the whole file.

---

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


1 Files Affected:

- (modified) lldb/source/API/SBTarget.cpp (+436-508) 


``diff
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..6363677bedf6e 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -166,8 +166,7 @@ SBProcess SBTarget::GetProcess() {
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 process_sp = target_sp->GetProcessSP();
 sb_process.SetSP(process_sp);
   }
@@ -178,22 +177,19 @@ SBProcess SBTarget::GetProcess() {
 SBPlatform SBTarget::GetPlatform() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return SBPlatform();
-
-  SBPlatform platform;
-  platform.m_opaque_sp = target_sp->GetPlatform();
-
-  return platform;
+  if (TargetSP target_sp = GetSP()) {
+SBPlatform platform;
+platform.m_opaque_sp = target_sp->GetPlatform();
+return platform;
+  }
+  return SBPlatform();
 }
 
 SBDebugger SBTarget::GetDebugger() const {
   LLDB_INSTRUMENT_VA(this);
 
   SBDebugger debugger;
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 debugger.reset(target_sp->GetDebugger().shared_from_this());
   return debugger;
 }
@@ -208,41 +204,37 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;
-  std::string json_str =
-  llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
- target_sp->GetDebugger(), target_sp.get(),
- options.ref()))
-  .str();
-  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  }
   return data;
 }
 
 void SBTarget::ResetStatistics() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
 }
 
 void SBTarget::SetCollectingStats(bool v) {
   LLDB_INSTRUMENT_VA(this, v);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return;
-  return DebuggerStats::SetCollectingStats(v);
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::SetCollectingStats(v);
 }
 
 bool SBTarget::GetCollectingStats() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return false;
-  return DebuggerStats::GetCollectingStats();
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::GetCollectingStats();
+  return false;
 }
 
 SBProcess SBTarget::LoadCore(const char *core_file) {
@@ -256,8 +248,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, 
lldb::SBError &error) {
   LLDB_INSTRUMENT_VA(this, core_file, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 FileSpec filespec(core_file);
 FileSystem::Instance().Resolve(filespec);
 ProcessSP process_sp(target_sp->CreateProcess(
@@ -303,8 +294,7 @@ SBError SBTarget::Install() {
   LLDB_INSTRUMENT_VA(this);
 
   SBError sb_error;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 sb_error.ref() = target_sp->Install(nullptr);
   }
@@ -323,9 +313,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const 
**argv,
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 
 if (stop_at_entry)
@@ -400,9 +388,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, 
SBError &error) {
   LLDB_INSTRUMENT_VA(this, sb_launch_info, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 StateType state = eStateInvalid;

[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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

JDevlieghere wrote:

The diff looks a whole lot less intimidating when ignoring whitespace changes.

https://github.com/llvm/llvm-project/pull/141284
___
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 address comparison in DisassembleRequestHandler (PR #140975)

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

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


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


[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)

2025-05-23 Thread via lldb-commits

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

When running a process that would exit before LLDB could stop the target, it 
would try to interpret (and subsequently format) the exit code as a Win32 
error. However, processes on Windows won't return Win32 errors in that case. 
They will often return an 
[NTSTATUS](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55).
 One common case for this to occur is when a DLL is missing. In that case, the 
process will start successfully, but it will exit with `STATUS_DLL_NOT_FOUND`.
LLDB would previously return "unknown error", because it tried to 
[`FormatMessage`](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage)
 `0xC135` which doesn't work, so it fell back to "unknown error".

This PR changes the error to be the string "Process prematurely exited with 
{0:x}" and doesn't try to format the exit code. One could `FormatMessage` an 
`NTSTATUS` by passing `FORMAT_MESSAGE_FROM_HMODULE` and a handle to 
`ntdll.dll`, however, I don't think we can get the required format arguments 
(e.g. the missing DLL name - `%hs`).

>From 31aab0ad4b134925b702fa24fedf48880c108f06 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Fri, 23 May 2025 21:47:40 +0200
Subject: [PATCH] [LLDB] Show exit code on Windows if process can't launch

---
 .../Windows/Common/ProcessDebugger.cpp|  3 ++-
 .../API/windows/launch/missing-dll/Makefile   |  5 +
 .../launch/missing-dll/TestMissingDll.py  | 22 +++
 .../windows/launch/missing-dll/dummy_dll.c|  1 +
 .../API/windows/launch/missing-dll/main.c |  6 +
 5 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/API/windows/launch/missing-dll/Makefile
 create mode 100644 lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
 create mode 100644 lldb/test/API/windows/launch/missing-dll/dummy_dll.c
 create mode 100644 lldb/test/API/windows/launch/missing-dll/main.c

diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
index bde72d61b0fee..a0f622fd69902 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) {
   // of the error otherwise WaitForDebuggerConnection() will be blocked.
   // An example of this issue is when a process fails to load a dependent DLL.
   if (m_session_data && !m_session_data->m_initial_stop_received) {
-Status error(exit_code, eErrorTypeWin32);
+Status error = Status::FromErrorStringWithFormatv(
+"Process prematurely exited with {0:x}", exit_code);
 OnDebuggerError(error, 0);
   }
 }
diff --git a/lldb/test/API/windows/launch/missing-dll/Makefile 
b/lldb/test/API/windows/launch/missing-dll/Makefile
new file mode 100644
index 0..43e02d1d8f22b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+DYLIB_C_SOURCES := dummy_dll.c
+DYLIB_NAME := dummy_dll
+
+include Makefile.rules
diff --git a/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py 
b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
new file mode 100644
index 0..b47040fbf794b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MissingDllTestCase(TestBase):
+@skipUnlessWindows
+def test(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+dll = self.getBuildArtifact("dummy_dll.dll")
+self.assertTrue(remove_file(dll))
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetWorkingDirectory(self.get_process_working_directory())
+
+error = lldb.SBError()
+target.Launch(launch_info, error)
+self.assertFailure(error, "Process prematurely exited with 0xc135")
diff --git a/lldb/test/API/windows/launch/missing-dll/dummy_dll.c 
b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
new file mode 100644
index 0..61bde26534966
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
@@ -0,0 +1 @@
+__declspec(dllexport) void SomeFunction(void) {}
diff --git a/lldb/test/API/windows/launch/missing-dll/main.c 
b/lldb/test/API/windows/launch/missing-dll/main.c
new file mode 100644
index 0..c1e0d3222c48b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/main.c
@@ -0,0 +1,6 @@
+__declspec(dllimport) void SomeFunction(void);
+
+int main(void) {
+SomeFunction();
+return 0;
+}

___

[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)

2025-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)


Changes

When running a process that would exit before LLDB could stop the target, it 
would try to interpret (and subsequently format) the exit code as a Win32 
error. However, processes on Windows won't return Win32 errors in that case. 
They will often return an 
[NTSTATUS](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55).
 One common case for this to occur is when a DLL is missing. In that case, the 
process will start successfully, but it will exit with `STATUS_DLL_NOT_FOUND`.
LLDB would previously return "unknown error", because it tried to 
[`FormatMessage`](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage)
 `0xC135` which doesn't work, so it fell back to "unknown error".

This PR changes the error to be the string "Process prematurely exited with 
{0:x}" and doesn't try to format the exit code. One could `FormatMessage` an 
`NTSTATUS` by passing `FORMAT_MESSAGE_FROM_HMODULE` and a handle to 
`ntdll.dll`, however, I don't think we can get the required format arguments 
(e.g. the missing DLL name - `%hs`).

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


5 Files Affected:

- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp 
(+2-1) 
- (added) lldb/test/API/windows/launch/missing-dll/Makefile (+5) 
- (added) lldb/test/API/windows/launch/missing-dll/TestMissingDll.py (+22) 
- (added) lldb/test/API/windows/launch/missing-dll/dummy_dll.c (+1) 
- (added) lldb/test/API/windows/launch/missing-dll/main.c (+6) 


``diff
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
index bde72d61b0fee..a0f622fd69902 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) {
   // of the error otherwise WaitForDebuggerConnection() will be blocked.
   // An example of this issue is when a process fails to load a dependent DLL.
   if (m_session_data && !m_session_data->m_initial_stop_received) {
-Status error(exit_code, eErrorTypeWin32);
+Status error = Status::FromErrorStringWithFormatv(
+"Process prematurely exited with {0:x}", exit_code);
 OnDebuggerError(error, 0);
   }
 }
diff --git a/lldb/test/API/windows/launch/missing-dll/Makefile 
b/lldb/test/API/windows/launch/missing-dll/Makefile
new file mode 100644
index 0..43e02d1d8f22b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+DYLIB_C_SOURCES := dummy_dll.c
+DYLIB_NAME := dummy_dll
+
+include Makefile.rules
diff --git a/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py 
b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
new file mode 100644
index 0..b47040fbf794b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MissingDllTestCase(TestBase):
+@skipUnlessWindows
+def test(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+dll = self.getBuildArtifact("dummy_dll.dll")
+self.assertTrue(remove_file(dll))
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetWorkingDirectory(self.get_process_working_directory())
+
+error = lldb.SBError()
+target.Launch(launch_info, error)
+self.assertFailure(error, "Process prematurely exited with 0xc135")
diff --git a/lldb/test/API/windows/launch/missing-dll/dummy_dll.c 
b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
new file mode 100644
index 0..61bde26534966
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
@@ -0,0 +1 @@
+__declspec(dllexport) void SomeFunction(void) {}
diff --git a/lldb/test/API/windows/launch/missing-dll/main.c 
b/lldb/test/API/windows/launch/missing-dll/main.c
new file mode 100644
index 0..c1e0d3222c48b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/main.c
@@ -0,0 +1,6 @@
+__declspec(dllimport) void SomeFunction(void);
+
+int main(void) {
+SomeFunction();
+return 0;
+}

``




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


[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)

2025-05-23 Thread via lldb-commits

https://github.com/Nerixyz updated 
https://github.com/llvm/llvm-project/pull/141290

>From aacbcb49354bfd29b21934a26748d58a3b4ae130 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Fri, 23 May 2025 21:47:40 +0200
Subject: [PATCH] [LLDB] Show exit code on Windows if process can't launch

---
 .../Windows/Common/ProcessDebugger.cpp|  3 ++-
 .../API/windows/launch/missing-dll/Makefile   |  5 +
 .../launch/missing-dll/TestMissingDll.py  | 22 +++
 .../windows/launch/missing-dll/dummy_dll.c|  1 +
 .../API/windows/launch/missing-dll/main.c |  6 +
 5 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/API/windows/launch/missing-dll/Makefile
 create mode 100644 lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
 create mode 100644 lldb/test/API/windows/launch/missing-dll/dummy_dll.c
 create mode 100644 lldb/test/API/windows/launch/missing-dll/main.c

diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
index bde72d61b0fee..a0f622fd69902 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -483,7 +483,8 @@ void ProcessDebugger::OnExitProcess(uint32_t exit_code) {
   // of the error otherwise WaitForDebuggerConnection() will be blocked.
   // An example of this issue is when a process fails to load a dependent DLL.
   if (m_session_data && !m_session_data->m_initial_stop_received) {
-Status error(exit_code, eErrorTypeWin32);
+Status error = Status::FromErrorStringWithFormatv(
+"Process prematurely exited with {0:x}", exit_code);
 OnDebuggerError(error, 0);
   }
 }
diff --git a/lldb/test/API/windows/launch/missing-dll/Makefile 
b/lldb/test/API/windows/launch/missing-dll/Makefile
new file mode 100644
index 0..43e02d1d8f22b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+DYLIB_C_SOURCES := dummy_dll.c
+DYLIB_NAME := dummy_dll
+
+include Makefile.rules
diff --git a/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py 
b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
new file mode 100644
index 0..b47040fbf794b
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/TestMissingDll.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MissingDllTestCase(TestBase):
+@skipUnlessWindows
+def test(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+dll = self.getBuildArtifact("dummy_dll.dll")
+self.assertTrue(remove_file(dll))
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetWorkingDirectory(self.get_process_working_directory())
+
+error = lldb.SBError()
+target.Launch(launch_info, error)
+self.assertFailure(error, "Process prematurely exited with 0xc135")
diff --git a/lldb/test/API/windows/launch/missing-dll/dummy_dll.c 
b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
new file mode 100644
index 0..61bde26534966
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/dummy_dll.c
@@ -0,0 +1 @@
+__declspec(dllexport) void SomeFunction(void) {}
diff --git a/lldb/test/API/windows/launch/missing-dll/main.c 
b/lldb/test/API/windows/launch/missing-dll/main.c
new file mode 100644
index 0..bf773cd945819
--- /dev/null
+++ b/lldb/test/API/windows/launch/missing-dll/main.c
@@ -0,0 +1,6 @@
+__declspec(dllimport) void SomeFunction(void);
+
+int main(void) {
+  SomeFunction();
+  return 0;
+}

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


[Lldb-commits] [lldb] [LLDB] Show exit code on Windows if process can't launch (PR #141290)

2025-05-23 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,c -- 
lldb/test/API/windows/launch/missing-dll/dummy_dll.c 
lldb/test/API/windows/launch/missing-dll/main.c 
lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/windows/launch/missing-dll/main.c 
b/lldb/test/API/windows/launch/missing-dll/main.c
index c1e0d3222..bf773cd94 100644
--- a/lldb/test/API/windows/launch/missing-dll/main.c
+++ b/lldb/test/API/windows/launch/missing-dll/main.c
@@ -1,6 +1,6 @@
 __declspec(dllimport) void SomeFunction(void);
 
 int main(void) {
-SomeFunction();
-return 0;
+  SomeFunction();
+  return 0;
 }

``




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


[Lldb-commits] [lldb] 35c15e4 - [lldb-dap] Fix address comparison in DisassembleRequestHandler (#140975)

2025-05-23 Thread via lldb-commits

Author: Ely Ronnen
Date: 2025-05-23T22:17:13+02:00
New Revision: 35c15e41ae9ce0c503efacda592c1aa5eb61e6ec

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

LOG: [lldb-dap] Fix address comparison in DisassembleRequestHandler (#140975)

Fix comparisons between addresses with the same load address that can
unexpectedly return false in `DisassembleRequestHandler`

Added: 


Modified: 
lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 9aa6995e5d668..c9061ef19f17a 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -87,6 +87,13 @@ static DisassembledInstruction 
ConvertSBInstructionToDisassembledInstruction(
 
   auto addr = inst.GetAddress();
   const auto inst_addr = addr.GetLoadAddress(target);
+
+  // FIXME: This is a workaround - this address might come from
+  // disassembly that started in a 
diff erent section, and thus
+  // comparisons between this object and other address objects with the
+  // same load address will return false.
+  addr = lldb::SBAddress(inst_addr, target);
+
   const char *m = inst.GetMnemonic(target);
   const char *o = inst.GetOperands(target);
   const char *c = inst.GetComment(target);



___
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 address comparison in DisassembleRequestHandler (PR #140975)

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

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


[Lldb-commits] [lldb] [lldb/cmake] Don't call llvm_process_sources (PR #141217)

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

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


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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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


@@ -208,41 +204,37 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;
-  std::string json_str =
-  llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
- target_sp->GetDebugger(), target_sp.get(),
- options.ref()))
-  .str();
-  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  }
   return data;
 }
 
 void SBTarget::ResetStatistics() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
 }
 
 void SBTarget::SetCollectingStats(bool v) {
   LLDB_INSTRUMENT_VA(this, v);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return;
-  return DebuggerStats::SetCollectingStats(v);
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::SetCollectingStats(v);

bulbazord wrote:

This function has no return type, you can remove the `return` here.

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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


@@ -2393,62 +2329,54 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() {
 bool SBTarget::IsLoaded(const SBModule &module) const {
   LLDB_INSTRUMENT_VA(this, module);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return false;
-
-  ModuleSP module_sp(module.GetSP());
-  if (!module_sp)
-return false;
-
-  return module_sp->IsLoadedInTarget(target_sp.get());
+  if (TargetSP target_sp = GetSP()) {
+ModuleSP module_sp(module.GetSP());
+if (module_sp)
+  return module_sp->IsLoadedInTarget(target_sp.get());
+  }
+  return false;
 }
 
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_INSTRUMENT_VA(this);
 
   lldb::SBLaunchInfo launch_info(nullptr);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
   return launch_info;
 }
 
 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
   LLDB_INSTRUMENT_VA(this, launch_info);
 
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
 }
 
 SBEnvironment SBTarget::GetEnvironment() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
 
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP())
 return SBEnvironment(target_sp->GetEnvironment());
-  }
 
   return SBEnvironment();
 }
 
 lldb::SBTrace SBTarget::GetTrace() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
 
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 return SBTrace(target_sp->GetTrace());
 
   return SBTrace();
 }
 
 lldb::SBTrace SBTarget::CreateTrace(lldb::SBError &error) {
   LLDB_INSTRUMENT_VA(this, error);
-  TargetSP target_sp(GetSP());
-  error.Clear();
 
-  if (target_sp) {
+  error.Clear();
+  if (TargetSP target_sp = GetSP()) {
+error.Clear();

bulbazord wrote:

The second clear is unnecessary

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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


@@ -208,41 +204,37 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;

bulbazord wrote:

This `return` can be removed now.

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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


@@ -1266,25 +1235,22 @@ lldb::SBError 
SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
   LLDB_INSTRUMENT_VA(this, dest_file, bkpt_list, append);
 
   SBError sberr;
-  TargetSP target_sp(GetSP());
-  if (!target_sp) {
-sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
+  if (TargetSP target_sp = GetSP()) {
+std::lock_guard guard(target_sp->GetAPIMutex());
+BreakpointIDList bp_id_list;
+bkpt_list.CopyToBreakpointIDList(bp_id_list);
+sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
+bp_id_list, append);
 return sberr;
   }
-
-  std::lock_guard guard(target_sp->GetAPIMutex());
-  BreakpointIDList bp_id_list;
-  bkpt_list.CopyToBreakpointIDList(bp_id_list);
-  sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
-  bp_id_list, append);
+  sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");

bulbazord wrote:

Same suggestion here

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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


@@ -1219,45 +1191,42 @@ lldb::SBError 
SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
   LLDB_INSTRUMENT_VA(this, source_file, matching_names, new_bps);
 
   SBError sberr;
-  TargetSP target_sp(GetSP());
-  if (!target_sp) {
-sberr.SetErrorString(
-"BreakpointCreateFromFile called with invalid target.");
-return sberr;
-  }
-  std::lock_guard guard(target_sp->GetAPIMutex());
+  if (TargetSP target_sp = GetSP()) {
+std::lock_guard guard(target_sp->GetAPIMutex());
 
-  BreakpointIDList bp_ids;
+BreakpointIDList bp_ids;
 
-  std::vector name_vector;
-  size_t num_names = matching_names.GetSize();
-  for (size_t i = 0; i < num_names; i++)
-name_vector.push_back(matching_names.GetStringAtIndex(i));
+std::vector name_vector;
+size_t num_names = matching_names.GetSize();
+for (size_t i = 0; i < num_names; i++)
+  name_vector.push_back(matching_names.GetStringAtIndex(i));
 
-  sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
- name_vector, bp_ids);
-  if (sberr.Fail())
-return sberr;
+sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
+   name_vector, bp_ids);
+if (sberr.Fail())
+  return sberr;
 
-  size_t num_bkpts = bp_ids.GetSize();
-  for (size_t i = 0; i < num_bkpts; i++) {
-BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
-new_bps.AppendByID(bp_id.GetBreakpointID());
+size_t num_bkpts = bp_ids.GetSize();
+for (size_t i = 0; i < num_bkpts; i++) {
+  BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
+  new_bps.AppendByID(bp_id.GetBreakpointID());
+}
+return sberr;
   }
+  sberr.SetErrorString("BreakpointCreateFromFile called with invalid target.");

bulbazord wrote:

Suggestion: Put the `SetErrorString` in an `else` clause and have both paths 
fall into the following `return sberr;`.

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


[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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

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

>From 5b85557ac91c19702a4b5a16d824572f268fe71c Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 23 May 2025 12:20:52 -0700
Subject: [PATCH] [lldb] Use if-with-initializer pattern in SBTarget (NFC)

Use the if statement with an initializer pattern that's very common in
LLVM in SBTarget. Every time someone adds a new method to SBTarget, I
want to encourage using this pattern, but I don't because it would be
inconsistent with the rest of the file. This solves that problem by
switching over the whole file.
---
 lldb/source/API/SBTarget.cpp | 946 ---
 1 file changed, 438 insertions(+), 508 deletions(-)

diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..3d1a78414387a 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -166,8 +166,7 @@ SBProcess SBTarget::GetProcess() {
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 process_sp = target_sp->GetProcessSP();
 sb_process.SetSP(process_sp);
   }
@@ -178,22 +177,19 @@ SBProcess SBTarget::GetProcess() {
 SBPlatform SBTarget::GetPlatform() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return SBPlatform();
-
-  SBPlatform platform;
-  platform.m_opaque_sp = target_sp->GetPlatform();
-
-  return platform;
+  if (TargetSP target_sp = GetSP()) {
+SBPlatform platform;
+platform.m_opaque_sp = target_sp->GetPlatform();
+return platform;
+  }
+  return SBPlatform();
 }
 
 SBDebugger SBTarget::GetDebugger() const {
   LLDB_INSTRUMENT_VA(this);
 
   SBDebugger debugger;
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 debugger.reset(target_sp->GetDebugger().shared_from_this());
   return debugger;
 }
@@ -208,41 +204,38 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;
-  std::string json_str =
-  llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
- target_sp->GetDebugger(), target_sp.get(),
- options.ref()))
-  .str();
-  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  }
   return data;
 }
 
 void SBTarget::ResetStatistics() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+
+  if (TargetSP target_sp = GetSP())
 DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
 }
 
 void SBTarget::SetCollectingStats(bool v) {
   LLDB_INSTRUMENT_VA(this, v);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return;
-  return DebuggerStats::SetCollectingStats(v);
+  if (TargetSP target_sp = GetSP())
+DebuggerStats::SetCollectingStats(v);
 }
 
 bool SBTarget::GetCollectingStats() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return false;
-  return DebuggerStats::GetCollectingStats();
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::GetCollectingStats();
+  return false;
 }
 
 SBProcess SBTarget::LoadCore(const char *core_file) {
@@ -256,8 +249,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, 
lldb::SBError &error) {
   LLDB_INSTRUMENT_VA(this, core_file, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 FileSpec filespec(core_file);
 FileSystem::Instance().Resolve(filespec);
 ProcessSP process_sp(target_sp->CreateProcess(
@@ -303,8 +295,7 @@ SBError SBTarget::Install() {
   LLDB_INSTRUMENT_VA(this);
 
   SBError sb_error;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 sb_error.ref() = target_sp->Install(nullptr);
   }
@@ -323,9 +314,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const 
**argv,
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 
 if (stop_at_entry)
@@ -400,9 +389,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, 
SBError &error) {
   LLDB_INSTRUMENT_VA(this, sb_launch_info, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_

[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

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

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

>From bcc6dd2bb7ea3a934ce2483e5a6d3549f86265e3 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 23 May 2025 12:20:52 -0700
Subject: [PATCH] [lldb] Use if-with-initializer pattern in SBTarget (NFC)

Use the if statement with an initializer pattern that's very common in
LLVM in SBTarget. Every time someone adds a new method to SBTarget, I
want to encourage using this pattern, but I don't because it would be
inconsistent with the rest of the file. This solves that problem by
switching over the whole file.
---
 lldb/source/API/SBTarget.cpp | 945 ---
 1 file changed, 437 insertions(+), 508 deletions(-)

diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..34e8b174cabe7 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -166,8 +166,7 @@ SBProcess SBTarget::GetProcess() {
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 process_sp = target_sp->GetProcessSP();
 sb_process.SetSP(process_sp);
   }
@@ -178,22 +177,19 @@ SBProcess SBTarget::GetProcess() {
 SBPlatform SBTarget::GetPlatform() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return SBPlatform();
-
-  SBPlatform platform;
-  platform.m_opaque_sp = target_sp->GetPlatform();
-
-  return platform;
+  if (TargetSP target_sp = GetSP()) {
+SBPlatform platform;
+platform.m_opaque_sp = target_sp->GetPlatform();
+return platform;
+  }
+  return SBPlatform();
 }
 
 SBDebugger SBTarget::GetDebugger() const {
   LLDB_INSTRUMENT_VA(this);
 
   SBDebugger debugger;
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+  if (TargetSP target_sp = GetSP())
 debugger.reset(target_sp->GetDebugger().shared_from_this());
   return debugger;
 }
@@ -208,41 +204,38 @@ SBStructuredData 
SBTarget::GetStatistics(SBStatisticsOptions options) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
+  if (TargetSP target_sp = GetSP()) {
+std::string json_str =
+llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(),
+   options.ref()))
+.str();
+data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
 return data;
-  std::string json_str =
-  llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(
- target_sp->GetDebugger(), target_sp.get(),
- options.ref()))
-  .str();
-  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  }
   return data;
 }
 
 void SBTarget::ResetStatistics() {
   LLDB_INSTRUMENT_VA(this);
-  TargetSP target_sp(GetSP());
-  if (target_sp)
+
+  if (TargetSP target_sp = GetSP())
 DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
 }
 
 void SBTarget::SetCollectingStats(bool v) {
   LLDB_INSTRUMENT_VA(this, v);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return;
-  return DebuggerStats::SetCollectingStats(v);
+  if (TargetSP target_sp = GetSP())
+DebuggerStats::SetCollectingStats(v);
 }
 
 bool SBTarget::GetCollectingStats() {
   LLDB_INSTRUMENT_VA(this);
 
-  TargetSP target_sp(GetSP());
-  if (!target_sp)
-return false;
-  return DebuggerStats::GetCollectingStats();
+  if (TargetSP target_sp = GetSP())
+return DebuggerStats::GetCollectingStats();
+  return false;
 }
 
 SBProcess SBTarget::LoadCore(const char *core_file) {
@@ -256,8 +249,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, 
lldb::SBError &error) {
   LLDB_INSTRUMENT_VA(this, core_file, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 FileSpec filespec(core_file);
 FileSystem::Instance().Resolve(filespec);
 ProcessSP process_sp(target_sp->CreateProcess(
@@ -303,8 +295,7 @@ SBError SBTarget::Install() {
   LLDB_INSTRUMENT_VA(this);
 
   SBError sb_error;
-  TargetSP target_sp(GetSP());
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 sb_error.ref() = target_sp->Install(nullptr);
   }
@@ -323,9 +314,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const 
**argv,
 
   SBProcess sb_process;
   ProcessSP process_sp;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_sp = GetSP()) {
 std::lock_guard guard(target_sp->GetAPIMutex());
 
 if (stop_at_entry)
@@ -400,9 +389,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, 
SBError &error) {
   LLDB_INSTRUMENT_VA(this, sb_launch_info, error);
 
   SBProcess sb_process;
-  TargetSP target_sp(GetSP());
-
-  if (target_sp) {
+  if (TargetSP target_

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

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

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

>From 975f510e96e0775db29b2f5bcdb9b838a8e4e95f Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 22 May 2025 11:00:06 -0700
Subject: [PATCH] [lldb][headers] Create script to fix up versioning

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.
---
 lldb/scripts/framework-header-fix.sh  |  6 ---
 lldb/scripts/version-header-fix.py| 46 +++
 lldb/source/API/CMakeLists.txt| 34 ++
 lldb/test/Shell/Scripts/Inputs/lldb-defines.h |  7 +++
 .../Shell/Scripts/TestVersionFixScript.test   | 11 +
 5 files changed, 98 insertions(+), 6 deletions(-)
 create mode 100755 lldb/scripts/version-header-fix.py
 create mode 100644 lldb/test/Shell/Scripts/Inputs/lldb-defines.h
 create mode 100644 lldb/test/Shell/Scripts/TestVersionFixScript.test

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..a1f2d4fee82c8 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,6 +290,40 @@ 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 ${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})
+foreach(header
+${public_headers}
+${generated_public_headers}
+${root_public_headers})
+  get_filename_component(basename ${header} NAME)
+  set(staged_header ${lldb_header_staging}/${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 ${staged_header})
+endforeach()
+
+add_custom_command(TARGET liblldb