[Lldb-commits] [lldb] [lldb] Fix block address resolution for functions in multiple sections (PR #137955)

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

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



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Fix block address resolution for functions in multiple sections (PR #137955)

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


@@ -283,39 +283,42 @@ uint32_t Block::GetRangeIndexContainingAddress(const 
Address &addr) {
   return m_ranges.FindEntryIndexThatContains(file_addr - func_file_addr);
 }
 
+static AddressRange ToAddressRange(const Address &func_addr,
+   const Block::Range &range) {
+  assert(func_addr.GetModule());
+  return AddressRange(func_addr.GetFileAddress() + range.base, range.size,

labath wrote:

It is. I've added it to the header to make it more visible.

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


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

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

labath wrote:

I'm not intimately familiar with this code, but I am somewhat suspicious of 
implementation.

Adding the number of base classes to the result makes sense to me. What 
surprises me is that this should be done only for fields with anonymous types. 
Can you explain why should the index of a field depend on whether its type is 
anonymous or not?

I am also surprised by the hardcoding of `omit_empty_base_classes` to true in 
the `GetNumBaseClasses` call. All of the other calls in this function pass the 
value from the argument. Why should this one be special?

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


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-05 Thread via lldb-commits

cmtice wrote:

> I'm not intimately familiar with this code, but I am somewhat suspicious of 
> implementation.
> 
> Adding the number of base classes to the result makes sense to me. What 
> surprises me is that this should be done only for fields with anonymous 
> types. Can you explain why should the index of a field depend on whether its 
> type is anonymous or not?

I knew that I needed to add it for anonymous structs; I wasn't sure about other 
cases. I've tested it more now, and it seems good to add it in all cases, so I 
will do that.
> 
> I am also surprised by the hardcoding of `omit_empty_base_classes` to true in 
> the `GetNumBaseClasses` call. All of the other calls in this function pass 
> the value from the argument. Why should this one be special?

I knew that in the case of anonymous structs we did not want to count empty 
base classes; since this line was for anonymous structs, I hard-coded it to 
make sure.  Now that I've updated the code to always add the number of base 
classes, I'm removing that hard-coding.



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


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

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

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

This looks good now. Thanks. I'm surprised that something like `derb.x` doesn't 
work -- both for "frame var" and in C++. You're not changing that, so it bears 
no relation to this patch, but overall, but overall, I think it wouldn't be 
*un*reasonable to make these kinds of expressions work in "frame var".

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


[Lldb-commits] [lldb] [LLDB] Fix GetIndexOfChildMemberWithName to handle anonymous structs. (PR #138487)

2025-05-05 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/138487

>From 780371cf111c97e2bce5f030625ff557bb2f40b6 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 4 May 2025 23:43:28 -0700
Subject: [PATCH 1/2] [LLDB] Fix GetIndexOfChildMemberWithName to handle
 anonymous structs.

When handling anonymous structs, GetIndexOfChildMemberWithName needs
to add the number of non-empty base classes to the child index, to get
the actual correct index. It was not doing so. This fixes that.
---
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  9 -
 .../lang/cpp/type_lookup_anon_struct/Makefile |  3 ++
 .../TestCppTypeLookupAnonStruct.py| 27 +++
 .../lang/cpp/type_lookup_anon_struct/main.cpp | 33 +++
 4 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
 create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a2b3d4133e51..dd8d144510056 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6743,7 +6743,14 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
 std::vector save_indices = child_indexes;
-child_indexes.push_back(child_idx);
+if (field_type.IsAnonymousType())
+  // We have to add on the number of non-empty base classes to this
+  // index!
+  child_indexes.push_back(
+  child_idx +
+  TypeSystemClang::GetNumBaseClasses(cxx_record_decl, true));
+else
+  child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_anon_struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
new file mode 100644
index 0..2295ecfe81ff7
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/TestCppTypeLookupAnonStruct.py
@@ -0,0 +1,27 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+
+class TestTypeLookupAnonStruct(TestBase):
+def test_lookup_anon_struct(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, '// Set breakpoint here', lldb.SBFileSpec('main.cpp')
+)
+
+self.expect_var_path('unnamed_derived.y', value='2')
+self.expect_var_path('unnamed_derived.z', value='13')
+self.expect('frame variable "derb.x"', error=True,
+substrs=['"x" is not a member of "(DerivedB) derb"'])
+self.expect('frame variable "derb.y"', error=True,
+substrs=['"y" is not a member of "(DerivedB) derb"'])
+self.expect_var_path('derb.w', value='14')
+self.expect_var_path('derb.k', value='15')
+self.expect_var_path('derb.a.x', value='1')
+self.expect_var_path('derb.a.y', value='2')
diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp 
b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
new file mode 100644
index 0..18dd997ea9563
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_anon_struct/main.cpp
@@ -0,0 +1,33 @@
+int main(int argc, char** argv) {
+  struct A {
+struct {
+  int x = 1;
+};
+int y = 2;
+  } a;
+
+   struct B {
+// Anonymous struct inherits another struct.
+struct : public A {
+  int z = 3;
+};
+int w = 4;
+A a;
+  } b;
+
+   struct : public A {
+ struct {
+   int z = 13;
+ };
+   } unnamed_derived;
+
+   struct DerivedB : public B {
+ struct {
+   // `w` in anonymous struct overrides `w` from `B`.
+   int w = 14;
+   int k = 15;
+ };
+   } derb;
+
+   return 0; // Set breakpoint here
+}

>From 81870ff46edc647695720d5635e700e77c7ca620 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Mon, 5 May 2025 21:45:50 -0700
Subject: [PATCH 2/2] Update to always add the number of base classes (not just
 for anonymous structs). Remove hard

[Lldb-commits] [lldb] [LLDB] Add IsCoreDumping to ProcessInstanceInfo (PR #138580)

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

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


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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

2025-05-05 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd updated 
https://github.com/llvm/llvm-project/pull/135843

>From 7cca4bf228ab2b882a1a6487eb24948cba9e5b12 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 16 Apr 2025 00:30:51 +0500
Subject: [PATCH 1/5] [lldb][TypeSystemClang] Add a function
 `IsValidDereferenceType` to TypeSystem to allow arrays to be dereferenced in
 C/C++.

---
 lldb/include/lldb/Symbol/CompilerType.h  | 2 ++
 lldb/include/lldb/Symbol/TypeSystem.h| 2 ++
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 9 +
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h   | 2 ++
 lldb/source/Symbol/CompilerType.cpp  | 7 +++
 lldb/source/ValueObject/ValueObject.cpp  | 7 ---
 6 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index fdbc2057ac10f..3d726fca5a16c 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -186,6 +186,8 @@ class CompilerType {
   bool IsReferenceType(CompilerType *pointee_type = nullptr,
bool *is_rvalue = nullptr) const;
 
+  bool IsValidDereferenceType() const;
+
   bool ShouldTreatScalarValueAsAddress() const;
 
   bool IsScalarType() const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index df87fea32b72a..753352b45e2d9 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -489,6 +489,8 @@ class TypeSystem : public PluginInterface,
   virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type, bool *is_rvalue) = 
0;
 
+  virtual bool IsValidDereferenceType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool
   ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
 return IsPointerOrReferenceType(type, nullptr);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cb0ecd6ebd406..4165e08a63302 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3443,6 +3443,13 @@ bool 
TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
   return false;
 }
 
+bool TypeSystemClang::IsValidDereferenceType(
+lldb::opaque_compiler_type_t type) {
+  CompilerType compiler_type = 
GetType(clang::QualType::getFromOpaquePtr(type));
+  return compiler_type.IsPointerOrReferenceType() ||
+ compiler_type.IsArrayType();
+}
+
 bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
   uint32_t &count, bool &is_complex) {
   if (type) {
@@ -6544,6 +6551,8 @@ llvm::Expected 
TypeSystemClang::GetChildCompilerTypeAtIndex(
 return size_or_err.takeError();
   child_byte_size = *size_or_err;
   child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
+  if (idx == 0)
+child_is_deref_of_parent = true;
   return element_type;
 }
   }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 93933846d114d..8924cf99e8f7f 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -716,6 +716,8 @@ class TypeSystemClang : public TypeSystem {
   bool IsReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type, bool *is_rvalue) override;
 
+  bool IsValidDereferenceType(lldb::opaque_compiler_type_t type) override;
+
   bool IsScalarType(lldb::opaque_compiler_type_t type) override;
 
   bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
diff --git a/lldb/source/Symbol/CompilerType.cpp 
b/lldb/source/Symbol/CompilerType.cpp
index 90c4dbf0c6206..183a6aa0ba6d4 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -233,6 +233,13 @@ bool CompilerType::IsReferenceType(CompilerType 
*pointee_type,
   return false;
 }
 
+bool CompilerType::IsValidDereferenceType() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->IsValidDereferenceType(m_type);
+  return false;
+}
+
 bool CompilerType::ShouldTreatScalarValueAsAddress() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index d5e0d462c3759..2c95e27c6e2c9 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2794,8 +2794,9 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   if (m_deref_valobj)
 return m_deref_valobj->GetSP();
 
-  const bool is_pointer_or_reference_type 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

2025-05-05 Thread Ilia Kuklin via lldb-commits


@@ -88,7 +88,7 @@ def cleanup():
 self.expect(
 "frame variable *number_not_engaged",
 error=True,
-substrs=["not a pointer or reference type"],
+substrs=["dereference failed: not a"],

kuilpd wrote:

I had a thought that a message might be different since it comes from 
`TypeSystem`, but now I realize it's C++ test and we know exactly which type 
system.

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


[Lldb-commits] [lldb] [LLDB] Fix `ValueObject::AddressOf()` return value (PR #137688)

2025-05-05 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

@labath 
Is this okay to merge now?

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-05 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/138174



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-05 Thread Rahul Joshi via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-05 Thread David Peixotto via lldb-commits

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

LGTM!

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-05 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/138174

>From 278179a35bacc7c70dd1724e7ef7a41e9cdd999a Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy

Add `llvm::uninitialized_copy` that accepts a range instead of two
iterators for the source of the copy and adopt it.
---
 clang/include/clang/AST/DeclCXX.h |  6 +-
 clang/include/clang/AST/DeclOpenACC.h |  9 +--
 clang/include/clang/AST/ExprCXX.h |  6 +-
 clang/include/clang/AST/OpenACCClause.h   | 72 +++
 clang/include/clang/AST/StmtOpenACC.h | 54 +++---
 clang/include/clang/Sema/ParsedTemplate.h |  4 +-
 clang/lib/AST/Decl.cpp|  6 +-
 clang/lib/AST/DeclObjC.cpp|  4 +-
 clang/lib/AST/DeclTemplate.cpp| 11 ++-
 clang/lib/AST/Expr.cpp|  8 +--
 clang/lib/AST/ExprCXX.cpp | 16 ++---
 clang/lib/AST/OpenACCClause.cpp   | 13 ++--
 clang/lib/AST/StmtOpenACC.cpp |  4 +-
 clang/lib/AST/Type.cpp|  8 +--
 clang/tools/libclang/CXIndexDataConsumer.cpp  |  3 +-
 lldb/source/Utility/Checksum.cpp  |  5 +-
 llvm/include/llvm/ADT/ArrayRef.h  |  2 +-
 llvm/include/llvm/ADT/STLExtras.h |  5 ++
 llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   |  4 +-
 llvm/lib/DebugInfo/MSF/MSFBuilder.cpp |  6 +-
 llvm/lib/IR/AttributeImpl.h   |  2 +-
 llvm/lib/ObjectYAML/MinidumpEmitter.cpp   |  2 +-
 llvm/lib/Support/FoldingSet.cpp   |  4 +-
 llvm/lib/TableGen/Record.cpp  | 23 +++---
 .../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp  |  2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  6 +-
 .../unittests/Support/TrailingObjectsTest.cpp | 19 ++---
 mlir/include/mlir/IR/BuiltinAttributes.td |  2 +-
 mlir/include/mlir/Support/StorageUniquer.h|  4 +-
 .../Dialect/Affine/Analysis/NestedMatcher.cpp |  4 +-
 mlir/lib/IR/AffineMapDetail.h |  3 +-
 mlir/lib/IR/Location.cpp  |  8 +--
 mlir/lib/IR/MLIRContext.cpp   |  2 +-
 mlir/lib/IR/TypeDetail.h  |  3 +-
 mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ---
 37 files changed, 164 insertions(+), 221 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
   InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
   }
 
   void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
   : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
 SC),
 NumBindings(Bindings.size()) {
-std::uninitialized_copy(Bindings.begin(), Bindings.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Bindings, getTrailingObjects());
 for (auto *B : Bindings) {
   B->setDecomposedDecl(this);
   if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h 
b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
   : OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
  StartLoc, DirLoc, EndLoc) {
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
 assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitializ

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-05 Thread Rahul Joshi via lldb-commits

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


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

2025-05-05 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd created 
https://github.com/llvm/llvm-project/pull/138551

None

>From cfe7359bd16c1e87932e2ebb8bcdfc88130e9729 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 30 Apr 2025 22:03:50 +0500
Subject: [PATCH] [LLDB] Add array subscription and integer parsing to DIL

---
 lldb/docs/dil-expr-lang.ebnf  |  12 +-
 lldb/include/lldb/ValueObject/DILAST.h|  46 +
 lldb/include/lldb/ValueObject/DILEval.h   |   6 +
 lldb/include/lldb/ValueObject/DILLexer.h  |   3 +
 lldb/include/lldb/ValueObject/DILParser.h |   3 +
 lldb/source/ValueObject/DILAST.cpp|  10 ++
 lldb/source/ValueObject/DILEval.cpp   | 159 ++
 lldb/source/ValueObject/DILLexer.cpp  |  43 -
 lldb/source/ValueObject/DILParser.cpp |  79 -
 .../var-dil/basics/ArraySubscript/Makefile|   3 +
 .../TestFrameVarDILArraySubscript.py  |  88 ++
 .../var-dil/basics/ArraySubscript/main.cpp|  31 
 lldb/unittests/ValueObject/DILLexerTests.cpp  |  34 +++-
 13 files changed, 506 insertions(+), 11 deletions(-)
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp

diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..0cbb5403785db 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -6,16 +6,20 @@
 expression = unary_expression ;
 
 unary_expression = unary_operator expression
- | primary_expression ;
+ | postfix_expression ;
 
 unary_operator = "*" | "&" ;
 
-primary_expression = id_expression
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]";
+
+primary_expression = numeric_literal
+   | id_expression
| "(" expression ")";
 
 id_expression = unqualified_id
   | qualified_id
- | register ;
+  | register ;
 
 unqualified_id = identifier ;
 
@@ -24,6 +28,8 @@ qualified_id = ["::"] [nested_name_specifier] unqualified_id
 
 identifier = ? C99 Identifier ? ;
 
+numeric_literal = ? C99 Integer constant ? ;
+
 register = "$" ? Register name ? ;
 
 nested_name_specifier = type_name "::"
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..6908deed7aee3 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -18,8 +18,10 @@ namespace lldb_private::dil {
 
 /// The various types DIL AST nodes (used by the DIL parser).
 enum class NodeKind {
+  eArraySubscriptNode,
   eErrorNode,
   eIdentifierNode,
+  eScalarLiteralNode,
   eUnaryOpNode,
 };
 
@@ -71,6 +73,26 @@ class ErrorNode : public ASTNode {
   }
 };
 
+class ScalarLiteralNode : public ASTNode {
+public:
+  ScalarLiteralNode(uint32_t location, lldb::BasicType type, Scalar value)
+  : ASTNode(location, NodeKind::eScalarLiteralNode), m_type(type),
+m_value(value) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  lldb::BasicType GetType() const { return m_type; }
+  Scalar GetValue() const & { return m_value; }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eScalarLiteralNode;
+  }
+
+private:
+  lldb::BasicType m_type;
+  Scalar m_value;
+};
+
 class IdentifierNode : public ASTNode {
 public:
   IdentifierNode(uint32_t location, std::string name)
@@ -108,6 +130,26 @@ class UnaryOpNode : public ASTNode {
   ASTNodeUP m_operand;
 };
 
+class ArraySubscriptNode : public ASTNode {
+public:
+  ArraySubscriptNode(uint32_t location, ASTNodeUP lhs, ASTNodeUP rhs)
+  : ASTNode(location, NodeKind::eArraySubscriptNode), 
m_lhs(std::move(lhs)),
+m_rhs(std::move(rhs)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *lhs() const { return m_lhs.get(); }
+  ASTNode *rhs() const { return m_rhs.get(); }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eArraySubscriptNode;
+  }
+
+private:
+  ASTNodeUP m_lhs;
+  ASTNodeUP m_rhs;
+};
+
 /// This class contains one Visit method for each specialized type of
 /// DIL AST node. The Visit methods are used to dispatch a DIL AST node to
 /// the correct function in the DIL expression evaluator for evaluating that
@@ -116,9 +158,13 @@ class Visitor {
 public:
   virtual ~Visitor() = default;
   virtual llvm::Expected
+  Visit(const ScalarLiteralNode *node) = 0;
+  virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
+  virtual llvm::Expected
+  Visit(const ArraySubscriptNode *node) = 0;
 };
 
 } // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h 

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

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)


Changes



---

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


13 Files Affected:

- (modified) lldb/docs/dil-expr-lang.ebnf (+9-3) 
- (modified) lldb/include/lldb/ValueObject/DILAST.h (+46) 
- (modified) lldb/include/lldb/ValueObject/DILEval.h (+6) 
- (modified) lldb/include/lldb/ValueObject/DILLexer.h (+3) 
- (modified) lldb/include/lldb/ValueObject/DILParser.h (+3) 
- (modified) lldb/source/ValueObject/DILAST.cpp (+10) 
- (modified) lldb/source/ValueObject/DILEval.cpp (+159) 
- (modified) lldb/source/ValueObject/DILLexer.cpp (+40-3) 
- (modified) lldb/source/ValueObject/DILParser.cpp (+78-1) 
- (added) lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/Makefile 
(+3) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 (+88) 
- (added) lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp 
(+31) 
- (modified) lldb/unittests/ValueObject/DILLexerTests.cpp (+30-4) 


``diff
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..0cbb5403785db 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -6,16 +6,20 @@
 expression = unary_expression ;
 
 unary_expression = unary_operator expression
- | primary_expression ;
+ | postfix_expression ;
 
 unary_operator = "*" | "&" ;
 
-primary_expression = id_expression
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]";
+
+primary_expression = numeric_literal
+   | id_expression
| "(" expression ")";
 
 id_expression = unqualified_id
   | qualified_id
- | register ;
+  | register ;
 
 unqualified_id = identifier ;
 
@@ -24,6 +28,8 @@ qualified_id = ["::"] [nested_name_specifier] unqualified_id
 
 identifier = ? C99 Identifier ? ;
 
+numeric_literal = ? C99 Integer constant ? ;
+
 register = "$" ? Register name ? ;
 
 nested_name_specifier = type_name "::"
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..6908deed7aee3 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -18,8 +18,10 @@ namespace lldb_private::dil {
 
 /// The various types DIL AST nodes (used by the DIL parser).
 enum class NodeKind {
+  eArraySubscriptNode,
   eErrorNode,
   eIdentifierNode,
+  eScalarLiteralNode,
   eUnaryOpNode,
 };
 
@@ -71,6 +73,26 @@ class ErrorNode : public ASTNode {
   }
 };
 
+class ScalarLiteralNode : public ASTNode {
+public:
+  ScalarLiteralNode(uint32_t location, lldb::BasicType type, Scalar value)
+  : ASTNode(location, NodeKind::eScalarLiteralNode), m_type(type),
+m_value(value) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  lldb::BasicType GetType() const { return m_type; }
+  Scalar GetValue() const & { return m_value; }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eScalarLiteralNode;
+  }
+
+private:
+  lldb::BasicType m_type;
+  Scalar m_value;
+};
+
 class IdentifierNode : public ASTNode {
 public:
   IdentifierNode(uint32_t location, std::string name)
@@ -108,6 +130,26 @@ class UnaryOpNode : public ASTNode {
   ASTNodeUP m_operand;
 };
 
+class ArraySubscriptNode : public ASTNode {
+public:
+  ArraySubscriptNode(uint32_t location, ASTNodeUP lhs, ASTNodeUP rhs)
+  : ASTNode(location, NodeKind::eArraySubscriptNode), 
m_lhs(std::move(lhs)),
+m_rhs(std::move(rhs)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *lhs() const { return m_lhs.get(); }
+  ASTNode *rhs() const { return m_rhs.get(); }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eArraySubscriptNode;
+  }
+
+private:
+  ASTNodeUP m_lhs;
+  ASTNodeUP m_rhs;
+};
+
 /// This class contains one Visit method for each specialized type of
 /// DIL AST node. The Visit methods are used to dispatch a DIL AST node to
 /// the correct function in the DIL expression evaluator for evaluating that
@@ -116,9 +158,13 @@ class Visitor {
 public:
   virtual ~Visitor() = default;
   virtual llvm::Expected
+  Visit(const ScalarLiteralNode *node) = 0;
+  virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
+  virtual llvm::Expected
+  Visit(const ArraySubscriptNode *node) = 0;
 };
 
 } // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h 
b/lldb/include/lldb/ValueObject/DILEval.h
index b1dd3fdb49739..e3df80862b082 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -47,9 +47,15 @@ class Interpreter : Visitor {
   llvm::Expected Evaluate(const ASTNode *node);
 
 private:
+  l

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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


@@ -2854,14 +2842,22 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   m_deref_valobj = new ValueObjectChild(
   *this, child_compiler_type, child_name, child_byte_size,
   child_byte_offset, child_bitfield_bit_size,
-  child_bitfield_bit_offset, child_is_base_class,
-  child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
+  child_bitfield_bit_offset, child_is_base_class, true,
+  eAddressTypeInvalid, language_flags);
 }
   }
 }
-
-  } else if (IsSynthetic()) {
-m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
+  } else {
+auto err = child_compiler_type_or_err.takeError();
+if (err.isA()) {
+  deref_error = llvm::toString(std::move(err));
+  LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
+ llvm::createStringError(deref_error),
+ "could not find child: {0}");
+}

labath wrote:

Any error can be converted to a string.

```suggestion
deref_error = llvm::toString(child_compiler_type_or_err.takeError());
LLDB_LOG(GetLog(LLDBLog::Types),
 "could not find child: {0}", deref_error);
```

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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


@@ -88,7 +88,7 @@ def cleanup():
 self.expect(
 "frame variable *number_not_engaged",
 error=True,
-substrs=["not a pointer or reference type"],
+substrs=["dereference failed: not a"],

labath wrote:

What's the full error message here? Would be nice to check that it's reasonable.

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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


@@ -2794,37 +2794,26 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   if (m_deref_valobj)
 return m_deref_valobj->GetSP();
 
-  const bool is_pointer_or_reference_type = IsPointerOrReferenceType();
-  if (is_pointer_or_reference_type) {
-bool omit_empty_base_classes = true;
-bool ignore_array_bounds = false;
-
-std::string child_name_str;
-uint32_t child_byte_size = 0;
-int32_t child_byte_offset = 0;
-uint32_t child_bitfield_bit_size = 0;
-uint32_t child_bitfield_bit_offset = 0;
-bool child_is_base_class = false;
-bool child_is_deref_of_parent = false;
-const bool transparent_pointers = false;
-CompilerType compiler_type = GetCompilerType();
-uint64_t language_flags = 0;
+  std::string child_name_str;
+  uint32_t child_byte_size = 0;
+  int32_t child_byte_offset = 0;
+  uint32_t child_bitfield_bit_size = 0;
+  uint32_t child_bitfield_bit_offset = 0;
+  bool child_is_base_class = false;

labath wrote:

I think `child_is_base_class` should go away as well, and maybe the bitfield 
fields as well (in principle I can imagine a pointer to a bitfield, but I don't 
think any current language has those).

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


[Lldb-commits] [lldb] [LLDB] Fix `ValueObject::AddressOf()` return value (PR #137688)

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

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

Yeah, yeah. If Jim says it's ok, that's good enough for me.

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


[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

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

Does attach normally only check the basename of the executable? Or is it 
supposed to match the entire path?

I see a comment in `TestDAP_attach.test_by_name` that mentions making the path 
more unique, so I'm wondering if something else has changed or if that previous 
attempt at making the name more unique was a little off the mark.

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


[Lldb-commits] [lldb] 0eff410 - [LLDB] Fix `ValueObject::AddressOf()` return value (#137688)

2025-05-05 Thread via lldb-commits

Author: Ilia Kuklin
Date: 2025-05-05T20:53:04+05:00
New Revision: 0eff4108cb1e0a597ba70a4e1b8e1ce3ae0cfd46

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

LOG: [LLDB] Fix `ValueObject::AddressOf()` return value (#137688)

`ValueObject::AddressOf()` used to return address as a value which has
it's own address, allowing to do `value.AddressOf().AddressOf()`.
This patch makes the return address a simple const value.

Added: 


Modified: 
lldb/source/ValueObject/ValueObject.cpp
lldb/test/API/python_api/sbvalue_const_addrof/main.cpp

Removed: 




diff  --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index d5e0d462c3759..e1c66763ff0b8 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2907,10 +2907,13 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
 std::string name(1, '&');
 name.append(m_name.AsCString(""));
 ExecutionContext exe_ctx(GetExecutionContextRef());
+
+lldb::DataBufferSP buffer(
+new lldb_private::DataBufferHeap(&addr, sizeof(lldb::addr_t)));
 m_addr_of_valobj_sp = ValueObjectConstResult::Create(
 exe_ctx.GetBestExecutionContextScope(),
-compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
-eAddressTypeInvalid, m_data.GetAddressByteSize());
+compiler_type.GetPointerType(), ConstString(name.c_str()), buffer,
+endian::InlHostByteOrder(), exe_ctx.GetAddressByteSize());
   }
 } break;
 default:

diff  --git a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp 
b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
index 318a45bc21a85..ae6abc8613406 100644
--- a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
+++ b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
@@ -3,21 +3,21 @@
 
 struct RegisterContext
 {
-uintptr_t r0;
-uintptr_t r1;
-uintptr_t r2;
-uintptr_t r3;
-uintptr_t r4;
-uintptr_t pc;
-uintptr_t fp;
-uintptr_t sp;
+  uintptr_t r0;
+  uintptr_t r1;
+  uintptr_t r2;
+  uintptr_t r3;
+  uintptr_t r4;
+  uintptr_t pc;
+  uintptr_t fp;
+  uintptr_t sp;
 };
 
 struct ThreadInfo {
-uint32_t tid;
-const char *name;
-RegisterContext regs;
-ThreadInfo *next;
+  uint32_t tid;
+  const char *name;
+  RegisterContext regs;
+  ThreadInfo *next;
 };
 int main (int argc, char const *argv[], char const *envp[]);
 
@@ -27,14 +27,17 @@ ThreadInfo *g_thread_list_ptr = &g_thread1;
 
 int main (int argc, char const *argv[], char const *envp[])
 {
-printf ("g_thread_list is %p\n", g_thread_list_ptr);
-return 0; //% v = 
self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr')
-//% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress()
-//% v_aof = 
v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
-//% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0))
-//% e = v.CreateValueFromExpression('e', expr)
-//% e_gla = e.GetChildMemberWithName('regs').GetLoadAddress()
-//% e_aof = 
e.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
-//% self.assertTrue(v_gla == e_gla, "GetLoadAddress() 
diff ers")
-//% self.assertTrue(v_aof == e_aof, "AddressOf() 
diff ers")
+  // clang-format off
+  printf ("g_thread_list is %p\n", g_thread_list_ptr);
+  return 0; //% v = 
self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr')
+  //% self.assertTrue(v.AddressOf().IsValid())
+  //% self.assertFalse(v.AddressOf().AddressOf().IsValid())
+  //% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress()
+  //% v_aof = 
v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
+  //% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0))
+  //% e = v.CreateValueFromExpression('e', expr)
+  //% e_gla = e.GetChildMemberWithName('regs').GetLoadAddress()
+  //% e_aof = 
e.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
+  //% self.assertTrue(v_gla == e_gla, "GetLoadAddress() 
diff ers")
+  //% self.assertTrue(v_aof == e_aof, "AddressOf() 
diff ers")
 }



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


[Lldb-commits] [lldb] [LLDB] Fix `ValueObject::AddressOf()` return value (PR #137688)

2025-05-05 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] c50cba6 - [LLDB][SBSaveCore] Sbsavecore subregions bug (#138206)

2025-05-05 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2025-05-05T11:04:55-07:00
New Revision: c50cba6275271fba69be661b9ec0665b2be88dbc

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

LOG: [LLDB][SBSaveCore] Sbsavecore subregions bug (#138206)

Custom regions in Process::GetUserSpecifiedCoreFileSaveRanges originally
used `FindEntryThatContains`. This made sense on my first attempt, but
what we really want are *intersecting* regions. This is so the user can
specify arbitrary memory, and if it's available we output it to the core
(Minidump or MachO).

Added: 

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
lldb/test/API/functionalities/process_save_core_minidump/minidump_mem64.yaml

Modified: 
lldb/include/lldb/Utility/RangeMap.h
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index 8af690e813c4a..2f7711c1eb11e 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -380,6 +380,25 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+  const Entry *FindEntryThatIntersects(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+assert(IsSorted());
+#endif
+if (!m_entries.empty()) {
+  typename Collection::const_iterator begin = m_entries.begin();
+  typename Collection::const_iterator end = m_entries.end();
+  typename Collection::const_iterator pos =
+  std::lower_bound(begin, end, range, BaseLessThan);
+
+  while (pos != begin && pos[-1].DoesIntersect(range))
+--pos;
+
+  if (pos != end && pos->DoesIntersect(range))
+return &(*pos);
+}
+return nullptr;
+  }
+
   using const_iterator = typename Collection::const_iterator;
   const_iterator begin() const { return m_entries.begin(); }
   const_iterator end() const { return m_entries.end(); }

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index ce64b44846a5d..13ff12b4ff953 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6706,6 +6706,18 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
   }
 }
 
+// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and
+// then add an intersect method on it, or MemoryRegionInfo.
+static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs,
+  const MemoryRegionInfo::RangeType &rhs) {
+
+  MemoryRegionInfo region_info;
+  region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
+  region_info.GetRange() = lhs.GetRange().Intersect(rhs);
+
+  return region_info;
+}
+
 static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
const MemoryRegionInfos 
®ions,
const SaveCoreOptions &options,
@@ -6715,9 +6727,15 @@ static void GetUserSpecifiedCoreFileSaveRanges(Process 
&process,
 return;
 
   for (const auto &range : regions) {
-auto entry = option_ranges.FindEntryThatContains(range.GetRange());
-if (entry)
-  AddRegion(range, true, ranges);
+auto *entry = option_ranges.FindEntryThatIntersects(range.GetRange());
+if (entry) {
+  if (*entry != range.GetRange()) {
+AddRegion(Intersect(range, *entry), true, ranges);
+  } else {
+// If they match, add the range directly.
+AddRegion(range, true, ranges);
+  }
+}
   }
 }
 

diff  --git 
a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
new file mode 100644
index 0..c0572e34d7746
--- /dev/null
+++ 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
@@ -0,0 +1,247 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class AddressRange:
+begin: int
+end: int
+
+def __init__(self, begin, end):
+self.begin = begin
+self.end = end
+
+
+# We skip all these tests on Windows because on Windows Minidumps
+# are not generated by LLDB.
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+def process_from_yaml(self, yaml_file):
+minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + 
".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.process
+
+@skipIfWindows
+def validate_regions_saved_correctly(

[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

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

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

labath wrote:

> Move the Proc Status (not stat) code to the HOST class

I'd put this first (in which case it wouldn't be called "move" but "extend" or 
"refactor"), for two reasons:
- it reduces the chance of ending up with two parsers
- I'm not very happy with the implementation you have here. I think using 
structured data is overkill and makes using it more complicated. Since this is 
an internal API, and we don't have to worry about stability, I think a struct 
with a bool field (or `optional` if you need to treat "not present" 
differently) would be better. (That's also more-or-less what the existing 
implementation does)

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


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

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


@@ -274,10 +274,8 @@ static Status spawn_process(const char *progname, const 
FileSpec &prog,
   self_args.AppendArgument(llvm::StringRef("platform"));
   self_args.AppendArgument(llvm::StringRef("--child-platform-fd"));
   self_args.AppendArgument(llvm::to_string(shared_socket.GetSendableFD()));
-#ifndef _WIN32
   launch_info.AppendDuplicateFileAction((int)shared_socket.GetSendableFD(),
 (int)shared_socket.GetSendableFD());

labath wrote:

I don't understand what's the problem with that. I'm pretty sure that zero is 
not a valid handle value 
(https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443), so it can't 
conflict with STDIN_FILENO.

Relatedly, I had an idea which might alleviate some of your concerns. While I 
firmly believe that getting right of the `child_process_inherit` constructor 
argument is the right thing to do, I'm not entirely happy that this results in 
making *all* pipe handles inheritable. In the description I propose creating a 
helper function which creates a copy of the handle which can be inherited. On 
windows this would call `DuplicateHandle` with `bInheritHandle=TRUE` and on 
posix it would be a no-op (as we're able to change the CLOEXEC flag on the fd 
later).

If we had that, we could also easily ensure that the returned handle does not 
conflict with our "reserved" values -- if `DuplicateHandle` returns 0/1/2, just 
call it again until it returns something bigger. It's kinda gross, but I also 
somehow like it :P

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

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

labath wrote:

Correct. :)

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


[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-05 Thread Hu Jialun via lldb-commits

SuibianP wrote:

> Another PR looks abandoned

It is actually not (yet). I have been actively waiting for maintainers to drop 
another review and have pinged & rebased several times over these three months.

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


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

2025-05-05 Thread Dmitry Vasilyev via lldb-commits

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

Ok, let's see how it flies in the real world.

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


[Lldb-commits] [lldb] [lldb-dap] Implement `runInTerminal` for Windows (PR #121269)

2025-05-05 Thread Hu Jialun via lldb-commits

https://github.com/SuibianP updated 
https://github.com/llvm/llvm-project/pull/121269

>From f9675fbe23abe59c3cf56a6263b7a78ec20e42d4 Mon Sep 17 00:00:00 2001
From: Jialun Hu 
Date: Mon, 24 Feb 2025 22:10:17 +0800
Subject: [PATCH] [lldb-dap] Implement runInTerminal for Windows

Currently, the named pipe is passed by name and a transient ofstream is
constructed at each I/O request. This assumes,
  - Blocking semantics: FIFO I/O waits for the other side to connect.
  - Buffered semantics: Closing one side does not discard existing data.

The former can be replaced by WaitNamedPipe/ConnectNamedPipe on Win32,
but the second cannot be easily worked around. It is also impossible to
have another "keep-alive" pipe server instance, as server-client pairs
are fixed on connection on Win32 and the client may get connected to it
instead of the real one.

Refactor FifoFile[IO] to use an open file handles rather than file name.

---

Win32 provides no way to replace the process image. Under the hood exec*
actually creates a new process with a new PID. DebugActiveProcess also
cannot get notified of process creations.

Create the new process in a suspended state and resume it after attach.
---
 lldb/packages/Python/lldbsuite/test/dotest.py |   2 +-
 .../API/tools/lldb-dap/runInTerminal/Makefile |   2 +-
 .../runInTerminal/TestDAP_runInTerminal.py|   5 +-
 .../API/tools/lldb-dap/runInTerminal/main.c   |  11 --
 .../API/tools/lldb-dap/runInTerminal/main.cpp |  13 ++
 lldb/tools/lldb-dap/FifoFiles.cpp | 131 +++---
 lldb/tools/lldb-dap/FifoFiles.h   |  35 +++--
 .../tools/lldb-dap/Handler/RequestHandler.cpp |   8 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |   2 +-
 lldb/tools/lldb-dap/RunInTerminal.cpp |  45 +++---
 lldb/tools/lldb-dap/RunInTerminal.h   |  11 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  63 +++--
 12 files changed, 244 insertions(+), 84 deletions(-)
 delete mode 100644 lldb/test/API/tools/lldb-dap/runInTerminal/main.c
 create mode 100644 lldb/test/API/tools/lldb-dap/runInTerminal/main.cpp

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 7cc8f2985043e..01b161733d62e 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -547,7 +547,7 @@ def setupSysPath():
 
 lldbDir = os.path.dirname(lldbtest_config.lldbExec)
 
-lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
+lldbDAPExec = os.path.join(lldbDir, "lldb-dap.exe" if os.name == "nt" else 
"lldb-dap")
 if is_exe(lldbDAPExec):
 os.environ["LLDBDAP_EXEC"] = lldbDAPExec
 
diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile 
b/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
index 10495940055b6..8b20bcb05 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 
 include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 9aab7ca3293db..3a47202c5e0b6 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -43,7 +43,6 @@ def isTestSupported(self):
 except:
 return False
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
@@ -53,7 +52,7 @@ def test_runInTerminal(self):
 launch the inferior with the correct environment variables and 
arguments.
 """
 program = self.getBuildArtifact("a.out")
-source = "main.c"
+source = "main.cpp"
 self.build_and_launch(
 program, runInTerminal=True, args=["foobar"], env=["FOO=bar"]
 )
@@ -113,7 +112,6 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertIn("FOO", request_envs)
 self.assertEqual("BAR", request_envs["FOO"])
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
@@ -132,7 +130,6 @@ def test_runInTerminalInvalidTarget(self):
 response["message"],
 )
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/main.c 
b/lldb/test/API/tools/lldb-dap/runInTerminal/main.c
deleted file mode 100644
index 676bd830e657b..0
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include 
-#include 
-#include 
-
-int main(int argc, char *argv[]) {
-  const char *foo = getenv("FOO");
-  for (int

[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-05-05 Thread Santhosh Kumar Ellendula via lldb-commits

https://github.com/santhoshe447 updated 
https://github.com/llvm/llvm-project/pull/131820



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


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

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


@@ -122,8 +123,14 @@ struct ForkLaunchInfo {
 ExitWithError(error_fd, "close");
   break;
 case FileAction::eFileActionDuplicate:
-  if (dup2(action.fd, action.arg) == -1)
-ExitWithError(error_fd, "dup2");
+  if (action.fd != action.arg) {

labath wrote:

Can you explain your reasoning?

This is something I have considered, and I came to the opposite conclusion. The 
reason is that I think this fits nicely into the `DuplicateFileAction(from, 
to)` interface. You're saying "I want to take fd `from` from my process and 
pass it as fd `to` to the child process". That statement makes sense regardless 
of whether `from` and `to` have the same value or not. The fact that one needs 
to use a different sequence of calls to achieve this effect is (can be) an 
implementation detail.

Imagine I have some file descriptor open, and for whatever reason, I want to 
pass it to the child process exactly as fd 47. That's something I can freely 
do, as I control all of the FDs of the child process, but if this were to be 
controlled by a separate flag, I would have to write special code to handle the 
case where the my own copy of that FD happens to be 47:
```
if (fd_I_want_to_pass != 47)
  info.AppendDuplicateFileAction(47, fd_I_want_to_pass);
else
  info.InheritFileAction(47);
```

>From a windows point of view, I agree that a separate action makes sense, but 
>if we can agree that the above makes sense for posix, then I think it also 
>makes sense to reuse the same thing here (we're sort of doing the same thing, 
>except that we only support the case where the two numbers are the same).

That said, since the `from==to` is going to be the only case that is going to 
work in cross-platform code, I can imagine having some wrapper/helper function, 
which lets you avoid specifying the same FD twice, but then calls 
`DuplicateFileAction(fd, fd)` under the hood. Would that address your concerns?

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


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

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

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

>From afd0475ea23ed79f074c3f4143b86e6efb557d37 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 2 May 2025 09:59:01 -0700
Subject: [PATCH] [lldb-dap] Change the launch sequence

This PR changes how we treat the launch sequence in lldb-dap.

 - Send the initialized event after we finish handling the initialize
   request, rather than after we finish attaching or launching.
 - Delay handling the launch and attach request until we have handled
   the configurationDone request. The latter is now largely a NO-OP and
   only exists to signal lldb-dap that it can handle the launch and
   attach requests.
 - Delay handling the initial threads requests until we have handled
   the launch or attach request.
 - Make all attaching and launching asynchronous, including when we have
   attach or launch commands. That removes the need to synchronize
   between the request and event thread.

Background: https://discourse.llvm.org/t/reliability-of-the-lldb-dap-tests/86125
---
 .../test/tools/lldb-dap/dap_server.py |  48 
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   7 ++
 .../tools/lldb-dap/attach/TestDAP_attach.py   |   3 +-
 .../attach/TestDAP_attachByPortNum.py |   8 +-
 .../breakpoint/TestDAP_breakpointLocations.py |   3 +-
 .../breakpoint/TestDAP_setBreakpoints.py  |   3 +-
 .../lldb-dap/commands/TestDAP_commands.py |   3 +-
 .../completions/TestDAP_completions.py|   6 +-
 .../tools/lldb-dap/console/TestDAP_console.py |   2 +-
 .../disassemble/TestDAP_disassemble.py|   3 +-
 .../lldb-dap/disconnect/TestDAP_disconnect.py |   6 +-
 .../lldb-dap/evaluate/TestDAP_evaluate.py |   3 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |   4 +-
 .../tools/lldb-dap/memory/TestDAP_memory.py   |   3 +-
 .../lldb-dap/progress/TestDAP_Progress.py |   2 +-
 .../repl-mode/TestDAP_repl_mode_detection.py  |   2 +-
 .../tools/lldb-dap/restart/TestDAP_restart.py |   1 -
 .../restart/TestDAP_restart_runInTerminal.py  |   1 -
 .../lldb-dap/stop-hooks/TestDAP_stop_hooks.py |   2 +-
 .../lldb-dap/variables/TestDAP_variables.py   |   3 +-
 lldb/tools/lldb-dap/DAP.cpp   |  39 +--
 lldb/tools/lldb-dap/DAP.h |   8 +-
 lldb/tools/lldb-dap/EventHelper.cpp   |   2 +-
 .../lldb-dap/Handler/AttachRequestHandler.cpp | 103 ++
 .../ConfigurationDoneRequestHandler.cpp   |  14 +--
 .../Handler/InitializeRequestHandler.cpp  |  44 +++-
 .../lldb-dap/Handler/LaunchRequestHandler.cpp |   7 +-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  67 +++-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   1 +
 29 files changed, 222 insertions(+), 176 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 6d9ab770684f1..93420e858bc4f 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
@@ -591,6 +591,7 @@ def request_attach(
 attachCommands=None,
 terminateCommands=None,
 coreFile=None,
+stopOnAttach=True,
 postRunCommands=None,
 sourceMap=None,
 gdbRemotePort=None,
@@ -620,6 +621,8 @@ def request_attach(
 args_dict["attachCommands"] = attachCommands
 if coreFile:
 args_dict["coreFile"] = coreFile
+if stopOnAttach:
+args_dict["stopOnEntry"] = stopOnAttach
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
 if sourceMap:
@@ -632,7 +635,7 @@ def request_attach(
 response = self.send_recv(command_dict)
 
 if response["success"]:
-self.wait_for_events(["process", "initialized"])
+self.wait_for_event("process")
 return response
 
 def request_breakpointLocations(
@@ -666,10 +669,6 @@ def request_configurationDone(self):
 response = self.send_recv(command_dict)
 if response:
 self.configuration_done_sent = True
-# Client requests the baseline of currently existing threads after
-# a successful launch or attach.
-# Kick off the threads request that follows
-self.request_threads()
 return response
 
 def _process_stopped(self):
@@ -887,7 +886,7 @@ def request_launch(
 response = self.send_recv(command_dict)
 
 if response["success"]:
-self.wait_for_events(["process", "initialized"])
+self.wait_for_event("process")
 return response
 
 def request_next(self, threadId, granularity="statement"):
@@ -1325,6 +1324,26 @@ def attach_options_specified(options):
 
 def run_vscode(dbg, args, options):
 dbg.request_initialize(options.sourceInitFile)
+
+if options.sourceBreakpoints:
+s

[Lldb-commits] [lldb] [lldb] Upstream lldb-rpc-gen and LLDB RPC server-side emitters (PR #136748)

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

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


[Lldb-commits] [lldb] [lldb] Upstream lldb-rpc-gen and LLDB RPC server-side emitters (PR #136748)

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

chelcassanova wrote:

I split this large patch up into 3 smaller ones:
This patch upstreams the `lldb-rpc-gen` tool itself as well as its common code: 
https://github.com/llvm/llvm-project/pull/138031
This upstreams the server-side emitter: 
https://github.com/llvm/llvm-project/pull/138032
This upstreams the Python scripts used to modify headers: 
https://github.com/llvm/llvm-project/pull/138028.

This current patch itself is very very large, so I'll close it and let 
discussion continue on the above 3.

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


[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)

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

Michael137 wrote:

> @Michael137 I looked into adding the diagnostic you asked about and while the 
> implementation is relatively straightforward, I'm even more convinced that I 
> don't think it belongs there because it's a semantic rather than a syntax 
> error.
> 
> We can detect a scope followed by an alternative scope, i.e. something like 
> `{{foo}|bar}` but what about something like `{foo|bar}`. Just like a scope, 
> `foo` will always resolve, so technically `bar` is unreachable. Should we 
> diagnose this too? And what about `{${frame.pc}||bar}`. The empty string 
> between the two pipes will always resolve. In other words, I don't think this 
> warrants special casing as there are plenty of other scenarios that trigger 
> similar behavior that would be much harder to diagnose.

Ok thanks for giving it a shot. I agree it doesn't quite fit the existing 
syntax diagnostics. We can always choose to revisit if this becomes a big point 
of confusion for people

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


[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)

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

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


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


[Lldb-commits] [lldb] 3e235a7 - [lldb] Support alternatives for scope format entries (#137751)

2025-05-05 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-05T16:10:57-07:00
New Revision: 3e235a7c601d80d6e8a0392ebec859068659ec19

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

LOG: [lldb] Support alternatives for scope format entries (#137751)

This PR implements support for specifying multiple alternatives for
scope format entries. Scopes are used to enclose things that should only
be printed when everything in the scope resolves.

For example, the following scope only resolves if both
`${line.file.basename}` and `${line.number}` resolve. `

```
{ at ${line.file.basename}:${line.number}}
```

However, the current implementation doesn't let you specify what to
print when they don't resolve. This PR adds support for specifying
multiple alternative scopes, which are evaluated left-to-right.

For example:

```
{ at ${line.file.basename}:${line.number}| in ${function.name}| }
```

This will resolve to:

- ` at ${line.file.basename}:${line.number}` if the corresponding
variables resolve.
- Otherwise, this resolves to ` in ${function.name}` if
`${function.name}` resolves.
- Otherwise, this resolves to ` ` which always
resolves.

This PR makes the `|` character a special character within a scope, but
allows it to be escaped.

I ended up with this approach because it fit quite nicely in the
existing architecture of the format entries and by limiting the
functionality to scopes, it sidesteps some complexity, like dealing with
recursion.

Added: 


Modified: 
lldb/include/lldb/Core/FormatEntity.h
lldb/source/Core/FormatEntity.cpp
lldb/unittests/Core/FormatEntityTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 97065afe19bfe..6acf6fbe43239 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -11,10 +11,10 @@
 
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
 #include 
-
 #include 
 #include 
 
@@ -158,9 +158,7 @@ struct Entry {
   }
 
   Entry(Type t = Type::Invalid, const char *s = nullptr,
-const char *f = nullptr)
-  : string(s ? s : ""), printf_format(f ? f : ""), type(t) {}
-
+const char *f = nullptr);
   Entry(llvm::StringRef s);
   Entry(char ch);
 
@@ -170,15 +168,19 @@ struct Entry {
 
   void AppendText(const char *cstr);
 
-  void AppendEntry(const Entry &&entry) { children.push_back(entry); }
+  void AppendEntry(const Entry &&entry);
+
+  void StartAlternative();
 
   void Clear() {
 string.clear();
 printf_format.clear();
-children.clear();
+children_stack.clear();
+children_stack.emplace_back();
 type = Type::Invalid;
 fmt = lldb::eFormatDefault;
 number = 0;
+level = 0;
 deref = false;
   }
 
@@ -191,7 +193,7 @@ struct Entry {
   return false;
 if (printf_format != rhs.printf_format)
   return false;
-if (children != rhs.children)
+if (children_stack != rhs.children_stack)
   return false;
 if (type != rhs.type)
   return false;
@@ -202,9 +204,18 @@ struct Entry {
 return true;
   }
 
+  std::vector &GetChildren();
+
   std::string string;
   std::string printf_format;
-  std::vector children;
+
+  /// A stack of children entries, used by Scope entries to provide alterantive
+  /// children. All other entries have a stack of size 1.
+  /// @{
+  llvm::SmallVector, 1> children_stack;
+  size_t level = 0;
+  /// @}
+
   Type type;
   lldb::Format fmt = lldb::eFormatDefault;
   lldb::addr_t number = 0;

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index f1c831b7ccc1e..4f2d39873c7fb 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -60,6 +60,7 @@
 #include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -281,31 +282,53 @@ constexpr Definition g_top_level_entries[] = {
 constexpr Definition g_root = Entry::DefinitionWithChildren(
 "", EntryType::Root, g_top_level_entries);
 
+FormatEntity::Entry::Entry(Type t, const char *s, const char *f)
+: string(s ? s : ""), printf_format(f ? f : ""), children_stack({{}}),
+  type(t) {}
+
 FormatEntity::Entry::Entry(llvm::StringRef s)
-: string(s.data(), s.size()), printf_format(), children(),
-  type(Type::String) {}
+: string(s.data(), s.size()), children_stack({{}}), type(Type::String) {}
 
 FormatEntity::Entry::Entry(char ch)
-: string(1, ch), printf_format(), children(), type(Type::String) {}
+: string(1, ch), printf_format(), children_stack({{}}), type(Type::String) 
{
+}
+
+std::vector &FormatEntity::Entry::GetChildren() {
+  assert(level < children_stack.size());
+  return children_

[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)

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

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


[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

JDevlieghere wrote:

This is still necessary, at least on Darwin, because `vAttachWait` only looks 
at the basename. 

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


[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

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

>From 50c11b4360cf8781c99ab207b70b8de291e5a36e Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 00:47:44 -0700
Subject: [PATCH] [lldb-dap] Give attach test binaries unique names

Give the test binaries used for attaching unique names to avoid
accidentally attaching to the wrong binary.

Fixes #138197
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   | 13 --
 .../tools/lldb-dap/attach/TestDAP_attach.py   | 40 +--
 .../attach/TestDAP_attachByPortNum.py | 13 ++
 .../lldb-dap/commands/TestDAP_commands.py |  4 +-
 4 files changed, 25 insertions(+), 45 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index ee5272850b9a8..2c14bb35162b5 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -1,6 +1,6 @@
 import os
 import time
-import subprocess
+import uuid
 
 import dap_server
 from lldbsuite.test.lldbtest import *
@@ -28,10 +28,17 @@ def create_debug_adapter(self, lldbDAPEnv=None, 
connection=None):
 env=lldbDAPEnv,
 )
 
-def build_and_create_debug_adapter(self, lldbDAPEnv=None):
-self.build()
+def build_and_create_debug_adapter(self, lldbDAPEnv=None, dictionary=None):
+self.build(dictionary=dictionary)
 self.create_debug_adapter(lldbDAPEnv)
 
+def build_and_create_debug_adapter_for_attach(self):
+"""Variant of build_and_create_debug_adapter that builds a uniquely
+named binary."""
+unique_name = str(uuid.uuid4())
+self.build_and_create_debug_adapter(dictionary={"EXE": unique_name})
+return self.getBuildArtifact(unique_name)
+
 def set_source_breakpoints(self, source_path, lines, data=None):
 """Sets source breakpoints and returns an array of strings containing
 the breakpoint IDs ("1", "2") for each breakpoint that was set.
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index 6f70316821c8c..f48d5a7db3c50 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -2,7 +2,6 @@
 Test lldb-dap attach request
 """
 
-
 import dap_server
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -25,7 +24,7 @@ def spawn_and_wait(program, delay):
 process.wait()
 
 
-@skipIf
+@skip
 class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
 def set_and_hit_breakpoint(self, continueToExit=True):
 source = "main.c"
@@ -45,8 +44,7 @@ def test_by_pid(self):
 """
 Tests attaching to a process by process ID.
 """
-self.build_and_create_debug_adapter()
-program = self.getBuildArtifact("a.out")
+program = self.build_and_create_debug_adapter_for_attach()
 self.process = subprocess.Popen(
 [program],
 stdin=subprocess.PIPE,
@@ -61,34 +59,15 @@ def test_by_name(self):
 """
 Tests attaching to a process by process name.
 """
-self.build_and_create_debug_adapter()
-orig_program = self.getBuildArtifact("a.out")
-# Since we are going to attach by process name, we need a unique
-# process name that has minimal chance to match a process that is
-# already running. To do this we use tempfile.mktemp() to give us a
-# full path to a location where we can copy our executable. We then
-# run this copy to ensure we don't get the error "more that one
-# process matches 'a.out'".
-program = tempfile.mktemp()
-shutil.copyfile(orig_program, program)
-shutil.copymode(orig_program, program)
+program = self.build_and_create_debug_adapter_for_attach()
 
 # Use a file as a synchronization point between test and inferior.
 pid_file_path = lldbutil.append_to_process_working_directory(
 self, "pid_file_%d" % (int(time.time()))
 )
 
-def cleanup():
-if os.path.exists(program):
-os.unlink(program)
-self.run_platform_command("rm %s" % (pid_file_path))
-
-# Execute the cleanup function during test case tear down.
-self.addTearDownHook(cleanup)
-
 popen = self.spawnSubprocess(program, [pid_file_path])
-
-pid = lldbutil.wait_for_file_on_target(self, pid_file_path)
+lldbutil.wait_for_file_on_target(self, pid_file_path)
 
 self.attach(program=program)
 self.set_and_hit_breakpoint(continueToExit=True)
@@ -101,8 +80,7 @@ def test_by_name_waitFor(self):
 next instance of a process to be launched, ingoring all current
 ones.
 """
- 

[Lldb-commits] [lldb] [lldb][docs] Update instructions to build standalone (PR #137383)

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

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



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Don't error out when the process is in eStateUnloaded (PR #138601)

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

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

DAP::WaitForProcessToStop treats the process in eStateUnloaded as an error. The 
process is in this state when it has just been created (before an attach or 
launch) or when it's restarted. Neither should be treated as errors.

The current implementation can trigger this error (and a corresponding test 
failure) when we call WaitForProcessToStop after attaching  in asynchronous 
mode (for example when using ConnectRemote which is always asynchronous (due to 
a bug).



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Don't error out when the process is in eStateUnloaded (PR #138601)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

DAP::WaitForProcessToStop treats the process in eStateUnloaded as an error. The 
process is in this state when it has just been created (before an attach or 
launch) or when it's restarted. Neither should be treated as errors.

The current implementation can trigger this error (and a corresponding test 
failure) when we call WaitForProcessToStop after attaching  in asynchronous 
mode (for example when using ConnectRemote which is always asynchronous (due to 
a bug).

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


1 Files Affected:

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


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4cb0d8e49004c..4b631484c9fab 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -968,6 +968,7 @@ lldb::SBError 
DAP::WaitForProcessToStop(std::chrono::seconds seconds) {
   while (std::chrono::steady_clock::now() < timeout_time) {
 const auto state = process.GetState();
 switch (state) {
+case lldb::eStateUnloaded:
 case lldb::eStateAttaching:
 case lldb::eStateConnected:
 case lldb::eStateInvalid:
@@ -982,9 +983,6 @@ lldb::SBError 
DAP::WaitForProcessToStop(std::chrono::seconds seconds) {
 case lldb::eStateExited:
   error.SetErrorString("process exited during launch or attach");
   return error;
-case lldb::eStateUnloaded:
-  error.SetErrorString("process unloaded during launch or attach");
-  return error;
 case lldb::eStateCrashed:
 case lldb::eStateStopped:
   return lldb::SBError(); // Success!

``




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


[Lldb-commits] [lldb] 3ceec26 - [lldb-dap] Give attach test binaries unique names (#138435)

2025-05-05 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-05T15:15:58-07:00
New Revision: 3ceec268413860b466b14600ce67d8bbd09ff75c

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

LOG: [lldb-dap] Give attach test binaries unique names (#138435)

Give the test binaries used for attaching unique names to avoid
accidentally attaching to the wrong binary.

Fixes #138197

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py
lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index ee5272850b9a8..2c14bb35162b5 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -1,6 +1,6 @@
 import os
 import time
-import subprocess
+import uuid
 
 import dap_server
 from lldbsuite.test.lldbtest import *
@@ -28,10 +28,17 @@ def create_debug_adapter(self, lldbDAPEnv=None, 
connection=None):
 env=lldbDAPEnv,
 )
 
-def build_and_create_debug_adapter(self, lldbDAPEnv=None):
-self.build()
+def build_and_create_debug_adapter(self, lldbDAPEnv=None, dictionary=None):
+self.build(dictionary=dictionary)
 self.create_debug_adapter(lldbDAPEnv)
 
+def build_and_create_debug_adapter_for_attach(self):
+"""Variant of build_and_create_debug_adapter that builds a uniquely
+named binary."""
+unique_name = str(uuid.uuid4())
+self.build_and_create_debug_adapter(dictionary={"EXE": unique_name})
+return self.getBuildArtifact(unique_name)
+
 def set_source_breakpoints(self, source_path, lines, data=None):
 """Sets source breakpoints and returns an array of strings containing
 the breakpoint IDs ("1", "2") for each breakpoint that was set.

diff  --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index 6f70316821c8c..f48d5a7db3c50 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -2,7 +2,6 @@
 Test lldb-dap attach request
 """
 
-
 import dap_server
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -25,7 +24,7 @@ def spawn_and_wait(program, delay):
 process.wait()
 
 
-@skipIf
+@skip
 class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
 def set_and_hit_breakpoint(self, continueToExit=True):
 source = "main.c"
@@ -45,8 +44,7 @@ def test_by_pid(self):
 """
 Tests attaching to a process by process ID.
 """
-self.build_and_create_debug_adapter()
-program = self.getBuildArtifact("a.out")
+program = self.build_and_create_debug_adapter_for_attach()
 self.process = subprocess.Popen(
 [program],
 stdin=subprocess.PIPE,
@@ -61,34 +59,15 @@ def test_by_name(self):
 """
 Tests attaching to a process by process name.
 """
-self.build_and_create_debug_adapter()
-orig_program = self.getBuildArtifact("a.out")
-# Since we are going to attach by process name, we need a unique
-# process name that has minimal chance to match a process that is
-# already running. To do this we use tempfile.mktemp() to give us a
-# full path to a location where we can copy our executable. We then
-# run this copy to ensure we don't get the error "more that one
-# process matches 'a.out'".
-program = tempfile.mktemp()
-shutil.copyfile(orig_program, program)
-shutil.copymode(orig_program, program)
+program = self.build_and_create_debug_adapter_for_attach()
 
 # Use a file as a synchronization point between test and inferior.
 pid_file_path = lldbutil.append_to_process_working_directory(
 self, "pid_file_%d" % (int(time.time()))
 )
 
-def cleanup():
-if os.path.exists(program):
-os.unlink(program)
-self.run_platform_command("rm %s" % (pid_file_path))
-
-# Execute the cleanup function during test case tear down.
-self.addTearDownHook(cleanup)
-
 popen = self.spawnSubprocess(program, [pid_file_path])
-
-pid = lldbutil.wait_for_file_on_target(self, pid_file_path)
+lldbutil.wait_for_file_on_target(self, pid_file_path)
 
 self.attach(program=program)
 self.set_and_hit_breakpoint(continueToE

[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

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


[Lldb-commits] [lldb] b86b529 - [lldb][test] Mark DynamicValueTestCase XFAIL on Windows

2025-05-05 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2025-05-06T03:37:54+05:00
New Revision: b86b5296cb649c06abbb6471d6f0f777b91a29c9

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

LOG: [lldb][test] Mark DynamicValueTestCase XFAIL on Windows

The newly added test test_from_forward_decl in TestDynamicValue.py
by PR #137974 is failing on Windows due to issues with dynamic type
resolution. This is a known issue tracked in PR24663.

LLDB Windows on Arm Buildbot Failure:
https://lab.llvm.org/buildbot/#/builders/141/builds/8391

This change marks the test as XFAIL on Windows using the consistent
with how similar tests in the same file are handled.

Added: 


Modified: 
lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py

Removed: 




diff  --git a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py 
b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
index 3952b88a6c28e..634bd13d7c71a 100644
--- a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
+++ b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
@@ -268,6 +268,7 @@ def examine_value_object_of_this_ptr(
 self.assertLess(contained_b_addr, contained_b_static_addr)
 
 @no_debug_info_test
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")
 def test_from_forward_decl(self):
 """Test fetching C++ dynamic values forward-declared types. It's
 imperative that this is a separate test so that we don't end up parsing



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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)

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

JDevlieghere wrote:

> @felipepiovezan Hopefully this should fix the problem in the macOS tests 
> ([#137512 
> (comment)](https://github.com/llvm/llvm-project/pull/137512#issuecomment-2846104161))
>  though I don't know how to trigger these tests from the PR :|

Unfortunately there's no pre-commit testing for Darwin. I applied your patch 
locally and ran the test suite and the test is still failing because `strip` on 
Darwin doesn't have a `--keep-symbol` flag. I think you'lll want to use the 
`-s` flag which allows you to specify a file with symbols to "save" (keep):

```
   -s filename
  Save the symbol table entries for the global symbols listed in 
filename.  The symbol names listed in filename must be one per line. Leading 
and trailing white space are not part of the symbol name.  Lines starting with 
# are ignored, as are lines with only white space.
```

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


[Lldb-commits] [lldb] [lldb-dap] Don't error out when the process is in eStateUnloaded (PR #138601)

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

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


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


[Lldb-commits] [lldb] 1c1238d - [lldb-dap] Don't error out when the process is in eStateUnloaded (#138601)

2025-05-05 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-05T17:29:40-07:00
New Revision: 1c1238d3615a7e1a99570d1e02de3b538d2e0669

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

LOG: [lldb-dap] Don't error out when the process is in eStateUnloaded (#138601)

DAP::WaitForProcessToStop treats the process in eStateUnloaded as an
error. The process is in this state when it has just been created
(before an attach or launch) or when it's restarted. Neither should be
treated as errors.

The current implementation can trigger this error (and a corresponding
test failure) when we call WaitForProcessToStop after attaching in
asynchronous mode (for example when using ConnectRemote which is always
asynchronous (due to a bug).

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4cb0d8e49004c..4b631484c9fab 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -968,6 +968,7 @@ lldb::SBError 
DAP::WaitForProcessToStop(std::chrono::seconds seconds) {
   while (std::chrono::steady_clock::now() < timeout_time) {
 const auto state = process.GetState();
 switch (state) {
+case lldb::eStateUnloaded:
 case lldb::eStateAttaching:
 case lldb::eStateConnected:
 case lldb::eStateInvalid:
@@ -982,9 +983,6 @@ lldb::SBError 
DAP::WaitForProcessToStop(std::chrono::seconds seconds) {
 case lldb::eStateExited:
   error.SetErrorString("process exited during launch or attach");
   return error;
-case lldb::eStateUnloaded:
-  error.SetErrorString("process unloaded during launch or attach");
-  return error;
 case lldb::eStateCrashed:
 case lldb::eStateStopped:
   return lldb::SBError(); // Success!



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


[Lldb-commits] [lldb] [lldb-dap] Don't error out when the process is in eStateUnloaded (PR #138601)

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

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


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

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

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

>From b7391070942219a691a691822477e2a7616be1ab Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 2 May 2025 09:59:01 -0700
Subject: [PATCH] [lldb-dap] Change the launch sequence

This PR changes how we treat the launch sequence in lldb-dap.

 - Send the initialized event after we finish handling the initialize
   request, rather than after we finish attaching or launching.
 - Delay handling the launch and attach request until we have handled
   the configurationDone request. The latter is now largely a NO-OP and
   only exists to signal lldb-dap that it can handle the launch and
   attach requests.
 - Delay handling the initial threads requests until we have handled
   the launch or attach request.
 - Make all attaching and launching asynchronous, including when we have
   attach or launch commands. That removes the need to synchronize
   between the request and event thread.

Background: https://discourse.llvm.org/t/reliability-of-the-lldb-dap-tests/86125
---
 .../test/tools/lldb-dap/dap_server.py |  65 +-
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   7 ++
 .../tools/lldb-dap/attach/TestDAP_attach.py   |   3 +-
 .../attach/TestDAP_attachByPortNum.py |   8 +-
 .../TestDAP_breakpointEvents.py   |  60 +++--
 .../breakpoint/TestDAP_breakpointLocations.py |   3 +-
 .../breakpoint/TestDAP_setBreakpoints.py  |   3 +-
 .../lldb-dap/commands/TestDAP_commands.py |   2 -
 .../completions/TestDAP_completions.py|   6 +-
 .../tools/lldb-dap/console/TestDAP_console.py |   2 +-
 .../disassemble/TestDAP_disassemble.py|   3 +-
 .../lldb-dap/disconnect/TestDAP_disconnect.py |   6 +-
 .../lldb-dap/evaluate/TestDAP_evaluate.py |   3 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |   4 +-
 .../tools/lldb-dap/memory/TestDAP_memory.py   |   3 +-
 .../lldb-dap/progress/TestDAP_Progress.py |   2 +-
 .../repl-mode/TestDAP_repl_mode_detection.py  |   2 +-
 .../tools/lldb-dap/restart/TestDAP_restart.py |   1 -
 .../restart/TestDAP_restart_runInTerminal.py  |   1 -
 .../lldb-dap/stop-hooks/TestDAP_stop_hooks.py |   2 +-
 .../lldb-dap/variables/TestDAP_variables.py   |   3 +-
 lldb/tools/lldb-dap/DAP.cpp   |  39 --
 lldb/tools/lldb-dap/DAP.h |   8 +-
 lldb/tools/lldb-dap/EventHelper.cpp   |   2 +-
 .../lldb-dap/Handler/AttachRequestHandler.cpp | 115 ++
 .../ConfigurationDoneRequestHandler.cpp   |  14 +--
 .../Handler/InitializeRequestHandler.cpp  |  44 +++
 .../lldb-dap/Handler/LaunchRequestHandler.cpp |   7 +-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  67 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   1 +
 30 files changed, 252 insertions(+), 234 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 6d9ab770684f1..e10342b72f4f0 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
@@ -132,7 +132,6 @@ def __init__(self, recv, send, init_commands, 
log_file=None):
 self.exit_status = None
 self.initialize_body = None
 self.thread_stop_reasons = {}
-self.breakpoint_events = []
 self.progress_events = []
 self.reverse_requests = []
 self.module_events = []
@@ -244,13 +243,6 @@ def handle_recv_packet(self, packet):
 self._process_stopped()
 tid = body["threadId"]
 self.thread_stop_reasons[tid] = body
-elif event == "breakpoint":
-# Breakpoint events come in when a breakpoint has locations
-# added or removed. Keep track of them so we can look for them
-# in tests.
-self.breakpoint_events.append(packet)
-# no need to add 'breakpoint' event packets to our packets list
-return keepGoing
 elif event.startswith("progress"):
 # Progress events come in as 'progressStart', 'progressUpdate',
 # and 'progressEnd' events. Keep these around in case test
@@ -412,6 +404,15 @@ def wait_for_stopped(self, timeout=None):
 self.threads = []
 return stopped_events
 
+def wait_for_breakpoint_events(self, timeout=None):
+breakpoint_events = []
+while True:
+event = self.wait_for_event("breakpoint", timeout=timeout)
+if not event:
+break
+breakpoint_events.append(event)
+return breakpoint_events
+
 def wait_for_exited(self):
 event_dict = self.wait_for_event("exited")
 if event_dict is None:
@@ -591,6 +592,7 @@ def request_attach(
 attachCommands=None,
 terminateCommands=None,
 coreFile=None

[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)

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

JDevlieghere wrote:

@Michael137 I looked into adding the diagnostic you asked about and while the 
implementation is relatively straightforward, I'm even more convinced that I 
don't think it belongs there because it's a semantic rather than a syntax 
error. 

We can detect a scope followed by an alternative scope, i.e. something like 
`{{foo}|bar}` but what about something like `{foo|bar}`. Just like a scope, 
`foo` will always resolve, so technically `bar` is unreachable. Should we 
diagnose this too? And what about `{${frame.pc}||bar}`. The empty string 
between the two pipes will always resolve. In other words, I don't think this 
warrants special casing as there are plenty of other scenarios that trigger 
similar behavior that would be much harder to diagnose. 

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


[Lldb-commits] [lldb] [DRAFT][lldb][RPC] Design doc for upstreaming PR (PR #138612)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

This mainly adds as design doc to help follow with the current PRs up for 
upstreaming the `lldb-rpc-gen` tool and emitters.

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


1 Files Affected:

- (added) lldb/docs/rpc-design-doc.rst (+94) 


``diff
diff --git a/lldb/docs/rpc-design-doc.rst b/lldb/docs/rpc-design-doc.rst
new file mode 100644
index 0..97b51e1dd4854
--- /dev/null
+++ b/lldb/docs/rpc-design-doc.rst
@@ -0,0 +1,94 @@
+LLDB RPC Upstreaming Design Doc
+===
+
+This document aims to explain the general structure of the upstreaming patches 
for adding LLDB RPC. The 2 primary concepts explained here will be:
+
+* How LLDB RPC is used
+* How the ``lldb-rpc-gen`` works and what it outputs
+
+LLDB RPC
+*
+
+LLDB RPC is a framework by which processes can communicate with LLDB out of 
process while maintaining compatibility with the SB API. More details are 
explained in the 
`RFC`_ for 
upstreaming LLDB RPC, but the main focus in this doc for this section will be 
how exactly the code is structured for the PRs that will upstream this code.
+
+The ``lldb-rpc-gen`` tool
+*
+
+``lldb-rpc-gen`` is the tool that generates the main client and server 
interfaces for LLDB RPC. It is a ``ClangTool`` that reads all SB API header 
files and their functions and outputs the client/server interfaces and certain 
other pieces of code, such as RPC-specfic versions of Python bindings used for 
the test suite. There's 3 main components behind ``lldb-rpc-gen``:
+
+1. The ``lldb-rpc-gen`` tool itself, which contains the main driver that uses 
the ``ClangTool``.
+2. The code that generates all interfaces, which we call "emitters". All 
generated code for the interfaces are in C++, so the server side has one 
emitter for its generated source code and another for its generated header 
code. The client side has the same.
+3. All common code shared between all emitters, such as helper methods and 
information about exceptions to take when emitting.
+
+The `current PR`_ up for 
upstreaming LLDB RPC upstreams a subset of the code used for the tool. It 
upstreams the ``lldb-rpc-gen`` tool and all code needed for the server side 
emitters. Here's an example of what ``lldb-rpc-gen`` will output for the server 
side interface:
+
+Input
+-
+
+We'll use ``SBDebugger::CreateTarget(const char *filename)`` as an example. 
``lldb-rpc-gen`` will read this method from ``SBDebugger.h``. The output is as 
follows.
+
+Source Code Output
+--
+
+::
+
+   bool 
rpc_server::_ZN4lldb10SBDebugger12CreateTargetEPKc::HandleRPCCall(rpc_common::Connection
 &connection, RPCStream &send, RPCStream &response) {
+   // 1) Make local storage for incoming function arguments
+   lldb::SBDebugger *this_ptr = nullptr;
+   rpc_common::ConstCharPointer filename;
+   // 2) Decode all function arguments
+   this_ptr = RPCServerObjectDecoder(send, 
rpc_common::RPCPacket::ValueType::Argument);
+   if (!this_ptr)
+   return false;
+   if (!RPCValueDecoder(send, rpc_common::RPCPacket::ValueType::Argument, 
filename))
+   return false;
+   // 3) Call the method and encode the return value
+   lldb::SBTarget && __result = this_ptr->CreateTarget(filename.c_str());
+   RPCServerObjectEncoder(response, 
rpc_common::RPCPacket::ValueType::ReturnValue, std::move(__result));
+   return true;
+   }
+
+Function signature
+~~
+
+All server-side source code functions have a function signature that take the 
format ``bool 
rpc_serverHandleRPCCall(rpc_common::Connection 
&connection, RPCStream &send, RPCStream &response)``. Here the ``connection`` 
is what's maintained between the client and server. The ``send`` variable is a 
byte stream that carries information sent from the client. ``response`` is also 
a byte stream that will be populated with the return value obtained from the 
call into the SB API function that will be sent back to the client.
+
+Local variable storage
+~~
+
+First, variables are created to hold all arguments coming in from the client 
side. These variables will be a pointer for the SB API class in question, and 
corresponding variables for all parameters that the function has. Since this 
signature for ``SBDebugger::CreateTarget()`` only has one parameter, a ``const 
char *``, 2 local variables get created. A pointer for an ``SBDebugger`` 
object, and an ``RPCCommon::ConstCharPointer`` for the ``const char * 
filename`` parameter. The ``ConstCharPointer`` is a typedef over ``const char 
*`` in the main RPC core code.
+
+Incoming stream decoding
+
+
+Following this, ``RPCServerObjectDecoder`` is used to decode the ``send`` byte 
stream. In this case, we're decoding this strea

[Lldb-commits] [lldb] [DRAFT][lldb][RPC] Design doc for upstreaming PR (PR #138612)

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

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/138612

This mainly adds as design doc to help follow with the current PRs up for 
upstreaming the `lldb-rpc-gen` tool and emitters.



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Specify the executable path in the attach info (PR #138557)

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


@@ -161,7 +157,13 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
 dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
  error);
   } else {
-// Attach by process name or id.
+// Attach by pid or process name.
+lldb::SBAttachInfo attach_info;
+if (pid != LLDB_INVALID_PROCESS_ID)
+  attach_info.SetProcessID(pid);
+if (dap.configuration.program.has_value())

Jlalond wrote:

just a nit, but wouldn't an `if else` make sense here, because if we have the 
pid we don't even need to send the executable path in the attach info?

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


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-05-05 Thread David Peixotto via lldb-commits

dmpots wrote:

ping @clayborg @JDevlieghere @jimingham. I updated the PR to include plugin 
info in the stats. Please take a look when you get a chance. Thanks!



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


[Lldb-commits] [lldb] [lldb-dap] Specify the executable path in the attach info (PR #138557)

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

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

LGTM!

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


[Lldb-commits] [lldb] [lldb/docs] Fix/improve the gdb command map for dynamic types (PR #138538)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The setting and option value names were wrong. I'm assuming this changed over 
time, but I haven't tried to figure out when.

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


1 Files Affected:

- (modified) lldb/docs/use/map.rst (+12-4) 


``diff
diff --git a/lldb/docs/use/map.rst b/lldb/docs/use/map.rst
index ed285b2d1f6e9..c648b212006e0 100644
--- a/lldb/docs/use/map.rst
+++ b/lldb/docs/use/map.rst
@@ -800,16 +800,24 @@ Print the dynamic type of the result of an expression
   (gdb) p someCPPObjectPtrOrReference
   (Only works for C++ objects)
 
+LLDB does this automatically if determining the dynamic type does not require
+running the target (in C++, running the target is never needed). This default 
is
+controlled by the `target.prefer-dynamic-value` setting. If that is disabled, 
it
+can be re-enabled on a per-command basis:
+
 .. code-block:: shell
 
-  (lldb) expr -d 1 -- [SomeClass returnAnObject]
-  (lldb) expr -d 1 -- someCPPObjectPtrOrReference
+  (lldb) settings set target.prefer-dynamic-value no-dynamic-values
+  (lldb) frame variable -d no-run-target someCPPObjectPtrOrReference
+  (lldb) expr -d no-run-target -- someCPPObjectPtr
 
-or set dynamic type printing to be the default:
+Note that printing of the dynamic type of references is not possible with the
+`expr` command. The workaround is to take the address of the reference and
+instruct lldb to print the children of the resulting pointer.
 
 .. code-block:: shell
 
-  (lldb) settings set target.prefer-dynamic run-target
+  (lldb) expr -P1 -d no-run-target -- &someCPPObjectReference
 
 Call a function so you can stop at a breakpoint in it
 ~

``




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


[Lldb-commits] [lldb] [lldb/docs] Fix/improve the gdb command map for dynamic types (PR #138538)

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

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

The setting and option value names were wrong. I'm assuming this changed over 
time, but I haven't tried to figure out when.



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb/docs] Fix/improve the gdb command map for dynamic types (PR #138538)

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


@@ -800,16 +800,24 @@ Print the dynamic type of the result of an expression
   (gdb) p someCPPObjectPtrOrReference
   (Only works for C++ objects)
 
+LLDB does this automatically if determining the dynamic type does not require
+running the target (in C++, running the target is never needed). This default 
is
+controlled by the `target.prefer-dynamic-value` setting. If that is disabled, 
it
+can be re-enabled on a per-command basis:
+
 .. code-block:: shell
 
-  (lldb) expr -d 1 -- [SomeClass returnAnObject]
-  (lldb) expr -d 1 -- someCPPObjectPtrOrReference
+  (lldb) settings set target.prefer-dynamic-value no-dynamic-values
+  (lldb) frame variable -d no-run-target someCPPObjectPtrOrReference
+  (lldb) expr -d no-run-target -- someCPPObjectPtr
 
-or set dynamic type printing to be the default:
+Note that printing of the dynamic type of references is not possible with the
+`expr` command. The workaround is to take the address of the reference and
+instruct lldb to print the children of the resulting pointer.

labath wrote:

I spent some time trying to make this work, but I came to the conclusion that 
this would require a relatively big change in how the expression evaluator 
works. Because we're creating persistent copies of the expression result, it's 
not just a matter of getting something to recognise the dynamic type of the 
result -- we would actually need to determine the dynamic type of the object 
before we create the copy (so that we copy the entire object) -- and then I 
guess somehow reset the original (non-dynamic) ValueObject to point to the 
subobject of the result. And that might be too much work to put on the 
shoulders of the "use-dynamic" setting?

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


[Lldb-commits] [lldb] [lldb/docs] Fix/improve the gdb command map for dynamic types (PR #138538)

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


@@ -800,16 +800,24 @@ Print the dynamic type of the result of an expression
   (gdb) p someCPPObjectPtrOrReference
   (Only works for C++ objects)
 
+LLDB does this automatically if determining the dynamic type does not require
+running the target (in C++, running the target is never needed). This default 
is
+controlled by the `target.prefer-dynamic-value` setting. If that is disabled, 
it
+can be re-enabled on a per-command basis:
+
 .. code-block:: shell
 
-  (lldb) expr -d 1 -- [SomeClass returnAnObject]
-  (lldb) expr -d 1 -- someCPPObjectPtrOrReference
+  (lldb) settings set target.prefer-dynamic-value no-dynamic-values
+  (lldb) frame variable -d no-run-target someCPPObjectPtrOrReference
+  (lldb) expr -d no-run-target -- someCPPObjectPtr
 
-or set dynamic type printing to be the default:
+Note that printing of the dynamic type of references is not possible with the
+`expr` command. The workaround is to take the address of the reference and
+instruct lldb to print the children of the resulting pointer.

labath wrote:

(If you're wondering why we're making a copy of a reference -- but not of a 
pointer -- I suspect that's because in the expression evaluator we do not 
differentiate between an object and a reference to it. I suppose we could do 
it, and then somehow treat references as pointers, but I don't exactly know 
what would that entail.)

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


[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

JDevlieghere wrote:

> I see a comment in `TestDAP_attach.test_by_name` that mentions making the 
> path more unique, so I'm wondering if something else has changed or if that 
> previous attempt at making the name more unique was a little off the mark.

Excellent question. We are indeed only using the executable name for the 
attach. Note how the AttachRequestHandler isn't setting the path in the attach 
info. We only use the program to create the target, which means we go down this 
path in `Target::Attach`:

```
  // If no process info was specified, then use the target executable name as
  // the process to attach to by default
  if (!attach_info.ProcessInfoSpecified()) {
if (old_exec_module_sp)
  attach_info.GetExecutableFile().SetFilename(
old_exec_module_sp->GetPlatformFileSpec().GetFilename());
[...]

  }

```

I still think the unique test names are preferable over the old logic to change 
the directory, but we should fix this too. 

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


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

2025-05-05 Thread via lldb-commits

jimingham wrote:

> One thing I'm not sure about here: will converting array type to a pointer, 
> adding the index and then dereferencing work for Swift? I tried just doing 
> `base->GetChildAtIndex(index)`, but it doesn't work when the base is a 
> pointer and it also returns an error when index is out of bounds, which 
> shouldn't happen with C++.

Swift doesn't have pointers really.  It does pass some things by value (called 
structs) and others by reference (called classes), but it doesn't let you know 
how.  So this ambiguity between "pointer to object" and "pointer to contiguous 
buffer of objects" doesn't come up.

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


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

2025-05-05 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

> Swift doesn't have pointers really. It does pass some things by value (called 
> structs) and others by reference (called classes), but it doesn't let you 
> know how. So this ambiguity between "pointer to object" and "pointer to 
> contiguous buffer of objects" doesn't come up.

So what happens if I use `ArrayToPointerConversion` function I added on a Swift 
array?

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


[Lldb-commits] [lldb] [lldb-dap] Specify the executable path in the attach info (PR #138557)

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

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

Currently, we are only using the executable name when attaching. The 
AttachRequestHandler isn't setting the path in the attach info, which means 
that we rely on the target when attaching by name. When wo go down this path, 
we only look at the executable's filename, not its full path. Since we know the 
full path from the attach arguments, we should specify it in the attach info.

Fixes #138197



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)

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

JDevlieghere wrote:

https://github.com/llvm/llvm-project/pull/138557

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


[Lldb-commits] [lldb] [lldb-dap] Specify the executable path in the attach info (PR #138557)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Currently, we are only using the executable name when attaching. The 
AttachRequestHandler isn't setting the path in the attach info, which means 
that we rely on the target when attaching by name. When wo go down this path, 
we only look at the executable's filename, not its full path. Since we know the 
full path from the attach arguments, we should specify it in the attach info.

Fixes #138197

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp (+7-5) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index 7084d30f2625b..a509aa09a385c 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -49,7 +49,6 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
-  lldb::SBAttachInfo attach_info;
   const int invalid_port = 0;
   const auto *arguments = request.getObject("arguments");
   const lldb::pid_t pid =
@@ -58,10 +57,7 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   GetInteger(arguments, 
"gdb-remote-port").value_or(invalid_port);
   const auto gdb_remote_hostname =
   GetString(arguments, "gdb-remote-hostname").value_or("localhost");
-  if (pid != LLDB_INVALID_PROCESS_ID)
-attach_info.SetProcessID(pid);
   const auto wait_for = GetBoolean(arguments, "waitFor").value_or(false);
-  attach_info.SetWaitForLaunch(wait_for, false /*async*/);
   dap.configuration.initCommands = GetStrings(arguments, "initCommands");
   dap.configuration.preRunCommands = GetStrings(arguments, "preRunCommands");
   dap.configuration.postRunCommands = GetStrings(arguments, "postRunCommands");
@@ -161,7 +157,13 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
 dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
  error);
   } else {
-// Attach by process name or id.
+// Attach by pid or process name.
+lldb::SBAttachInfo attach_info;
+if (pid != LLDB_INVALID_PROCESS_ID)
+  attach_info.SetProcessID(pid);
+if (dap.configuration.program.has_value())
+  attach_info.SetExecutable(dap.configuration.program->data());
+attach_info.SetWaitForLaunch(wait_for, false /*async*/);
 dap.target.Attach(attach_info, error);
   }
 } else {

``




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


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

2025-05-05 Thread via lldb-commits

jimingham wrote:

> > Swift doesn't have pointers really. It does pass some things by value 
> > (called structs) and others by reference (called classes), but it doesn't 
> > let you know how. So this ambiguity between "pointer to object" and 
> > "pointer to contiguous buffer of objects" doesn't come up.
> 
> So what happens if I use `ArrayToPointerConversion` function I added on a 
> Swift array?

Swift has an out for dealing with pointers of classes (for instance to help 
pass objects back and forth between swift & C-based languages).  So asking for 
the pointer type for a class type doesn't get None (which you would expect for 
a language that doesn't have the notion of pointers.)  Instead you get 
`Swift.UnsafePointer`.  But that's a pointer to the swift 
object, not to some buffer containing the array objects.  I don't think 
indexing that will get what you want.

We probably need to ask the language "Are Arrays contiguous buffers of objects 
for you", and return an error from here if they are not.

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-dap] Specify the executable path in the attach info (PR #138557)

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

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

>From 8289d760034dc18315d116aaeddda9033ff1390a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 5 May 2025 10:18:12 -0700
Subject: [PATCH 1/2] [lldb-dap] Specify the executable path in the attach info

Currently, we are only using the executable name when attaching. The
AttachRequestHandler isn't setting the path in the attach info, which
means that we rely on the target when attaching by name. When wo go down
this path, we only look at the executable's filename, not its full path.
Since we know the full path from the attach arguments, we should specify
it in the attach info.

Fixes #138197
---
 lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index 7084d30f2625b..a509aa09a385c 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -49,7 +49,6 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
-  lldb::SBAttachInfo attach_info;
   const int invalid_port = 0;
   const auto *arguments = request.getObject("arguments");
   const lldb::pid_t pid =
@@ -58,10 +57,7 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   GetInteger(arguments, 
"gdb-remote-port").value_or(invalid_port);
   const auto gdb_remote_hostname =
   GetString(arguments, "gdb-remote-hostname").value_or("localhost");
-  if (pid != LLDB_INVALID_PROCESS_ID)
-attach_info.SetProcessID(pid);
   const auto wait_for = GetBoolean(arguments, "waitFor").value_or(false);
-  attach_info.SetWaitForLaunch(wait_for, false /*async*/);
   dap.configuration.initCommands = GetStrings(arguments, "initCommands");
   dap.configuration.preRunCommands = GetStrings(arguments, "preRunCommands");
   dap.configuration.postRunCommands = GetStrings(arguments, "postRunCommands");
@@ -161,7 +157,13 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
 dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
  error);
   } else {
-// Attach by process name or id.
+// Attach by pid or process name.
+lldb::SBAttachInfo attach_info;
+if (pid != LLDB_INVALID_PROCESS_ID)
+  attach_info.SetProcessID(pid);
+if (dap.configuration.program.has_value())
+  attach_info.SetExecutable(dap.configuration.program->data());
+attach_info.SetWaitForLaunch(wait_for, false /*async*/);
 dap.target.Attach(attach_info, error);
   }
 } else {

>From 67cf8207acca1856c05c84fd6d3b82efd1409483 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 5 May 2025 12:33:58 -0700
Subject: [PATCH 2/2] Address Jacob's feedback

---
 lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index a509aa09a385c..7a0f091128e4a 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -161,7 +161,7 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
 lldb::SBAttachInfo attach_info;
 if (pid != LLDB_INVALID_PROCESS_ID)
   attach_info.SetProcessID(pid);
-if (dap.configuration.program.has_value())
+else if (dap.configuration.program.has_value())
   attach_info.SetExecutable(dap.configuration.program->data());
 attach_info.SetWaitForLaunch(wait_for, false /*async*/);
 dap.target.Attach(attach_info, error);

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


[Lldb-commits] [lldb] 1ff2953 - Revert "Handle step-in over a Darwin "branch island". (#138330)" (#138569)

2025-05-05 Thread via lldb-commits

Author: jimingham
Date: 2025-05-05T12:45:17-07:00
New Revision: 1ff2953f5e393eb8634ea3c4ccc85221e76dfcb9

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

LOG: Revert "Handle step-in over a Darwin "branch island". (#138330)" (#138569)

This reverts commit 1ba89ad2c6e405bd5ac0c44e2ee5aa5504c7aba1.

This was failing on the Green Dragon bot, which has an older OS than
have on hand, so I'll have to dig up one and see why it's failing there.

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Removed: 
lldb/test/API/macosx/branch-islands/Makefile
lldb/test/API/macosx/branch-islands/TestBranchIslands.py
lldb/test/API/macosx/branch-islands/foo.c
lldb/test/API/macosx/branch-islands/main.c
lldb/test/API/macosx/branch-islands/padding1.s
lldb/test/API/macosx/branch-islands/padding2.s



diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 52c50cd88902a..e25c4ff55e408 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,7 +26,6 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -924,15 +923,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
-ConstString current_name =
-current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
+  ConstString trampoline_name =
+  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (current_name) {
+  if (trampoline_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -946,8 +945,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
-  reexported_symbols);
+images.FindSymbolsWithNameAndType(
+trampoline_name, eSymbolTypeReExported, reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -969,7 +968,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1029,18 +1028,6 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
-// One more case we have to consider is "branch islands".  These are 
regular
-// TEXT symbols but their names end in .island.  They are to allow arm64
-// code to branch further than the size of the address slot allows.  We
-// just need to single-instruction step in that case.
-if (!thread_plan_sp && current_name.GetStringRef().ends_with(".island")) {
-  thread_plan_sp = std::make_shared(
-  thread,
-  /* step_over= */ false, /* stop_others */ false, eVoteNoOpinion,
-  eVoteNoOpinion);
-  LLDB_LOG(log, "Stepping one instruction over branch island: '{0}'.",
-   current_name);
-}
   } else {
 LLDB_LOGF(log, "Could not find symbol for step through.");
   }

diff  --git a/lldb/test/API/macosx/branch-islands/Makefile 
b/lldb/test/API/macosx/branch-islands/Makefile
deleted file mode 100644
index 8675bbf6f85de..0
--- a/lldb/test/API/macosx/branch-islands/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-C_SOURCES := main.c foo.c
-CFLAGS_EXTRAS := -std=c99
-
-include Makefile.rules
-
-a.out: main.o padding1.o padding2.o foo.o
-   ${CC} ${LDFLAGS} foo.o padding1.o padding2.o main.o -o a.o

[Lldb-commits] [lldb] Revert "Handle step-in over a Darwin "branch island". (#138330)" (PR #138569)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

This reverts commit 1ba89ad2c6e405bd5ac0c44e2ee5aa5504c7aba1.

This was failing on the Green Dragon bot, which has an older OS than have on 
hand, so I'll have to dig up one and see why it's failing there.

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


7 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+7-20) 
- (removed) lldb/test/API/macosx/branch-islands/Makefile (-13) 
- (removed) lldb/test/API/macosx/branch-islands/TestBranchIslands.py (-35) 
- (removed) lldb/test/API/macosx/branch-islands/foo.c (-6) 
- (removed) lldb/test/API/macosx/branch-islands/main.c (-6) 
- (removed) lldb/test/API/macosx/branch-islands/padding1.s (-3) 
- (removed) lldb/test/API/macosx/branch-islands/padding2.s (-3) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 52c50cd88902a..e25c4ff55e408 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,7 +26,6 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -924,15 +923,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
-ConstString current_name =
-current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
+  ConstString trampoline_name =
+  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (current_name) {
+  if (trampoline_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -946,8 +945,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
-  reexported_symbols);
+images.FindSymbolsWithNameAndType(
+trampoline_name, eSymbolTypeReExported, reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -969,7 +968,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1029,18 +1028,6 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
-// One more case we have to consider is "branch islands".  These are 
regular
-// TEXT symbols but their names end in .island.  They are to allow arm64
-// code to branch further than the size of the address slot allows.  We
-// just need to single-instruction step in that case.
-if (!thread_plan_sp && current_name.GetStringRef().ends_with(".island")) {
-  thread_plan_sp = std::make_shared(
-  thread,
-  /* step_over= */ false, /* stop_others */ false, eVoteNoOpinion,
-  eVoteNoOpinion);
-  LLDB_LOG(log, "Stepping one instruction over branch island: '{0}'.",
-   current_name);
-}
   } else {
 LLDB_LOGF(log, "Could not find symbol for step through.");
   }
diff --git a/lldb/test/API/macosx/branch-islands/Makefile 
b/lldb/test/API/macosx/branch-islands/Makefile
deleted file mode 100644
index 8675bbf6f85de..0
--- a/lldb/test/API/macosx/branch-islands/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-C_SOURCES := main.c foo.c
-CFLAGS_EXTRAS := -std=c99
-
-include Makefile.rules
-
-a.out: main.o padding1.o padding2.o foo.o
-   ${CC} ${LDFLAGS} foo.o padding1.o padding2.o main.o -o a.out
-
-padding1.o: padding1.s
-   ${CC} -c $(SRCDIR)/padding1.s
-
-padding2.o: padding2.s
-   ${CC} -c $(SRCDIR)/padding2.s
diff --git a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py 
b

[Lldb-commits] [lldb] Revert "Handle step-in over a Darwin "branch island". (#138330)" (PR #138569)

2025-05-05 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/138569

This reverts commit 1ba89ad2c6e405bd5ac0c44e2ee5aa5504c7aba1.

This was failing on the Green Dragon bot, which has an older OS than have on 
hand, so I'll have to dig up one and see why it's failing there.



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] Revert "Handle step-in over a Darwin "branch island". (#138330)" (PR #138569)

2025-05-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] 9544943 - [lldb-dap] Specify the executable path in the attach info (#138557)

2025-05-05 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-05T13:34:29-07:00
New Revision: 9544943e2458597dc2cdcbed6de2a8d50da0d382

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

LOG: [lldb-dap] Specify the executable path in the attach info (#138557)

Currently, we are only using the executable name when attaching. The
AttachRequestHandler isn't setting the path in the attach info, which
means that we rely on the target when attaching by name. When wo go down
this path, we only look at the executable's filename, not its full path.
Since we know the full path from the attach arguments, we should specify
it in the attach info.

Fixes #138197

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index 7084d30f2625b..7a0f091128e4a 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -49,7 +49,6 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
-  lldb::SBAttachInfo attach_info;
   const int invalid_port = 0;
   const auto *arguments = request.getObject("arguments");
   const lldb::pid_t pid =
@@ -58,10 +57,7 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
   GetInteger(arguments, 
"gdb-remote-port").value_or(invalid_port);
   const auto gdb_remote_hostname =
   GetString(arguments, "gdb-remote-hostname").value_or("localhost");
-  if (pid != LLDB_INVALID_PROCESS_ID)
-attach_info.SetProcessID(pid);
   const auto wait_for = GetBoolean(arguments, "waitFor").value_or(false);
-  attach_info.SetWaitForLaunch(wait_for, false /*async*/);
   dap.configuration.initCommands = GetStrings(arguments, "initCommands");
   dap.configuration.preRunCommands = GetStrings(arguments, "preRunCommands");
   dap.configuration.postRunCommands = GetStrings(arguments, "postRunCommands");
@@ -161,7 +157,13 @@ void AttachRequestHandler::operator()(const 
llvm::json::Object &request) const {
 dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
  error);
   } else {
-// Attach by process name or id.
+// Attach by pid or process name.
+lldb::SBAttachInfo attach_info;
+if (pid != LLDB_INVALID_PROCESS_ID)
+  attach_info.SetProcessID(pid);
+else if (dap.configuration.program.has_value())
+  attach_info.SetExecutable(dap.configuration.program->data());
+attach_info.SetWaitForLaunch(wait_for, false /*async*/);
 dap.target.Attach(attach_info, error);
   }
 } else {



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


[Lldb-commits] [lldb] [lldb-dap] Specify the executable path in the attach info (PR #138557)

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

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


[Lldb-commits] [lldb] [LLDB] Add IsCoreDumping to ProcessInstanceInfo (PR #138580)

2025-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

This is the first useful patch in the series related to enabling `PTRACE_SEIZE` 
for processes Coredumping. In order to make the decision if we want to seize or 
attach, we need to expose that in processinfo.

We currently select a few entries from `/proc/pid/status`, and I now also 
extract CoreDumping.

Note that in status it is `CoreDumping` not `Coredumping`, so I kept with that, 
even if I prefer `Coredumping`

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


3 Files Affected:

- (modified) lldb/include/lldb/Utility/ProcessInfo.h (+6) 
- (modified) lldb/source/Host/linux/Host.cpp (+5) 
- (modified) lldb/unittests/Host/posix/HostTest.cpp (+3) 


``diff
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 78ade4bbb1ee6..24041faad80bf 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -247,6 +247,11 @@ class ProcessInstanceInfo : public ProcessInfo {
 
   std::optional IsZombie() const { return m_zombie; }
 
+  // proc/../status specifies CoreDumping as the field
+  // so we match the case here.
+  void SetIsCoreDumping(bool is_coredumping) { m_coredumping = is_coredumping; 
}
+  std::optional IsCoreDumping() const { return m_coredumping; }
+
   void Dump(Stream &s, UserIDResolver &resolver) const;
 
   static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
@@ -266,6 +271,7 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_cumulative_system_time;
   std::optional m_priority_value = std::nullopt;
   std::optional m_zombie = std::nullopt;
+  std::optional m_coredumping = std::nullopt;
 };
 
 typedef std::vector ProcessInstanceInfoList;
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 8b475a7ab5003..2e2d4fdd84097 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -213,6 +213,11 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
 } else if (Line.consume_front("Tgid:")) {
   Line = Line.ltrim();
   Line.consumeInteger(10, Tgid);
+} else if (Line.consume_front("CoreDumping:")) {
+  uint32_t coredumping;
+  Line = Line.ltrim();
+  Line.consumeInteger(1, coredumping);
+  ProcessInfo.SetIsCoreDumping(coredumping);
 }
   }
   return true;
diff --git a/lldb/unittests/Host/posix/HostTest.cpp 
b/lldb/unittests/Host/posix/HostTest.cpp
index 5d50de3524d1e..082edccf4e774 100644
--- a/lldb/unittests/Host/posix/HostTest.cpp
+++ b/lldb/unittests/Host/posix/HostTest.cpp
@@ -115,5 +115,8 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
   }
   ASSERT_TRUE(Info.IsZombie().has_value());
   ASSERT_FALSE(Info.IsZombie().value());
+
+  ASSERT_TRUE(Info.IsCoreDumping().has_value());
+  ASSERT_FALSE(Info.IsCoreDumping().value());
 }
 #endif

``




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


[Lldb-commits] [lldb] [LLDB] Add IsCoreDumping to ProcessInstanceInfo (PR #138580)

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

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/138580

This is the first useful patch in the series related to enabling `PTRACE_SEIZE` 
for processes Coredumping. In order to make the decision if we want to seize or 
attach, we need to expose that in processinfo.

We currently select a few entries from `/proc/pid/status`, and I now also 
extract CoreDumping.

Note that in status it is `CoreDumping` not `Coredumping`, so I kept with that, 
even if I prefer `Coredumping`

>From 03d5449b30f414e2a3f322f102101dc4b2c05c4f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 5 May 2025 11:33:05 -0700
Subject: [PATCH 1/2] Add IsCoredumping to ProcessInfo to use in the future of
 the ptrace_seize code

---
 lldb/include/lldb/Utility/ProcessInfo.h | 6 ++
 lldb/source/Host/linux/Host.cpp | 5 +
 2 files changed, 11 insertions(+)

diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 78ade4bbb1ee6..24041faad80bf 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -247,6 +247,11 @@ class ProcessInstanceInfo : public ProcessInfo {
 
   std::optional IsZombie() const { return m_zombie; }
 
+  // proc/../status specifies CoreDumping as the field
+  // so we match the case here.
+  void SetIsCoreDumping(bool is_coredumping) { m_coredumping = is_coredumping; 
}
+  std::optional IsCoreDumping() const { return m_coredumping; }
+
   void Dump(Stream &s, UserIDResolver &resolver) const;
 
   static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
@@ -266,6 +271,7 @@ class ProcessInstanceInfo : public ProcessInfo {
   struct timespec m_cumulative_system_time;
   std::optional m_priority_value = std::nullopt;
   std::optional m_zombie = std::nullopt;
+  std::optional m_coredumping = std::nullopt;
 };
 
 typedef std::vector ProcessInstanceInfoList;
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 8b475a7ab5003..97e8024da6c07 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -213,6 +213,11 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
 } else if (Line.consume_front("Tgid:")) {
   Line = Line.ltrim();
   Line.consumeInteger(10, Tgid);
+} else if (Line.consume_front("CoreDumping:")) {
+  uint32_t coredumping;
+  Line = Line.ltrim();
+  Line.consumeInteger(1, coredumping);
+  ProcessInfo.SetIsCoredumping(coredumping);
 }
   }
   return true;

>From 7e2b11ff8d63260d34ff63e9eeb2d519d887742c Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 5 May 2025 13:18:31 -0700
Subject: [PATCH 2/2] Add test

---
 lldb/source/Host/linux/Host.cpp| 2 +-
 lldb/unittests/Host/posix/HostTest.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index 97e8024da6c07..2e2d4fdd84097 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -217,7 +217,7 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo 
&ProcessInfo,
   uint32_t coredumping;
   Line = Line.ltrim();
   Line.consumeInteger(1, coredumping);
-  ProcessInfo.SetIsCoredumping(coredumping);
+  ProcessInfo.SetIsCoreDumping(coredumping);
 }
   }
   return true;
diff --git a/lldb/unittests/Host/posix/HostTest.cpp 
b/lldb/unittests/Host/posix/HostTest.cpp
index 5d50de3524d1e..082edccf4e774 100644
--- a/lldb/unittests/Host/posix/HostTest.cpp
+++ b/lldb/unittests/Host/posix/HostTest.cpp
@@ -115,5 +115,8 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
   }
   ASSERT_TRUE(Info.IsZombie().has_value());
   ASSERT_FALSE(Info.IsZombie().value());
+
+  ASSERT_TRUE(Info.IsCoreDumping().has_value());
+  ASSERT_FALSE(Info.IsCoreDumping().value());
 }
 #endif

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


[Lldb-commits] [lldb] [LLDB] Add IsCoreDumping to ProcessInstanceInfo (PR #138580)

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

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

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

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



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

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

Jlalond wrote:

Updated the tests to skip on Windows. It would otherwise fail there.

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


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

2025-05-05 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

One thing I'm not sure about here: will converting array type to a pointer, 
adding the index and then dereferencing work for Swift?
I tried just doing `base->GetChildAtIndex(index)`, but it doesn't work when the 
base is a pointer and it also returns an error when index is out of bounds, 
which shouldn't happen with C++. 

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


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

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

labath wrote:

> One thing I'm not sure about here: will converting array type to a pointer, 
> adding the index and then dereferencing work for Swift? I tried just doing 
> `base->GetChildAtIndex(index)`, but it doesn't work when the base is a 
> pointer and it also returns an error when index is out of bounds, which 
> shouldn't happen with C++.

I don't have an answer to that, but I do know that it's possible to index 
pointers in the current implementation. I suggest checking out how it achieves 
that and seeing if it can be translated to here.

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


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

2025-05-05 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

> I don't have an answer to that, but I do know that it's possible to index 
> pointers in the current implementation. I suggest checking out how it 
> achieves that and seeing if it can be translated to here.

Ah, I will look into this further, thanks.

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] 1ba89ad - Handle step-in over a Darwin "branch island". (#138330)

2025-05-05 Thread via lldb-commits

Author: jimingham
Date: 2025-05-05T09:55:32-07:00
New Revision: 1ba89ad2c6e405bd5ac0c44e2ee5aa5504c7aba1

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

LOG: Handle step-in over a Darwin "branch island". (#138330)

Added: 
lldb/test/API/macosx/branch-islands/Makefile
lldb/test/API/macosx/branch-islands/TestBranchIslands.py
lldb/test/API/macosx/branch-islands/foo.c
lldb/test/API/macosx/branch-islands/main.c
lldb/test/API/macosx/branch-islands/padding1.s
lldb/test/API/macosx/branch-islands/padding2.s

Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index e25c4ff55e408..52c50cd88902a 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,6 +26,7 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -923,15 +924,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
+ConstString current_name =
+current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
-  ConstString trampoline_name =
-  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (trampoline_name) {
+  if (current_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -945,8 +946,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(
-trampoline_name, eSymbolTypeReExported, reexported_symbols);
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
+  reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -968,7 +969,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1028,6 +1029,18 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
+// One more case we have to consider is "branch islands".  These are 
regular
+// TEXT symbols but their names end in .island.  They are to allow arm64
+// code to branch further than the size of the address slot allows.  We
+// just need to single-instruction step in that case.
+if (!thread_plan_sp && current_name.GetStringRef().ends_with(".island")) {
+  thread_plan_sp = std::make_shared(
+  thread,
+  /* step_over= */ false, /* stop_others */ false, eVoteNoOpinion,
+  eVoteNoOpinion);
+  LLDB_LOG(log, "Stepping one instruction over branch island: '{0}'.",
+   current_name);
+}
   } else {
 LLDB_LOGF(log, "Could not find symbol for step through.");
   }

diff  --git a/lldb/test/API/macosx/branch-islands/Makefile 
b/lldb/test/API/macosx/branch-islands/Makefile
new file mode 100644
index 0..8675bbf6f85de
--- /dev/null
+++ b/lldb/test/API/macosx/branch-islands/Makefile
@@ -0,0 +1,13 @@
+C_SOURCES := main.c foo.c
+CFLAGS_EXTRAS := -std=c99
+
+include Makefile.rules
+
+a.out: main.o padding1.o padding2.o foo.o
+   ${CC} ${LDFLAGS} foo.o padding1.o padding2.o main.o -o a.out
+
+padding1.o: padding1.s
+   ${CC} -c $(SRCDIR)/padding1.s
+
+padding2.o: padding2.s
+   ${CC} -c $(SRCDIR)/padding2.s

diff  --git a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py 
b/lldb/test/API/macosx/br

[Lldb-commits] [lldb] Handle step-in over a Darwin "branch island". (PR #138330)

2025-05-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Upstream lldb-rpc-gen and LLDB RPC server-side emitters (PR #136748)

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


@@ -0,0 +1,535 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// FIXME: We should be able to annotate these methods instead of maintaining a
+// list in the generator itself.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",

chelcassanova wrote:

I believe that the mangling should be stable on platforms using Clang. Since 
this is a ClangTool itself, I'm actually currently unsure as to how this would 
compile using GCC.

By the way, we can continue this line of discussion on one of the smaller 
patches I put up to upstream this tool and its shared common code: 
https://github.com/llvm/llvm-project/pull/138031

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