[Lldb-commits] [lldb] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (PR #70054)

2023-10-25 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> Please make sure there is a test that exercises this behavior in your 
> follow-up.

This fixes a crash when trying to use cpsr field info with a core file, so this 
will be covered in those tests later.

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


[Lldb-commits] [lldb] a770098 - [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (#70054)

2023-10-25 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-25T09:08:01+01:00
New Revision: a7700985577694d6cc2498833f27b4fb5eeaf252

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

LOG: [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core 
files (#70054)

As ReadRegister always read into a uint64_t, when it called operator=
with uint64_t it was setting the RegisterValue's type to eTypeUInt64
regardless of its size.

This mostly works because most registers are 64 bit, and very few bits
of code rely on the type being correct. However, cpsr, fpsr and fpcr are
in fact 32 bit, and my upcoming register fields code relies on this type
being correct.

Which is how I found this bug and unfortunately is the only way to test
it. As RegisterValue::Type never makes it out via the API anywhere. So
this change will be tested once I start adding register field
information.

Added: 


Modified: 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 6f6c6d073939a61..f3e763b0475ceb1 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -184,11 +184,9 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 
   offset = reg_info->byte_offset;
   if (offset + reg_info->byte_size <= GetGPRSize()) {
-uint64_t v = m_gpr_data.GetMaxU64(&offset, reg_info->byte_size);
-if (offset == reg_info->byte_offset + reg_info->byte_size) {
-  value = v;
-  return true;
-}
+value.SetFromMemoryData(*reg_info, m_gpr_data.GetDataStart() + offset,
+reg_info->byte_size, lldb::eByteOrderLittle, 
error);
+return error.Success();
   }
 
   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];



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


[Lldb-commits] [lldb] [lldb][AArch64] Correct type of 32 bit GPR RegisterValues when using core files (PR #70054)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] f2c09e5 - [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (#66768)

2023-10-25 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-25T09:16:58+01:00
New Revision: f2c09e5e16d592303b5a1c158cdef28ef08104f0

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

LOG: [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (#66768)

This fixes a bug where writing vg during streaming mode
could prevent you reading za directly afterwards.

vg is invalidated just prior to us reading it in AArch64Reconfigure,
but svg was not. This lead to some situations where vg would be
updated or cleared and re-read, but svg would not be.

This meant it had some undefined value which lead to errors
that prevented us reading ZA. Likely we received a lot more
data than we were expecting.

There are at least 2 ways to get into this situation:
* Explicit write by the user to vg.
* We have just stopped and need to get the potentially new svg and vg.

The first is handled by invalidating svg client side before fetching the
new one. This also
covers some but not all of the second scenario. For the second, I've
made writes to vg
invalidate svg by noting this in the register information.

Whichever one of those kicks in, we'll get the latest value of svg.

The bug may depend on timing, I could not find a consistent way
to trigger it. I originally found it when checking whether za
is disabled after a vg change, so I've added checks for that
to TestZAThreadedDynamic.

The SVE VG version of the bug did show up on the buildbot,
but not consistently. So it's possible that TestZAThreadedDynamic
does in fact cover this, but I haven't run it enough times to know.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index 60070819cb92699..e6e6c12d0404aed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -374,6 +374,17 @@ void RegisterInfoPOSIX_arm64::AddRegSetSME() {
   std::make_pair(sme_regnum, m_dynamic_reg_infos.size());
   m_dynamic_reg_sets.push_back(g_reg_set_sme_arm64);
   m_dynamic_reg_sets.back().registers = m_sme_regnum_collection.data();
+
+  // When vg is written during streaming mode, svg will also change, as vg and
+  // svg in this state are both showing the streaming vector length.
+  // We model this as vg invalidating svg. In non-streaming mode this doesn't
+  // happen but to keep things simple we will invalidate svg anyway.
+  //
+  // This must be added now, rather than when vg is defined because SME is a
+  // dynamic set that may or may not be present.
+  static const uint32_t vg_invalidates[] = {sme_regnum + 1 /*svg*/,
+LLDB_INVALID_REGNUM};
+  m_dynamic_reg_infos[GetRegNumSMESVG()].invalidate_regs = vg_invalidates;
 }
 
 uint32_t RegisterInfoPOSIX_arm64::ConfigureVectorLengthSVE(uint32_t sve_vq) {

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index b127d3d6213a4aa..72280927471f883 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -783,6 +783,11 @@ void GDBRemoteRegisterContext::AArch64Reconfigure() {
   std::optional svg_reg_value;
   const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
   if (svg_reg_info) {
+// When vg is written it is automatically made invalid. Writing vg will 
also
+// change svg if we're in streaming mode but it will not be made invalid
+// so do this manually so the following read gets the latest svg value.
+SetRegisterIsValid(svg_reg_info, false);
+
 uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
 uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
 if (reg_value != fail_value && reg_value <= 32)

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
index 65d1071c26b2a34..d2a26ce71bde1d8 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -125,11 +125,13 @@ def za_test_impl(self, enable_za):

[Lldb-commits] [lldb] [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (PR #66768)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] 8d80a45 - Revert "[lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (#66768)"

2023-10-25 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-25T08:27:27Z
New Revision: 8d80a452b841a211e0f3bce01a01c9a015d287f3

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

LOG: Revert "[lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef 
(#66768)"

This reverts commit f2c09e5e16d592303b5a1c158cdef28ef08104f0, due to compilation
failures on buildbots.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index e6e6c12d0404aed..60070819cb92699 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -374,17 +374,6 @@ void RegisterInfoPOSIX_arm64::AddRegSetSME() {
   std::make_pair(sme_regnum, m_dynamic_reg_infos.size());
   m_dynamic_reg_sets.push_back(g_reg_set_sme_arm64);
   m_dynamic_reg_sets.back().registers = m_sme_regnum_collection.data();
-
-  // When vg is written during streaming mode, svg will also change, as vg and
-  // svg in this state are both showing the streaming vector length.
-  // We model this as vg invalidating svg. In non-streaming mode this doesn't
-  // happen but to keep things simple we will invalidate svg anyway.
-  //
-  // This must be added now, rather than when vg is defined because SME is a
-  // dynamic set that may or may not be present.
-  static const uint32_t vg_invalidates[] = {sme_regnum + 1 /*svg*/,
-LLDB_INVALID_REGNUM};
-  m_dynamic_reg_infos[GetRegNumSMESVG()].invalidate_regs = vg_invalidates;
 }
 
 uint32_t RegisterInfoPOSIX_arm64::ConfigureVectorLengthSVE(uint32_t sve_vq) {

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 72280927471f883..b127d3d6213a4aa 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -783,11 +783,6 @@ void GDBRemoteRegisterContext::AArch64Reconfigure() {
   std::optional svg_reg_value;
   const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
   if (svg_reg_info) {
-// When vg is written it is automatically made invalid. Writing vg will 
also
-// change svg if we're in streaming mode but it will not be made invalid
-// so do this manually so the following read gets the latest svg value.
-SetRegisterIsValid(svg_reg_info, false);
-
 uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
 uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
 if (reg_value != fail_value && reg_value <= 32)

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
index d2a26ce71bde1d8..65d1071c26b2a34 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -125,13 +125,11 @@ def za_test_impl(self, enable_za):
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(4, 2)
 self.runCmd("register write vg 2")
-self.check_disabled_za_register(2)
 
 elif stopped_at_line_number == thY_break_line1:
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(2, 3)
 self.runCmd("register write vg 4")
-self.check_disabled_za_register(4)
 
 self.runCmd("thread continue 2")
 self.runCmd("thread continue 3")



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


[Lldb-commits] [lldb] [mlir][LLVM] Verify too many indices in GEP verifier (PR #70174)

2023-10-25 Thread Markus Böck via lldb-commits

https://github.com/zero9178 updated 
https://github.com/llvm/llvm-project/pull/70174

From 03fb7aceae81227c3a64cf4b9ba1e53a69e46511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20B=C3=B6ck?= 
Date: Wed, 25 Oct 2023 09:54:16 +0200
Subject: [PATCH 1/3] [mlir][LLVM] Verify too many indices in GEP verifier

The current verifier stopped verification with a success value as soon as a 
type was encountered that cannot be indexed into. The correct behaviour in this 
case is to error out as there are too many indices for the element type. Not 
doing so leads to bad user-experience as an invalid GEP is likely to fail only 
later during LLVM IR translation.

This PR implements the correct verification behaviour. Some tests upstream had 
to also be fixed as they were creating invalid GEPs.

Fixes https://github.com/llvm/llvm-project/issues/70168
---
 mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp| 69 ---
 mlir/test/Dialect/LLVMIR/invalid.mlir |  8 +++
 mlir/test/Dialect/LLVMIR/mem2reg.mlir |  9 ++-
 .../LLVMIR/roundtrip-typed-pointers.mlir  |  4 +-
 mlir/test/Dialect/LLVMIR/roundtrip.mlir   |  4 +-
 5 files changed, 60 insertions(+), 34 deletions(-)

diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 95c04098d05fc2f..70045d028cc3214 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -704,50 +704,72 @@ struct GEPStaticIndexError
<< "to be constant";
   }
 };
+
+/// llvm::Error for non-static GEP index indexing a struct.
+struct GEPCannotIndexError
+: public llvm::ErrorInfo {
+  static char ID;
+
+  using ErrorInfo::ErrorInfo;
+
+  void log(llvm::raw_ostream &os) const override {
+os << "expected index " << indexPos << " indexing a struct "
+   << "to be constant";
+  }
+};
+
 } // end anonymous namespace
 
 char GEPIndexError::ID = 0;
 char GEPIndexOutOfBoundError::ID = 0;
 char GEPStaticIndexError::ID = 0;
-
-/// For the given `structIndices` and `indices`, check if they're complied
-/// with `baseGEPType`, especially check against LLVMStructTypes nested within.
-static llvm::Error verifyStructIndices(Type baseGEPType, unsigned indexPos,
-   GEPIndicesAdaptor indices) {
+char GEPCannotIndexError::ID = 0;
+
+/// For the given `indices`, check if they comply with `baseGEPType`,
+// especially check against LLVMStructTypes nested within.
+static LogicalResult
+verifyStructIndices(Type baseGEPType, unsigned indexPos,
+GEPIndicesAdaptor indices,
+function_ref emitOpError) {
   if (indexPos >= indices.size())
 // Stop searching
-return llvm::Error::success();
+return success();
 
-  return llvm::TypeSwitch(baseGEPType)
-  .Case([&](LLVMStructType structType) -> llvm::Error {
+  return llvm::TypeSwitch(baseGEPType)
+  .Case([&](LLVMStructType structType) -> LogicalResult {
 if (!indices[indexPos].is())
-  return llvm::make_error(indexPos);
+  return emitOpError() << "expected index " << indexPos
+   << " indexing a struct to be constant";
 
 int32_t gepIndex = indices[indexPos].get().getInt();
 ArrayRef elementTypes = structType.getBody();
 if (gepIndex < 0 ||
 static_cast(gepIndex) >= elementTypes.size())
-  return llvm::make_error(indexPos);
+  return emitOpError() << "index " << indexPos
+   << " indexing a struct is out of bounds";
 
 // Instead of recursively going into every children types, we only
 // dive into the one indexed by gepIndex.
 return verifyStructIndices(elementTypes[gepIndex], indexPos + 1,
-   indices);
+   indices, emitOpError);
   })
   .Case([&](auto containerType) -> llvm::Error {
+LLVMArrayType>([&](auto containerType) -> LogicalResult {
 return verifyStructIndices(containerType.getElementType(), indexPos + 
1,
-   indices);
+   indices, emitOpError);
   })
-  .Default(
-  [](auto otherType) -> llvm::Error { return llvm::Error::success(); 
});
+  .Default([&](auto otherType) -> LogicalResult {
+return emitOpError()
+   << "type " << otherType << " cannot be indexed (index #"
+   << indexPos << ")";
+  });
 }
 
-/// Driver function around `recordStructIndices`. Note that we always check
-/// from the second GEP index since the first one is always dynamic.
-static llvm::Error verifyStructIndices(Type baseGEPType,
-   GEPIndicesAdaptor indices) {
-  return verifyStructIndices(baseGEPType, /*indexPos=*/1, indices);
+/// Driver function around `verifyStructIndices`.
+static LogicalResult
+verifyStructIndices(Type baseGEPType, GEPIndicesAd

[Lldb-commits] [lldb] 1d10369 - Reland "[lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef (#66768)""

2023-10-25 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-25T08:40:17Z
New Revision: 1d10369f534a1d8e83c847a2be86a252078f653c

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

LOG: Reland "[lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef 
(#66768)""

This reverts commit 8d80a452b841a211e0f3bce01a01c9a015d287f3.

The pointer to the invalidates lists needs to be non-const. Though in this case
I don't think it's ever modified.

Also I realised that the invalidate list was being set on svg not vg.
Should be the other way around.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index 60070819cb92699..20ce4df3027acf1 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -374,6 +374,17 @@ void RegisterInfoPOSIX_arm64::AddRegSetSME() {
   std::make_pair(sme_regnum, m_dynamic_reg_infos.size());
   m_dynamic_reg_sets.push_back(g_reg_set_sme_arm64);
   m_dynamic_reg_sets.back().registers = m_sme_regnum_collection.data();
+
+  // When vg is written during streaming mode, svg will also change, as vg and
+  // svg in this state are both showing the streaming vector length.
+  // We model this as vg invalidating svg. In non-streaming mode this doesn't
+  // happen but to keep things simple we will invalidate svg anyway.
+  //
+  // This must be added now, rather than when vg is defined because SME is a
+  // dynamic set that may or may not be present.
+  static uint32_t vg_invalidates[] = {sme_regnum + 1 /*svg*/,
+  LLDB_INVALID_REGNUM};
+  m_dynamic_reg_infos[GetRegNumSVEVG()].invalidate_regs = vg_invalidates;
 }
 
 uint32_t RegisterInfoPOSIX_arm64::ConfigureVectorLengthSVE(uint32_t sve_vq) {

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index b127d3d6213a4aa..72280927471f883 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -783,6 +783,11 @@ void GDBRemoteRegisterContext::AArch64Reconfigure() {
   std::optional svg_reg_value;
   const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
   if (svg_reg_info) {
+// When vg is written it is automatically made invalid. Writing vg will 
also
+// change svg if we're in streaming mode but it will not be made invalid
+// so do this manually so the following read gets the latest svg value.
+SetRegisterIsValid(svg_reg_info, false);
+
 uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
 uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
 if (reg_value != fail_value && reg_value <= 32)

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
index 65d1071c26b2a34..d2a26ce71bde1d8 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -125,11 +125,13 @@ def za_test_impl(self, enable_za):
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(4, 2)
 self.runCmd("register write vg 2")
+self.check_disabled_za_register(2)
 
 elif stopped_at_line_number == thY_break_line1:
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(2, 3)
 self.runCmd("register write vg 4")
+self.check_disabled_za_register(4)
 
 self.runCmd("thread continue 2")
 self.runCmd("thread continue 3")



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


[Lldb-commits] [lldb] d8abce1 - [lldb][AArch64] Read mte_ctrl register from core files (#69689)

2023-10-25 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-25T09:54:34+01:00
New Revision: d8abce1181cf089ef1161aad97072b1e53c1e941

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

LOG: [lldb][AArch64] Read mte_ctrl register from core files (#69689)

This register reports the configuration of the AArch64 Linux tagged
address ABI, part of which is the memory tagging (MTE) settings.

It will always be present in core files because even without MTE, there
are parts of the tagged address ABI that can be configured (these parts
use the Top Byte Ignore feature).

I missed adding this when I previously worked on MTE support. Until now
you could read memory tags from a core file but not this register.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
lldb/source/Plugins/Process/elf-core/RegisterUtilities.h

lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
index b57538e185f71fa..50e25568f2ae012 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
@@ -55,6 +55,10 @@ bool RegisterContextPOSIX_arm64::IsTLS(unsigned reg) const {
   return m_register_info_up->IsTLSReg(reg);
 }
 
+bool RegisterContextPOSIX_arm64::IsMTE(unsigned reg) const {
+  return m_register_info_up->IsMTEReg(reg);
+}
+
 RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64(
 lldb_private::Thread &thread,
 std::unique_ptr register_info)

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index aad95f33735f178..b1226b25b4be107 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -57,6 +57,7 @@ class RegisterContextPOSIX_arm64 : public 
lldb_private::RegisterContext {
   bool IsPAuth(unsigned reg) const;
   bool IsTLS(unsigned reg) const;
   bool IsSME(unsigned reg) const;
+  bool IsMTE(unsigned reg) const;
 
   bool IsSVEZ(unsigned reg) const { return m_register_info_up->IsSVEZReg(reg); 
}
   bool IsSVEP(unsigned reg) const { return m_register_info_up->IsSVEPReg(reg); 
}

diff  --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index f3e763b0475ceb1..99cee83eed12515 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -50,6 +50,10 @@ RegisterContextCorePOSIX_arm64::Create(Thread &thread, const 
ArchSpec &arch,
   if (za_data.GetByteSize() >= sizeof(sve::user_za_header))
 opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskZA);
 
+  DataExtractor mte_data = getRegset(notes, arch.GetTriple(), 
AARCH64_MTE_Desc);
+  if (mte_data.GetByteSize() >= sizeof(uint64_t))
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskMTE);
+
   auto register_info_up =
   std::make_unique(arch, opt_regsets);
   return std::unique_ptr(
@@ -91,6 +95,9 @@ 
RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
   if (m_register_info_up->IsZAEnabled())
 m_za_data = getRegset(notes, target_triple, AARCH64_ZA_Desc);
 
+  if (m_register_info_up->IsMTEEnabled())
+m_mte_data = getRegset(notes, target_triple, AARCH64_MTE_Desc);
+
   ConfigureRegisterContext();
 }
 
@@ -280,6 +287,11 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 assert(offset < m_tls_data.GetByteSize());
 value.SetFromMemoryData(*reg_info, m_tls_data.GetDataStart() + offset,
 reg_info->byte_size, lldb::eByteOrderLittle, 
error);
+  } else if (IsMTE(reg)) {
+offset = reg_info->byte_offset - m_register_info_up->GetMTEOffset();
+assert(offset < m_mte_data.GetByteSize());
+value.SetFromMemoryData(*reg_info, m_mte_data.GetDataStart() + offset,
+reg_info->byte_size, lldb::eByteOrderLittle, 
error);
   } else if (IsSME(reg)) {
 // If you had SME in the process, active or otherwise, there will at least
 // be a ZA header. No header, no SME at all.

diff  --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h 
b/lldb/source/Plugins/Process/elf-core

[Lldb-commits] [lldb] [lldb][AArch64] Read mte_ctrl register from core files (PR #69689)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] e7012ba - [lldb][AArch64] Add isAArch64SMEFA64 check to SME testing (#68094)

2023-10-25 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-25T09:56:00+01:00
New Revision: e7012ba8d36f8a38ab58edccf7267f12266218ab

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

LOG: [lldb][AArch64] Add isAArch64SMEFA64 check to SME testing (#68094)

FEAT_SME_FA64 (smefa64 in Linux cpuinfo) allows the use of the full A64
instruction set while in streaming SVE mode.

See https://developer.arm.com/documentation/ddi0616/latest/ for details.

This means for example if we want to write to the ffr register during or
use floating point registers while in streaming mode, we need this
extension.

I initially was using QEMU which has it by default, and switched to
Arm's FVP which does not. So this change adds a more strict check and
converts most of the tests to use that. It would be possible in some
cases to avoid the offending instructions but it would be a lot of
effort and liable to fail randomly as the C library changes.

It is also my assumption that the majority of systems will have smefa64
as QEMU has chosen to have. If I turn out to be wrong, we can make the
effort to get the tests working without smefa64.

`isAArch64SME` remains for some tests, which are as follows:
* `test_aarch64_dynamic_regset_config` merely checks for the presence of
a register set, which appears for any SME system not just one with
smefa64.
* `test_aarch64_dynamic_regset_config_sme_za_disabled` only needs the ZA
register and does not enter streaming mode.
* `test_sme_not_present` tests for the absence of the SME register set,
so must be skipped if any form of SME is present.
* Various tests in `TestSVERegisters.py` need to know if SME is present
at all to generate an expected SVCR value. Earlier in the callstack
something else checked `isAArch64SMEFA64` already.
* `TestAArch64LinuxTLSRegisters.py` needs to test the `tpidr2` register
if any form of SME is present. msr/mrs instructions are used to do this
and are allowed even if smefa64 is not present.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py

lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c

lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 6d736a56ecb89bf..af8d24efc4f807e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1271,6 +1271,14 @@ def isAArch64SVE(self):
 def isAArch64SME(self):
 return self.isAArch64() and "sme" in self.getCPUInfo()
 
+def isAArch64SMEFA64(self):
+# smefa64 allows the use of the full A64 instruction set in streaming
+# mode. This is required by certain test programs to setup register
+# state.
+return self.isAArch64SME() and set(["sme", "smefa64"]).issuperset(
+set(self.getCPUInfo())
+)
+
 def isAArch64MTE(self):
 return self.isAArch64() and "mte" in self.getCPUInfo()
 

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
 
b/lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
index 2fb8b33126417c2..0ad69c268a9fd29 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -142,8 +142,8 @@ def make_za_value(self, vl, generator):
 def test_aarch64_dynamic_regset_config_sme(self):
 """Test AArch64 Dynamic Register sets configuration, but only SME
 registers."""
-if not self.isAArch64SME():
-self.skipTest("SME must be present.")
+if not self.isAArch64SMEFA64():
+self.skipTest("SME and the smefa64 extension must be present")
 
 register_sets = self.setup_register_config_test("sme")
 

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
 
b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynam

[Lldb-commits] [lldb] [lldb][AArch64] Add isAArch64SMEFA64 check to SME testing (PR #68094)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/69951

>From 5c8b9538e1e5646f19d5bb40ab19afaf2c68e804 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 9 Oct 2023 10:33:08 +0100
Subject: [PATCH 1/6] [lldb][lldb-server] Enable sending registerflags as XML

This adds ToXML methods to encode RegisterFlags and its fields
into XML according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML,
so this follows the existing code that uses strings. Indentation
is used so the result is still human readable.

```

  

```

This is used by lldb-server when building target XML,
though no one sets any fields yet. That'll come in a later commit.
---
 lldb/include/lldb/Target/RegisterFlags.h  |  8 +
 .../GDBRemoteCommunicationServerLLGS.cpp  | 10 ++
 lldb/source/Target/RegisterFlags.cpp  | 32 +++
 lldb/unittests/Target/RegisterFlagsTest.cpp   | 32 +++
 4 files changed, 82 insertions(+)

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index d98bc0263e35e23..4edbe7255f621e5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
 
 namespace lldb_private {
 
@@ -51,6 +52,10 @@ class RegisterFlags {
 /// covered by either field.
 unsigned PaddingDistance(const Field &other) const;
 
+/// Output XML that describes this field, to be inserted into a target XML
+/// file.
+void ToXML(StreamString &strm) const;
+
 bool operator<(const Field &rhs) const {
   return GetStart() < rhs.GetStart();
 }
@@ -106,6 +111,9 @@ class RegisterFlags {
   /// be split into many tables as needed.
   std::string AsTable(uint32_t max_width) const;
 
+  // Output XML that describes this set of flags.
+  void ToXML(StreamString &strm) const;
+
 private:
   const std::string m_id;
   /// Size in bytes
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 23c2f18cd388a86..1a4d561146c3bfb 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3094,6 +3094,12 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   continue;
 }
 
+if (reg_info->flags_type) {
+  response.IndentMore();
+  reg_info->flags_type->ToXML(response);
+  response.IndentLess();
+}
+
 response.Indent();
 response.Printf("flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}
+
 const char *const register_set_name =
 reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
 if (register_set_name)
diff --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index 06fb45d777ec36f..a0019d15a2088b2 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "";
+}
diff --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 167e28d0cecb3bd..3b34e6b1e1c160c 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -258,3 +258,35 @@ TEST(RegisterFlagsTest, AsTable) {
 "| really long name |",
 max_many_columns.AsTable(23));
 }
+
+TEST(RegisterFieldsTest, ToXML) {
+  StreamString strm;
+
+  // RegisterFlags requires that some fields be given, so no testing of empty
+  // input.
+
+  // Unnamed fields are padding that are ignored. This applies to fields passed
+  // in, and those generated to fill the other bits (31-1 here).
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "\n");
+
+  strm.Clear();
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("abc", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "  \n"
+  "\n");
+
+  strm.Cl

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread David Spickett via lldb-commits


@@ -9,10 +9,16 @@
 #ifndef LLDB_TARGET_REGISTERFLAGS_H
 #define LLDB_TARGET_REGISTERFLAGS_H
 
-#include "lldb/Utility/Log.h"
+#include 
+#include 
+#include 
+#include 

DavidSpickett wrote:

string and vector are needed, presumably because RegisterFlags is a leaf on the 
build graph so it gets built in relative isolation.

```
In file included from 
/home/david.spickett/llvm-project/lldb/source/Target/RegisterFlags.cpp:9:
/home/david.spickett/llvm-project/lldb/include/lldb/Target/RegisterFlags.h:84:28:
 error: no template named 'vector' in namespace 'std'
const std::vector &fields);
```

And I can't move them to cpp because we include RegisterFlags.h first.

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread David Spickett via lldb-commits


@@ -9,10 +9,16 @@
 #ifndef LLDB_TARGET_REGISTERFLAGS_H
 #define LLDB_TARGET_REGISTERFLAGS_H
 
-#include "lldb/Utility/Log.h"
+#include 

DavidSpickett wrote:

Moved the assert into the cpp file and removed the include in the header.

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


[Lldb-commits] [lldb] [lldb] On POSIX, check for duplicate interpreter modules without loading them (PR #69932)

2023-10-25 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I'd really like to get Arm checks going again, so I'm going to land this today 
and see how the bot does. Of course I'll revert if there's any sign of 
instability on the BSD side.

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


[Lldb-commits] [lldb] ff67b68 - [lldb] On POSIX, check for duplicate interpreter modules without loading them (#69932)

2023-10-25 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-25T10:12:45+01:00
New Revision: ff67b68e43db5b4feb46670445561fab976fb0ef

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

LOG: [lldb] On POSIX, check for duplicate interpreter modules without loading 
them (#69932)

Fixes #68987

Early on we load the interpreter (most commonly ld-linux) in
LoadInterpreterModule. Then later when we get the first DYLD rendezvous
we get a list of libraries that commonly includes ld-linux again.

Previously we would load this duplicate, see that it was a duplicate,
and unload it.

Problem was that this unloaded the section information of the first copy
of ld-linux. On platforms where you can place a breakpoint using only an
address, this wasn't an issue.

On ARM you have ARM and Thumb modes. We must know which one the section
we're breaking in is, otherwise we'll go there in the wrong mode and
SIGILL. This happened on ARM when lldb tried to call mmap during
expression evaluation.

To fix this, I am making the assumption that the base address we see in
the module prior to loading can be compared with what we know the
interpreter base address is. Then we don't have to load the module to
know we can ignore it.

This fixes the lldb test suite on Ubuntu versions where
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1927192 has been
fixed. Which was recently done on Jammy.

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index c427b476089e458..3d65f496742099d 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -437,6 +437,14 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
   m_initial_modules_added = true;
 }
 for (; I != E; ++I) {
+  // Don't load a duplicate copy of ld.so if we have already loaded it
+  // earlier in LoadInterpreterModule. If we instead loaded then unloaded 
it
+  // later, the section information for ld.so would be removed. That
+  // information is required for placing breakpoints on Arm/Thumb systems.
+  if ((m_interpreter_module.lock() != nullptr) &&
+  (I->base_addr == m_interpreter_base))
+continue;
+
   ModuleSP module_sp =
   LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
   if (!module_sp.get())
@@ -450,15 +458,6 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
 } else if (module_sp == interpreter_sp) {
   // Module already loaded.
   continue;
-} else {
-  // If this is a duplicate instance of ld.so, unload it.  We may end
-  // up with it if we load it via a 
diff erent path than before
-  // (symlink vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
 }
   }
 



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


[Lldb-commits] [lldb] [lldb] On POSIX, check for duplicate interpreter modules without loading them (PR #69932)

2023-10-25 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [mlir][LLVM] Verify too many indices in GEP verifier (PR #70174)

2023-10-25 Thread Markus Böck via lldb-commits

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


[Lldb-commits] [lldb] dddd0c2 - [lldb][AArch64] Simplify AArch64SMEFA64 check

2023-10-25 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-25T11:19:37+01:00
New Revision: 0c2501beeb372252826aab71da7691d17bc2

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

LOG: [lldb][AArch64] Simplify AArch64SMEFA64 check

So we only have to read cpuinfo once.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index af8d24efc4f807e..fefe91401cb8e52 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1275,9 +1275,8 @@ def isAArch64SMEFA64(self):
 # smefa64 allows the use of the full A64 instruction set in streaming
 # mode. This is required by certain test programs to setup register
 # state.
-return self.isAArch64SME() and set(["sme", "smefa64"]).issuperset(
-set(self.getCPUInfo())
-)
+cpuinfo = self.getCPUInfo()
+return self.isAArch64() and "sme" in cpuinfo and "smefa64" in cpuinfo
 
 def isAArch64MTE(self):
 return self.isAArch64() and "mte" in self.getCPUInfo()



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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-25 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> > > Is there a way to have Visual Studio change the display format of the 
> > > enum values?
> > 
> > 
> > Sort of. You can specify you want to view values in hex and then you'll get 
> > `EK_ParenAggInitMember (0x0015)` instead of `EK_ParenAggInitMember 
> > (21)`, but that all the more formatting changes you can get in the debug 
> > view.
> 
> How is Visual Studio getting access to LLDB when debugging? Is it using the 
> lldb-vscode debug adaptor protocol from the VS Code stuff?

I'm sorry for the confusion! I didn't mean to imply that I was using lldb 
through Visual Studio, only that I'm used to my debugger showing me both pieces 
of information at the same time instead of making me ask it twice, and I 
support lldb doing something similar.

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


[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

2023-10-25 Thread David Spickett via lldb-commits

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

SME2 is documented as part of the main SME supplement:
https://developer.arm.com/documentation/ddi0616/latest/

The one change for debug is this new ZT0 register. This register
contains data to be used with new table lookup instructions.
It's size is always 512 bits (not scalable) and can be
interpreted in many different ways depending on the instructions
that use it. 

The kernel has implemented this as a new register set containing
this single register. It always returns register data (with no header,
unlike ZA which does have a header).

https://docs.kernel.org/arch/arm64/sme.html

ZT0 is only active when ZA is active (when SVCR.ZA is 1). In the 
inactive state the kernel returns 0s for its contents. Therefore
lldb doesn't need to create 0s like it does for ZA. 

However, we will skip restoring the value of ZT0 if we know that
ZA is inactive. As writing to an inactive ZT0 sets SVCR.ZA to 1,
which is not desireable as it would activate ZA also. Whether
SVCR.ZA is set will be determined only by the ZA data we restore.

Due to this, I've added a new save/restore kind SME2. This is easier
than accounting for the variable length ZA in the SME data. We'll only
save an SME2 data block if ZA is active. If it's not we can get fresh
0s back from the kernel for ZT0 anyway so there's nothing for us to restore.

This new register will only show up if the system has SME2 therefore
the SME set presented to the user may change, and I've had to account
for that in in a few places.

I've referred to it internally as simply "ZT" as the kernel does in
NT_ARM_ZT, but the architecture refers to the specific register as "ZT0"
so that's what you'll see in lldb.

```
(lldb) register read -s 6
Scalable Matrix Extension Registers:
  svcr = 0x
   svg = 0x0004
za = {0x00 <...> 0x00}
   zt0 = {0x00 <...> 0x00}
```

>From 80e01960f247ab9ee06daa59d9c033fda5fc3978 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 3 Oct 2023 13:24:39 +0100
Subject: [PATCH 1/2] [lldb][AArch64] Add SME2's ZT0 register

SME2 is documented as part of the main SME supplement:
https://developer.arm.com/documentation/ddi0616/latest/

The one change for debug is this new ZT0 register. This register
contains data to be used with new table lookup instructions.
It's size is always 512 bits (not scalable) and can be
interpreted in many different ways depending on the instructions
that use it.

The kernel has implemented this as a new register set containing
this single register. It always returns register data (with no header,
unlike ZA which does have a header).

https://docs.kernel.org/arch/arm64/sme.html

ZT0 is only active when ZA is active (when SVCR.ZA is 1). In the
inactive state the kernel returns 0s for its contents. Therefore
lldb doesn't need to create 0s like it does for ZA.

However, we will skip restoring the value of ZT0 if we know that
ZA is inactive. As writing to an inactive ZT0 sets SVCR.ZA to 1,
which is not desireable as it would activate ZA also. Whether
SVCR.ZA is set will be determined only by the ZA data we restore.

Due to this, I've added a new save/restore kind SME2. This is easier
than accounting for the variable length ZA in the SME data. We'll only
save an SME2 data block if ZA is active. If it's not we can get fresh
0s back from the kernel for ZT0 anyway so there's nothing for us to restore.

This new register will only show up if the system has SME2 therefore
the SME set presented to the user may change, and I've had to account
for that in in a few places.

I've referred to it internally as simply "ZT" as the kernel does in
NT_ARM_ZT, but the architecture refers to the specific register as "ZT0"
so that's what you'll see in lldb.

```
(lldb) register read -s 6
Scalable Matrix Extension Registers:
  svcr = 0x
   svg = 0x0004
za = {0x00 <...> 0x00}
   zt0 = {0x00 <...> 0x00}
```
---
 .../NativeRegisterContextLinux_arm64.cpp  | 133 --
 .../Linux/NativeRegisterContextLinux_arm64.h  |  12 ++
 .../Utility/RegisterInfoPOSIX_arm64.cpp   |  50 +--
 .../Process/Utility/RegisterInfoPOSIX_arm64.h |   5 +-
 .../Process/elf-core/RegisterUtilities.h  |   4 +
 5 files changed, 177 insertions(+), 27 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..d4c83dcba6363f5 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -45,6 +45,11 @@
 #define NT_ARM_ZA 0x40c /* ARM Scalable Matrix Extension, Array Storage */
 #endif
 
+#ifndef NT_ARM_ZT
+#define NT_ARM_ZT  
\
+  0x40d /* ARM Scalable Matrix Extension 2, lookup table 

[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

2023-10-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

SME2 is documented as part of the main SME supplement:
https://developer.arm.com/documentation/ddi0616/latest/

The one change for debug is this new ZT0 register. This register
contains data to be used with new table lookup instructions.
It's size is always 512 bits (not scalable) and can be
interpreted in many different ways depending on the instructions
that use it. 

The kernel has implemented this as a new register set containing
this single register. It always returns register data (with no header,
unlike ZA which does have a header).

https://docs.kernel.org/arch/arm64/sme.html

ZT0 is only active when ZA is active (when SVCR.ZA is 1). In the 
inactive state the kernel returns 0s for its contents. Therefore
lldb doesn't need to create 0s like it does for ZA. 

However, we will skip restoring the value of ZT0 if we know that
ZA is inactive. As writing to an inactive ZT0 sets SVCR.ZA to 1,
which is not desireable as it would activate ZA also. Whether
SVCR.ZA is set will be determined only by the ZA data we restore.

Due to this, I've added a new save/restore kind SME2. This is easier
than accounting for the variable length ZA in the SME data. We'll only
save an SME2 data block if ZA is active. If it's not we can get fresh
0s back from the kernel for ZT0 anyway so there's nothing for us to restore.

This new register will only show up if the system has SME2 therefore
the SME set presented to the user may change, and I've had to account
for that in in a few places.

I've referred to it internally as simply "ZT" as the kernel does in
NT_ARM_ZT, but the architecture refers to the specific register as "ZT0"
so that's what you'll see in lldb.

```
(lldb) register read -s 6
Scalable Matrix Extension Registers:
  svcr = 0x
   svg = 0x0004
za = {0x00 <...> 0x00}
   zt0 = {0x00 <...> 0x00}
```

---

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


13 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+4) 
- (modified) 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
(+119-14) 
- (modified) 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h (+12) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
(+38-12) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h 
(+4-1) 
- (modified) lldb/source/Plugins/Process/elf-core/RegisterUtilities.h (+4) 
- (modified) 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
 (+74-14) 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/Makefile
 (+1-1) 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py
 (+23-1) 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/main.c
 (+26-5) 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
 () 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py
 () 
- (renamed) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/main.c
 () 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index fefe91401cb8e52..15e8ba21266c896 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1271,6 +1271,10 @@ def isAArch64SVE(self):
 def isAArch64SME(self):
 return self.isAArch64() and "sme" in self.getCPUInfo()
 
+def isAArch64SME2(self):
+# If you have sme2, you also have sme.
+return self.isAArch64() and "sme2" in self.getCPUInfo()
+
 def isAArch64SMEFA64(self):
 # smefa64 allows the use of the full A64 instruction set in streaming
 # mode. This is required by certain test programs to setup register
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..d4c83dcba6363f5 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -45,6 +45,11 @@
 #define NT_ARM_ZA 0x40c /* ARM Scalable Matrix Extension, Array Storage */
 #endif
 
+#ifndef NT_ARM_ZT
+#define NT_ARM_ZT  
\
+  0x40d /* ARM Scalable Matrix Extension 2, lookup table register */
+#endif
+
 #ifndef NT_ARM_PAC_MASK
 #define NT_ARM_PAC_MASK 0x406 /* Pointer authentication code masks */
 #endif
@@ -104,6 +109,17 @@ 
NativeRegisterContextLinux::CreateHostNativeRe

[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

2023-10-25 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I've pushed this as two commits the first is adding the register, the second 
updates tests, for easier review. I intend to squash both once approved.

This does not cover core files, that'll be the follow up PR.

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


[Lldb-commits] [lldb] 42c25fd - [lldb][docs][AArch64] Update example in SME docs

2023-10-25 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-25T13:12:37Z
New Revision: 42c25fddcb1ad7407cd42cae3c15d943708fe8ad

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

LOG: [lldb][docs][AArch64] Update example in SME docs

This output has now changed because I moved the za register
into the main SME register set.

Added: 


Modified: 
lldb/docs/use/aarch64-linux.rst

Removed: 




diff  --git a/lldb/docs/use/aarch64-linux.rst b/lldb/docs/use/aarch64-linux.rst
index 707087a9bd72ea2..fcd0d1b805bf7df 100644
--- a/lldb/docs/use/aarch64-linux.rst
+++ b/lldb/docs/use/aarch64-linux.rst
@@ -146,12 +146,10 @@ as ``vg`` is showing the streaming mode vector length::
tpidr = 0xf7ff4320
   tpidr2 = 0x1122334455667788
 
-  Scalable Matrix Array Storage Registers:
-  za = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 <...> }
-
   Scalable Matrix Extension Registers:
  svg = 0x0002
 svcr = 0x0003
+  za = {0x00 <...> 0x00}
 
 Changing the Streaming Vector Length
 



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


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-25 Thread Med Ismail Bennani via lldb-commits


@@ -19,11 +19,11 @@
 namespace lldb_private {
 class ScriptedPlatformInterface : virtual public ScriptedInterface {
 public:
-  StructuredData::GenericSP
+  virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) override {
-return {};
+ StructuredData::Generic *script_obj = nullptr) {
+llvm_unreachable("unimplemented!");

medismailben wrote:

This can't be virtual pure because the `ScriptInterpreter` base class 
implements `virtual lldb::Scripted{Process,Platform,Thread}Interface()` methods 
that instantiate each base interface.

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


[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-25 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] f22d82c - [lldb/Interpreter] Make ScriptedInterface Object creation more generic (#68052)

2023-10-25 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-25T10:05:54-07:00
New Revision: f22d82cef28a882cec4d242910933e9f5d7dcdce

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

LOG: [lldb/Interpreter] Make ScriptedInterface Object creation more generic 
(#68052)

This patch changes the way plugin objects used with Scripted Interfaces
are created.

Instead of implementing a different SWIG method to create the object for
every scripted interface, this patch makes the creation more generic by
re-using some of the ScriptedPythonInterface templated Dispatch code.

This patch also improves error handling of the object creation by
returning an `llvm::Expected`.

Signed-off-by: Med Ismail Bennani 

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index cb54901e66d03c6..17bc7b1f2198709 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,49 +229,6 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject(
-const char *python_class_name, const char *session_dictionary_name,
-lldb::ExecutionContextRefSP exe_ctx_sp,
-const lldb_private::StructuredDataImpl &args_impl,
-std::string &error_string) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::ResolveNameWithDictionary(
-  python_class_name, dict);
-
-  if (!pfunc.IsAllocated()) {
-error_string.append("could not find script class: ");
-error_string.append(python_class_name);
-return PythonObject();
-  }
-
-  llvm::Expected arg_info = pfunc.GetArgInfo();
-  if (!arg_info) {
-llvm::handleAllErrors(
-arg_info.takeError(),
-[&](PythonException &E) { error_string.append(E.ReadBacktrace()); },
-[&](const llvm::ErrorInfoBase &E) {
-  error_string.append(E.message());
-});
-return PythonObject();
-  }
-
-  PythonObject result = {};
-  if (arg_info.get().max_positional_args == 2) {
-  result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp), 
SWIGBridge::ToSWIGWrapper(args_impl));
-  } else {
-error_string.assign("wrong number of arguments in __init__, should be 2 "
-"(not including self)");
-  }
-  return result;
-}
-
 PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb_private::StructuredDataImpl &args_impl,

diff  --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 948f763e95ecea4..2406f0f1f9aee27 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -25,11 +25,6 @@ class ScriptedInterface {
   ScriptedInterface() = default;
   virtual ~ScriptedInterface() = default;
 
-  virtual StructuredData::GenericSP
-  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
- StructuredData::DictionarySP args_sp,
- 

[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-25 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [Clang] Ensure zero-init is not overridden when initializing a base class in a constant expression context (PR #70150)

2023-10-25 Thread Shafik Yaghmour via lldb-commits

shafik wrote:

The clang-format error is a false positive.

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


[Lldb-commits] [lldb] [Clang] Ensure zero-init is not overridden when initializing a base class in a constant expression context (PR #70150)

2023-10-25 Thread Shafik Yaghmour via lldb-commits

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


[Lldb-commits] [PATCH] D159127: [lldb][libc++] Adds chrono data formatters.

2023-10-25 Thread Mark de Wever via Phabricator via lldb-commits
Mordante added a comment.

In D159127#4654774 , @Michael137 
wrote:

> Was looking at leftover reviews, would be nice to land this

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159127/new/

https://reviews.llvm.org/D159127

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

https://github.com/jeffreytan81 created 
https://github.com/llvm/llvm-project/pull/70231

While using dwarf5 `.debug_names` in internal large targets, we noticed a 
performance issue (around 10 seconds delay) while `lldb-vscode` tries to show 
`scopes` for a compile unit. Profiling shows the bottleneck is inside 
`DebugNamesDWARFIndex::GetGlobalVariables` which linearly search all index 
entries belongs to a compile unit. 

This patch improves the performance by using the compile units list to filter 
first before checking index entries. This significantly improves the 
performance (drops from 10 seconds => under 1 second) in the split dwarf 
situation because each compile unit has its own named index. 




>From c8d9a1f7387e3e4944d92ccb33699b6a9d0dcf89 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Wed, 25 Oct 2023 10:21:06 -0700
Subject: [PATCH] Improve debug names index fetching global variables
 performance

---
 .../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 292ea2806c59dc7..f94491b29bdbe14 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -130,6 +130,17 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool has_match_cu = false;
+for (uint32_t i = 0;i < ni.getCUCount();++i) {
+  if (ni.getCUOffset(i) == cu_offset) {
+has_match_cu = true;
+break;
+  }
+}
+if (!has_match_cu)
+  continue;
+
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);

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


[Lldb-commits] [lldb] 7b8e686 - [lldb] Fix build failure introduced by f22d82c

2023-10-25 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-25T10:31:43-07:00
New Revision: 7b8e6861150e56198b5e477f382845439f4d1c06

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

LOG: [lldb] Fix build failure introduced by f22d82c

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 190cb40dc0fc79e..18651f3ddb03069 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -110,7 +110,7 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
   transformed_args);
 
   if (llvm::Error e = expected_return_object.takeError())
-return e;
+return std::move(e);
   result = std::move(expected_return_object.get());
 }
 



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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Greg Clayton via lldb-commits

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

Looks good, just rename the "has_match_cu" to "cu_matches" and this is good to 
go.

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Greg Clayton via lldb-commits


@@ -130,6 +130,17 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool has_match_cu = false;

clayborg wrote:

I would rename this maybe to "cu_matches".

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] 0e4264a - [lldb][libc++] Adds chrono data formatters.

2023-10-25 Thread Mark de Wever via lldb-commits

Author: Mark de Wever
Date: 2023-10-25T19:36:47+02:00
New Revision: 0e4264ab1e7a3d82a32d0d096d014afade1e2fae

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

LOG: [lldb][libc++] Adds chrono data formatters.

This adds the data formatters for chrono duration typedefs.

Reviewed By: Michael137

Differential Revision: https://reviews.llvm.org/D159127

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp

Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index ad6d627938c0520..8b8d330799cb6c7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -979,6 +979,57 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   "std::unordered_map iterator synthetic children",
   "^std::__[[:alnum:]]+::__hash_map_(const_)?iterator<.+>$",
   stl_synth_flags, true);
+  // Chrono duration typedefs
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::nanoseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} 
ns")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::microseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} 
µs")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::milliseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} 
ms")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::seconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::minutes", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren |
+eTypeOptionHideValue,
+"${var.__rep_} min")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::hours", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} h")));
+
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::days", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren |
+eTypeOptionHideValue,
+"${var.__rep_} days")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::weeks", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren |
+eTypeOptionHideValue,
+"${var.__rep_} weeks")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::months", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren |
+eTypeOptionHideValue,
+"${var.__rep_} months")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::years", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren |
+eTypeOptionHideValue,
+"${var.__rep_} years")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::seconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s")));
 }
 
 static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
new file mode 10

[Lldb-commits] [PATCH] D159127: [lldb][libc++] Adds chrono data formatters.

2023-10-25 Thread Mark de Wever via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e4264ab1e7a: [lldb][libc++] Adds chrono data formatters. 
(authored by Mordante).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159127/new/

https://reviews.llvm.org/D159127

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp
@@ -0,0 +1,19 @@
+#include 
+#include 
+
+int main() {
+  // break here
+  std::chrono::nanoseconds ns{1};
+  std::chrono::microseconds us{12};
+  std::chrono::milliseconds ms{123};
+  std::chrono::seconds s{1234};
+  std::chrono::minutes min{12345};
+  std::chrono::hours h{123456};
+
+  std::chrono::days d{654321};
+  std::chrono::weeks w{54321};
+  std::chrono::months m{4321};
+  std::chrono::years y{321};
+
+  std::cout << "break here\n";
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
@@ -0,0 +1,33 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxChronoDataFormatterTestCase(TestBase):
+@add_test_categories(["libc++"])
+def test_with_run_command(self):
+"""Test that that file and class static variables display correctly."""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(process, bkpt)
+self.expect("frame variable ns", substrs=["ns = 1 ns"])
+self.expect("frame variable us", substrs=["us = 12 µs"])
+self.expect("frame variable ms", substrs=["ms = 123 ms"])
+self.expect("frame variable s", substrs=["s = 1234 s"])
+self.expect("frame variable min", substrs=["min = 12345 min"])
+self.expect("frame variable h", substrs=["h = 123456 h"])
+
+self.expect("frame variable d", substrs=["d = 654321 days"])
+self.expect("frame variable w", substrs=["w = 54321 weeks"])
+self.expect("frame variable m", substrs=["m = 4321 months"])
+self.expect("frame variable y", substrs=["y = 321 years"])
+
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
@@ -0,0 +1,6 @@
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+
+CXXFLAGS_EXTRAS := -std=c++20
+include Makefile.rules
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -979,6 +979,57 @@
   "std::unordered_map iterator synthetic children",
   "^std::__[[:alnum:]]+::__hash_map_(const_)?iterator<.+>$",
   stl_synth_flags, true);
+  // Chrono duration typedefs
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::nanoseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} ns")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::microseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} µs")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::milliseconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} ms")));
+  cpp_category_sp->AddTypeSummary(
+  "^std::__[[:alnum:]]+::chrono::seconds", eFormatterMatchRegex,
+  TypeSummaryImplSP(new StringSummaryFormat(
+  eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s")));
+  cpp_category_sp->AddTypeSummary

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread Greg Clayton via lldb-commits


@@ -9,10 +9,16 @@
 #ifndef LLDB_TARGET_REGISTERFLAGS_H
 #define LLDB_TARGET_REGISTERFLAGS_H
 
-#include "lldb/Utility/Log.h"
+#include 
+#include 
+#include 
+#include 

clayborg wrote:

Sorry, I hadn't expanded the full file to see  being used in code that 
didn't change.

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 8efd6799f006000a5e3aacbb403f262db37290b6 
c8d9a1f7387e3e4944d92ccb33699b6a9d0dcf89 -- 
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index f94491b29bdb..d5ff2f0da9ac 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -132,7 +132,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 // Check if this name index contains an entry for the given CU.
 bool has_match_cu = false;
-for (uint32_t i = 0;i < ni.getCUCount();++i) {
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
   if (ni.getCUOffset(i) == cu_offset) {
 has_match_cu = true;
 break;

``




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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
 return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];

bulbazord wrote:

Looking over this again, is there a use case where you would want to reference 
a specific owner by index instead of using `Owners()`?

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;

bulbazord wrote:

`return it != m_owners.end();`

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;

bulbazord wrote:

`WatchpointCollection` got removed right? I think you'll need to rewrite it... 
I'd suggest using `find_if`

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);

bulbazord wrote:

It should take advantage of copy elision. Specifically we should be able to 
take advantage of NRVO.

https://en.cppreference.com/w/cpp/language/copy_elision

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-25 Thread Alex Langford via lldb-commits

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

LGTM. I didn't realize lldb-server didn't use libXML, learned something new 
today. :)

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-25 Thread via lldb-commits

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-25 Thread via lldb-commits

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/70231

>From c8d9a1f7387e3e4944d92ccb33699b6a9d0dcf89 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Wed, 25 Oct 2023 10:21:06 -0700
Subject: [PATCH 1/2] Improve debug names index fetching global variables
 performance

---
 .../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 292ea2806c59dc7..f94491b29bdbe14 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -130,6 +130,17 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool has_match_cu = false;
+for (uint32_t i = 0;i < ni.getCUCount();++i) {
+  if (ni.getCUOffset(i) == cu_offset) {
+has_match_cu = true;
+break;
+  }
+}
+if (!has_match_cu)
+  continue;
+
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);

>From 19b7055e813471728f95ca42efcd4802261f2ea3 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Wed, 25 Oct 2023 11:15:14 -0700
Subject: [PATCH 2/2] Address formatter/review feedback

---
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp| 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index f94491b29bdbe14..4fc3866a3b608fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -129,19 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
 // Check if this name index contains an entry for the given CU.
-bool has_match_cu = false;
-for (uint32_t i = 0;i < ni.getCUCount();++i) {
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
   if (ni.getCUOffset(i) == cu_offset) {
-has_match_cu = true;
+cu_matches = true;
 break;
   }
 }
-if (!has_match_cu)
+if (!cu_matches)
   continue;
 
-for (DebugNames::NameTableEntry nte: ni) {
+for (DebugNames::NameTableEntry nte : ni) {
   uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

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


[Lldb-commits] [lldb] d4e6e40 - Improve debug names index fetching global variables performance (#70231)

2023-10-25 Thread via lldb-commits

Author: jeffreytan81
Date: 2023-10-25T11:46:11-07:00
New Revision: d4e6e403372fbc62f032d85f22fe0c1aeeb15146

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

LOG: Improve debug names index fetching global variables performance (#70231)

While using dwarf5 `.debug_names` in internal large targets, we noticed
a performance issue (around 10 seconds delay) while `lldb-vscode` tries
to show `scopes` for a compile unit. Profiling shows the bottleneck is
inside `DebugNamesDWARFIndex::GetGlobalVariables` which linearly search
all index entries belongs to a compile unit.

This patch improves the performance by using the compile units list to
filter first before checking index entries. This significantly improves
the performance (drops from 10 seconds => under 1 second) in the split
dwarf situation because each compile unit has its own named index.

-

Co-authored-by: jeffreytan81 

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 292ea2806c59dc7..4fc3866a3b608fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
-for (DebugNames::NameTableEntry nte: ni) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+  if (ni.getCUOffset(i) == cu_offset) {
+cu_matches = true;
+break;
+  }
+}
+if (!cu_matches)
+  continue;
+
+for (DebugNames::NameTableEntry nte : ni) {
   uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {



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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jeffreytan81)


Changes

While using dwarf5 `.debug_names` in internal large targets, we noticed a 
performance issue (around 10 seconds delay) while `lldb-vscode` tries to show 
`scopes` for a compile unit. Profiling shows the bottleneck is inside 
`DebugNamesDWARFIndex::GetGlobalVariables` which linearly search all index 
entries belongs to a compile unit. 

This patch improves the performance by using the compile units list to filter 
first before checking index entries. This significantly improves the 
performance (drops from 10 seconds => under 1 second) in the split dwarf 
situation because each compile unit has its own named index. 




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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(+13-2) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 292ea2806c59dc7..4fc3866a3b608fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
-for (DebugNames::NameTableEntry nte: ni) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+  if (ni.getCUOffset(i) == cu_offset) {
+cu_matches = true;
+break;
+  }
+}
+if (!cu_matches)
+  continue;
+
+for (DebugNames::NameTableEntry nte : ni) {
   uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {

``




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


[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

2023-10-25 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -625,6 +662,18 @@ 
NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) {
 error = ReadZA();
 if (error.Fail())
   return error;
+
+// We will only be restoring ZT data if ZA is active. As writing to an
+// inactive ZT enables ZA, which may not be desireable.
+if (GetRegisterInfo().IsZTEnabled() &&
+m_za_header.size > sizeof(m_za_header)) {

bulbazord wrote:

The comment and the code are a little confusing to me. Reading the code, it's 
not obvious that `GetRegisterInfo().IsZTEnabled() && m_za_header.size > 
sizeof(m_za_header)` checks to see if ZA is active. This reads to me like "if 
ZT0 is enabled and the za header is filled in correctly".

Why is "is ZT0 enabled" a condition if we just need to check ZA? Sorry if this 
is a noob question, I'm trying to learn more about this so I can help review 
these patches. 😄 

I also see you doing this below, might be good to build an abstraction for this?

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

This patch looks fine to me in idea, but next time please leave your review up 
for longer so others have time to take a look as well.

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
-for (DebugNames::NameTableEntry nte: ni) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+  if (ni.getCUOffset(i) == cu_offset) {
+cu_matches = true;
+break;
+  }
+}
+if (!cu_matches)
+  continue;

bulbazord wrote:

It'd be great if we could use some kind of `find_if` instead of manually 
walking the CU Offsets.

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


[Lldb-commits] [lldb] [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (PR #69991)

2023-10-25 Thread Alex Langford via lldb-commits

bulbazord wrote:

> > > I think I looked at every changed line, looks good to me overall. Found 
> > > one place with a small style issue but it's not a blocker. Thanks!
> > 
> > 
> > Thanks @bulbazord! Do you know why the `code_formatter` check/bot didn't 
> > flag that or the other one-line `if` statements?
> 
> This could be because it's part of the LLVM style guide but not enforced in 
> the `.clang-format`.
> 
> Also looked at most of the lines, LGTM. I wonder however why did you decide 
> to make 2 separate PRs for this ? Is there any reason for this ? It could 
> have been 2 commits in the same PR.

Yeah, I think it's probably not enforced. Maybe it should be? 🤔 


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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread David Blaikie via lldb-commits


@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
-for (DebugNames::NameTableEntry nte: ni) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+  if (ni.getCUOffset(i) == cu_offset) {

dwblaikie wrote:

If NameIndex exposed the CUOffsets as a range (which seems pretty 
easy/reasonable for it to do - ah, because it requires potentially applying 
relocations it'd probably require a custom iterator - maybe a mapped iterator 
would be adequate & easy to do) then this could be written as:
```
if (llvm::none_of(ni.CUOffsets(), [&](uint64_t off) { return off == cu_offset; 
}))
  continue;
```

I /think/ `CUOffsets()` would look something roughly like this:
```
auto CUOffsets() const {
  assert(TU < Hdr.CompUnitCount);
  const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
  uint64_t Offset = CUsBase + SectionOffsetSize * CU;
  auto R = /* Guess we need some sort of generator to produce the values 
[CUsBase, CUsBase+SectionOffsetSize*Hdr.CompUnitCount) in SectionOffsetSize 
increments... 
some enhancement to llvm::seq that takes a stride size would be suitable */
  return llvm::map_range(llvm::seq(CUsBase, 
  [&](uint64_t Offset) {
return Section.AccelSection.getRelocatedValue(SectionOffsetSize, 
&Offset);
  });
}
```

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


[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread David Blaikie via lldb-commits


@@ -129,8 +129,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
   bool found_entry_for_cu = false;
-  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
-for (DebugNames::NameTableEntry nte: ni) {
+  for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
+// Check if this name index contains an entry for the given CU.
+bool cu_matches = false;
+for (uint32_t i = 0; i < ni.getCUCount(); ++i) {
+  if (ni.getCUOffset(i) == cu_offset) {

dwblaikie wrote:

Oh, also, if you kept the result (more like a `llvm::find_if` as @bulbazord was 
suggesting, rather than my `llvm::none_of` here) of this search, you could save 
a small amount of time (no need to indirect through the index and reapply 
relocations to get the CU offset) by using `getCUInedx()` and comparing that to 
the index you would've found in this search - down on line 139/150

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


[Lldb-commits] [lldb] Complex range (PR #70244)

2023-10-25 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 0ab694754e3722f7edbd8b3ad23ac0b312515d3b 
2aa766352db0c3010991b4bc53ded7a2d1693bfd -- 
clang/test/CodeGen/cx-complex-range.c 
clang/test/CodeGen/pragma-cx-limited-range.c clang/include/clang/Parse/Parser.h 
clang/include/clang/Sema/Sema.h clang/lib/CodeGen/CGExprComplex.cpp 
clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Parse/ParsePragma.cpp 
clang/lib/Parse/ParseStmt.cpp clang/lib/Parse/Parser.cpp 
clang/lib/Sema/SemaAttr.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index 4b559a5dc747..f73dd0538e78 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -920,8 +920,8 @@ ComplexPairTy 
ComplexExprEmitter::EmitRangeReductionDiv(llvm::Value *LHSr,
   // f = (b - ar)/tmp
   llvm::Value *DdC = Builder.CreateFDiv(RHSi, RHSr); // d/c
 
-  llvm::Value *RD = Builder.CreateFMul(DdC, RHSi);   // (d/c)d
-  llvm::Value *CpRD = Builder.CreateFAdd(RHSr, RD);  // c+((d/c)d)
+  llvm::Value *RD = Builder.CreateFMul(DdC, RHSi);  // (d/c)d
+  llvm::Value *CpRD = Builder.CreateFAdd(RHSr, RD); // c+((d/c)d)
 
   llvm::Value *T3 = Builder.CreateFMul(LHSi, DdC);   // b(d/c)
   llvm::Value *T4 = Builder.CreateFAdd(LHSr, T3);// a+b(d/c)
@@ -938,17 +938,17 @@ ComplexPairTy 
ComplexExprEmitter::EmitRangeReductionDiv(llvm::Value *LHSr,
   // tmp = d + rc
   // e = (ar + b)/tmp
   // f = (br - a)/tmp
-  llvm::Value *CdD = Builder.CreateFDiv(RHSr, RHSi);  // c/d
+  llvm::Value *CdD = Builder.CreateFDiv(RHSr, RHSi); // c/d
 
-  llvm::Value *RC = Builder.CreateFMul(CdD, RHSr);// (c/d)c
-  llvm::Value *DpRC = Builder.CreateFAdd(RHSi, RC);   // d+(c/d)c
+  llvm::Value *RC = Builder.CreateFMul(CdD, RHSr);  // (c/d)c
+  llvm::Value *DpRC = Builder.CreateFAdd(RHSi, RC); // d+(c/d)c
 
-  llvm::Value *T7 = Builder.CreateFAdd(CdD, RHSi);// (c/d)+b
-  llvm::Value *T8 = Builder.CreateFMul(LHSr, T7); // a((c/d)+b)
-  llvm::Value *DSTFr = Builder.CreateFDiv(T8, DpRC);  // 
(a((c/d)+b)/(d+(c/d)c))
+  llvm::Value *T7 = Builder.CreateFAdd(CdD, RHSi);   // (c/d)+b
+  llvm::Value *T8 = Builder.CreateFMul(LHSr, T7);// a((c/d)+b)
+  llvm::Value *DSTFr = Builder.CreateFDiv(T8, DpRC); // (a((c/d)+b)/(d+(c/d)c))
 
-  llvm::Value *T9 = Builder.CreateFSub(CdD, LHSr);// (c/d)-a
-  llvm::Value *T10 = Builder.CreateFMul(RHSi, T9);// b((c/d)-a)
+  llvm::Value *T9 = Builder.CreateFSub(CdD, LHSr); // (c/d)-a
+  llvm::Value *T10 = Builder.CreateFMul(RHSi, T9); // b((c/d)-a)
   llvm::Value *DSTFi =
   Builder.CreateFDiv(T10, DpRC); // (b((c/d)-a))/(d+(c/d)c))
   Builder.CreateBr(ContBB);
@@ -977,7 +977,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const 
BinOpInfo &Op) {
 !Op.FPFeatures.getCxLimitedRange()) {
   return EmitRangeReductionDiv(LHSr, LHSi, RHSr, RHSi);
 } else if (RHSi && (Op.FPFeatures.getCxLimitedRange() ||
- CGF.getLangOpts().CxLimitedRange)) {
+CGF.getLangOpts().CxLimitedRange)) {
   if (!LHSi)
 LHSi = llvm::Constant::getNullValue(RHSi->getType());
   return EmitAlgebraicDiv(LHSr, LHSi, RHSr, RHSi);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f10912d772bd..ca414b1956f5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3295,14 +3295,14 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
options::OPT_fstrict_float_cast_overflow, false))
 CmdArgs.push_back("-fno-strict-float-cast-overflow");
 
-   if (const Arg *A = Args.getLastArg(options::OPT_fcx_limited_range))
-CmdArgs.push_back("-fcx-limited-range");
-   if (const Arg *A = Args.getLastArg(options::OPT_fcx_fortran_rules))
- CmdArgs.push_back("-fcx-fortran-rules");
-   if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_limited_range))
- CmdArgs.push_back("-fno-cx-limited-range");
-   if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_fortran_rules))
- CmdArgs.push_back("-fno-cx-fortran-rules");
+  if (const Arg *A = Args.getLastArg(options::OPT_fcx_limited_range))
+CmdArgs.push_back("-fcx-limited-range");
+  if (const Arg *A = Args.getLastArg(options::OPT_fcx_fortran_rules))
+CmdArgs.push_back("-fcx-fortran-rules");
+  if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_limited_range))
+CmdArgs.push_back("-fno-cx-limited-range");
+  if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_fortran_rules))
+CmdArgs.push_back("-fno-cx-fortran-rules");
 }
 
 static void RenderAnalyzerOptions(const ArgList &Args, ArgStringList &CmdArgs,

``




https://github.com/llvm/llvm-project/pull/70244
_

[Lldb-commits] [lldb] Complex range (PR #70244)

2023-10-25 Thread Zahira Ammarguellat via lldb-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/70244

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/9] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortFra

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-25 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/69388

>From bafeea33e1aea4a9e947220a78801ef241106eac Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 18 Oct 2023 17:16:50 -0700
Subject: [PATCH 1/2] [lldb] Refactor InstrumentationRuntimeAsan

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

rdar://112491689
---
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../ASan/CMakeLists.txt   |   5 +-
 .../ASan/InstrumentationRuntimeASan.cpp   | 242 ++---
 .../ASan/InstrumentationRuntimeASan.h |   7 -
 .../InstrumentationRuntime/CMakeLists.txt |   1 +
 .../Utility/CMakeLists.txt|  10 +
 .../Utility/ReportRetriever.cpp   | 252 ++
 .../Utility/ReportRetriever.h |  34 +++
 8 files changed, 315 insertions(+), 237 deletions(-)
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )
diff --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int access_type;
-void *pc;
-void *bp;
-void *sp;
-void *address;
-size_t access_size;
-const char *description;
-} t;
-
-t.present = __asan_report_present();
-t.access_type = __asan_get_report_access_type();
-t.pc = __asan_get_report_pc();
-t.bp = __asan_get_report_bp();
-t.sp = __asan_get_report_sp();
-t.address = __asan_get_report_address();
-t.access_size = __asan_get_report_access_size();
-t.description = __asan_get_report_description();
-t
-)";
-
-StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
-  ProcessSP process_sp = GetProcessSP();
-  if (!process_sp)
-return StructuredDat

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-25 Thread Usama Hameed via lldb-commits

usama54321 wrote:

Thanks everyone!

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


[Lldb-commits] [lldb] 77edd9b - [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (#69388)

2023-10-25 Thread via lldb-commits

Author: Usama Hameed
Date: 2023-10-25T12:52:52-07:00
New Revision: 77edd9b77317d008b86a2543fbafdc0c3e8a3759

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

LOG: [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (#69388)

[lldb] Refactor InstrumentationRuntimeAsan and add a new plugin
InstrumentationRuntimeLibsanitizers.

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

The commit also adds InstrumentationRuntimeASanLibsanitizers, a new runtime
plugin for ASan. The plugin provides the same
functionality as InstrumentationRuntimeASan, but provides a different
set of symbols/library names to search for while activating the plugin.

rdar://112491689

Added: 
lldb/source/Plugins/InstrumentationRuntime/ASanLibsanitizers/CMakeLists.txt

lldb/source/Plugins/InstrumentationRuntime/ASanLibsanitizers/InstrumentationRuntimeASanLibsanitizers.cpp

lldb/source/Plugins/InstrumentationRuntime/ASanLibsanitizers/InstrumentationRuntimeASanLibsanitizers.h
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt

lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
lldb/source/Plugins/InstrumentationRuntime/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )

diff  --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int 

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-25 Thread Usama Hameed via lldb-commits

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


[Lldb-commits] [lldb] Complex range (PR #70244)

2023-10-25 Thread Zahira Ammarguellat via lldb-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/70244

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 01/10] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[Lldb-commits] [lldb] Improve debug names index fetching global variables performance (PR #70231)

2023-10-25 Thread via lldb-commits

jeffreytan81 wrote:

Sounds good. Will keep the PR alive at least half day or one day before merging 
in future.

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Augusto Noronha via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Greg Clayton via lldb-commits


@@ -325,15 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
-protected:
   typedef llvm::DenseMap DIEToTypePtr;
-  typedef llvm::DenseMap
-  DIEToVariableSP;
+
+  virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
+
   typedef llvm::DenseMap
   DIEToClangType;
+
+  virtual DIEToClangType &GetForwardDeclDieToClangType() {

clayborg wrote:

`DIEToClangType` could be renamed to `DieToCompilerType`
`ClangTypeToDIE` could be renamed to `ComilerTypeToDIE`
Anything that is a map of something to `lldb::opaque_compiler_type_t`, or 
`lldb::opaque_compiler_type_t` to something can be renamed to be "CompilerType" 
instead of "ClangType"

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

We might want to rename anything that says "ClangType*" to be "CompilerType*". 
This is still left over from when we didn't think we would ever have the 
TypeSystem stuff. See some inline comments for examples. Since we are 
refactoring a bit and making things public, it is a good idea to clean this up.

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Walter Erquinigo via lldb-commits


@@ -325,15 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
-protected:
   typedef llvm::DenseMap DIEToTypePtr;
-  typedef llvm::DenseMap
-  DIEToVariableSP;
+
+  virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
+
   typedef llvm::DenseMap
   DIEToClangType;
+
+  virtual DIEToClangType &GetForwardDeclDieToClangType() {

walter-erquinigo wrote:

Awesome! I'll do that

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


[Lldb-commits] [lldb] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-25 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/66963

>From 5a2c930770cf548c5e3f3451e76b48cb067e6762 Mon Sep 17 00:00:00 2001
From: Zijun Zhao 
Date: Wed, 13 Sep 2023 14:26:01 -0700
Subject: [PATCH 1/6] [libc++] Implement ranges::contains_subrange

---
 libcxx/include/CMakeLists.txt |   1 +
 .../__algorithm/ranges_contains_subrange.h| 145 +
 libcxx/include/algorithm  |  14 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../ranges.contains_subrange.pass.cpp | 293 ++
 .../niebloid.compile.pass.cpp |   3 +
 6 files changed, 460 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 2ec755236dbaee2..b096259f85f6ac8 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains_subrange.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h 
b/libcxx/include/__algorithm/ranges_contains_subrange.h
new file mode 100644
index 000..16de6c29cb2a1a4
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains_subrange.h
@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_starts_with.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  for (; __offset >= 0; __offset--, __first1++) {
+auto result = ranges::starts_with(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+std::ref(__pred),
+std::ref(__proj1),
+std::ref(__proj2));
+if (result)
+  return true;
+  }
+  return false;
+}
+  }
+
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {
+auto __n1 = ranges::distance(__first1, __last1);
+auto __n2 = ranges::distance(__first2, __last2);
+auto __offset = __n1 - __n2;
+
+return __contains_subrange_fn_impl(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+__pred,
+__proj1,
+__proj2,
+std::move(__offset));
+  }
+
+  template 
+requires indirectly_comparable, iterator_t<_Range2>, 
_Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 
__proj1 = {}, _Proj2 __proj2 = {}) const {
+auto __n1 = 0;
+auto __n2 = 0;
+
+if cons

[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/70157

>From 98c80871a753c58a49e8ba0d535e03e99d633109 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Tue, 24 Oct 2023 22:32:38 -0400
Subject: [PATCH 1/2] [LLDB][NFC] Remove DWARFASTParserClang as friend from
 SymbolFileDWARF

This effectively moves a few functions from protected to public. In any case, 
for the sake of having a cleaner SymbolFileDWARF API, it's better if it's not a 
friend of a one of its consumers, DWARFASTParserClang.
Another effect of this change is that I can use SymbolFileDWARF for the 
out-of-tree mojo dwarf parser, which relies on pretty much the same functions 
that DWARFASTParserClang needs from SymbolFileDWARF.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 65 ++-
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 1ce62e6a6bb9e44..5b651a910e6deca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -83,7 +83,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   friend class DWARFCompileUnit;
   friend class DWARFDIE;
   friend class DWARFASTParser;
-  friend class ::DWARFASTParserClang;
 
   // Static Functions
   static void Initialize();
@@ -138,7 +137,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 
   size_t ParseVariablesForContext(const SymbolContext &sc) override;
 
-  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   std::optional
   GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
 const ExecutionContext *exe_ctx) override;
@@ -325,15 +323,46 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_file_index = file_index;
   }
 
-protected:
   typedef llvm::DenseMap DIEToTypePtr;
-  typedef llvm::DenseMap
-  DIEToVariableSP;
+
+  virtual DIEToTypePtr &GetDIEToType() { return m_die_to_type; }
+
   typedef llvm::DenseMap
   DIEToClangType;
+
+  virtual DIEToClangType &GetForwardDeclDieToClangType() {
+return m_forward_decl_die_to_clang_type;
+  }
+
   typedef llvm::DenseMap ClangTypeToDIE;
 
+  virtual ClangTypeToDIE &GetForwardDeclClangTypeToDie() {
+return m_forward_decl_clang_type_to_die;
+  }
+
+  virtual UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap();
+
+  bool ClassOrStructIsVirtual(const DWARFDIE &die);
+
+  SymbolFileDWARFDebugMap *GetDebugMapSymfile();
+
+  virtual lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
+
+  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
+  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
+
+  Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
+
+  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
+
+  Type *ResolveTypeUID(const DIERef &die_ref);
+
+protected:
+  typedef llvm::DenseMap
+  DIEToVariableSP;
+
   SymbolFileDWARF(const SymbolFileDWARF &) = delete;
   const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
 
@@ -371,10 +400,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   bool ParseSupportFiles(DWARFUnit &dwarf_cu, const lldb::ModuleSP &module,
  FileSpecList &support_files);
 
-  Type *ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
-
-  Type *ResolveTypeUID(const DIERef &die_ref);
-
   lldb::VariableSP ParseVariableDIE(const SymbolContext &sc,
 const DWARFDIE &die,
 const lldb::addr_t func_low_pc);
@@ -402,8 +427,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
 DIEArray &&variable_dies);
 
-  bool ClassOrStructIsVirtual(const DWARFDIE &die);
-
   // Given a die_offset, figure out the symbol context representing that die.
   bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
SymbolContextList &sc_list);
@@ -415,12 +438,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
   void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
SymbolContext &sc);
 
-  virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die);
-
-  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
-  const DWARFDIE &die, ConstString type_name, bool must_be_implementation);
-
   Symbol *GetObjCClassSymbol(ConstString objc_class_name);
 
   lldb::TypeSP GetTypeForDIE(const DWARFDIE &die,
@@ -430,8 +447,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 m_debug_map_module_wp = module_sp;
   }
 
-  SymbolFileDWARFDebugMap *GetDebugMapSymfile();
-
   DWARFDIE
   FindBlockContainingSpecification(const DIERef &func_die_ref,
dw_offset_t spec_block_die_

[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Jason Molenda via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
 return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];

jasonmolenda wrote:

Right now nothing is using the WatchpointResource owners - I need to add that 
in a follow on patch when a watchpoint has been triggered.  BreakpointSite uses 
this method in many places, but I agree that the Owners() method could be used. 
 We lose the range check/possible-assert in GetOwnerAtIndex() but hopefully 
that shouldn't actually happen...

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Jason Molenda via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
 return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];

jasonmolenda wrote:

I'm not completely clear what having WatchpointResource::Owners() returning a 
WatchpointIterable is going to do beyond allowing someone to write `for 
(WatchpointSP &wp_sp : wp_resource_sp->Owners())` - it's not exposing the 
underlying std::vector so I can't call `wp_resource_sp->Owners().size()` or 
`wp_resource_sp->Owners()[2]` is it?  Right now the WatchpointResource has 
methods like `AddOwner`, `RemoveOwner`, `GetNumberOfOwners`, `GetOwnerAtIndex`, 
and some methods to check if the list of owners contains a watchpoint; should 
callers be able to lock the Resource's mutex and get a reference to the 
std::vector and query/manipulate it directly?  

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


[Lldb-commits] [lldb] 10508b6 - [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (#70157)

2023-10-25 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-10-25T18:04:25-04:00
New Revision: 10508b6db72d8ee4ef022b85fe51c671921088f3

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

LOG: [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF 
(#70157)

This effectively moves a few functions from protected to public. In any
case, for the sake of having a cleaner SymbolFileDWARF API, it's better
if it's not a friend of a one of its consumers, DWARFASTParserClang.
Another effect of this change is that I can use SymbolFileDWARF for the
out-of-tree mojo dwarf parser, which relies on pretty much the same
functions that DWARFASTParserClang needs from SymbolFileDWARF.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f642e8d67403dee..182cc6764651747 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -834,9 +834,9 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext 
&sc,
 
   CompilerType enumerator_clang_type;
   CompilerType clang_type;
-  clang_type =
-  CompilerType(m_ast.weak_from_this(),
-   dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+  clang_type = CompilerType(
+  m_ast.weak_from_this(),
+  dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
   if (!clang_type) {
 if (attrs.type.IsValid()) {
   Type *enumerator_type =
@@ -1764,9 +1764,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   assert(tag_decl_kind != -1);
   (void)tag_decl_kind;
   bool clang_type_was_created = false;
-  clang_type =
-  CompilerType(m_ast.weak_from_this(),
-   dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+  clang_type = CompilerType(
+  m_ast.weak_from_this(),
+  dwarf->GetForwardDeclDIEToCompilerType().lookup(die.GetDIE()));
   if (!clang_type) {
 clang::DeclContext *decl_ctx =
 GetClangDeclContextContainingDIE(die, nullptr);
@@ -1896,16 +1896,16 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   // the SymbolFile virtual function
   // "SymbolFileDWARF::CompleteType(Type *)" When the definition
   // needs to be defined.
-  assert(!dwarf->GetForwardDeclClangTypeToDie().count(
+  assert(!dwarf->GetForwardDeclCompilerTypeToDIE().count(
  ClangUtil::RemoveFastQualifiers(clang_type)
  .GetOpaqueQualType()) &&
  "Type already in the forward declaration map!");
   // Can't assume m_ast.GetSymbolFile() is actually a
   // SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
   // binaries.
-  dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
+  dwarf->GetForwardDeclDIEToCompilerType()[die.GetDIE()] =
   clang_type.GetOpaqueQualType();
-  dwarf->GetForwardDeclClangTypeToDie().try_emplace(
+  dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
   ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
   *die.GetDIERef());
   m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index bfec67ce83bc3d0..ee7164d2f050ed1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1532,11 +1532,11 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE 
&die,
 // This function is used when SymbolFileDWARFDebugMap owns a bunch of
 // SymbolFileDWARF objects to detect if this DWARF file is the one that can
 // resolve a compiler_type.
-bool SymbolFileDWARF::HasForwardDeclForClangType(
+bool SymbolFileDWARF::HasForwardDeclForCompilerType(
 const CompilerType &compiler_type) {
   CompilerType compiler_type_no_qualifiers =
   ClangUtil::RemoveFastQualifiers(compiler_type);
-  if (GetForwardDeclClangTypeToDie().count(
+  if (GetForwardDeclCompilerTypeToDIE().count(
   compiler_type_no_qualifiers.GetOpaqueQualType())) {
 return true;
   }
@@ -1564,9 +1564,9 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   // We have a struct/union/class/enum that needs t

[Lldb-commits] [lldb] [LLDB][NFC] Remove DWARFASTParserClang as friend from SymbolFileDWARF (PR #70157)

2023-10-25 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
 return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];

bulbazord wrote:

Well, I'm not entirely sure how we're going to want to access the Owners list, 
so I'd like to understand more how you plan on using it. If you want to do 
something like `wp_resource_sp->Owners()[2]` then this method makes sense to 
keep around, but I'd also be curious to know why you would want to access the 
3rd owner directly. What I would like to avoid is writing a loop like this:
```
for (int i = 0; i < wp_resource_sp.GetNumberOfOwners(); i++) {
  WatchpointSP wp_sp = wp_resource_sp->GetOwnerAtIndex(i);
  // Use wp_sp
}
```
The two main reasons I am not a fan of this pattern:
1. As you pointed out, one would need to grab the `wp_resource_sp` owner mutex 
to do this safely since another thread may call `RemoveOwner` in the middle of 
this loop. I can't say I'm a fan of exposing the vector primarily because it 
would mean we'd have to expose the mutex too.
2. Off-by-one errors are fairly easy to put in by mistake. Doubly so if we ever 
iterate in reverse (i >0 vs i >=0 for the termination condition).

If we don't need to be able to access any of the owners at an arbitrary index, 
I would suggest removing it so nobody can write that kind of loop. WDYT?

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -67,18 +67,15 @@ size_t WatchpointResource::GetNumberOfOwners() {
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
   const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
-  if (it != m_owners.end())
-return true;
-  return false;
+  return it != m_owners.end();
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  for (WatchpointCollection::const_iterator it = m_owners.begin();
-   it != m_owners.end(); ++it)
-if ((*it).get() == wp)
-  return true;
-  return false;
+  WatchpointCollection::const_iterator match =

bulbazord wrote:

Looks fine, but the type should be different right? I think you removed 
`WatchpointCollection` in the 3rd commit

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Jason Molenda via lldb-commits


@@ -67,18 +67,15 @@ size_t WatchpointResource::GetNumberOfOwners() {
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
   const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
-  if (it != m_owners.end())
-return true;
-  return false;
+  return it != m_owners.end();
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  for (WatchpointCollection::const_iterator it = m_owners.begin();
-   it != m_owners.end(); ++it)
-if ((*it).get() == wp)
-  return true;
-  return false;
+  WatchpointCollection::const_iterator match =

jasonmolenda wrote:

It's a typedef to std::vector.

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Alex Langford via lldb-commits


@@ -67,18 +67,15 @@ size_t WatchpointResource::GetNumberOfOwners() {
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
   const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
-  if (it != m_owners.end())
-return true;
-  return false;
+  return it != m_owners.end();
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  for (WatchpointCollection::const_iterator it = m_owners.begin();
-   it != m_owners.end(); ++it)
-if ((*it).get() == wp)
-  return true;
-  return false;
+  WatchpointCollection::const_iterator match =

bulbazord wrote:

My bad... 🤦 

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


[Lldb-commits] [lldb] 463a02b - [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (#69989)

2023-10-25 Thread via lldb-commits

Author: Pete Lawrence
Date: 2023-10-25T15:55:27-07:00
New Revision: 463a02bc2260d01ac9e8457792bb455e48097ce5

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

LOG: [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` 
(not `bool`) (#69989)

[lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` to return
`void` instead of ~~`bool`~~

Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically
with a `result` parameter.
- Each command return object already contains:
- A more precise status
- The error code(s) that apply to that status

Part 2 refactors the `CommandObject::DoExecute(...)` method.
- See
[https://github.com/llvm/llvm-project/pull/69991](https://github.com/llvm/llvm-project/pull/69991)

rdar://117378957

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandAlias.h
lldb/include/lldb/Interpreter/CommandObject.h
lldb/include/lldb/Interpreter/CommandObjectMultiword.h
lldb/source/Commands/CommandObjectMultiword.cpp
lldb/source/Interpreter/CommandAlias.cpp
lldb/source/Interpreter/CommandObject.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandAlias.h 
b/lldb/include/lldb/Interpreter/CommandAlias.h
index 26826db62705d67..7b59ea0a74bb9e5 100644
--- a/lldb/include/lldb/Interpreter/CommandAlias.h
+++ b/lldb/include/lldb/Interpreter/CommandAlias.h
@@ -56,7 +56,7 @@ class CommandAlias : public CommandObject {
 
   void SetHelpLong(llvm::StringRef str) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   lldb::CommandObjectSP GetUnderlyingCommand() {
 return m_underlying_command_sp;

diff  --git a/lldb/include/lldb/Interpreter/CommandObject.h 
b/lldb/include/lldb/Interpreter/CommandObject.h
index d8358435a483bab..004f5d42f1e44ee 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -312,7 +312,7 @@ class CommandObject : public 
std::enable_shared_from_this {
   return false;
   }
 
-  virtual bool Execute(const char *args_string,
+  virtual void Execute(const char *args_string,
CommandReturnObject &result) = 0;
 
 protected:
@@ -398,7 +398,7 @@ class CommandObjectParsed : public CommandObject {
 
   ~CommandObjectParsed() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(Args &command, CommandReturnObject &result) = 0;
@@ -415,7 +415,7 @@ class CommandObjectRaw : public CommandObject {
 
   ~CommandObjectRaw() override = default;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   virtual bool DoExecute(llvm::StringRef command,

diff  --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index 1c14b492c8097fe..bceb7f0e51edb6c 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -59,7 +59,7 @@ class CommandObjectMultiword : public CommandObject {
   std::optional GetRepeatCommand(Args ¤t_command_args,
   uint32_t index) override;
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
   bool IsRemovable() const override { return m_can_be_removed; }
 
@@ -129,7 +129,7 @@ class CommandObjectProxy : public CommandObject {
   /// Execute is called) and \a GetProxyCommandObject returned null.
   virtual llvm::StringRef GetUnsupportedError();
 
-  bool Execute(const char *args_string, CommandReturnObject &result) override;
+  void Execute(const char *args_string, CommandReturnObject &result) override;
 
 protected:
   // These two want to iterate over the subcommand dictionary.

diff  --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 7ef829afaab6e7d..4efa5652a717035 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -159,25 +159,25 @@ llvm::Error 
CommandObjectMultiword::RemoveUserSubcommand(llvm::StringRef cmd_nam
   return llvm::Error::success();
 }
 
-bool CommandObjectMultiword::Execute(const char *args_string,
+void CommandObjectMultiword::Execute(const char *args_string,

[Lldb-commits] [lldb] [lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (PR #69989)

2023-10-25 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-25 Thread Jason Molenda via lldb-commits


@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+   it != m_owners.end(); ++it)
+if ((*it).get() == wp)
+  return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
 return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];

jasonmolenda wrote:

This is a good point.  I am mostly trying to copy the API of BreakpointSite 
which has methods like this, and that's how its Owners are accessed today in 
different parts of lldb.  I haven't gotten to the point where I use the Owners 
anywhere yet, so I'm not locked in to the same API that BreakpointSite exposes. 
 We have things like `SBThread::GetStopReasonDataAtIndex()` which for 
Breakpoints exposes all of the Breakpoints that were owning the BreakpointSite 
that was hit.  We have other places like 
`StackFrameList::ResetCurrentInlinedDepth` which is iterating over a 
BreakpointSite's owners to see if any of them are internal; the 
IterableWatchpoint returned by `WatchpointResources::Owners` would be a cleaner 
approach in this case.  We have some places in the code that need to know the 
address of the breakpoint that was hit and are grabbing the first 
BreakpointLocation associated with the BreakpointSite, e.g. 
`PlatformDarwin::GetSoftwareBreakpointTrapOpcode` (for some arm/thumb reason).  
In `ThreadPlanCallFunction::DoPlanExplainsStop` we're iterating over the Owners 
to log about them and detect if any are Internal breakpoint locations, which 
could be done with an Iterable.  

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


[Lldb-commits] [lldb] dfa3570 - [lldb] Add test dependency on the `runtimes` instead of the `cxx` target

2023-10-25 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-25T16:03:51-07:00
New Revision: dfa357026be3d9ecacc910abb8d55b8fe2d8d01d

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

LOG: [lldb] Add test dependency on the `runtimes` instead of the `cxx` target

Instead of adding individual dependencies on the enabled runtimes, make
the `lldb-test-depends` target depend on the `runtimes` target. The
`cxx` target broke after 0fc8f0b.

Added: 


Modified: 
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 59f87fe0662b207..1aa8843b6a2e78d 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -139,6 +139,10 @@ if(NOT LLDB_BUILT_STANDALONE)
   )
 endif()
 
+if (LLVM_ENABLE_RUNTIMES)
+  add_lldb_test_dependency(runtimes)
+endif()
+
 # Add dependencies if we test with the in-tree clang.
 # This works with standalone builds as they import the clang target.
 if(TARGET clang)
@@ -157,12 +161,10 @@ if(TARGET clang)
   set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
   set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
 endif()
-add_lldb_test_dependency(cxx)
   endif()
 
   if (TARGET compiler-rt OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
 set(LLDB_HAS_COMPILER_RT ON)
-add_lldb_test_dependency(compiler-rt)
   endif()
 
   if(APPLE AND NOT LLVM_TARGET_IS_CROSSCOMPILE_HOST)



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


[Lldb-commits] [lldb] b82c629 - Fix log format strings

2023-10-25 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2023-10-25T16:42:37-07:00
New Revision: b82c62978690a8a518f22780bd13ac2b5ddcd2b8

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

LOG: Fix log format strings

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 1af450374e776b1..e3506a01c606b78 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -394,7 +394,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   if (log) {
 std::string cmdstr;
 args.GetCommandString(cmdstr);
-log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
+LLDB_LOG(log, "GetXcodeSDK() running shell cmd '{0}'", cmdstr);
   }
 
   int status = 0;
@@ -410,13 +410,13 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   // Check that xcrun returned something useful.
   if (error.Fail()) {
 // Catastrophic error.
-LLDB_LOG(log, "xcrun failed to execute: %s", error.AsCString());
+LLDB_LOG(log, "xcrun failed to execute: {0}", error);
 return error.ToError();
   }
   if (status != 0) {
 // xcrun didn't find a matching SDK. Not an error, we'll try
 // 
diff erent spellings.
-LLDB_LOG(log, "xcrun returned exit code %d", status);
+LLDB_LOG(log, "xcrun returned exit code {0}", status);
 return "";
   }
   if (output_str.empty()) {



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


[Lldb-commits] [lldb] 2abf997 - [lldb] Fix assertions caused by un-checked errors in ScriptedProcess

2023-10-25 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-25T17:31:02-07:00
New Revision: 2abf997f8272e88d1a17138da61448bac721b6c1

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

LOG: [lldb] Fix assertions caused by un-checked errors in ScriptedProcess

This patch should fix some assertion that started getting hit after f22d82c.

That commit changed the scripted object plugin creation to use
`llvm::Expected` as a return type to enforce error handling, however
I forgot to handle the error which caused the assert.

The interesting  part about this, is that since that assert was triggered
in the ScriptedProcess constructor (where the `llvm::Error` wasn't
handled), that impacted every test that launched any kind of process,
since the process plugin manager would eventually also iterate over the
`ScriptedProcess::Create` factory method.

This patch should fix the assertions by handling the errors.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index e0e6693399dec3a..f2a647c1b0bea4c 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -113,6 +113,7 @@ ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
   m_scripted_metadata.GetArgsSP());
 
   if (!obj_or_err) {
+llvm::consumeError(obj_or_err.takeError());
 error.SetErrorString("Failed to create script object.");
 return;
   }

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index 5a955fa14009265..aa2796db15cd00a 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -60,9 +60,11 @@ ScriptedThread::Create(ScriptedProcess &process,
   thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(),
   script_object);
 
-  if (!obj_or_err)
+  if (!obj_or_err) {
+llvm::consumeError(obj_or_err.takeError());
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Failed to create script object.");
+  }
 
   StructuredData::GenericSP owned_script_object_sp = *obj_or_err;
 



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