[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)

2025-05-28 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/140762

>From cc3c6d1c86ae0ed579c4f325778ee1b4cd90d6be Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Tue, 20 May 2025 17:45:20 +0100
Subject: [PATCH 1/9] refactor demangler range tracking

---
 lldb/include/lldb/Core/DemangledNameInfo.h | 18 +-
 lldb/include/lldb/Core/FormatEntity.h  |  1 +
 lldb/source/Core/FormatEntity.cpp  |  3 +++
 lldb/source/Core/Mangled.cpp   |  2 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp   |  4 ++--
 lldb/unittests/Core/CMakeLists.txt |  2 +-
 ...{MangledTest.cpp => ItaniumMangledTest.cpp} | 13 +++--
 7 files changed, 33 insertions(+), 10 deletions(-)
 rename lldb/unittests/Core/{MangledTest.cpp => ItaniumMangledTest.cpp} (98%)

diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
index 11d3bb58871b8..76cf8908fcbe6 100644
--- a/lldb/include/lldb/Core/DemangledNameInfo.h
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -39,7 +39,7 @@ struct DemangledNameInfo {
   /// \endcode
   std::pair ScopeRange;
 
-  /// Indicates the [start, end) of the function argument lits.
+  /// Indicates the [start, end) of the function argument list.
   /// E.g.,
   /// \code{.cpp}
   ///int (*getFunc(float, double))(int, int)
@@ -59,11 +59,27 @@ struct DemangledNameInfo {
   /// \endcode
   std::pair QualifiersRange;
 
+  /// Indicates the [start, end) of the function's prefix. This is a
+  /// catch-all range for anything that is not tracked by the rest of
+  /// the pairs.
+  std::pair PrefixRange;
+
+  /// Indicates the [start, end) of the function's suffix. This is a
+  /// catch-all range for anything that is not tracked by the rest of
+  /// the pairs.
+  std::pair SuffixRange;
+
   /// Returns \c true if this object holds a valid basename range.
   bool hasBasename() const {
 return BasenameRange.second > BasenameRange.first &&
BasenameRange.second > 0;
   }
+
+  /// Returns \c true if this object holds a valid arguments range.
+  bool hasArguments() const {
+return ArgumentsRange.second > ArgumentsRange.first &&
+   ArgumentsRange.second > 0;
+  }
 };
 
 /// An OutputBuffer which keeps a record of where certain parts of a
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 6acf6fbe43239..1aed3c6ff9e9d 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -88,6 +88,7 @@ struct Entry {
 FunctionNameWithArgs,
 FunctionNameNoArgs,
 FunctionMangledName,
+FunctionPrefix,
 FunctionScope,
 FunctionBasename,
 FunctionTemplateArguments,
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 4f2d39873c7fb..4dcfa43a7bb04 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = {
 Definition("initial-function", EntryType::FunctionInitial),
 Definition("changed", EntryType::FunctionChanged),
 Definition("is-optimized", EntryType::FunctionIsOptimized),
+Definition("prefix", EntryType::FunctionPrefix),
 Definition("scope", EntryType::FunctionScope),
 Definition("basename", EntryType::FunctionBasename),
 Definition("template-arguments", EntryType::FunctionTemplateArguments),
@@ -385,6 +386,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
 ENUM_TO_CSTR(FunctionNameWithArgs);
 ENUM_TO_CSTR(FunctionNameNoArgs);
 ENUM_TO_CSTR(FunctionMangledName);
+ENUM_TO_CSTR(FunctionPrefix);
 ENUM_TO_CSTR(FunctionScope);
 ENUM_TO_CSTR(FunctionBasename);
 ENUM_TO_CSTR(FunctionTemplateArguments);
@@ -1835,6 +1837,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 return true;
   }
 
+  case Entry::Type::FunctionPrefix:
   case Entry::Type::FunctionScope:
   case Entry::Type::FunctionBasename:
   case Entry::Type::FunctionTemplateArguments:
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index ce4db4e0daa8b..e6f7d198d7316 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -172,6 +172,8 @@ GetItaniumDemangledStr(const char *M) {
 
 TrackingOutputBuffer OB(demangled_cstr, demangled_size);
 demangled_cstr = ipd.finishDemangle(&OB);
+OB.NameInfo.SuffixRange.first = OB.NameInfo.QualifiersRange.second;
+OB.NameInfo.SuffixRange.second = std::string(demangled_cstr).length();
 info = std::move(OB.NameInfo);
 
 assert(demangled_cstr &&
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 542f13bef23e7..f45b4fb816b3b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -401,8 +401,8 @@ GetDemangledFun

[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/141738

This test has been flaky on Linaro's Windows on Arm bot and I was able to 
reproduce it within 10 or so runs locally.

When it fails it's because we failed to read the value of int_arr[100]. When 
that happens the memory looks like this:
```
[0x006bf88fd000-0x006bf890) rw-  <-- sp (0x006bf88ffe20)
[0x006bf890-0x025fec90) ---  <-- int_arr[100] 
(0x006bf8900070)
```
The first region is the stack and the stack pointer is pointing within that 
region, as expected.

The second region is where we are trying to read int_arr[100] from and this is 
not mapped because we're trying to read above the start of the stack.

Sometimes the test passes I think because ASLR / DYNAMICBASE moves the start of 
the stack down enough so there is some readable memory at the top.

https://learn.microsoft.com/en-us/cpp/build/reference/dynamicbase?view=msvc-170

Note "Because ASLR can't be disabled on ARM, ARM64, or ARM64EC architectures, 
/DYNAMICBASE:NO isn't supported for these targets.". Which means on this bot, 
the layout is definitely being randomised.

To fix this, I've setup main to pad its stack frame with 100 integers, then 
called a new function where we declare all the variables that used to be in 
main.

We have to pad this way because if we pad around int_arr, in the same function, 
the compiler could decide to move int_arr to the end of the frame, and defeat 
the padding.

By padding main, it doesn't matter how the compiler treats that as long as it 
makes main's frame larger.

We saw this failure on Windows only but I wouldn't be surprised if it can 
happen on Linux as well.

>From ad5fddbdecfa4aab893c07f9bd36ff28e15c674b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 28 May 2025 10:15:42 +
Subject: [PATCH] [lldb][test] Add padding to fix flaky DIL array subscript
 test

This test has been flaky on Linaro's Windows on Arm bot and I was
able to reproduce it within 10 or so runs locally.

When it fails it's because we failed to read the value of int_arr[100].
When that happens the memory looks like this:
```
[0x006bf88fd000-0x006bf890) rw-  <-- sp (0x006bf88ffe20)
[0x006bf890-0x025fec90) ---  <-- int_arr[100] 
(0x006bf8900070)
```
The first region is the stack and the stack pointer is pointing
within that region, as expected.

The second region is where we are trying to read int_arr[100] from
and this is not mapped because we're trying to read above the start
of the stack.

Sometimes the test passes I think because ASLR / DYNAMICBASE moves
the start of the stack down enough so there is some readable memory
at the top.

https://learn.microsoft.com/en-us/cpp/build/reference/dynamicbase?view=msvc-170

Note "Because ASLR can't be disabled on ARM, ARM64, or ARM64EC architectures,
/DYNAMICBASE:NO isn't supported for these targets.". Which means on this bot,
the layout is definitely being randomised.

To fix this, I've setup main to pad its stack frame with 100 integers,
then called a new function where we declare all the variables that used
to be in main.

We have to pad this way because if we pad around int_arr, in the same
function, the compiler could decide to move int_arr to the end of the
frame, and defeat the padding.

By padding main, it doesn't matter how the compiler treats that as
long as it makes main's frame larger.

We saw this failure on Windows only but I wouldn't be surprised if it
can happen on Linux as well.
---
 .../TestFrameVarDILArraySubscript.py  |  2 --
 .../var-dil/basics/ArraySubscript/main.cpp| 22 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
index 66f4c62761004..740a64f1477ff 100644
--- 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
+++ 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.
-@skipIfWindows
 def test_subscript(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
index 485666ae46c20..5efbefeea684b 100644
--- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
+++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
@@ -1,6 +1,21 @@
 

[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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


@@ -0,0 +1,57 @@
+// clang-format off
+
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl -o %t.exe --std c++20 -- %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "b main" -o "run" 
-o "fr v" -o c | FileCheck %s
+
+#include 

DavidSpickett wrote:

If this smoke test ensures they don't crash horribly, which I think it does, we 
should accept it. If we have issue(s) talking about MSVC formatter support link 
to them, or if we don't have an overall one, open one and link to that.

If this test fails way too often and it's holding up formatter development 
elsewhere, then we can revisit it of course.

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


[Lldb-commits] [lldb] [Demangling] Refactor Demangler range tracking (PR #140762)

2025-05-28 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/140762

>From cc3c6d1c86ae0ed579c4f325778ee1b4cd90d6be Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Tue, 20 May 2025 17:45:20 +0100
Subject: [PATCH 1/8] refactor demangler range tracking

---
 lldb/include/lldb/Core/DemangledNameInfo.h | 18 +-
 lldb/include/lldb/Core/FormatEntity.h  |  1 +
 lldb/source/Core/FormatEntity.cpp  |  3 +++
 lldb/source/Core/Mangled.cpp   |  2 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp   |  4 ++--
 lldb/unittests/Core/CMakeLists.txt |  2 +-
 ...{MangledTest.cpp => ItaniumMangledTest.cpp} | 13 +++--
 7 files changed, 33 insertions(+), 10 deletions(-)
 rename lldb/unittests/Core/{MangledTest.cpp => ItaniumMangledTest.cpp} (98%)

diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
index 11d3bb58871b8..76cf8908fcbe6 100644
--- a/lldb/include/lldb/Core/DemangledNameInfo.h
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -39,7 +39,7 @@ struct DemangledNameInfo {
   /// \endcode
   std::pair ScopeRange;
 
-  /// Indicates the [start, end) of the function argument lits.
+  /// Indicates the [start, end) of the function argument list.
   /// E.g.,
   /// \code{.cpp}
   ///int (*getFunc(float, double))(int, int)
@@ -59,11 +59,27 @@ struct DemangledNameInfo {
   /// \endcode
   std::pair QualifiersRange;
 
+  /// Indicates the [start, end) of the function's prefix. This is a
+  /// catch-all range for anything that is not tracked by the rest of
+  /// the pairs.
+  std::pair PrefixRange;
+
+  /// Indicates the [start, end) of the function's suffix. This is a
+  /// catch-all range for anything that is not tracked by the rest of
+  /// the pairs.
+  std::pair SuffixRange;
+
   /// Returns \c true if this object holds a valid basename range.
   bool hasBasename() const {
 return BasenameRange.second > BasenameRange.first &&
BasenameRange.second > 0;
   }
+
+  /// Returns \c true if this object holds a valid arguments range.
+  bool hasArguments() const {
+return ArgumentsRange.second > ArgumentsRange.first &&
+   ArgumentsRange.second > 0;
+  }
 };
 
 /// An OutputBuffer which keeps a record of where certain parts of a
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 6acf6fbe43239..1aed3c6ff9e9d 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -88,6 +88,7 @@ struct Entry {
 FunctionNameWithArgs,
 FunctionNameNoArgs,
 FunctionMangledName,
+FunctionPrefix,
 FunctionScope,
 FunctionBasename,
 FunctionTemplateArguments,
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 4f2d39873c7fb..4dcfa43a7bb04 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = {
 Definition("initial-function", EntryType::FunctionInitial),
 Definition("changed", EntryType::FunctionChanged),
 Definition("is-optimized", EntryType::FunctionIsOptimized),
+Definition("prefix", EntryType::FunctionPrefix),
 Definition("scope", EntryType::FunctionScope),
 Definition("basename", EntryType::FunctionBasename),
 Definition("template-arguments", EntryType::FunctionTemplateArguments),
@@ -385,6 +386,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
 ENUM_TO_CSTR(FunctionNameWithArgs);
 ENUM_TO_CSTR(FunctionNameNoArgs);
 ENUM_TO_CSTR(FunctionMangledName);
+ENUM_TO_CSTR(FunctionPrefix);
 ENUM_TO_CSTR(FunctionScope);
 ENUM_TO_CSTR(FunctionBasename);
 ENUM_TO_CSTR(FunctionTemplateArguments);
@@ -1835,6 +1837,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 return true;
   }
 
+  case Entry::Type::FunctionPrefix:
   case Entry::Type::FunctionScope:
   case Entry::Type::FunctionBasename:
   case Entry::Type::FunctionTemplateArguments:
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index ce4db4e0daa8b..e6f7d198d7316 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -172,6 +172,8 @@ GetItaniumDemangledStr(const char *M) {
 
 TrackingOutputBuffer OB(demangled_cstr, demangled_size);
 demangled_cstr = ipd.finishDemangle(&OB);
+OB.NameInfo.SuffixRange.first = OB.NameInfo.QualifiersRange.second;
+OB.NameInfo.SuffixRange.second = std::string(demangled_cstr).length();
 info = std::move(OB.NameInfo);
 
 assert(demangled_cstr &&
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 542f13bef23e7..f45b4fb816b3b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -401,8 +401,8 @@ GetDemangledFun

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

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

DavidSpickett wrote:

One of the tests added by this was flaky on Linaro's Windows on Arm bot, I've 
skipped it for now and https://github.com/llvm/llvm-project/pull/141738 will 
fix it properly.

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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

DavidSpickett wrote:

This does not fix the test that is xfailed, where you can't read the first 
element of a vector. That's something entirely different.

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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


@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.

Michael137 wrote:

Does `frame var` suffer from the same problem? If not, should DIL handle things 
differently?

https://github.com/llvm/llvm-project/pull/141738
___
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-28 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] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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

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


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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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


@@ -0,0 +1,57 @@
+// clang-format off

Michael137 wrote:

```suggestion
// clang-format off
```

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/140761
___
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-28 Thread Hemang Gadhavi via lldb-commits


@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
 
+TEST(Host, FindProcesses) {
+  SubsystemRAII subsystems;
+
+  if (test_arg != 0)
+exit(0);

HemangGadhavi wrote:

Done

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] Avoid crashes when inspecting MSVC STL types (PR #140761)

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


@@ -0,0 +1,57 @@
+// clang-format off
+
+// REQUIRES: target-windows

Michael137 wrote:

Can you add a comment here to explain why this test exists? I.e., that this 
just ensures that debugging with MSVC STL doesn't crash, etc.

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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

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

LGTM (just left small test comments)

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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

https://github.com/DavidSpickett requested changes to this pull request.

Request changes just so the remaining comment doesn't get forgotten, the rest 
Michael has approved and if he's cool with it so am I.

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

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


@@ -683,14 +683,14 @@ def _get_compilation_command(self, source, obj):
 args.append("-fms-compatibility-version=19")
 args.append("/c")
 
+if self.std:

DavidSpickett wrote:

This still needs to be done.

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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


@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.

DavidSpickett wrote:

Do you mean it should be able to say:
```
int_arr[100] = ;
```
Like registers can do?

I'll check what frame var does.

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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


@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.

DavidSpickett wrote:

Tbh I'm not even sure what DIL is :) So feel free to educate me.

https://github.com/llvm/llvm-project/pull/141738
___
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-28 Thread Hemang Gadhavi via lldb-commits


@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
 
+TEST(Host, FindProcesses) {
+  SubsystemRAII subsystems;
+
+  if (test_arg != 0)
+exit(0);
+
+  ProcessLaunchInfo info;
+  ProcessInstanceInfoList processes;
+  ProcessInstanceInfoMatch match(TestMainArgv0, NameMatch::Equals);
+  info.SetExecutableFile(FileSpec(TestMainArgv0),
+ /*add_exe_file_as_first_arg=*/true);
+  info.GetArguments().AppendArgument("--gtest_filter=Host.FindProcesses");
+  info.GetArguments().AppendArgument("--test-arg=48");
+  std::promise exit_status;
+  info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) {
+exit_status.set_value(status);
+  });
+  ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded());
+  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+  ASSERT_TRUE(Host::FindProcesses(match, processes));
+  ASSERT_EQ(processes[0].GetArg0(), TestMainArgv0);

HemangGadhavi wrote:

Thanks @labath for the review comments, 
I addressed all the comments. Please review once again.

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][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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


@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.

Michael137 wrote:

Summoning @labath @igorkudrin who've been much more involved in DIL

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

2025-05-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

This test has been flaky on Linaro's Windows on Arm bot and I was able to 
reproduce it within 10 or so runs locally.

When it fails it's because we failed to read the value of int_arr[100]. When 
that happens the memory looks like this:
```
[0x006bf88fd000-0x006bf890) rw-  <-- sp (0x006bf88ffe20)
[0x006bf890-0x025fec90) ---  <-- int_arr[100] 
(0x006bf8900070)
```
The first region is the stack and the stack pointer is pointing within that 
region, as expected.

The second region is where we are trying to read int_arr[100] from and this is 
not mapped because we're trying to read above the start of the stack.

Sometimes the test passes I think because ASLR / DYNAMICBASE moves the start of 
the stack down enough so there is some readable memory at the top.

https://learn.microsoft.com/en-us/cpp/build/reference/dynamicbase?view=msvc-170

Note "Because ASLR can't be disabled on ARM, ARM64, or ARM64EC architectures, 
/DYNAMICBASE:NO isn't supported for these targets.". Which means on this bot, 
the layout is definitely being randomised.

To fix this, I've setup main to pad its stack frame with 100 integers, then 
called a new function where we declare all the variables that used to be in 
main.

We have to pad this way because if we pad around int_arr, in the same function, 
the compiler could decide to move int_arr to the end of the frame, and defeat 
the padding.

By padding main, it doesn't matter how the compiler treats that as long as it 
makes main's frame larger.

We saw this failure on Windows only but I wouldn't be surprised if it can 
happen on Linux as well.

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


2 Files Affected:

- (modified) 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 (-2) 
- (modified) 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp (+21-1) 


``diff
diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
index 66f4c62761004..740a64f1477ff 100644
--- 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
+++ 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.
-@skipIfWindows
 def test_subscript(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
index 485666ae46c20..5efbefeea684b 100644
--- a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
+++ b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp
@@ -1,6 +1,21 @@
 #include 
 
-int main(int argc, char **argv) {
+// The variables being tested here are not delcared in main for a specific
+// reason. This is because during testing we access some of them out of their
+// bounds, such as int_arr[100]. If we put all these variables in main, the
+// compiler could decide to arrange them in such a way, that when combined with
+// how the stack offset was randomised by the OS, and how much was already used
+// by the libc's startup code, int_arr[100] would point to somewhere beyond the
+// top of the stack. Unmapped memory.
+//
+// To fix this we could pad around int_arr, but the compiler is free to shuffle
+// the order of stack variables. So instead, we pad main's frame so that the
+// stack pointer during fn will be far enough down that int_arr[100] will still
+// point to stack memory. It does not matter what the compiler does with the
+// padding in main as far as ordering, as long as it increases main's stack
+// frame size.
+
+int fn() {
   int int_arr[] = {1, 2, 3};
   int *int_ptr = int_arr;
   int(&int_arr_ref)[3] = int_arr;
@@ -30,3 +45,8 @@ int main(int argc, char **argv) {
 
   return 0; // Set a breakpoint here
 }
+
+int main(int argc, char **argv) {
+  int stack_frame_padding[100];
+  return fn();
+}

``




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


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

2025-05-28 Thread Chuanqi Xu via lldb-commits

ChuanqiXu9 wrote:

> CC @ChuanqiXu9 @hokein, since the both of you also looked into debuggability 
> of C++20 coroutines earlier CC @labath @adrian-prantl as reviewers of the 
> latest significant changes in this area (https://reviews.llvm.org/D132624, 
> https://reviews.llvm.org/D132735, https://reviews.llvm.org/D132815)
> 
> Would appreciate your reviews on this pull request :)

LGTM too. But I'd like to leave the formal approval to LLDB devs too.

https://github.com/llvm/llvm-project/pull/141516
___
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-28 Thread Hemang Gadhavi via lldb-commits


@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
 
+TEST(Host, FindProcesses) {
+  SubsystemRAII subsystems;
+
+  if (test_arg != 0)
+exit(0);
+
+  ProcessLaunchInfo info;
+  ProcessInstanceInfoList processes;
+  ProcessInstanceInfoMatch match(TestMainArgv0, NameMatch::Equals);
+  info.SetExecutableFile(FileSpec(TestMainArgv0),
+ /*add_exe_file_as_first_arg=*/true);
+  info.GetArguments().AppendArgument("--gtest_filter=Host.FindProcesses");
+  info.GetArguments().AppendArgument("--test-arg=48");
+  std::promise exit_status;
+  info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) {
+exit_status.set_value(status);
+  });
+  ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded());
+  std::this_thread::sleep_for(std::chrono::milliseconds(1000));

HemangGadhavi wrote:

Done

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] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-28 Thread Haojian Wu via lldb-commits

hokein wrote:

The enhancement to the pretty-printer looks reasonable to me.
I'm not familiar with the LLDB codebase, so I'll leave the approval to the LLDB 
maintainers.



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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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

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


[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/141426

>From 79a0a7b83360a517b090dad297ccb5a5a7849d0f Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Wed, 21 May 2025 23:39:56 +0200
Subject: [PATCH 1/3] Reuse creation of Source objects for assembly and normal
 sources

---
 lldb/tools/lldb-dap/Breakpoint.cpp|  14 +-
 .../Handler/DisassembleRequestHandler.cpp |  21 +--
 .../Handler/LocationsRequestHandler.cpp   |  10 +-
 .../Handler/StackTraceRequestHandler.cpp  |   6 +-
 lldb/tools/lldb-dap/JSONUtils.cpp | 123 +-
 lldb/tools/lldb-dap/JSONUtils.h   |  49 ++-
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |   2 +
 7 files changed, 100 insertions(+), 125 deletions(-)

diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
index 2d0fd9c9c3954..440d589b912fc 100644
--- a/lldb/tools/lldb-dap/Breakpoint.cpp
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -9,12 +9,10 @@
 #include "Breakpoint.h"
 #include "DAP.h"
 #include "JSONUtils.h"
-#include "LLDBUtils.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBLineEntry.h"
 #include "lldb/API/SBMutex.h"
-#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringExtras.h"
 #include 
 #include 
@@ -66,17 +64,15 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
 "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget()));
 breakpoint.instructionReference = formatted_addr;
 
-lldb::StopDisassemblyType stop_disassembly_display =
-GetStopDisassemblyDisplay(m_dap.debugger);
-auto line_entry = bp_addr.GetLineEntry();
-if (!ShouldDisplayAssemblySource(line_entry, stop_disassembly_display)) {
+auto source = CreateSource(bp_addr, m_dap.debugger);
+if (!source.IsAssemblySource()) {
+  auto line_entry = bp_addr.GetLineEntry();
   const auto line = line_entry.GetLine();
   if (line != LLDB_INVALID_LINE_NUMBER)
 breakpoint.line = line;
   const auto column = line_entry.GetColumn();
   if (column != LLDB_INVALID_COLUMN_NUMBER)
 breakpoint.column = column;
-  breakpoint.source = CreateSource(line_entry);
 } else {
   // Assembly breakpoint.
   auto symbol = bp_addr.GetSymbol();
@@ -86,10 +82,10 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
 .ReadInstructions(symbol.GetStartAddress(), bp_addr, nullptr)
 .GetSize() +
 1;
-
-breakpoint.source = CreateAssemblySource(m_dap.target, bp_addr);
   }
 }
+
+breakpoint.source = std::move(source);
   }
 
   return breakpoint;
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 1d110eac18126..49e7c788a7fb3 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -13,6 +13,7 @@
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/lldb-types.h"
@@ -81,12 +82,15 @@ static lldb::SBAddress 
GetDisassembleStartAddress(lldb::SBTarget target,
   .GetAddress();
 }
 
-static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
-lldb::SBTarget &target, lldb::SBInstruction &inst, bool resolve_symbols) {
+static DisassembledInstruction
+ConvertSBInstructionToDisassembledInstruction(lldb::SBDebugger &debugger,
+  lldb::SBInstruction &inst,
+  bool resolve_symbols) {
   if (!inst.IsValid())
 return GetInvalidInstruction();
 
-  auto addr = inst.GetAddress();
+  lldb::SBTarget target = debugger.GetSelectedTarget();
+  lldb::SBAddress addr = inst.GetAddress();
   const auto inst_addr = addr.GetLoadAddress(target);
 
   // FIXME: This is a workaround - this address might come from
@@ -139,15 +143,14 @@ static DisassembledInstruction 
ConvertSBInstructionToDisassembledInstruction(
 
   disassembled_inst.instruction = std::move(instruction);
 
+  auto source = CreateSource(addr, debugger);
   auto line_entry = addr.GetLineEntry();
-  // If the line number is 0 then the entry represents a compiler generated
-  // location.
 
-  if (line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
+  if (!source.IsAssemblySource() && line_entry.IsValid() &&
+  line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
   line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0) {
-auto source = CreateSource(line_entry);
-disassembled_inst.location = std::move(source);
 
+disassembled_inst.location = std::move(source);
 const auto line = line_entry.GetLine();
 if (line != 0 && line != LLDB_INVALID_LINE_NUMBER)
   disassembled

[Lldb-commits] [lldb] [lldb] Make AddressRange dump easier on the eye (PR #141062)

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

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


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

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

labath wrote:

> @labath
> 
> We need to handle situations where the core won't have a valid platform, and 
> then fallback to other info (like PRSTATUS).
> 
> Please check the last commit in this patch. I think this will almost 
> exclusively be an artifact of our tests, but I'm not sure how else to handle 
> this

So, this particular failure is due to broken/incomplete support for these 
architectures (they weren't added to [this 
list](https://github.com/llvm/llvm-project/blob/f8ca9e59cb438bd35b29a6d7cf6d72f50673aec9/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp#L126)).
 The list only matters on mac because we probably end up somehow falling back 
to the host platform.

I expect adding them there would fix this. *However* I also think it makes 
sense to not fail catastrophically in case we cannot read/parse signal info, so 
I'm fine with the change you made in principle, but the I find the 
implementation somewhat unelegant. Do we actually need to access the platform 
class from `ELFLinuxSigInfo::Parse`? The data extractor should have already 
been set to the size of the siginfo note, right? Could we postpone the size 
check and move it closer to the place which actually uses the type? 
Thread::GetSiginfoValue maybe?

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


[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

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

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

Looks good. Thanks for the fix.

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


[Lldb-commits] [lldb] [lldb] Fix warnings (PR #141687)

2025-05-28 Thread Walter Lee via lldb-commits

googlewalt wrote:

I don't have any expertise in this code, but it looks like it shouldn't break 
anything and fixes a bunch of build breakages, so I'm going to check it in.

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


[Lldb-commits] [lldb] [lldb] Fix warnings (PR #141687)

2025-05-28 Thread Walter Lee via lldb-commits

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


[Lldb-commits] [lldb] a69487d - [lldb] Fix warnings (#141687)

2025-05-28 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-28T04:00:18-04:00
New Revision: a69487da2e746d747fc0dc19d416a7d654c8c148

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

LOG: [lldb] Fix warnings (#141687)

This patch fixes:

  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4137:11:
  error: enumeration value 'HLSLInlineSpirv' not handled in switch
  [-Werror,-Wswitch]

  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4844:11:
  error: enumeration value 'HLSLInlineSpirv' not handled in switch
  [-Werror,-Wswitch]

  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5142:11:
  error: enumeration value 'HLSLInlineSpirv' not handled in switch
  [-Werror,-Wswitch]

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 8c19d5be76bcf..16ea40bd5e9bc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4262,6 +4262,8 @@ 
TypeSystemClang::GetTypeClass(lldb::opaque_compiler_type_t type) {
 
   case clang::Type::HLSLAttributedResource:
 break;
+  case clang::Type::HLSLInlineSpirv:
+break;
   }
   // We don't know hot to display this type...
   return lldb::eTypeClassOther;
@@ -5128,6 +5130,8 @@ lldb::Encoding 
TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
 
   case clang::Type::HLSLAttributedResource:
 break;
+  case clang::Type::HLSLInlineSpirv:
+break;
   }
   count = 0;
   return lldb::eEncodingInvalid;
@@ -5292,6 +5296,8 @@ lldb::Format 
TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
 
   case clang::Type::HLSLAttributedResource:
 break;
+  case clang::Type::HLSLInlineSpirv:
+break;
   }
   // We don't know hot to display this type...
   return lldb::eFormatBytes;



___
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-28 Thread Pavel Labath via lldb-commits

labath wrote:

> > @petrhosek Hey Petr, can you provide more information? For Linux 
> > environments, SI_DETHREAD should be present. The commit for this signal 
> > specifically is 13 years old, @DavidSpickett do you have any insight as to 
> > why this is happening?
> > [SI_DETHREAD](https://github.com/torvalds/linux/blob/015a99fa76650e7d6efa3e36f20c0f5b346fe9ce/include/uapi/asm-generic/siginfo.h#L182)
> > (Updated with an actually useful Linux line number)
> 
> I'm not sure what the issue is yet, I checked 
> `usr/include/asm-generic/siginfo.h` in our sysroot and it contains the 
> `SI_DETHREAD` definition.

This is a linux kernel header, and is not included when building regular 
applications. For me, the definition of SI_DETHREAD comes from 
/usr/include/bits/siginfo-consts.h (which comes from (g)libc). Maybe you don't 
have it if you have an old libc version.

I also checked the glibc version used internally at google (2.27, which is 
"only" seven years old :/), and it also does not have this symbol.

> Because the Linux CI is passing, are you opposed to merging the reapply? I'm 
> not sure how I would help debug your builders failing to link it. We could 
> also drop SI_DETHREAD for now and follow up in the future.

It's true that these libraries are old, but it seems wrong to make this not 
build on (old) linuxes if the code actually builds on windows. We are actually 
providing the hardcoded values of these constants. The only reason we're 
referencing the os-defined values is so we can validate our values for them. 
There's already a 
[precedent](https://github.com/llvm/llvm-project/blob/cbe2352c4dc607da71e7bd40213b8922fbdee482/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp#L18)
 for handling unavailable constants, so you could just do the same with these.

(Although overall, I think it be better to move these checks to a test where 
the checks for individual constants could be guarded by `#ifdef SI_CONSTANT`)

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] Fix warnings (PR #141687)

2025-05-28 Thread Walter Lee via lldb-commits

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


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


[Lldb-commits] [lldb] 8b6e985 - [lldb][test] Skip DIL array subscript test on Windows

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

Author: David Spickett
Date: 2025-05-28T10:14:28Z
New Revision: 8b6e98559de15dc75edddf616ed37c5b6e23dfba

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

LOG: [lldb][test] Skip DIL array subscript test on Windows

This has been flaky on Linaro's Windows on Arm bot, failing
with errors all along these lines:

Traceback (most recent call last):
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\commands\frame\var-dil\basics\ArraySubscript\TestFrameVarDILArraySubscript.py",
 line 56, in test_subscript
self.expect_var_path("int_arr[100]", True, type="int")
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\commands\frame\var-dil\basics\ArraySubscript\TestFrameVarDILArraySubscript.py",
 line 15, in expect_var_path
value_dil = super().expect_var_path(expr, value=value, type=type)
^
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 2589, in expect_var_path
value_check.check_value(self, eval_result, str(eval_result))
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 301, in check_value
test_base.assertSuccess(val.GetError())
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 2597, in assertSuccess
self.fail(self._formatMessage(msg, "'{}' is not success".format(error)))

AssertionError: 'read memory from 0x68119c00b0 failed (0 of 4 bytes read)' is 
not success

I think this is because we are trying to read off of the top of the
stack which is unmapped memory on Windows.

I have a fix I'm going to put in review shortly.

Added: 


Modified: 

lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py

Removed: 




diff  --git 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
index 740a64f1477ff..66f4c62761004 100644
--- 
a/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
+++ 
b/lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
@@ -19,6 +19,8 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
+# int_arr[100] sometimes points to above the stack region, fix coming soon.
+@skipIfWindows
 def test_subscript(self):
 self.build()
 lldbutil.run_to_source_breakpoint(



___
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-28 Thread Pavel Labath via lldb-commits


@@ -1926,20 +1863,21 @@ SBValueList SBTarget::FindGlobalVariables(const char 
*name,
 
   SBValueList sb_value_list;
 
-  TargetSP target_sp(GetSP());
-  if (name && target_sp) {
-VariableList variable_list;
-target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
-   variable_list);
-if (!variable_list.Empty()) {
-  ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
-  if (exe_scope == nullptr)
-exe_scope = target_sp.get();
-  for (const VariableSP &var_sp : variable_list) {
-lldb::ValueObjectSP valobj_sp(
-ValueObjectVariable::Create(exe_scope, var_sp));
-if (valobj_sp)
-  sb_value_list.Append(SBValue(valobj_sp));
+  if (TargetSP target_sp = GetSP()) {

labath wrote:

h

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-28 Thread Pavel Labath via lldb-commits


@@ -1593,11 +1545,12 @@ SBModule SBTarget::FindModule(const SBFileSpec 
&sb_file_spec) {
   LLDB_INSTRUMENT_VA(this, sb_file_spec);
 
   SBModule sb_module;
-  TargetSP target_sp(GetSP());
-  if (target_sp && sb_file_spec.IsValid()) {
-ModuleSpec module_spec(*sb_file_spec);
-// The module list is thread safe, no need to lock
-sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
+  if (TargetSP target_sp = GetSP()) {
+if (sb_file_spec.IsValid()) {

labath wrote:

missed two :)

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-28 Thread Pavel Labath via lldb-commits


@@ -1113,10 +1082,11 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t 
bp_id) {
   LLDB_INSTRUMENT_VA(this, bp_id);
 
   SBBreakpoint sb_breakpoint;
-  TargetSP target_sp(GetSP());
-  if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
-std::lock_guard guard(target_sp->GetAPIMutex());
-sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
+  if (TargetSP target_sp = GetSP()) {
+if (bp_id != LLDB_INVALID_BREAK_ID) {

labath wrote:

missed one

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-28 Thread Pavel Labath via lldb-commits


@@ -1954,41 +1892,42 @@ SBValueList SBTarget::FindGlobalVariables(const char 
*name,
 
   SBValueList sb_value_list;
 
-  TargetSP target_sp(GetSP());
-  if (name && target_sp) {
-llvm::StringRef name_ref(name);
-VariableList variable_list;
+  if (TargetSP target_sp = GetSP()) {

labath wrote:

h

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-28 Thread Pavel Labath via lldb-commits


@@ -1887,34 +1823,35 @@ lldb::SBTypeList SBTarget::FindTypes(const char 
*typename_cstr) {
   LLDB_INSTRUMENT_VA(this, typename_cstr);
 
   SBTypeList sb_type_list;
-  TargetSP target_sp(GetSP());
-  if (typename_cstr && typename_cstr[0] && target_sp) {
-ModuleList &images = target_sp->GetImages();
-ConstString const_typename(typename_cstr);
-TypeQuery query(typename_cstr);
-TypeResults results;
-images.FindTypes(nullptr, query, results);
-for (const TypeSP &type_sp : results.GetTypeMap().Types())
-  sb_type_list.Append(SBType(type_sp));
-
-// Try the loaded language runtimes
-if (auto process_sp = target_sp->GetProcessSP()) {
-  for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-if (auto *vendor = runtime->GetDeclVendor()) {
-  auto types =
-  vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
-  for (auto type : types)
-sb_type_list.Append(SBType(type));
+  if (TargetSP target_sp = GetSP()) {

labath wrote:

h

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-28 Thread Pavel Labath via lldb-commits


@@ -1606,66 +1559,60 @@ SBSymbolContextList SBTarget::FindCompileUnits(const 
SBFileSpec &sb_file_spec) {
   LLDB_INSTRUMENT_VA(this, sb_file_spec);
 
   SBSymbolContextList sb_sc_list;
-  const TargetSP target_sp(GetSP());
-  if (target_sp && sb_file_spec.IsValid())
-target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list);
+  if (TargetSP target_sp = GetSP()) {

labath wrote:

and 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-28 Thread Pavel Labath via lldb-commits

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


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-28 Thread Pavel Labath via lldb-commits


@@ -1841,31 +1776,33 @@ lldb::SBSymbolContextList 
SBTarget::FindGlobalFunctions(const char *name,
 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
   LLDB_INSTRUMENT_VA(this, typename_cstr);
 
-  TargetSP target_sp(GetSP());
-  if (typename_cstr && typename_cstr[0] && target_sp) {
-ConstString const_typename(typename_cstr);
-TypeQuery query(const_typename.GetStringRef(),
-TypeQueryOptions::e_find_one);
-TypeResults results;
-target_sp->GetImages().FindTypes(/*search_first=*/nullptr, query, results);
-TypeSP type_sp = results.GetFirstType();
-if (type_sp)
-  return SBType(type_sp);
-// Didn't find the type in the symbols; Try the loaded language runtimes.
-if (auto process_sp = target_sp->GetProcessSP()) {
-  for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-if (auto vendor = runtime->GetDeclVendor()) {
-  auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
-  if (!types.empty())
-return SBType(types.front());
+  if (TargetSP target_sp = GetSP()) {

labath wrote:

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-28 Thread Pavel Labath via lldb-commits


@@ -1355,29 +1312,30 @@ SBTarget::WatchpointCreateByAddress(lldb::addr_t addr, 
size_t size,
 
   SBWatchpoint sb_watchpoint;
   lldb::WatchpointSP watchpoint_sp;
-  TargetSP target_sp(GetSP());
-  uint32_t watch_type = 0;
-  if (options.GetWatchpointTypeRead())
-watch_type |= LLDB_WATCH_TYPE_READ;
-  if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways)
-watch_type |= LLDB_WATCH_TYPE_WRITE;
-  if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify)
-watch_type |= LLDB_WATCH_TYPE_MODIFY;
-  if (watch_type == 0) {
-error.SetErrorString("Can't create a watchpoint that is neither read nor "
- "write nor modify.");
-return sb_watchpoint;
-  }
-  if (target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) {
-std::lock_guard guard(target_sp->GetAPIMutex());
-// Target::CreateWatchpoint() is thread safe.
-Status cw_error;
-// This API doesn't take in a type, so we can't figure out what it is.
-CompilerType *type = nullptr;
-watchpoint_sp =
-target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
-error.SetError(std::move(cw_error));
-sb_watchpoint.SetSP(watchpoint_sp);
+  if (TargetSP target_sp = GetSP()) {
+uint32_t watch_type = 0;
+if (options.GetWatchpointTypeRead())
+  watch_type |= LLDB_WATCH_TYPE_READ;
+if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways)
+  watch_type |= LLDB_WATCH_TYPE_WRITE;
+if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify)
+  watch_type |= LLDB_WATCH_TYPE_MODIFY;
+if (watch_type == 0) {
+  error.SetErrorString("Can't create a watchpoint that is neither read nor 
"
+   "write nor modify.");
+  return sb_watchpoint;
+}
+if (addr != LLDB_INVALID_ADDRESS && size > 0) {

labath wrote:

```suggestion
uint32_t watch_type = 0;
if (options.GetWatchpointTypeRead())
  watch_type |= LLDB_WATCH_TYPE_READ;
if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways)
  watch_type |= LLDB_WATCH_TYPE_WRITE;
if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify)
  watch_type |= LLDB_WATCH_TYPE_MODIFY;
if (watch_type == 0) {
  error.SetErrorString("Can't create a watchpoint that is neither read nor "
   "write nor modify.");
  return sb_watchpoint;
}
  if (TargetSP target_sp = GetSP();
target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) {
```

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-28 Thread Pavel Labath via lldb-commits


@@ -2393,62 +2321,53 @@ 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)

labath wrote:

This is an interesting one, because this pattern comes into conflict with the 
"early exit" rule. For a small function like this, this is fine, but if it was 
longer, I'd say that the early exit should win.

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] 4528942 - [lldb] Make AddressRange dump easier on the eye (#141062)

2025-05-28 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-05-28T09:02:36+02:00
New Revision: 452894207ae28cde9c22e2935df2d960fa7585a9

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

LOG: [lldb] Make AddressRange dump easier on the eye (#141062)

Added: 


Modified: 
lldb/source/Core/AddressRange.cpp
lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test
lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
lldb/test/Shell/Unwind/basic-block-sections-with-dwarf-static.test

Removed: 




diff  --git a/lldb/source/Core/AddressRange.cpp 
b/lldb/source/Core/AddressRange.cpp
index 6cef7e149cd20..315fcf1a6da32 100644
--- a/lldb/source/Core/AddressRange.cpp
+++ b/lldb/source/Core/AddressRange.cpp
@@ -162,15 +162,18 @@ bool AddressRange::Dump(Stream *s, Target *target, 
Address::DumpStyle style,
   default:
 break;
   case Address::DumpStyleSectionNameOffset:
-  case Address::DumpStyleSectionPointerOffset:
+  case Address::DumpStyleSectionPointerOffset: {
 s->PutChar('[');
 m_base_addr.Dump(s, target, style, fallback_style);
 s->PutChar('-');
-DumpAddress(s->AsRawOstream(), m_base_addr.GetOffset() + GetByteSize(),
-addr_size);
+addr_t end = m_base_addr.GetOffset() + GetByteSize();
+if (m_base_addr.GetSection())
+  s->Format("{0}", end);
+else
+  DumpAddress(s->AsRawOstream(), end, addr_size);
 s->PutChar(')');
 return true;
-break;
+  }
 
   case Address::DumpStyleModuleWithFileAddress:
 show_module = true;

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test 
b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
index 539b8096b58bc..9fbd29489c89b 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
@@ -11,7 +11,7 @@ image show-unwind -n func0
 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
 # CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no.
 # CHECK-NEXT: This UnwindPlan is for a trap handler function: no.
-# CHECK-NEXT: Address range of this UnwindPlan: 
[stack-cfi-parsing.out..module_image + 0-0x0002)
+# CHECK-NEXT: Address range of this UnwindPlan: 
[stack-cfi-parsing.out..module_image + 0-2)
 # CHECK-NEXT: row[0]:0: CFA=DW_OP_breg7 +0 => rbp=DW_OP_breg7 +0 
rip=DW_OP_pick 0x0
 # CHECK-NEXT: row[1]:1: CFA=DW_OP_breg7 +0 => rbx=DW_OP_breg2 +0 
rbp=DW_OP_breg0 +0 rip=DW_OP_pick 0x0
 
@@ -48,6 +48,6 @@ image show-unwind -n func9
 # CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'breakpad 
STACK CFI'
 # CHECK: Synchronous (restricted to call-sites) UnwindPlan is 'breakpad STACK 
CFI'
 # CHECK: Symbol file UnwindPlan:
-# CHECK: Address range of this UnwindPlan: 
[stack-cfi-parsing.out..module_image + 9-0x000a)
+# CHECK: Address range of this UnwindPlan: 
[stack-cfi-parsing.out..module_image + 9-10)
 # CHECK: row[0]:0: CFA=DW_OP_breg6 +0 => rip=DW_OP_breg0 +0
 

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test 
b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
index 0bcebaa00540d..580ccf8492a0f 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
@@ -15,7 +15,7 @@ image show-unwind -n call_many
 # CHECK: This UnwindPlan is sourced from the compiler: yes.
 # CHECK: This UnwindPlan is valid at all instruction locations: no.
 # CHECK: This UnwindPlan is for a trap handler function: no.
-# CHECK: Address range of this UnwindPlan: 
[unwind-via-stack-win.exe..module_image + 4112-0x107d)
+# CHECK: Address range of this UnwindPlan: 
[unwind-via-stack-win.exe..module_image + 4112-4221)
 # CHECK: row[0]:0: CFA=RaSearch@SP+0 => esp=DW_OP_pick 0x0, DW_OP_consts 
+4, DW_OP_plus  eip=DW_OP_pick 0x0, DW_OP_deref
 
 image show-unwind -n nonzero_frame_size

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test 
b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
index dade708519f5b..991ae4d47cba5 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
@@ -13,7 +13,7 @@ image show-unwind -n bar
 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
 # CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no.
 # CHECK-NEXT: This UnwindPlan is for a trap handler function: no.
-# CHECK-NEXT: Address range of this UnwindPlan: 
[unwind-via-stack-cfi..module_image + 1056-0x0

[Lldb-commits] [lldb] 3d0f885 - [AArch64][LLDB] Add missing AArch64SVEACLETypes.def rename

2025-05-28 Thread David Green via lldb-commits

Author: David Green
Date: 2025-05-28T13:16:25+01:00
New Revision: 3d0f88552a43533799d9bf24cf4f61c89dd8af46

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

LOG: [AArch64][LLDB] Add missing AArch64SVEACLETypes.def rename

Fixup from 3a42cbd47d3e92b8794378d2a0e8ec7ae81950d7.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 16ea40bd5e9bc..41f5f96074f65 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5031,7 +5031,7 @@ lldb::Encoding 
TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
 
 // ARM -- Scalable Vector Extension
 #define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
+#include "clang/Basic/AArch64ACLETypes.def"
   break;
 
 // RISC-V V builtin types.



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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-28 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/141543

>From 75f0f1463c7bcabb5ffef34c0f1e1c0b4ca91b04 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 27 May 2025 12:10:36 +0800
Subject: [PATCH 1/2] [libc++][lldb-dap][test] Fix CI for bootstrapping-build

---
 libcxx/include/__config | 2 ++
 .../lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py| 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 57223e4f1db18..49abe17a4da76 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1219,3 +1219,5 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
+
+// Just for CI, will be reverted.
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1e41e841e39bc..1751c52072aac 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
+self.build_and_launch(program, disableASLR=False)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

>From aa5bb01d57c54bde6d1f7dffc57498517bc38c18 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Wed, 28 May 2025 02:41:00 +0800
Subject: [PATCH 2/2] =?UTF-8?q?Adopt=20@ashgti=E2=80=98s=20review=20commen?=
 =?UTF-8?q?ts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- Change the default argument for `disableASLR` in `dap_server.py`.
- Revert change in `TestDAP_subtleFrames.py`.
---
 .../packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 2 +-
 .../lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a028381a0a4f9..4c8c51905e1d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -856,7 +856,7 @@ def request_launch(
 cwd: Optional[str] = None,
 env: Optional[dict[str, str]] = None,
 stopOnEntry=False,
-disableASLR=True,
+disableASLR=False,
 disableSTDIO=False,
 shellExpandArguments=False,
 runInTerminal=False,
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1751c52072aac..1e41e841e39bc 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program, disableASLR=False)
+self.build_and_launch(program)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

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


[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF ParseSymtab handling (PR #141577)

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

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

>From a62cd7b510f3cf74ee356a95a26e0f9922f4b39c Mon Sep 17 00:00:00 2001
From: DhruvSrivastavaX 
Date: Tue, 27 May 2025 05:44:55 -0500
Subject: [PATCH 1/2] Added XCOFF ParseSymtab handling

---
 .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp  | 66 ++-
 1 file changed, 65 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index e629355cd40b9..7dfe6c362add4 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -188,7 +188,71 @@ AddressClass ObjectFileXCOFF::GetAddressClass(addr_t 
file_addr) {
   return AddressClass::eUnknown;
 }
 
-void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
+lldb::SymbolType MapSymbolType(llvm::object::SymbolRef::Type sym_type) {
+  if (sym_type == llvm::object::SymbolRef::ST_Function)
+return lldb::eSymbolTypeCode;
+  else if (sym_type == llvm::object::SymbolRef::ST_Data)
+return lldb::eSymbolTypeData;
+  else if (sym_type == llvm::object::SymbolRef::ST_File)
+return lldb::eSymbolTypeSourceFile;
+  return lldb::eSymbolTypeInvalid;
+}
+
+void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
+  SectionList *sectionList = GetSectionList();
+
+  for (const auto &symbol_ref : m_binary->symbols()) {
+llvm::object::XCOFFSymbolRef xcoff_sym_ref(symbol_ref);
+llvm::Expected name_or_err = xcoff_sym_ref.getName();
+if (!name_or_err) {
+  consumeError(name_or_err.takeError());
+  continue;
+}
+llvm::StringRef symbolName = name_or_err.get();
+// Remove the dot prefix for demangle
+llvm::StringRef symbol_name =
+symbolName.starts_with(".") ? symbolName.drop_front() : symbolName;
+auto storageClass = xcoff_sym_ref.getStorageClass();
+if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") {
+  if (xcoff_sym_ref.getNumberOfAuxEntries() != 1)
+continue;
+  auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef();
+  if (!aux_csect_or_err) {
+consumeError(aux_csect_or_err.takeError());
+continue;
+  }
+  const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get();
+  if (csect_aux.getStorageMappingClass() != XCOFF::XMC_PR ||
+  (m_binary->is64Bit() ? (csect_aux.getAuxType64() != XCOFF::AUX_CSECT)
+   : false))
+continue;
+}
+
+Symbol symbol;
+symbol.GetMangled().SetValue(ConstString(symbol_name));
+
+int16_t sectionNumber = xcoff_sym_ref.getSectionNumber();
+size_t sectionIndex = static_cast(sectionNumber - 1);
+if (sectionNumber > 0 && sectionIndex < sectionList->GetSize()) {
+  lldb::SectionSP section_sp =
+  sectionList->GetSectionAtIndex(sectionNumber - 1);
+  if (!section_sp || section_sp->GetFileAddress() == LLDB_INVALID_ADDRESS)
+continue;
+  lldb::addr_t file_addr = section_sp->GetFileAddress();
+  lldb::addr_t symbolValue = xcoff_sym_ref.getValue();
+  if (symbolValue < file_addr)
+continue;
+  symbol.GetAddressRef() = Address(section_sp, symbolValue - file_addr);
+}
+
+Expected sym_type_or_err =
+symbol_ref.getType();
+symbol.SetType(MapSymbolType(sym_type_or_err.get()));
+printf("%s %d\n", symbol.GetName(), *sym_type_or_err);
+
+lldb_symtab.AddSymbol(symbol);
+  }
+}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 

>From 21f5a39976457589e2ab9666820c08331aaf4542 Mon Sep 17 00:00:00 2001
From: Dhruv Srivastava 
Date: Tue, 27 May 2025 16:33:08 +0530
Subject: [PATCH 2/2] cleanup

---
 lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 7dfe6c362add4..1e84b86cd6f0a 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -247,8 +247,11 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
 
 Expected sym_type_or_err =
 symbol_ref.getType();
+if (!sym_type_or_err) {
+  consumeError(sym_type_or_err.takeError());
+  continue;
+}
 symbol.SetType(MapSymbolType(sym_type_or_err.get()));
-printf("%s %d\n", symbol.GetName(), *sym_type_or_err);
 
 lldb_symtab.AddSymbol(symbol);
   }

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-28 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] 7ed185a - [lldb] Expose language plugin commands based based on language of current frame (#136766)

2025-05-28 Thread via lldb-commits

Author: Dave Lee
Date: 2025-05-28T11:04:57-07:00
New Revision: 7ed185a8f2b9f2436db1ccd82964424f641917e9

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

LOG: [lldb] Expose language plugin commands based based on language of current 
frame (#136766)

Use the current frame's language to lookup commands provided by language 
plugins.

This means commands like `language {objc,cplusplus} ` can be used 
directly, without using the `language ` prefix.

For example, when stopped on a C++ frame, `demangle _Z1fv` will run `language 
cplusplus demangle _Z1fv`.

rdar://149882520

Added: 
lldb/test/API/commands/command/language/Makefile
lldb/test/API/commands/command/language/TestFrameLanguageCommands.py
lldb/test/API/commands/command/language/commands.py
lldb/test/API/commands/command/language/lib.cpp
lldb/test/API/commands/command/language/main.mm

Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Commands/CommandObjectLanguage.cpp
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,

diff  --git a/lldb/source/Commands/CommandObjectLanguage.cpp 
b/lldb/source/Commands/CommandObjectLanguage.cpp
index 925db599e4abb..7272241551058 100644
--- a/lldb/source/Commands/CommandObjectLanguage.cpp
+++ b/lldb/source/Commands/CommandObjectLanguage.cpp
@@ -21,6 +21,18 @@ 
CommandObjectLanguage::CommandObjectLanguage(CommandInterpreter &interpreter)
   "language   []") {
   // Let the LanguageRuntime populates this command with subcommands
   LanguageRuntime::InitializeCommands(this);
+  SetHelpLong(
+  R"(
+Language specific subcommands may be used directly (without the `language
+` prefix), when stopped on a frame written in that language. For
+example, from a C++ frame, users may run `demangle` directly, instead of
+`language cplusplus demangle`.
+
+Language specific subcommands are only available when the command name cannot 
be
+misinterpreted. Take the `demangle` command for example, if a Python command
+named `demangle-tree` were loaded, then the invocation `demangle` would run
+`demangle-tree`, not `language cplusplus demangle`.
+  )");
 }
 
 CommandObjectLanguage::~CommandObjectLanguage() = default;

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 34749d890bf03..4f9ae104dedea 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,28 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  auto frame_sp = GetExecutionContext().GetFrameSP();
+  if (!frame_sp)
+return {};
+  auto frame_language =
+  Language::GetPrimaryLanguage(frame_sp->GuessLanguage().AsLanguageType());
+
+  auto it = m_command_dict.find("language");
+  if (it == m_command_dict.end())
+return {};
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  auto *plugin = Language::FindPlugin(frame_language);
+  if (!plugin)
+return {};
+  // "cplusplus", "objc", etc.
+  auto lang_name = plugin->GetPluginName();
+
+  return language_cmd_sp->GetSubcommandSPExact(lang_name);
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1136,7 +1158,34 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   else
 return user_match_sp;
 }
-  } else if (matches && command_sp) {
+  }
+
+  // When no single match is found, attempt to resolve the command as a 
language
+  // plugin subcommand.
+  if (!command_sp) {
+// The `language` subcommand ("language objc", "language cplusplus", etc).
+CommandObjectMultiwor

[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-28 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Show more children of top level values (PR #140938)

2025-05-28 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/140938

>From f07c408bcbc221e69f56459d0cca27a27ed8551c Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 21 May 2025 09:44:16 -0700
Subject: [PATCH 1/3] [lldb] Show more children of top level values

This changes printing values at the top level (such as variables). The original 
default
value for `target.max-children-count` was 256. The default has since been 
reduced, to
avoid printing too much data (ff127624be).

However, users will naturally have expectations that all (or significantly many)
children are shown for top level values. The following code keeps 256 as the 
max count
for top level values (unless customized). The value of 
`target.max-children-count` will
continue to apply to nested values (depth >= 1).
---
 lldb/include/lldb/Target/Target.h |  2 +-
 lldb/source/API/SBTarget.cpp  |  2 +-
 lldb/source/Core/FormatEntity.cpp |  2 +-
 lldb/source/DataFormatters/FormatManager.cpp  |  2 +-
 .../DataFormatters/ValueObjectPrinter.cpp | 27 ---
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp |  2 +-
 lldb/source/Target/Target.cpp |  9 ---
 7 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 0d4e11b65339e..bcde310378acf 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -186,7 +186,7 @@ class TargetProperties : public Properties {
 
   uint32_t GetMaxZeroPaddingInFloatFormat() const;
 
-  uint32_t GetMaximumNumberOfChildrenToDisplay() const;
+  std::pair GetMaximumNumberOfChildrenToDisplay() const;
 
   /// Get the max depth value, augmented with a bool to indicate whether the
   /// depth is the default.
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..c3e3b6105d56f 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1713,7 +1713,7 @@ uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() 
const {
 
   TargetSP target_sp(GetSP());
   if(target_sp){
- return target_sp->GetMaximumNumberOfChildrenToDisplay();
+return target_sp->GetMaximumNumberOfChildrenToDisplay().first;
   }
   return 0;
 }
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 4f2d39873c7fb..98e5bfe37cd62 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1025,7 +1025,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
 if (index_higher < 0)
   index_higher = valobj->GetNumChildrenIgnoringErrors() - 1;
 
-uint32_t max_num_children =
+auto [max_num_children, _] =
 target->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
 
 bool success = true;
diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index 3b891cecb1c8b..feb69840bc64b 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -458,7 +458,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
&valobj) {
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  const size_t max_num_children =
+  const auto [max_num_children, _] =
   (target_sp ? *target_sp : Target::GetGlobalProperties())
   .GetMaximumNumberOfChildrenToDisplay();
   auto num_children = valobj.GetNumChildren(max_num_children);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 5e04a621bbda8..4890aa8f7ee66 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -633,6 +633,27 @@ void ValueObjectPrinter::PrintChild(
   }
 }
 
+static uint32_t determineMaxChildren(bool ignore_cap, uint32_t cur_depth,
+ TargetSP target_sp) {
+  if (ignore_cap)
+return UINT32_MAX;
+
+  const auto [max_num_children, max_is_default] =
+  target_sp->GetMaximumNumberOfChildrenToDisplay();
+
+  // Special handling for printing values at the top level (such as variables).
+  // The original default value for target.max-children-count was 256. The
+  // default has since been reduced, to avoid printing too much data. However,
+  // users will naturally have expectations that all children are shown for top
+  // level values. The following code keeps 256 as the max count for top level
+  // values (unless customized).
+  const uint32_t top_level_max_num_childen = 256;
+  if (cur_depth == 0 && max_is_default)
+return top_level_max_num_childen;
+
+  return max_num_children;
+}
+
 llvm::Expected
 ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) {
   ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
@@ -641,10 +662,8 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool 

[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-28 Thread Louis Dionne via lldb-commits

ldionne wrote:

I'm going to land this to attempt to unbreak libc++'s CI, which is in a really 
bad shape right now. From the comments above, this seems to have consensus to 
move forward.

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


[Lldb-commits] [lldb] add explicit default initialization to DemangledNameInfo to remove warning (PR #141790)

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

kazutakahirata wrote:

@charles-zablit I've verified that this PR fixes `check-lldb-unit` in my local 
build.  Thank you for fixing this!

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


[Lldb-commits] [lldb] 4304d90 - [libc++][lldb-dap][test] Fix CI for bootstrapping-build (#141543)

2025-05-28 Thread via lldb-commits

Author: A. Jiang
Date: 2025-05-28T14:30:45-04:00
New Revision: 4304d90f0ac171f86c26d7d2da4fd03b336957bb

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

LOG: [libc++][lldb-dap][test] Fix CI for bootstrapping-build (#141543)

#140107 changed the default argument of `disableASLR` of related
functions from `False` to `True`. libc++ CI has been stably failing for
`TestDAP_subtleFrames.py` (in bootstrapping-build) since then. The error
message "personality set failed: Operation not permitted" seems related
to ASLR.

This PR attempts to fix the CI failure by changing the default value of
`disableASLR` in `dap_server.py` to `False`.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a028381a0a4f9..4c8c51905e1d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -856,7 +856,7 @@ def request_launch(
 cwd: Optional[str] = None,
 env: Optional[dict[str, str]] = None,
 stopOnEntry=False,
-disableASLR=True,
+disableASLR=False,
 disableSTDIO=False,
 shellExpandArguments=False,
 runInTerminal=False,



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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-28 Thread Louis Dionne via lldb-commits

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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-28 Thread Louis Dionne via lldb-commits

ldionne wrote:

Thanks a lot for investigating this folks, in particular @frederick-vs-ja for 
jumping on the issue to restore libc++'s CI.

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


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

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

ZequanWu wrote:

Ping.

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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-28 Thread Louis Dionne via lldb-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/141543

>From 75f0f1463c7bcabb5ffef34c0f1e1c0b4ca91b04 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 27 May 2025 12:10:36 +0800
Subject: [PATCH 1/3] [libc++][lldb-dap][test] Fix CI for bootstrapping-build

---
 libcxx/include/__config | 2 ++
 .../lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py| 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 57223e4f1db18..49abe17a4da76 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1219,3 +1219,5 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
+
+// Just for CI, will be reverted.
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1e41e841e39bc..1751c52072aac 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
+self.build_and_launch(program, disableASLR=False)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

>From aa5bb01d57c54bde6d1f7dffc57498517bc38c18 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Wed, 28 May 2025 02:41:00 +0800
Subject: [PATCH 2/3] =?UTF-8?q?Adopt=20@ashgti=E2=80=98s=20review=20commen?=
 =?UTF-8?q?ts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- Change the default argument for `disableASLR` in `dap_server.py`.
- Revert change in `TestDAP_subtleFrames.py`.
---
 .../packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 2 +-
 .../lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a028381a0a4f9..4c8c51905e1d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -856,7 +856,7 @@ def request_launch(
 cwd: Optional[str] = None,
 env: Optional[dict[str, str]] = None,
 stopOnEntry=False,
-disableASLR=True,
+disableASLR=False,
 disableSTDIO=False,
 shellExpandArguments=False,
 runInTerminal=False,
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1751c52072aac..1e41e841e39bc 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program, disableASLR=False)
+self.build_and_launch(program)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

>From 1780da1747a089e41566bf17c9944a447f8b8202 Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 28 May 2025 14:29:18 -0400
Subject: [PATCH 3/3] Remove comment

---
 libcxx/include/__config | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 49abe17a4da76..57223e4f1db18 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1219,5 +1219,3 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
-
-// Just for CI, will be reverted.

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


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

2025-05-28 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

2025-05-28 Thread via lldb-commits


@@ -58,6 +59,9 @@ class LLDB_API SBAddress {
   // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
   lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
 
+  lldb::SBSymbolContext GetSymbolContext(const SBTarget &target,
+ uint32_t resolve_scope);

jimingham wrote:

You might put a comment to that effect before your new version.

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


[Lldb-commits] [lldb] [lldb] Refactor away UB in SBValue::GetLoadAddress (PR #141799)

2025-05-28 Thread via lldb-commits

jimingham wrote:

It always makes me a little sad to see `.first` or `.second` showing up - they 
are so non-self-documenting.  How horrible would this be if you used a `struct 
AddrAndType { AddressType type; lldb::addr_t address}` (I'm a bit surprised we 
don't have one already) instead so that you would do `GetLoadAddress().address` 
rather than `GetLoadAddress().second`?

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

chelcassanova wrote:

I think this could be ready to land now @DavidSpickett and @JDevlieghere, could 
you give this another once over?

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


[Lldb-commits] [lldb] add explicit default initialization to DemangledNameInfo to remove warning (PR #141790)

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

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

Thanks! LGTM.

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


[Lldb-commits] [lldb] [lldb] Show more children of top level values (PR #140938)

2025-05-28 Thread Dave Lee via lldb-commits

kastiglione wrote:

I've updated the help description for `max-children-count` to reflect how it is 
applied.

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


[Lldb-commits] [lldb] [lldb] Show more children of top level values (PR #140938)

2025-05-28 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/140938

>From f07c408bcbc221e69f56459d0cca27a27ed8551c Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 21 May 2025 09:44:16 -0700
Subject: [PATCH 1/2] [lldb] Show more children of top level values

This changes printing values at the top level (such as variables). The original 
default
value for `target.max-children-count` was 256. The default has since been 
reduced, to
avoid printing too much data (ff127624be).

However, users will naturally have expectations that all (or significantly many)
children are shown for top level values. The following code keeps 256 as the 
max count
for top level values (unless customized). The value of 
`target.max-children-count` will
continue to apply to nested values (depth >= 1).
---
 lldb/include/lldb/Target/Target.h |  2 +-
 lldb/source/API/SBTarget.cpp  |  2 +-
 lldb/source/Core/FormatEntity.cpp |  2 +-
 lldb/source/DataFormatters/FormatManager.cpp  |  2 +-
 .../DataFormatters/ValueObjectPrinter.cpp | 27 ---
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp |  2 +-
 lldb/source/Target/Target.cpp |  9 ---
 7 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 0d4e11b65339e..bcde310378acf 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -186,7 +186,7 @@ class TargetProperties : public Properties {
 
   uint32_t GetMaxZeroPaddingInFloatFormat() const;
 
-  uint32_t GetMaximumNumberOfChildrenToDisplay() const;
+  std::pair GetMaximumNumberOfChildrenToDisplay() const;
 
   /// Get the max depth value, augmented with a bool to indicate whether the
   /// depth is the default.
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..c3e3b6105d56f 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1713,7 +1713,7 @@ uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() 
const {
 
   TargetSP target_sp(GetSP());
   if(target_sp){
- return target_sp->GetMaximumNumberOfChildrenToDisplay();
+return target_sp->GetMaximumNumberOfChildrenToDisplay().first;
   }
   return 0;
 }
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 4f2d39873c7fb..98e5bfe37cd62 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1025,7 +1025,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
 if (index_higher < 0)
   index_higher = valobj->GetNumChildrenIgnoringErrors() - 1;
 
-uint32_t max_num_children =
+auto [max_num_children, _] =
 target->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
 
 bool success = true;
diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index 3b891cecb1c8b..feb69840bc64b 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -458,7 +458,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
&valobj) {
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
-  const size_t max_num_children =
+  const auto [max_num_children, _] =
   (target_sp ? *target_sp : Target::GetGlobalProperties())
   .GetMaximumNumberOfChildrenToDisplay();
   auto num_children = valobj.GetNumChildren(max_num_children);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 5e04a621bbda8..4890aa8f7ee66 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -633,6 +633,27 @@ void ValueObjectPrinter::PrintChild(
   }
 }
 
+static uint32_t determineMaxChildren(bool ignore_cap, uint32_t cur_depth,
+ TargetSP target_sp) {
+  if (ignore_cap)
+return UINT32_MAX;
+
+  const auto [max_num_children, max_is_default] =
+  target_sp->GetMaximumNumberOfChildrenToDisplay();
+
+  // Special handling for printing values at the top level (such as variables).
+  // The original default value for target.max-children-count was 256. The
+  // default has since been reduced, to avoid printing too much data. However,
+  // users will naturally have expectations that all children are shown for top
+  // level values. The following code keeps 256 as the max count for top level
+  // values (unless customized).
+  const uint32_t top_level_max_num_childen = 256;
+  if (cur_depth == 0 && max_is_default)
+return top_level_max_num_childen;
+
+  return max_num_children;
+}
+
 llvm::Expected
 ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) {
   ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
@@ -641,10 +662,8 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint(bool 

[Lldb-commits] [lldb] [lldb-dap] Treat empty thread names as unset (PR #141529)

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

JDevlieghere wrote:

> > (on Windows)?
> 
> That's the hard part 😅. I tried to get 
> https://github.com/llvm/llvm-project/blob/main/lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
>  to run on Windows, but it's too flaky. From my observation, the debug 
> adapter is too fast at launching the program before the test can set the 
> breakpoints. If I understand DAP correctly, then the server can send 
> breakpoint requests after the connection has been initialized, but that 
> doesn't seem to be easily doable in the tests right now[?] as 
> `DAPTestCaseBase.launch` already does an initialization request (and launch 
> request). Ideally, one could set the breakpoints inbetween.

Ack. One solution could be to hand-roll your launch sequence so you can send 
the requests in the order that reproduces the issue. The other alternative is 
to extend the helpers to make them support your use case. Without knowing what 
exactly you need I'm leaning towards the latter as that means everyone can 
benefit from it and if something changes in the launch sequence, we don't need 
to update multiple places. 

> I don't know why, but for some reason, my VS Code sends the launch request 
> before existing breakpoints with lldb-dap, but when using the MSVC debugger 
> from the cpptools (vsdbg), the breakpoints are sent before the launch request 
> (as documented in [launch 
> sequencing](https://microsoft.github.io/debug-adapter-protocol/overview#launch-sequencing)).

The launch sequence is in parallel. Is it possible that the two debug adapter 
implements are handling them in different orders? It took me a while to realize 
this. I found this diagram enlightening: 
https://github.com/microsoft/vscode/issues/4902#issuecomment-368583522

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-28 Thread Dave Lee via lldb-commits

kastiglione wrote:

> If would be really cool if when I'm in a C++ frame and I did:
> 
> `(lldb) help demangle`
>
> I would get a preface like:
>
> Chosen from 'language cplusplus demangle' because the current frame's 
> language is cplusplus.

I plan to do this in a follow up. Note that `help demangle` will show `language 
cplusplus demangle`, but not reason "because the current frame's language is 
cplusplus".

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


[Lldb-commits] [lldb] e653dc9 - [lldb] Fix TestFrameLanguageCommands.py build (#141829)

2025-05-28 Thread via lldb-commits

Author: Dave Lee
Date: 2025-05-28T12:25:49-07:00
New Revision: e653dc9ca00819dc7767dbde4422e96ddc296d03

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

LOG: [lldb] Fix TestFrameLanguageCommands.py build (#141829)

The use of `-lobjc` resulted in this test failing to build on Linux. The
flag is not necessary, this removes the flag with the expectation it
will fix the test on Linux.

Added: 


Modified: 
lldb/test/API/commands/command/language/Makefile

Removed: 




diff  --git a/lldb/test/API/commands/command/language/Makefile 
b/lldb/test/API/commands/command/language/Makefile
index 2d5049417ee70..ce845d59ac035 100644
--- a/lldb/test/API/commands/command/language/Makefile
+++ b/lldb/test/API/commands/command/language/Makefile
@@ -1,4 +1,3 @@
 OBJCXX_SOURCES := main.mm
 CXX_SOURCES := lib.cpp
-LD_EXTRAS := -lobjc
 include Makefile.rules



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


[Lldb-commits] [lldb] [lldb] Fix TestFrameLanguageCommands.py build (PR #141829)

2025-05-28 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix TestFrameLanguageCommands.py build (PR #141829)

2025-05-28 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix TestFrameLanguageCommands.py build (PR #141829)

2025-05-28 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/141829

None

>From f46ad6b01c84dce72cf1547acd2a877f4a8b1dbe Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 28 May 2025 12:24:16 -0700
Subject: [PATCH] [lldb] Fix TestFrameLanguageCommands.py build

---
 lldb/test/API/commands/command/language/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/test/API/commands/command/language/Makefile 
b/lldb/test/API/commands/command/language/Makefile
index 2d5049417ee70..ce845d59ac035 100644
--- a/lldb/test/API/commands/command/language/Makefile
+++ b/lldb/test/API/commands/command/language/Makefile
@@ -1,4 +1,3 @@
 OBJCXX_SOURCES := main.mm
 CXX_SOURCES := lib.cpp
-LD_EXTRAS := -lobjc
 include Makefile.rules

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


[Lldb-commits] [lldb] [lldb] Fix TestFrameLanguageCommands.py build (PR #141829)

2025-05-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes



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


1 Files Affected:

- (modified) lldb/test/API/commands/command/language/Makefile (-1) 


``diff
diff --git a/lldb/test/API/commands/command/language/Makefile 
b/lldb/test/API/commands/command/language/Makefile
index 2d5049417ee70..ce845d59ac035 100644
--- a/lldb/test/API/commands/command/language/Makefile
+++ b/lldb/test/API/commands/command/language/Makefile
@@ -1,4 +1,3 @@
 OBJCXX_SOURCES := main.mm
 CXX_SOURCES := lib.cpp
-LD_EXTRAS := -lobjc
 include Makefile.rules

``




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


[Lldb-commits] [lldb] [lldb] Fix TestFrameLanguageCommands.py build (PR #141829)

2025-05-28 Thread Dave Lee via lldb-commits

kastiglione wrote:

See https://github.com/llvm/llvm-project/pull/136766

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


[Lldb-commits] [lldb] [lldb][Expression] Remove m_found_function_with_type_info in favour of boolean return (PR #141774)

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

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

:+1:

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


[Lldb-commits] [lldb] [lldb][Expression] Remove m_found_function_with_type_info in favour of boolean return (PR #141774)

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

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


[Lldb-commits] [lldb] [lldb][test] Add stack frame padding to fix flaky DIL array subscript test (PR #141738)

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


@@ -19,8 +19,6 @@ def expect_var_path(self, expr, compare_to_framevar=False, 
value=None, type=None
 self.runCmd("settings set target.experimental.use-DIL true")
 self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
 
-# int_arr[100] sometimes points to above the stack region, fix coming soon.

DavidSpickett wrote:

Oh but the long comments are the most fun :)

I agree though, I'll find a smaller out of bounds that is consistently within 
the stack.

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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

2025-05-28 Thread via lldb-commits

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

>From af77293d36a6eeec3d06ded70ebdc2dcc5e97873 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Wed, 21 May 2025 17:32:48 +0200
Subject: [PATCH] [LLDB] Avoid crashes when inspecting MS STL types

---
 .../Language/CPlusPlus/GenericOptional.cpp|  7 ++-
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp  |  3 +
 .../Shell/Process/Windows/msstl_smoke.cpp | 56 +++
 lldb/test/Shell/helper/build.py   |  6 +-
 4 files changed, 66 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/Shell/Process/Windows/msstl_smoke.cpp

diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
index b1fdc0fe37763..c041f39022d10 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
@@ -74,9 +74,10 @@ lldb::ChildCacheState GenericOptionalFrontend::Update() {
 
   if (m_stdlib == StdLib::LibCxx)
 engaged_sp = m_backend.GetChildMemberWithName("__engaged_");
-  else if (m_stdlib == StdLib::LibStdcpp)
-engaged_sp = m_backend.GetChildMemberWithName("_M_payload")
- ->GetChildMemberWithName("_M_engaged");
+  else if (m_stdlib == StdLib::LibStdcpp) {
+if (ValueObjectSP payload = m_backend.GetChildMemberWithName("_M_payload"))
+  engaged_sp = payload->GetChildMemberWithName("_M_engaged");
+  }
 
   if (!engaged_sp)
 return lldb::ChildCacheState::eRefetch;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 02113baf64b8c..08cfcd4a26b8e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -379,6 +379,9 @@ LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() 
{
 
 lldb::ValueObjectSP
 LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
+  if (!m_ptr_obj)
+return nullptr;
+
   if (idx == 0)
 return m_ptr_obj->GetSP();
   if (idx == 1) {
diff --git a/lldb/test/Shell/Process/Windows/msstl_smoke.cpp 
b/lldb/test/Shell/Process/Windows/msstl_smoke.cpp
new file mode 100644
index 0..1dcb9c0093b10
--- /dev/null
+++ b/lldb/test/Shell/Process/Windows/msstl_smoke.cpp
@@ -0,0 +1,56 @@
+// This smoke test ensures that LLDB doesn't crash when formatting types from 
MSVC's STL.
+// FIXME: LLDB currently has no built-in formatters for MSVC's STL (#24834)
+
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl -o %t.exe --std c++20 -- %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "b main" -o "run" 
-o "fr v" -o c | FileCheck %s
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int main() {
+  std::shared_ptr foo;
+  std::weak_ptr weak = foo;
+  std::unique_ptr unique(new int(42));
+  std::optional opt;
+  std::string str = "str";
+  std::string longStr = "string that is long enough such that no SSO can 
happen";
+  std::wstring wStr = L"wstr";
+  std::wstring longWStr = L"string that is long enough such that no SSO can 
happen";
+  std::tuple tuple{1, false, 4.2};
+  std::coroutine_handle<> coroHandle;
+  std::bitset<16> bitset(123);
+
+  std::map map{{1, 2}, {2, 4}, {3, 6}, {4, 8}, {5, 10}};
+  auto mapIt = map.find(3);
+  auto mapItEnd = map.find(9);
+  std::set set{1, 2, 3};
+  std::multimap mMap{{1, 2}, {1, 1}, {2, 4}};
+  std::multiset mSet{1, 2, 3};
+
+  std::variant variant;
+  std::list list{1, 2, 3};
+  std::forward_list fwList{1, 2, 3};
+
+  std::unordered_map uMap{{1, 2}, {2, 4}, {3, 6}};
+  std::unordered_set uSet{1, 2, 4};
+  std::unordered_multimap uMMap{{1, 2}, {1, 1}, {2, 4}};
+  std::unordered_multiset uMSet{1, 1, 2};
+  std::deque deque{1, 2, 3};
+  std::vector vec{1, 2, 3};
+}
+
+// CHECK: Process {{.*}} exited with status = 0 (0x)
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index b2b8146e88c75..caaa14f90af1c 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -683,14 +683,14 @@ def _get_compilation_command(self, source, obj):
 args.append("-fms-compatibility-version=19")
 args.append("/c")
 
+if self.std:
+args.append("/std:" + self.std)
+
 args.append("/Fo" + obj)
 if self.toolchain_type == "clang-cl":
 args.append("--")
 args.append(source)
 
-if self.std:
-args.append("/std:" + self.std)
-
 return ("compiling", [source], obj, self.compile_env, args)
 
 def _get_link_command(self):

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


[Lldb-commits] [lldb] [LLDB] Pass `/std:...` before `--` on MSVC (PR #141782)

2025-05-28 Thread via lldb-commits

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

>From https://github.com/llvm/llvm-project/pull/140761. `MsvcBuilder` passed 
>`/std:` (if specified) after `--`, so the compiler would interpret this 
>as a file. This moves the argument before the `--`.

>From e14af7d191e1983df5a821a98a19e2dc0c6e9c48 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Wed, 21 May 2025 17:32:48 +0200
Subject: [PATCH] [LLDB] Pass `/std:...` before `--` on MSVC

---
 lldb/test/Shell/helper/build.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index b2b8146e88c75..caaa14f90af1c 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -683,14 +683,14 @@ def _get_compilation_command(self, source, obj):
 args.append("-fms-compatibility-version=19")
 args.append("/c")
 
+if self.std:
+args.append("/std:" + self.std)
+
 args.append("/Fo" + obj)
 if self.toolchain_type == "clang-cl":
 args.append("--")
 args.append(source)
 
-if self.std:
-args.append("/std:" + self.std)
-
 return ("compiling", [source], obj, self.compile_env, args)
 
 def _get_link_command(self):

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


[Lldb-commits] [lldb] [LLDB] Pass `/std:...` before `--` on MSVC (PR #141782)

2025-05-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)


Changes

>From https://github.com/llvm/llvm-project/pull/140761. `MsvcBuilder` passed 
>`/std:` (if specified) after `--`, so the compiler would 
>interpret this as a file. This moves the argument before the `--`.

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


1 Files Affected:

- (modified) lldb/test/Shell/helper/build.py (+3-3) 


``diff
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index b2b8146e88c75..caaa14f90af1c 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -683,14 +683,14 @@ def _get_compilation_command(self, source, obj):
 args.append("-fms-compatibility-version=19")
 args.append("/c")
 
+if self.std:
+args.append("/std:" + self.std)
+
 args.append("/Fo" + obj)
 if self.toolchain_type == "clang-cl":
 args.append("--")
 args.append(source)
 
-if self.std:
-args.append("/std:" + self.std)
-
 return ("compiling", [source], obj, self.compile_env, args)
 
 def _get_link_command(self):

``




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


[Lldb-commits] [lldb] [LLDB] Avoid crashes when inspecting MSVC STL types (PR #140761)

2025-05-28 Thread via lldb-commits


@@ -683,14 +683,14 @@ def _get_compilation_command(self, source, obj):
 args.append("-fms-compatibility-version=19")
 args.append("/c")
 
+if self.std:

Nerixyz wrote:

Sorry, I should've asked if it's supposed to be a separate PR or commit - 
opened https://github.com/llvm/llvm-project/pull/141782 now.

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


[Lldb-commits] [lldb] [LLDB] Pass `/std:...` before `--` on MSVC (PR #141782)

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

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


https://github.com/llvm/llvm-project/pull/141782
___
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-28 Thread Jonas Devlieghere via lldb-commits

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

>From 2735f5ad08bd6ac5bdf31104af452f6a1abf0920 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 23 May 2025 12:20:52 -0700
Subject: [PATCH 1/2] [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 | 801 ---
 1 file changed, 360 insertions(+), 441 deletions(-)

diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cd8a770a0ec04..2a28a5367b7c1 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 tar

[Lldb-commits] [lldb] add explicit default initialization to DemangledNameInfo to remove warning (PR #141790)

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

JDevlieghere wrote:

The warning in question is `-Wmissing-field-initializers`, which is warning 
that in the unit test not all fields of this struct are explicitly initialized. 
Even if these fields are optional, I think this is the wrong way to address 
this: we should either update the unit tests to initialize those fields by 
adding `{}, {}`, or add a constructor with default arguments.

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

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

>From 40793cd53f94744ee157865b579ff01eb5776f59 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| 61 +++
 lldb/source/API/CMakeLists.txt| 39 
 lldb/test/Shell/Scripts/Inputs/lldb-defines.h |  7 +++
 .../Shell/Scripts/TestVersionFixScript.test   | 11 
 5 files changed, 118 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..4139f8a9c7821 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -290,6 +290,45 @@ else()
   endif()
 endif()
 
+# Stage all headers in the include directory in the build dir.
+file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
+set(lldb_header_staging_dir ${CMAKE_BINARY_DIR}/include/lldb)
+file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
+file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
+list(REMOVE_ITEM root_public_headers ${root_private_headers})
+
+find_program(unifdef_EXECUTABLE unifdef)
+
+foreach(header
+${public_headers}
+${generated_public_headers}
+${root_public_headers})
+  get_filename_component(basename ${header} NAME)
+  set(staged_header ${lldb_header_staging_dir}/${basename})
+
+  if(unifdef_EXECUTABLE)
+# unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
+# That means if we successfully remove SWIG code, the build system believes
+# that the command has failed and stops. This is undesirable.
+set(copy_command ${unifdef_EXECUTABLE} -USWIG -o ${staged_header} 
${header} || (exit 0))
+  else()
+set(copy_command ${CMAKE_COMMAND} -E copy ${header} ${staged_header})
+  endif()
+
+  add_custom_command(
+DEPENDS ${header} OUTPUT ${staged_header}

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

2025-05-28 Thread via lldb-commits

Author: Zequan Wu
Date: 2025-05-28T16:04:24-04:00
New Revision: 02916a432ca6465e2e45f67be94f1c89c9cd425d

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

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

Currently, the type `T`'s summary formatter will be matched for `T`,
`T*`, `T**` and so on. This is unexpected in many data formatters. Such
unhandled cases could cause the data formatter to crash. An example
would be the lldb's built-in data formatter for `std::optional`:
```
$ cat main.cpp
#include 

int main() {
  std::optional o_null;
  auto po_null = &o_null;
  auto ppo_null = &po_null;
  auto pppo_null = &ppo_null;
  return 0;
}
$ clang++ -g main.cpp && lldb -o "b 8" -o "r" -o "v pppo_null"
[lldb crash]
```

This change adds an options `--pointer-match-depth` to `type summary
add` command to allow users to specify how many layer of pointers can be
dereferenced at most when matching a summary formatter of type `T`, as
Jim suggested
[here](https://github.com/llvm/llvm-project/pull/124048/#issuecomment-2611164133).
By default, this option has value 1 which means summary formatter for
`T` could also be used for `T*` but not `T**` nor beyond. This option is
no-op when `--skip-pointers` is set as well.

I didn't add such option for `type synthetic add`, `type format add`,
`type filter add`, because it useful for those command. Instead, they
all have the pointer match depth of 1. When printing a type `T*`, lldb
never print the children of `T` even if there is a synthetic formatter
registered for `T`.

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/TestDataFormatterPtrMatching.py

lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp

Modified: 
lldb/docs/use/variable.rst
lldb/include/lldb/API/SBTypeSummary.h
lldb/include/lldb/DataFormatters/FormatClasses.h
lldb/include/lldb/DataFormatters/FormatManager.h
lldb/include/lldb/DataFormatters/FormattersContainer.h
lldb/include/lldb/DataFormatters/TypeFormat.h
lldb/include/lldb/DataFormatters/TypeSummary.h
lldb/include/lldb/DataFormatters/TypeSynthetic.h
lldb/source/API/SBTypeSummary.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Commands/Options.td
lldb/source/DataFormatters/FormatManager.cpp
lldb/source/DataFormatters/TypeCategoryMap.cpp
lldb/source/DataFormatters/TypeSummary.cpp

Removed: 




diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index c9bf76b0d4964..212e5c5f8a140 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -366,6 +366,20 @@ The command to obtain the output shown in the example is:
 Initially, we will focus on summary strings, and then describe the Python
 binding mechanism.
 
+Summary Format Matching On Pointers
+--
+
+A summary formatter for a type ``T`` might or might not be appropriate to use
+for pointers to that type. If the formatter is only appropriate for the type 
and
+not its pointers, use the ``-p`` option to restrict it to match SBValues of 
type
+``T``. If you want the formatter to also match pointers to the type, you can 
use
+the ``-d`` option to specify how many pointer layers the formatter should 
match.
+The default value is 1, so if you don't specify ``-p`` or ``-d``, your 
formatter
+will be used on SBValues of type ``T`` and ``T*``. If you want to also match
+``T**`` set ``-d`` to 2, etc. In all cases, the SBValue passed to the summary
+formatter will be the matched ValueObject. lldb doesn't dereference the matched
+value down to the SBValue of type ``T`` before passing it to your formatter.
+
 Summary Strings
 ---
 

diff  --git a/lldb/include/lldb/API/SBTypeSummary.h 
b/lldb/include/lldb/API/SBTypeSummary.h
index 40fa146b4e31b..b6869e53a39e7 100644
--- a/lldb/include/lldb/API/SBTypeSummary.h
+++ b/lldb/include/lldb/API/SBTypeSummary.h
@@ -109,6 +109,10 @@ class SBTypeSummary {
 
   void SetFunctionCode(const char *data);
 
+  uint32_t GetPtrMatchDepth();
+
+  void SetPtrMatchDepth(uint32_t ptr_match_depth);
+
   uint32_t GetOptions();
 
   void SetOptions(uint32_t);

diff  --git a/lldb/include/lldb/DataFormatters/FormatClasses.h 
b/lldb/include/lldb/DataFormatters/FormatClasses.h
index a6bc3a3542536..89d74649ecc64 100644
--- a/lldb/include/lldb/DataFormatters/FormatClasses.h
+++ b/lldb/include/lldb/DataFormatters/FormatClasses.h
@@ -76,9 +76,10 @@ class FormattersMatchCandidate {
 
   FormattersMatchCandidate(ConstString name,
ScriptInterpreter *script_interpreter, TypeImpl 
type,
-   Flags flags)
+

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

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

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


[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)

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

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


[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)

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

ZequanWu wrote:

Closed this as #138209 is preferred.

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


[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/141426

>From 79a0a7b83360a517b090dad297ccb5a5a7849d0f Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Wed, 21 May 2025 23:39:56 +0200
Subject: [PATCH 1/4] Reuse creation of Source objects for assembly and normal
 sources

---
 lldb/tools/lldb-dap/Breakpoint.cpp|  14 +-
 .../Handler/DisassembleRequestHandler.cpp |  21 +--
 .../Handler/LocationsRequestHandler.cpp   |  10 +-
 .../Handler/StackTraceRequestHandler.cpp  |   6 +-
 lldb/tools/lldb-dap/JSONUtils.cpp | 123 +-
 lldb/tools/lldb-dap/JSONUtils.h   |  49 ++-
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |   2 +
 7 files changed, 100 insertions(+), 125 deletions(-)

diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
index 2d0fd9c9c3954..440d589b912fc 100644
--- a/lldb/tools/lldb-dap/Breakpoint.cpp
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -9,12 +9,10 @@
 #include "Breakpoint.h"
 #include "DAP.h"
 #include "JSONUtils.h"
-#include "LLDBUtils.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBLineEntry.h"
 #include "lldb/API/SBMutex.h"
-#include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringExtras.h"
 #include 
 #include 
@@ -66,17 +64,15 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
 "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget()));
 breakpoint.instructionReference = formatted_addr;
 
-lldb::StopDisassemblyType stop_disassembly_display =
-GetStopDisassemblyDisplay(m_dap.debugger);
-auto line_entry = bp_addr.GetLineEntry();
-if (!ShouldDisplayAssemblySource(line_entry, stop_disassembly_display)) {
+auto source = CreateSource(bp_addr, m_dap.debugger);
+if (!source.IsAssemblySource()) {
+  auto line_entry = bp_addr.GetLineEntry();
   const auto line = line_entry.GetLine();
   if (line != LLDB_INVALID_LINE_NUMBER)
 breakpoint.line = line;
   const auto column = line_entry.GetColumn();
   if (column != LLDB_INVALID_COLUMN_NUMBER)
 breakpoint.column = column;
-  breakpoint.source = CreateSource(line_entry);
 } else {
   // Assembly breakpoint.
   auto symbol = bp_addr.GetSymbol();
@@ -86,10 +82,10 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
 .ReadInstructions(symbol.GetStartAddress(), bp_addr, nullptr)
 .GetSize() +
 1;
-
-breakpoint.source = CreateAssemblySource(m_dap.target, bp_addr);
   }
 }
+
+breakpoint.source = std::move(source);
   }
 
   return breakpoint;
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 1d110eac18126..49e7c788a7fb3 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -13,6 +13,7 @@
 #include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/lldb-types.h"
@@ -81,12 +82,15 @@ static lldb::SBAddress 
GetDisassembleStartAddress(lldb::SBTarget target,
   .GetAddress();
 }
 
-static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
-lldb::SBTarget &target, lldb::SBInstruction &inst, bool resolve_symbols) {
+static DisassembledInstruction
+ConvertSBInstructionToDisassembledInstruction(lldb::SBDebugger &debugger,
+  lldb::SBInstruction &inst,
+  bool resolve_symbols) {
   if (!inst.IsValid())
 return GetInvalidInstruction();
 
-  auto addr = inst.GetAddress();
+  lldb::SBTarget target = debugger.GetSelectedTarget();
+  lldb::SBAddress addr = inst.GetAddress();
   const auto inst_addr = addr.GetLoadAddress(target);
 
   // FIXME: This is a workaround - this address might come from
@@ -139,15 +143,14 @@ static DisassembledInstruction 
ConvertSBInstructionToDisassembledInstruction(
 
   disassembled_inst.instruction = std::move(instruction);
 
+  auto source = CreateSource(addr, debugger);
   auto line_entry = addr.GetLineEntry();
-  // If the line number is 0 then the entry represents a compiler generated
-  // location.
 
-  if (line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
+  if (!source.IsAssemblySource() && line_entry.IsValid() &&
+  line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
   line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0) {
-auto source = CreateSource(line_entry);
-disassembled_inst.location = std::move(source);
 
+disassembled_inst.location = std::move(source);
 const auto line = line_entry.GetLine();
 if (line != 0 && line != LLDB_INVALID_LINE_NUMBER)
   disassembled

[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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


@@ -58,6 +59,9 @@ class LLDB_API SBAddress {
   // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
   lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
 
+  lldb::SBSymbolContext GetSymbolContext(const SBTarget &target,
+ uint32_t resolve_scope);

eronnen wrote:

Added a small comment

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


[Lldb-commits] [lldb] add explicit default initialization to DemangledNameInfo to remove warning (PR #141790)

2025-05-28 Thread Charles Zablit via lldb-commits

charles-zablit wrote:

Please feel free to merge when possible, as I do not have commit access yet.

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


[Lldb-commits] [lldb] 711a177 - add explicit default initialization to DemangledNameInfo to remove warning (#141790)

2025-05-28 Thread via lldb-commits

Author: Charles Zablit
Date: 2025-05-28T21:41:45+01:00
New Revision: 711a1779dcb4ed5616d5727d990b642a3593855f

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

LOG: add explicit default initialization to DemangledNameInfo to remove warning 
(#141790)

https://github.com/llvm/llvm-project/pull/140762 introduces some
compilation warnings in `lldb/unittests/Core/MangledTest.cpp`. This
patch adds explicit default initialization to `DemangledNameInfo` to
suppress those warnings.

We only had the default initialization values to `PrefixRange` and
`SuffixRange` because they are the only _optional_ fields of the
structure.

Added: 


Modified: 
lldb/unittests/Core/MangledTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/MangledTest.cpp 
b/lldb/unittests/Core/MangledTest.cpp
index 44651eb94c23b..ff8ae1b2f3a47 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -414,110 +414,112 @@ DemanglingPartsTestCase g_demangling_parts_test_cases[] 
= {
 // clang-format off
{ 
"_ZNVKO3BarIN2ns3QuxIiEEE1CIPFi3FooIS_IiES6_EEE6methodIS6_EENS5_IT_SC_E5InnerIiEESD_SD_",
  { /*.BasenameRange=*/{92, 98}, /*.ScopeRange=*/{36, 92}, 
/*.ArgumentsRange=*/{ 108, 158 },
-   /*.QualifiersRange=*/{158, 176} },
+   /*.QualifiersRange=*/{158, 176}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"method",
  /*.scope=*/"Bar>::C, Bar>)>::",
  /*.qualifiers=*/" const volatile &&"
},
{ "_Z7getFuncIfEPFiiiET_",
- { /*.BasenameRange=*/{6, 13}, /*.ScopeRange=*/{6, 6}, 
/*.ArgumentsRange=*/{ 20, 27 }, /*.QualifiersRange=*/{38, 38} },
+ { /*.BasenameRange=*/{6, 13}, /*.ScopeRange=*/{6, 6}, 
/*.ArgumentsRange=*/{ 20, 27 },
+   /*.QualifiersRange=*/{38, 38}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"getFunc",
  /*.scope=*/"",
  /*.qualifiers=*/""
},
{ "_ZN1f1b1c1gEv",
  { /*.BasenameRange=*/{9, 10}, /*.ScopeRange=*/{0, 9}, 
/*.ArgumentsRange=*/{ 10, 12 },
-   /*.QualifiersRange=*/{12, 12} },
+   /*.QualifiersRange=*/{12, 12}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"g",
  /*.scope=*/"f::b::c::",
  /*.qualifiers=*/""
},
{ "_ZN5test73fD1IiEEDTcmtlNS_1DEL_ZNS_1bEEEcvT__EES2_",
  { /*.BasenameRange=*/{45, 48}, /*.ScopeRange=*/{38, 45}, 
/*.ArgumentsRange=*/{ 53, 58 },
-   /*.QualifiersRange=*/{58, 58} },
+   /*.QualifiersRange=*/{58, 58}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"fD1",
  /*.scope=*/"test7::",
  /*.qualifiers=*/""
},
{ "_ZN5test73fD1IiEEDTcmtlNS_1DEL_ZNS_1bINDT1cE1dEcvT__EES2_",
  { /*.BasenameRange=*/{61, 64}, /*.ScopeRange=*/{54, 61}, 
/*.ArgumentsRange=*/{ 69, 79 },
-   /*.QualifiersRange=*/{79, 79} },
+   /*.QualifiersRange=*/{79, 79}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"fD1",
  /*.scope=*/"test7::",
  /*.qualifiers=*/""
},
{ 
"_ZN5test7INDT1cE1dINDT1cE1d3fD1INDT1cE1dINDT1cE1dEDTcmtlNS_1DEL_ZNS_1bINDT1cE1dEcvT__EES2_",
  { /*.BasenameRange=*/{120, 123}, /*.ScopeRange=*/{81, 120}, 
/*.ArgumentsRange=*/{ 155, 168 },
-   /*.QualifiersRange=*/{168, 168} },
+   /*.QualifiersRange=*/{168, 168}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"fD1",
  /*.scope=*/"test7>::",
  /*.qualifiers=*/""
},
{ 
"_ZN8nlohmann16json_abi_v3_11_310basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcbxydS8_NS0_14adl_serializerENS4_IhNS8_IhvE5parseIRA29_KcEESE_OT_NS2_8functionIFbiNS0_6detail13parse_event_tERSE_EEEbb",
  { /*.BasenameRange=*/{687, 692}, /*.ScopeRange=*/{343, 687}, 
/*.ArgumentsRange=*/{ 713, 1174 },
-   /*.QualifiersRange=*/{1174, 1174} },
+   /*.QualifiersRange=*/{1174, 1174}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"parse",
  /*.scope=*/"nlohmann::json_abi_v3_11_3::basic_json, 
std::__1::allocator>, bool, long long, unsigned long long, double, 
std::__1::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, 
std::__1::vector>, void>::",
  /*.qualifiers=*/""
},
{ 
"_ZN8nlohmann16json_abi_v3_11_310basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcbxydS8_NS0_14adl_serializerENS4_IhNS8_IhvEC1EDn",
  { /*.BasenameRange=*/{344, 354}, /*.ScopeRange=*/{0, 344}, 
/*.ArgumentsRange=*/{ 354, 370 },
-   /*.QualifiersRange=*/{370, 370} },
+   /*.QualifiersRange=*/{370, 370}, /*.PrefixRange=*/{0, 0}, 
/*.SuffixRange=*/{0, 0} },
  /*.basename=*/"basic_json",
  /*.scope=*/"nlohmann::json_abi_v3_11_3::basic_json, 
std::__1::allocator>, bo

[Lldb-commits] [lldb] add explicit default initialization to DemangledNameInfo to remove warning (PR #141790)

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

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


[Lldb-commits] [lldb] [lldb-dap] Test Gardening, improving DebugCommunication. (PR #141689)

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

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

>From ad0a9cd321d260cd87b852b335da9565f8326449 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 27 May 2025 16:40:10 -0700
Subject: [PATCH 1/2] [lldb-dap] Test Gardening, improving DebugCommunication.

Improving the readability and correctness of DebugCommunication by adding type 
annotations to many parts of the library and trying to improve the 
implementation of a few key areas of the code to better handle correctness.

Specifically, this refactored the `DebugCommunication._handle_recv_packet` 
function to ensure consistency with the reader thread when handling state 
changes and improved the `DebugCommunication._recv_packet` helper to make it 
easier to follow by adding some additional helpers.
---
 .../test/tools/lldb-dap/dap_server.py | 557 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  16 +-
 .../tools/lldb-dap/cancel/TestDAP_cancel.py   |  27 +-
 3 files changed, 340 insertions(+), 260 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a028381a0a4f9..cc235f4fe8b1a 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -12,13 +12,52 @@
 import sys
 import threading
 import time
-from typing import Any, Optional, Union, BinaryIO, TextIO
+from typing import (
+Any,
+Optional,
+Union,
+BinaryIO,
+TextIO,
+TypedDict,
+Literal,
+Callable,
+TypeVar,
+)
 
 ## DAP type references
-Event = dict[str, Any]
-Request = dict[str, Any]
-Response = dict[str, Any]
+
+
+class Event(TypedDict):
+type: Literal["event"]
+seq: Literal[0]
+event: str
+body: Optional[dict]
+
+
+class Request(TypedDict):
+type: Literal["request"]
+seq: int
+command: str
+arguments: Optional[dict]
+
+
+class Response(TypedDict):
+type: Literal["response"]
+seq: Literal[0]
+request_seq: int
+success: bool
+command: str
+message: Optional[str]
+body: Optional[dict]
+
+
+_T = TypeVar("_T")
 ProtocolMessage = Union[Event, Request, Response]
+# An internal type used for tracking protocol messages and an EOF sentinel
+# value. 'None' cannot easily be used as a sentinel because it is a falsey
+# value. When returned outside of DebugCommunication an EOFError is typically
+# converted into 'None'.
+_InternalProtocolMessage = Union[Event, Request, Response, EOFError]
 
 
 def dump_memory(base_addr, data, num_per_line, outfile):
@@ -58,44 +97,42 @@ def dump_memory(base_addr, data, num_per_line, outfile):
 outfile.write("\n")
 
 
-def read_packet(f, verbose=False, trace_file=None):
+def read_packet(
+f: BinaryIO, verbose=False, trace_file=None
+) -> _InternalProtocolMessage:
 """Decode a JSON packet that starts with the content length and is
 followed by the JSON bytes from a file 'f'. Returns None on EOF.
 """
-line = f.readline().decode("utf-8")
+line = f.readline().decode()
 if len(line) == 0:
-return None  # EOF.
+return EOFError()  # EOF.
 
 # Watch for line that starts with the prefix
 prefix = "Content-Length: "
 if line.startswith(prefix):
 # Decode length of JSON bytes
 if verbose:
-print('content: "%s"' % (line))
+print("content:", line)
 length = int(line[len(prefix) :])
 if verbose:
-print('length: "%u"' % (length))
+print("length:", length)
 # Skip empty line
-line = f.readline()
+line = f.readline().decode()
 if verbose:
-print('empty: "%s"' % (line))
+print("empty:", line)
 # Read JSON bytes
-json_str = f.read(length)
+json_str = f.read(length).decode()
 if verbose:
-print('json: "%s"' % (json_str))
+print("json:", json_str)
 if trace_file:
-trace_file.write("from adapter:\n%s\n" % (json_str))
+trace_file.write(f"from adapter:\n{json_str}\n")
 # Decode the JSON bytes into a python dictionary
 return json.loads(json_str)
 
 raise Exception("unexpected malformed message from lldb-dap: " + line)
 
 
-def packet_type_is(packet, packet_type):
-return "type" in packet and packet["type"] == packet_type
-
-
-def dump_dap_log(log_file):
+def dump_dap_log(log_file: str):
 print("= DEBUG ADAPTER PROTOCOL LOGS =", file=sys.stderr)
 if log_file is None:
 print("no log file available", file=sys.stderr)
@@ -124,8 +161,8 @@ def __init__(
 def __str__(self):
 return f"Source(name={self.name}, path={self.path}), 
source_reference={self.source_reference})"
 
-def as_dict(self):
-source_dict = {}
+def as_dict(self) -> dict:
+source_dict: dict[str, Any] = {}

[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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


@@ -58,6 +59,9 @@ class LLDB_API SBAddress {
   // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
   lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
 
+  lldb::SBSymbolContext GetSymbolContext(const SBTarget &target,
+ uint32_t resolve_scope);

ashgti wrote:

Does the `SBTarget::ResolveSymbolContextForAddress()` 
https://github.com/llvm/llvm-project/blob/711a1779dcb4ed5616d5727d990b642a3593855f/lldb/include/lldb/API/SBTarget.h#L587-L588
 apply source-maps correctly?

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


[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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




ashgti wrote:

nit: Should this live in the lldb-dap top level folder? I could go either way 
on that, but it matches the existing helpers.

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


[Lldb-commits] [lldb] [lldb-dap] Test Gardening, improving DebugCommunication. (PR #141689)

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


@@ -104,6 +103,17 @@ def waitUntil(self, condition_callback):
 time.sleep(0.5)
 return False
 
+def assertResponseSuccess(self, response: Response):
+self.assertIsNotNone(response)
+if not response.get("success", False):

ashgti wrote:

Done.

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


  1   2   >