[Lldb-commits] [lldb] [lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (PR #71402)

2023-11-07 Thread David Spickett via lldb-commits

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

>From 8b074aa5024deadfb74db6c10a812e5a474c6f1a Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 6 Nov 2023 15:02:29 +
Subject: [PATCH 1/2] [lldb] Add template method for getting const or mutable
 regs from DynamicRegisterInfo

GDBRemoteRegisterContext only needs to iterate them,
ArchitectureAArch64 needs to mutate them if scalable
registers change size.
---
 .../include/lldb/Target/DynamicRegisterInfo.h | 14 +
 .../AArch64/ArchitectureAArch64.cpp   | 21 ---
 .../gdb-remote/GDBRemoteRegisterContext.cpp   |  4 +++-
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index 0e175a99eb7d58a..6dc1380e22059f1 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -89,12 +89,18 @@ class DynamicRegisterInfo {
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
   typedef std::vector reg_collection;
-  llvm::iterator_range registers() const {
-return llvm::iterator_range(m_regs);
+
+  template  T registers();
+
+  typedef llvm::iterator_range
+  reg_collection_const_range;
+  template <> reg_collection_const_range registers() {
+return reg_collection_const_range(m_regs);
   }
 
-  llvm::iterator_range registers_mutable() {
-return llvm::iterator_range(m_regs);
+  typedef llvm::iterator_range reg_collection_range;
+  template <> reg_collection_range registers() {
+return reg_collection_range(m_regs);
   }
 
   void ConfigureOffsets();
diff --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 2954eaa2083af08..181ba4e7d877216 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -38,11 +38,9 @@ ArchitectureAArch64::Create(const ArchSpec &arch) {
   return std::unique_ptr(new ArchitectureAArch64());
 }
 
-static void UpdateARM64SVERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t vg) {
+static void
+UpdateARM64SVERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t vg) {
   // SVE Z register size is vg x 8 bytes.
   uint32_t z_reg_byte_size = vg * 8;
 
@@ -62,11 +60,9 @@ static void UpdateARM64SVERegistersInfos(
   }
 }
 
-static void UpdateARM64SMERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t svg) {
+static void
+UpdateARM64SMERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t svg) {
   for (auto ® : regs) {
 if (strcmp(reg.name, "za") == 0) {
   // ZA is a register with size (svg*8) * (svg*8). A square essentially.
@@ -108,10 +104,11 @@ bool 
ArchitectureAArch64::ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
   if (!vg_reg_value && !svg_reg_value)
 return false;
 
+  auto regs = reg_info.registers();
   if (vg_reg_value)
-UpdateARM64SVERegistersInfos(reg_info.registers_mutable(), *vg_reg_value);
+UpdateARM64SVERegistersInfos(regs, *vg_reg_value);
   if (svg_reg_value)
-UpdateARM64SMERegistersInfos(reg_info.registers_mutable(), *svg_reg_value);
+UpdateARM64SMERegistersInfos(regs, *svg_reg_value);
 
   // At this point if we have updated any registers, their offsets will all be
   // invalid. If we did, we need to update them all.
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index e35983f0e7fbd40..e9bd65fad1502bf 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -228,7 +228,9 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const 
RegisterInfo *reg_info) {
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+  for (auto x : llvm::enumerate(
+   m_reg_info_sp->registers<
+   DynamicRegisterInfo::reg_collection_const_range>())) {
 const struct RegisterInfo ®info = x.value();
 m_reg_valid[x.index()] =
 (reginfo.byte_offset + reginfo.byte_size <=

>From f3a8fe418db028727dad4214647ac58ba95c3a96 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 7 Nov 2023 08:54:29 +
Subject: [PATCH 2/2] Delete default template

---
 lldb/include/lldb/Target/DynamicRegisterInfo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Target

[Lldb-commits] [lldb] [lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (PR #71402)

2023-11-07 Thread David Spickett via lldb-commits


@@ -89,12 +89,18 @@ class DynamicRegisterInfo {
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
   typedef std::vector reg_collection;
-  llvm::iterator_range registers() const {
-return llvm::iterator_range(m_regs);
+
+  template  T registers();

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (PR #71402)

2023-11-07 Thread David Spickett via lldb-commits


@@ -108,10 +104,11 @@ bool 
ArchitectureAArch64::ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
   if (!vg_reg_value && !svg_reg_value)
 return false;
 
+  auto regs = reg_info.registers();

DavidSpickett wrote:

I couldn't figure out how to get that to work:
```
/home/david.spickett/llvm-project/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp:107:61:
 error: no matching member function for call to 'registers'
  DynamicRegisterInfo::reg_collection_range regs = reg_info.registers();
   ~^
/home/david.spickett/llvm-project/lldb/include/lldb/Target/DynamicRegisterInfo.h:93:27:
 note: candidate template ignored: couldn't infer template argument 'T'
  template  T registers() = delete;
  ^
1 error generated.
```
Feel free to do it yourself if you know what the syntax should be.

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


[Lldb-commits] [lldb] 4989c62 - [lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (#71402)

2023-11-07 Thread via lldb-commits

Author: David Spickett
Date: 2023-11-07T09:01:36Z
New Revision: 4989c62b318229bff2643c244ebbd03c20e2f781

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

LOG: [lldb] Add template method for getting const or mutable regs from 
DynamicRegisterInfo (#71402)

GDBRemoteRegisterContext only needs to iterate them, ArchitectureAArch64
needs to mutate them if scalable registers change size.

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index 0e175a99eb7d58a..af76c742c98f961 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -89,12 +89,18 @@ class DynamicRegisterInfo {
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
   typedef std::vector reg_collection;
-  llvm::iterator_range registers() const {
-return llvm::iterator_range(m_regs);
+
+  template  T registers() = delete;
+
+  typedef llvm::iterator_range
+  reg_collection_const_range;
+  template <> reg_collection_const_range registers() {
+return reg_collection_const_range(m_regs);
   }
 
-  llvm::iterator_range registers_mutable() {
-return llvm::iterator_range(m_regs);
+  typedef llvm::iterator_range reg_collection_range;
+  template <> reg_collection_range registers() {
+return reg_collection_range(m_regs);
   }
 
   void ConfigureOffsets();

diff  --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 2954eaa2083af08..181ba4e7d877216 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -38,11 +38,9 @@ ArchitectureAArch64::Create(const ArchSpec &arch) {
   return std::unique_ptr(new ArchitectureAArch64());
 }
 
-static void UpdateARM64SVERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t vg) {
+static void
+UpdateARM64SVERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t vg) {
   // SVE Z register size is vg x 8 bytes.
   uint32_t z_reg_byte_size = vg * 8;
 
@@ -62,11 +60,9 @@ static void UpdateARM64SVERegistersInfos(
   }
 }
 
-static void UpdateARM64SMERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t svg) {
+static void
+UpdateARM64SMERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t svg) {
   for (auto ® : regs) {
 if (strcmp(reg.name, "za") == 0) {
   // ZA is a register with size (svg*8) * (svg*8). A square essentially.
@@ -108,10 +104,11 @@ bool 
ArchitectureAArch64::ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
   if (!vg_reg_value && !svg_reg_value)
 return false;
 
+  auto regs = reg_info.registers();
   if (vg_reg_value)
-UpdateARM64SVERegistersInfos(reg_info.registers_mutable(), *vg_reg_value);
+UpdateARM64SVERegistersInfos(regs, *vg_reg_value);
   if (svg_reg_value)
-UpdateARM64SMERegistersInfos(reg_info.registers_mutable(), *svg_reg_value);
+UpdateARM64SMERegistersInfos(regs, *svg_reg_value);
 
   // At this point if we have updated any registers, their offsets will all be
   // invalid. If we did, we need to update them all.

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index e35983f0e7fbd40..e9bd65fad1502bf 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -228,7 +228,9 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const 
RegisterInfo *reg_info) {
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+  for (auto x : llvm::enumerate(
+   m_reg_info_sp->registers<
+   DynamicRegisterInfo::reg_collection_const_range>())) {
 const struct RegisterInfo ®info = x.value();
 m_reg_valid[x.index()] =
 (reginfo.byte_offset + reginfo.byte_size <=



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


[Lldb-commits] [lldb] [lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (PR #71402)

2023-11-07 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] 75b195c - Revert "[lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (#71402)"

2023-11-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-11-07T09:07:35Z
New Revision: 75b195cc4cee8d6f3216b7602f8247f5888a47af

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

LOG: Revert "[lldb] Add template method for getting const or mutable regs from 
DynamicRegisterInfo (#71402)"

This reverts commit 4989c62b318229bff2643c244ebbd03c20e2f781 as it fails to 
build with g++.

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index af76c742c98f961..0e175a99eb7d58a 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -89,18 +89,12 @@ class DynamicRegisterInfo {
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
   typedef std::vector reg_collection;
-
-  template  T registers() = delete;
-
-  typedef llvm::iterator_range
-  reg_collection_const_range;
-  template <> reg_collection_const_range registers() {
-return reg_collection_const_range(m_regs);
+  llvm::iterator_range registers() const {
+return llvm::iterator_range(m_regs);
   }
 
-  typedef llvm::iterator_range reg_collection_range;
-  template <> reg_collection_range registers() {
-return reg_collection_range(m_regs);
+  llvm::iterator_range registers_mutable() {
+return llvm::iterator_range(m_regs);
   }
 
   void ConfigureOffsets();

diff  --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 181ba4e7d877216..2954eaa2083af08 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -38,9 +38,11 @@ ArchitectureAArch64::Create(const ArchSpec &arch) {
   return std::unique_ptr(new ArchitectureAArch64());
 }
 
-static void
-UpdateARM64SVERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
- uint64_t vg) {
+static void UpdateARM64SVERegistersInfos(
+llvm::iterator_range<
+lldb_private::DynamicRegisterInfo::reg_collection::iterator>
+regs,
+uint64_t vg) {
   // SVE Z register size is vg x 8 bytes.
   uint32_t z_reg_byte_size = vg * 8;
 
@@ -60,9 +62,11 @@ 
UpdateARM64SVERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
   }
 }
 
-static void
-UpdateARM64SMERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
- uint64_t svg) {
+static void UpdateARM64SMERegistersInfos(
+llvm::iterator_range<
+lldb_private::DynamicRegisterInfo::reg_collection::iterator>
+regs,
+uint64_t svg) {
   for (auto ® : regs) {
 if (strcmp(reg.name, "za") == 0) {
   // ZA is a register with size (svg*8) * (svg*8). A square essentially.
@@ -104,11 +108,10 @@ bool 
ArchitectureAArch64::ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
   if (!vg_reg_value && !svg_reg_value)
 return false;
 
-  auto regs = reg_info.registers();
   if (vg_reg_value)
-UpdateARM64SVERegistersInfos(regs, *vg_reg_value);
+UpdateARM64SVERegistersInfos(reg_info.registers_mutable(), *vg_reg_value);
   if (svg_reg_value)
-UpdateARM64SMERegistersInfos(regs, *svg_reg_value);
+UpdateARM64SMERegistersInfos(reg_info.registers_mutable(), *svg_reg_value);
 
   // At this point if we have updated any registers, their offsets will all be
   // invalid. If we did, we need to update them all.

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index e9bd65fad1502bf..e35983f0e7fbd40 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -228,9 +228,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const 
RegisterInfo *reg_info) {
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  for (auto x : llvm::enumerate(
-   m_reg_info_sp->registers<
-   DynamicRegisterInfo::reg_collection_const_range>())) {
+  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
 const struct RegisterInfo ®info = x.value();
 m_reg_valid[x.index()] =
 (reginfo.byte_offset + reginfo.byte_size <=



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

[Lldb-commits] [lldb] ea9d44f - Reland "[lldb] Add template method for getting const or mutable regs from DynamicRegisterInfo (#71402)"

2023-11-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-11-07T09:35:25Z
New Revision: ea9d44f5ec13383372b0b972fceafca881e89186

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

LOG: Reland "[lldb] Add template method for getting const or mutable regs from 
DynamicRegisterInfo (#71402)"

This reverts commit 75b195cc4cee8d6f3216b7602f8247f5888a47af.

I've moved the specialisations out of the class to fix the g++ compilation.

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index 0e175a99eb7d58a..43bba5038e5371e 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -89,13 +89,11 @@ class DynamicRegisterInfo {
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
   typedef std::vector reg_collection;
-  llvm::iterator_range registers() const {
-return llvm::iterator_range(m_regs);
-  }
+  typedef llvm::iterator_range
+  reg_collection_const_range;
+  typedef llvm::iterator_range reg_collection_range;
 
-  llvm::iterator_range registers_mutable() {
-return llvm::iterator_range(m_regs);
-  }
+  template  T registers() = delete;
 
   void ConfigureOffsets();
 
@@ -135,6 +133,18 @@ class DynamicRegisterInfo {
   bool m_is_reconfigurable = false;
 };
 
+template <>
+inline DynamicRegisterInfo::reg_collection_const_range
+DynamicRegisterInfo::registers() {
+  return reg_collection_const_range(m_regs);
+}
+
+template <>
+inline DynamicRegisterInfo::reg_collection_range
+DynamicRegisterInfo::registers() {
+  return reg_collection_range(m_regs);
+}
+
 void addSupplementaryRegister(std::vector ®s,
   DynamicRegisterInfo::Register new_reg_info);
 

diff  --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 2954eaa2083af08..181ba4e7d877216 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -38,11 +38,9 @@ ArchitectureAArch64::Create(const ArchSpec &arch) {
   return std::unique_ptr(new ArchitectureAArch64());
 }
 
-static void UpdateARM64SVERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t vg) {
+static void
+UpdateARM64SVERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t vg) {
   // SVE Z register size is vg x 8 bytes.
   uint32_t z_reg_byte_size = vg * 8;
 
@@ -62,11 +60,9 @@ static void UpdateARM64SVERegistersInfos(
   }
 }
 
-static void UpdateARM64SMERegistersInfos(
-llvm::iterator_range<
-lldb_private::DynamicRegisterInfo::reg_collection::iterator>
-regs,
-uint64_t svg) {
+static void
+UpdateARM64SMERegistersInfos(DynamicRegisterInfo::reg_collection_range regs,
+ uint64_t svg) {
   for (auto ® : regs) {
 if (strcmp(reg.name, "za") == 0) {
   // ZA is a register with size (svg*8) * (svg*8). A square essentially.
@@ -108,10 +104,11 @@ bool 
ArchitectureAArch64::ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
   if (!vg_reg_value && !svg_reg_value)
 return false;
 
+  auto regs = reg_info.registers();
   if (vg_reg_value)
-UpdateARM64SVERegistersInfos(reg_info.registers_mutable(), *vg_reg_value);
+UpdateARM64SVERegistersInfos(regs, *vg_reg_value);
   if (svg_reg_value)
-UpdateARM64SMERegistersInfos(reg_info.registers_mutable(), *svg_reg_value);
+UpdateARM64SMERegistersInfos(regs, *svg_reg_value);
 
   // At this point if we have updated any registers, their offsets will all be
   // invalid. If we did, we need to update them all.

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index e35983f0e7fbd40..e9bd65fad1502bf 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -228,7 +228,9 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const 
RegisterInfo *reg_info) {
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+  for (auto x : llvm::enumerate(
+   m_reg_info_sp->registers<
+   DynamicRegisterInfo::reg_collection_const_range>())

[Lldb-commits] [lldb] cab0a19 - [lldb][test] Remove xfail for integral member test on Windows

2023-11-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-11-07T09:37:21Z
New Revision: cab0a19467ac2e6e1e022087f4b6cb90d55da040

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

LOG: [lldb][test] Remove xfail for integral member test on Windows

Juding by 
https://lab.llvm.org/buildbot/#/builders/219/builds/6774/steps/6/logs/stdio
this is passing now.

Added: 


Modified: 

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index ac6273f4c44e8d8..8679ac75acc78b7 100644
--- 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -125,7 +125,7 @@ def check_global_var(self, name: str, expect_type, 
expect_val):
 # wouldn't get indexed into the Names accelerator table preventing LLDB 
from finding
 # them.
 @expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"])
-@expectedFailureAll(debug_info=no_match(["dsym"]), 
oslist=no_match(["linux"]))
+@expectedFailureAll(debug_info=no_match(["dsym"]), 
oslist=no_match(["linux", "windows"]))
 def test_inline_static_members(self):
 self.build()
 lldbutil.run_to_source_breakpoint(



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


[Lldb-commits] [llvm] [clang] [flang] [clang-tools-extra] [libcxx] [lldb] [openmp] [compiler-rt] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)

2023-11-07 Thread Giorgis Georgakoudis via lldb-commits

ggeorgakoudis wrote:

LGTM but fix comments:
1. Comments should be in their own line, move them above the relevant line
2. Comments should be complete sentences ending with a full stop

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread David Spickett via lldb-commits

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

>From 45a9d131ce6c9fb31355519cd810ceff32c05ee7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 11 Oct 2023 14:54:07 +0100
Subject: [PATCH 1/6] [lldb][AArch64][Linux] Add field information for the CPSR
 register

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
cpsr = 0x80001000
 = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll want
to have fields and handles detecting fields and updating register info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
  with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields,
we only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be made
more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't ideal.
For CPSR, we do know the register number ahead of time but we do not for
other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers including 
cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.
---
 lldb/include/lldb/Target/RegisterFlags.h  |   5 +
 lldb/include/lldb/lldb-private-types.h|   5 +-
 .../NativeRegisterContextLinux_arm64.cpp  |  18 
 .../Plugins/Process/Utility/CMakeLists.txt|   1 +
 .../Utility/RegisterFlagsLinux_arm64.cpp  | 100 ++
 .../Utility/RegisterFlagsLinux_arm64.h|  75 +
 .../RegisterContextPOSIXCore_arm64.cpp|  17 +++
 .../elf-core/RegisterContextPOSIXCore_arm64.h |   3 +
 lldb/source/Target/RegisterFlags.cpp  |  14 ++-
 .../register_command/TestRegisters.py |  12 +++
 .../postmortem/elf-core/TestLinuxCore.py  |   4 +
 11 files changed, 249 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 7c5b97c2265fda3..1d8c8e943813e77 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -83,6 +83,11 @@ class RegisterFlags {
   RegisterFlags(std::string id, unsigned size,
 const std::vector &fields);
 
+  /// Replace all the fields with the new set of fields. All the assumptions
+  /// and checks apply as when you use the constructor. Intended to only be 
used
+  /// when runtime field detection is needed.
+  void SetFields(const std::vector &fields);
+
   // Reverse the order of the fields, keeping their values the same.
   // For example a field from bit 31 to 30 with value 0b10 will become bits
   // 1 to 0, with the same 0b10 value.
diff --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index e6717836331f590..f2ced61b7cc315b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(context_base + byte_offset, byte_size);
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..b55d60f3d9bbd13 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plu

[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,77 @@
+//===-- RegisterFlagsLinux_arm64.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_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERFLAGSLINUX_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERFLAGSLINUX_ARM64_H
+
+#include "lldb/Target/RegisterFlags.h"
+#include 
+
+namespace lldb_private {
+
+struct RegisterInfo;
+
+/// This class manages the storage and detection of register field information
+/// for Arm64 Linux registers. The same register may have different fields on
+/// different CPUs. This class abstracts out the field detection process so we
+/// can use it on live processes and core files.
+///
+/// The general way to use this class is:
+/// * Make an instance somewhere that will last as long as the debug session
+///   (because your final register info will point to this instance).
+/// * Read hardware capabilities from a core note, binary, prctl, etc.
+/// * Pass those to DetectFields.
+/// * Call UpdateRegisterInfo with your RegisterInfo to add pointers
+///   to the detected fields for all registers listed in this class.
+///
+/// This must be done in that order, and you should ensure that if multiple
+/// threads will reference the information, a mutex is used to make sure only
+/// one calls DetectFields.
+class LinuxArm64RegisterFlags {
+public:
+  /// For the registers listed in this class, detect which fields are
+  /// present. Must be called before UpdateRegisterInfos.
+  /// If called more than once, fields will be redetected each time from
+  /// scratch. If you do not have access to hwcap, just pass 0 for each one, 
you
+  /// will only get unconditional fields.
+  void DetectFields(uint64_t hwcap, uint64_t hwcap2);
+
+  /// Add the field information of any registers named in this class,
+  /// to the relevant RegisterInfo instances. Note that this will be done
+  /// with a pointer to the instance of this class that you call this on, so
+  /// the lifetime of that instance must be at least that of the register info.
+  void UpdateRegisterInfo(const RegisterInfo *reg_info, uint32_t num_regs);
+
+  /// Returns true if field detection has been run at least once.
+  bool HasDetected() const { return m_has_detected; }
+
+private:
+  using Fields = std::vector;
+  using DetectorFn = std::function;
+
+  static Fields DetectCPSRFields(uint64_t hwcap, uint64_t hwcap2);
+
+  struct RegisterEntry {
+RegisterEntry(const char *name, unsigned size, DetectorFn detector)
+: m_name(name), m_flags(std::string(name) + "_flags", size, {{"", 0}}),

DavidSpickett wrote:

Done, this also let me use `operator==` later.

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 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 4506de1e2bfe9352331d75fe6d3c89f3d2f5287c 
efeedcbf1ac6071f0cf480301cbc11f82db25b22 -- 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h 
lldb/include/lldb/Target/RegisterFlags.h lldb/include/lldb/lldb-private-types.h 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h 
lldb/source/Target/RegisterFlags.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
index 1019d5d0797d..b16f81260485 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
@@ -80,7 +80,8 @@ void LinuxArm64RegisterFlags::UpdateRegisterInfo(const 
RegisterInfo *reg_info,
   // Register names will not be duplicated, so we do not want to compare 
against
   // one if it has already been found. Each time we find one, we erase it from
   // this list.
-  std::vector> 
search_registers;
+  std::vector>
+  search_registers;
   for (const auto ® : m_registers) {
 // It is possible that a register is all extension dependent fields, and
 // none of them are present.

``




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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread David Spickett via lldb-commits

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

>From 45a9d131ce6c9fb31355519cd810ceff32c05ee7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 11 Oct 2023 14:54:07 +0100
Subject: [PATCH 1/7] [lldb][AArch64][Linux] Add field information for the CPSR
 register

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
cpsr = 0x80001000
 = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll want
to have fields and handles detecting fields and updating register info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
  with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields,
we only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be made
more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't ideal.
For CPSR, we do know the register number ahead of time but we do not for
other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers including 
cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.
---
 lldb/include/lldb/Target/RegisterFlags.h  |   5 +
 lldb/include/lldb/lldb-private-types.h|   5 +-
 .../NativeRegisterContextLinux_arm64.cpp  |  18 
 .../Plugins/Process/Utility/CMakeLists.txt|   1 +
 .../Utility/RegisterFlagsLinux_arm64.cpp  | 100 ++
 .../Utility/RegisterFlagsLinux_arm64.h|  75 +
 .../RegisterContextPOSIXCore_arm64.cpp|  17 +++
 .../elf-core/RegisterContextPOSIXCore_arm64.h |   3 +
 lldb/source/Target/RegisterFlags.cpp  |  14 ++-
 .../register_command/TestRegisters.py |  12 +++
 .../postmortem/elf-core/TestLinuxCore.py  |   4 +
 11 files changed, 249 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 7c5b97c2265fda3..1d8c8e943813e77 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -83,6 +83,11 @@ class RegisterFlags {
   RegisterFlags(std::string id, unsigned size,
 const std::vector &fields);
 
+  /// Replace all the fields with the new set of fields. All the assumptions
+  /// and checks apply as when you use the constructor. Intended to only be 
used
+  /// when runtime field detection is needed.
+  void SetFields(const std::vector &fields);
+
   // Reverse the order of the fields, keeping their values the same.
   // For example a field from bit 31 to 30 with value 0b10 will become bits
   // 1 to 0, with the same 0b10 value.
diff --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index e6717836331f590..f2ced61b7cc315b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(context_base + byte_offset, byte_size);
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..b55d60f3d9bbd13 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plu

[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,102 @@
+//===-- RegisterFlagsLinux_arm64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterFlagsLinux_arm64.h"
+#include "lldb/lldb-private-types.h"
+
+// This file is built on all systems because it is used by native processes and
+// core files, so we manually define the needed HWCAP values here.
+
+#define HWCAP_DIT (1 << 24)
+#define HWCAP_SSBS (1 << 28)
+
+#define HWCAP2_BTI (1 << 17)
+#define HWCAP2_MTE (1 << 18)
+
+using namespace lldb_private;
+
+LinuxArm64RegisterFlags::Fields
+LinuxArm64RegisterFlags::DetectCPSRFields(uint64_t hwcap, uint64_t hwcap2) {
+  // The fields here are a combination of the Arm manual's SPSR_EL1,
+  // plus a few changes where Linux has decided not to make use of them at all,
+  // or at least not from userspace.
+
+  // Status bits that are always present.
+  std::vector cpsr_fields{
+  {"N", 31}, {"Z", 30}, {"C", 29}, {"V", 28},
+  // Bits 27-26 reserved.
+  };
+
+  if (hwcap2 & HWCAP2_MTE)
+cpsr_fields.push_back({"TCO", 25});
+  if (hwcap & HWCAP_DIT)
+cpsr_fields.push_back({"DIT", 24});
+
+  // UAO and PAN are bits 23 and 22 and have no meaning for userspace so
+  // are treated as reserved by the kernel.
+
+  cpsr_fields.push_back({"SS", 21});
+  cpsr_fields.push_back({"IL", 20});
+  // Bits 19-14 reserved.
+
+  // Bit 13, ALLINT, requires FEAT_NMI that isn't relevant to userspace, and we
+  // can't detect either, don't show this field.
+  if (hwcap & HWCAP_SSBS)
+cpsr_fields.push_back({"SSBS", 12});
+  if (hwcap2 & HWCAP2_BTI)
+cpsr_fields.push_back({"BTYPE", 10, 11});
+
+  cpsr_fields.push_back({"D", 9});
+  cpsr_fields.push_back({"A", 8});
+  cpsr_fields.push_back({"I", 7});
+  cpsr_fields.push_back({"F", 6});
+  // Bit 5 reserved
+  // Called "M" in the ARMARM.
+  cpsr_fields.push_back({"nRW", 4});
+  // This is a 4 bit field M[3:0] in the ARMARM, we split it into parts.
+  cpsr_fields.push_back({"EL", 2, 3});
+  // Bit 1 is unused and expected to be 0.
+  cpsr_fields.push_back({"SP", 0});
+
+  return cpsr_fields;
+}
+
+void LinuxArm64RegisterFlags::DetectFields(uint64_t hwcap, uint64_t hwcap2) {
+  for (auto ® : m_registers)
+reg.m_flags.SetFields(reg.m_detector(hwcap, hwcap2));
+  m_has_detected = true;
+}
+
+void LinuxArm64RegisterFlags::UpdateRegisterInfo(const RegisterInfo *reg_info,
+ uint32_t num_regs) {
+  assert(m_has_detected &&
+ "Must call DetectFields before updating register info.");
+
+  // Register names will not be duplicated, so we do not want to compare 
against
+  // one if it has already been found. Each time we find one, we erase it from
+  // this list.
+  std::vector> search_registers;
+  for (const auto ® : m_registers) {
+// It is possible that a register is all extension dependent fields, and
+// none of them are present.
+if (reg.m_flags.GetFields().size())
+  search_registers.push_back({reg.m_name, ®.m_flags});
+  }
+
+  uint32_t idx = 0;
+  for (; idx < num_regs && search_registers.size(); ++idx, ++reg_info) {
+auto end = search_registers.cend();
+for (auto it = search_registers.cbegin(); it != end; ++it) {
+  if (std::strcmp(reg_info->name, it->first) == 0) {
+reg_info->flags_type = it->second;
+search_registers.erase(it);
+break;
+  }
+}
+  }
+}

DavidSpickett wrote:

Remove if doesn't early exit, but I've switched to find_if as it means we're 
not (at least visually) mutating a container while we're iterating it.

Also added a comment to explain that we don't want to assert the 
search_registers are empty at the end, which won't always be the case.

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread David Spickett via lldb-commits

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

>From 45a9d131ce6c9fb31355519cd810ceff32c05ee7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 11 Oct 2023 14:54:07 +0100
Subject: [PATCH 1/8] [lldb][AArch64][Linux] Add field information for the CPSR
 register

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
cpsr = 0x80001000
 = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll want
to have fields and handles detecting fields and updating register info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
  with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields,
we only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be made
more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't ideal.
For CPSR, we do know the register number ahead of time but we do not for
other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers including 
cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.
---
 lldb/include/lldb/Target/RegisterFlags.h  |   5 +
 lldb/include/lldb/lldb-private-types.h|   5 +-
 .../NativeRegisterContextLinux_arm64.cpp  |  18 
 .../Plugins/Process/Utility/CMakeLists.txt|   1 +
 .../Utility/RegisterFlagsLinux_arm64.cpp  | 100 ++
 .../Utility/RegisterFlagsLinux_arm64.h|  75 +
 .../RegisterContextPOSIXCore_arm64.cpp|  17 +++
 .../elf-core/RegisterContextPOSIXCore_arm64.h |   3 +
 lldb/source/Target/RegisterFlags.cpp  |  14 ++-
 .../register_command/TestRegisters.py |  12 +++
 .../postmortem/elf-core/TestLinuxCore.py  |   4 +
 11 files changed, 249 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 7c5b97c2265fda3..1d8c8e943813e77 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -83,6 +83,11 @@ class RegisterFlags {
   RegisterFlags(std::string id, unsigned size,
 const std::vector &fields);
 
+  /// Replace all the fields with the new set of fields. All the assumptions
+  /// and checks apply as when you use the constructor. Intended to only be 
used
+  /// when runtime field detection is needed.
+  void SetFields(const std::vector &fields);
+
   // Reverse the order of the fields, keeping their values the same.
   // For example a field from bit 31 to 30 with value 0b10 will become bits
   // 1 to 0, with the same 0b10 value.
diff --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index e6717836331f590..f2ced61b7cc315b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(context_base + byte_offset, byte_size);
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..b55d60f3d9bbd13 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plu

[Lldb-commits] [llvm] [lldb] [lldb][AArch64][Linux] Add SME2 release notes and usage docs (PR #70935)

2023-11-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

ping!

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

> While I was working in the test you recommended, I noticed the following: if 
> I run image lookup -r -s UNEXPECTED_PATTERN through the '-o' flag, any 
> command passed after that with another '-o' flag will not be executed, i.e.,

This is expected, lldb stops if one of those commands fails. It just so happens 
that `image lookup` does not print a message on finding no symbols.

https://github.com/llvm/llvm-project/blob/6e56c35d1959295289734baf8924d477f770d6f8/lldb/source/Commands/CommandObjectTarget.cpp#L4209

Presumably because to a user on the interactive command line, if they get no 
output they'll likely assume no symbols found.

If you do this with some command that does fail in a verbose way, it'll make 
more sense:
```
$ ./bin/lldb -o "foo" -o "help"
(lldb) foo
error: 'foo' is not a valid command.
(lldb)
```

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+
+  // Checking if the name (i.e., searched symbol is passed as an argument to 
the
+  // function) In that case, we use the DumpName function to colorize the
+  // symbol.
+  if (auto mangled_name = m_mangled.GetMangledName()) {
+s->Printf(", mangled=");
+if (name)
+  Address::DumpName(s, mangled_name.GetStringRef(), name);
+else
+  s->Printf("\"%s\"", mangled_name.AsCString());
+  } else {
+ConstString demangled = GetMangled().GetDemangledName();
+s->Printf(", name=");
+if (name)
+  Address::DumpName(s, demangled.AsCString(), name);
+else
+  s->Printf("\"%s\"", demangled.AsCString());

DavidSpickett wrote:

A bit worried here that one path is printing with `""` around the name and one 
isn't. Both should do so.

Ideally you'd just have Address::DumpName do that always but if it's not done 
universally then you could make a temporary stream, dump into that and then 
call printf once with the `, name=`"%s\"` format.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+

DavidSpickett wrote:

This change has lost the original meaning which was to print the mangled name 
if we have it, then also print the demangled name if we have it.

```
Address: test.cpp.o[0x071c] (test.cpp.o.PT_LOAD[0]..text + 
268)
Summary: test.cpp.o`foo(int) at test.cpp:1:17
 Module: file = "/tmp/test.cpp.o", arch = "aarch64"
CompileUnit: id = {0x}, file = "/tmp/test.cpp", language = "c++"
   Function: id = {0x0089}, name = "foo(int)", mangled = "_Z3fooi", 
range = [0xa71c-0xa730)
   FuncType: id = {0x0089}, byte-size = 0, decl = test.cpp:1:6, 
compiler_type = "void (int)"
 Blocks: id = {0x0089}, range = [0xa71c-0xa730)
  LineEntry: [0xa71c-0xa724): /tmp/test.cpp:1:17
 Symbol: id = {0x0053}, range = 
[0xa71c-0xa730), name="foo(int)", mangled="_Z3fooi"
   Variable: id = {0x00a7}, name = "i", type = "int", valid ranges = 
, location = DW_OP_fbreg -4, decl = test.cpp:1:14
```

So it would be good to add a verbose test case to your test cases to prevent 
this happening in future.

This is the key line:
```
 Symbol: id = {0x0053}, range = 
[0xa71c-0xa730), name="foo(int)", mangled="_Z3fooi"
```

You can recreate output like this using a program like:
```
void foo(int i) {}
void foo(char i) {}

int main() {
  foo(1);
  foo('c');
  return 0;
}
```
Since name mangling is used to implement function overloading by parameter 
type, in the flat namespace that the linker expects to see.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -163,6 +176,14 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   dumped_something = true;
   if (symbol->GetType() == eSymbolTypeTrampoline)
 s->PutCString("symbol stub for: ");
+
+  // Similar here, Using DumpName if the function is called by regex symbol

DavidSpickett wrote:

Just an FYI, readers will not necessarily be reading code in a straight line. 
So relative references like "similar here" are mostly useless unless very close 
to each other.

Also we'll want to remove these comments eventually but they are fine to keep 
around while you iterate, if it helps you.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+
+  // Checking if the name (i.e., searched symbol is passed as an argument to 
the
+  // function) In that case, we use the DumpName function to colorize the
+  // symbol.
+  if (auto mangled_name = m_mangled.GetMangledName()) {
+s->Printf(", mangled=");
+if (name)
+  Address::DumpName(s, mangled_name.GetStringRef(), name);
+else
+  s->Printf("\"%s\"", mangled_name.AsCString());
+  } else {
+ConstString demangled = GetMangled().GetDemangledName();
+s->Printf(", name=");
+if (name)
+  Address::DumpName(s, demangled.AsCString(), name);
+else
+  s->Printf("\"%s\"", demangled.AsCString());

DavidSpickett wrote:

If you need it, Stringstream is the thing to look for I think.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -89,13 +97,18 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   s->Printf("<");
   dumped_something = true;
 } else {
-  ConstString name;
+  ConstString name_func;

DavidSpickett wrote:

This is what I mean about the name clashes too.

You're calling the function's name name and the pattern used to match "name". 
It's not a name though, it's a pattern. So if you can get to a stable place 
with the rest of the changes, I highly recommend changing `name` to `pattern` 
throughout.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -89,13 +97,18 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   s->Printf("<");
   dumped_something = true;
 } else {
-  ConstString name;
+  ConstString name_func;

DavidSpickett wrote:

Also name_func sounds like a function you call to get a name not the name of a 
function which would be func_name if anything.

But I digress, you see my point.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t

DavidSpickett wrote:

Pick one of the two test files, I can't tell which one is supposed to be the 
actual one (perhaps you forgot to `git rm` the previous one?).

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Please go through the unresolved comments and reply if you feel that you've 
done them, or ask questions if they don't make sense (I know Github doesn't 
make this super easy, but scrolling through the changed files should show you 
most of them).

>From here:
* Please remove any commented out code, comments that are now obvious from 
reading the code, etc.
* Rename `name` to `pattern`, it will be a 1000% less confusing for all of us :)
* Make sure that `ninja check-lldb` has no failures.
* clang-format your changes (https://clang.llvm.org/docs/ClangFormat.html)

This is not an exhaustive list but with all that done I can give it a fresh 
look without distractions and we'll get this moving along toward final review.

For clang-format here is a one liner I use, run from the `llvm-project` repo 
root:
```
git diff -U0 --no-color --relative HEAD^ | 
./clang/tools/clang-format/clang-format-diff.py -p1 -i -b /bin/clang-format
```
If you want to keep your commit history you can interactive rebase (`git rebase 
-i`) and do this at each commit, adding any changes as you go.

This is not super important now, but it does help me a little when reading the 
code, and it's something you'll need to know how to do for the final change in 
any case. Generally reviewers expect to see formatted code.

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


[Lldb-commits] [lldb] [LLDB] Don't ignore artificial variables and members for coroutines (PR #70779)

2023-11-07 Thread Michael Buch via lldb-commits


@@ -771,6 +771,10 @@ TypeSystemClang 
*TypeSystemClang::GetASTContext(clang::ASTContext *ast) {
   return clang_ast;
 }
 
+bool TypeSystemClang::ShouldIgnoreArtificialField(llvm::StringRef Name) {
+  return Name.starts_with("_vptr$");

Michael137 wrote:

On GCC I see we get a slightly different name:
```
< 2><0x0166>  DW_TAG_member
DW_AT_name  _vptr.Base
DW_AT_type  <0x01cc>
DW_AT_data_member_location  0
DW_AT_artificialyes(1)
```

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


[Lldb-commits] [lldb] [LLDB] Don't ignore artificial variables and members for coroutines (PR #70779)

2023-11-07 Thread Michael Buch via lldb-commits


@@ -3059,9 +3059,8 @@ void DWARFASTParserClang::ParseSingleMember(
   // This needs to be done after updating FieldInfo which keeps track of where
   // field start/end so we don't later try to fill the space of this
   // artificial member with (unnamed bitfield) padding.
-  // FIXME: This check should verify that this is indeed an artificial member
-  // we are supposed to ignore.
-  if (attrs.is_artificial) {
+  if (attrs.is_artificial &&
+  TypeSystemClang::ShouldIgnoreArtificialField(attrs.name)) {

Michael137 wrote:

We'll need to double check how clang's layout builder is affected by not 
ignoring these artificial fields

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


[Lldb-commits] [compiler-rt] [lldb] [mlir] [libc] [libcxx] [llvm] [clang] [lld] [flang] [libc][bazel] Add powf target and fix bazel overlay. (PR #71464)

2023-11-07 Thread via lldb-commits

https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/71464

>From c5b8cfbae37c302158e3671a271634c71693123a Mon Sep 17 00:00:00 2001
From: Tue Ly 
Date: Mon, 6 Nov 2023 18:52:11 -0500
Subject: [PATCH] [libc][bazel] Add powf target and fix bazel overlay.

---
 libc/src/math/generic/exp10f_impl.h   |  1 -
 .../llvm-project-overlay/libc/BUILD.bazel | 46 ---
 .../libc/test/src/math/BUILD.bazel|  7 +++
 3 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/libc/src/math/generic/exp10f_impl.h 
b/libc/src/math/generic/exp10f_impl.h
index 6fe542649400276..24888b7d4c98f5d 100644
--- a/libc/src/math/generic/exp10f_impl.h
+++ b/libc/src/math/generic/exp10f_impl.h
@@ -19,7 +19,6 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/math/exp10f.h"
 
 #include 
 
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index f2449cbfc17045d..c3f82eb7f69e31d 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1271,9 +1271,10 @@ libc_math_function(
 ],
 )
 
-libc_math_function(
-name = "exp10f",
-additional_deps = [
+libc_support_library(
+name = "exp10f_impl",
+hdrs = ["src/math/generic/exp10f_impl.h"],
+deps = [
 ":__support_fputil_fma",
 ":__support_fputil_multiply_add",
 ":__support_fputil_nearest_integer",
@@ -1285,6 +1286,13 @@ libc_math_function(
 ],
 )
 
+libc_math_function(
+name = "exp10f",
+additional_deps = [
+":exp10f_impl",
+],
+)
+
 libc_math_function(
 name = "exp2",
 additional_deps = [
@@ -1301,9 +1309,10 @@ libc_math_function(
 ],
 )
 
-libc_math_function(
-name = "exp2f",
-additional_deps = [
+libc_support_library(
+name = "exp2f_impl",
+hdrs = ["src/math/generic/exp2f_impl.h"],
+deps = [
 ":__support_fputil_fma",
 ":__support_fputil_multiply_add",
 ":__support_fputil_nearest_integer",
@@ -1315,6 +1324,13 @@ libc_math_function(
 ],
 )
 
+libc_math_function(
+name = "exp2f",
+additional_deps = [
+":exp2f_impl",
+],
+)
+
 libc_math_function(
 name = "logf",
 additional_deps = [
@@ -1546,6 +1562,24 @@ libc_math_function(
 ],
 )
 
+libc_math_function(
+name = "powf",
+additional_deps = [
+":__support_fputil_double_double",
+":__support_fputil_multiply_add",
+":__support_fputil_nearest_integer",
+":__support_fputil_polyeval",
+":__support_fputil_rounding_mode",
+":__support_fputil_sqrt",
+":__support_fputil_triple_double",
+":__support_macros_optimization",
+":common_constants",
+":explogxf",
+":exp2f_impl",
+":exp10f_impl",
+],
+)
+
 libc_math_function(name = "fabs")
 
 libc_math_function(name = "fabsf")
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index f2ce0d54803b584..22df9fa494ead24 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -760,6 +760,13 @@ math_test(
 ],
 )
 
+math_test(
+name = "powf",
+deps = [
+"//libc/utils/MPFRWrapper:mpfr_wrapper",
+],
+)
+
 math_test(
 name = "fmod",
 hdrs = ["FModTest.h"],

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


[Lldb-commits] [lldb] [LLDB] Don't ignore artificial variables and members for coroutines (PR #70779)

2023-11-07 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [compiler-rt] [lldb] [mlir] [libc] [libcxx] [llvm] [clang] [lld] [flang] [libc][bazel] Add powf target and fix bazel overlay. (PR #71464)

2023-11-07 Thread via lldb-commits

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


[Lldb-commits] [lldb] [clang] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)

2023-11-07 Thread via lldb-commits

zmodem wrote:

This causes Clang to assert:

```
  llvm/lib/IR/Metadata.cpp:689:
  void llvm::MDNode::resolve(): Assertion `isUniqued() && "Expected this to 
be uniqued"' failed.
```

See https://bugs.chromium.org/p/chromium/issues/detail?id=1500262#c1 for a 
reproducer.

I'll revert to green.

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


[Lldb-commits] [lldb] 066eea7 - Revert "Reland "clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (#70639)""

2023-11-07 Thread Hans Wennborg via lldb-commits

Author: Hans Wennborg
Date: 2023-11-07T15:52:19+01:00
New Revision: 066eea75d38957353824b46474413ef2632d01a7

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

LOG: Revert "Reland "clang][DebugInfo] Emit global variable definitions for 
static data members with constant initializers (#70639)""

This casued asserts:

  llvm/lib/IR/Metadata.cpp:689:
  void llvm::MDNode::resolve(): Assertion `isUniqued() && "Expected this to be 
uniqued"' failed.

See comments on the PR.

This also reverts the dependent follow-up commits, see below.

> When an LLDB user asks for the value of a static data member, LLDB
> starts by searching the Names accelerator table for the corresponding
> variable definition DIE. For static data members with out-of-class
> definitions that works fine, because those get represented as global
> variables with a location and making them eligible to be added to the
> Names table. However, in-class definitions won<80><99>t get indexed 
> because
> we usually don't emit global variables for them. So in DWARF we end
> up with a single `DW_TAG_member` that usually holds the constant
> initializer.  But we don't get a corresponding CU-level
> `DW_TAG_variable` like we do for out-of-class definitions.
>
> To make it more convenient for debuggers to get to the value of
> inline static data members, this patch makes sure we emit definitions
> for static variables with constant initializers the same way we do
> for other static variables. This also aligns Clang closer to GCC,
> which produces CU-level definitions for inline statics and also
> emits these into `.debug_pubnames`.
>
> The implementation keeps track of newly created static data members.
> Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable`
> with a `DW_AT_const_value` for any of those declarations that didn't
> end up with a definition in the `DeclCache`.
>
> The newly emitted `DW_TAG_variable` will look as follows:
> ```
> 0x007b:   DW_TAG_structure_type
> DW_AT_calling_convention(DW_CC_pass_by_value)
> DW_AT_name  ("Foo")
> ...
>
> 0x008d: DW_TAG_member
>   DW_AT_name("i")
>   DW_AT_type(0x0062 "const int")
>   DW_AT_external(true)
>   DW_AT_declaration (true)
>   DW_AT_const_value (4)
>
> Newly added
> v
>
> 0x009a:   DW_TAG_variable
> DW_AT_specification (0x008d "i")
> DW_AT_const_value   (4)
> DW_AT_linkage_name  ("_ZN2t2IiE1iIfEE")
> ```
>
> This patch also drops the `DW_AT_const_value` off of the declaration
> since we now always have it on the definition. This ensures that the
> `DWARFParallelLinker` can type-merge class with static members where
> we couldn't attach the constant on the declaration in some CUs.

This reverts commit 7c3707aea8a6f1fc245ad2862982b8a51b6c0fea.
This reverts commit cab0a19467ac2e6e1e022087f4b6cb90d55da040.
This reverts commit 317481b3c8b34b0c3f106c514e6aa39b70886110.
This reverts commit 15fc809404d4715822e5349b76dcca50eb100eec.
This reverts commit 470de2bbec7f5fdd199775aa99c68ac76f4d5c74.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-static-member.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py

Removed: 
clang/test/CodeGenCXX/debug-info-static-inline-member.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 410c8f522b1017f..84a166d3ac3659c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1677,13 +1677,22 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl 
*Var, llvm::DIType *RecordTy,
 
   unsigned LineNumber = getLineNumber(Var->getLocation());
   StringRef VName = Var->getName();
+  llvm::Constant *C = nullptr;
+  if (Var->getInit()) {
+const APValue *Value = Var->evaluateValue();
+if (Value) {
+  if (Value->isInt())
+C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+  if (Value->isFloat())
+C = llvm::ConstantFP

[Lldb-commits] [lldb] [lldb] Replace some register handling asserts with lldbassert (PR #71175)

2023-11-07 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Since ReadRegister returns a Status anyway, this shouldn't be too difficult to 
achieve?

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


[Lldb-commits] [lldb] [lldb] Print a warning on checksum mismatch (PR #71459)

2023-11-07 Thread Adrian Prantl via lldb-commits


@@ -300,6 +300,16 @@ size_t 
SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
 break;
   }
 }
+
+Checksum checksum = last_file_sp->GetFileSpec().GetChecksum();
+if (checksum && checksum != last_file_sp->GetChecksum()) {
+  llvm::call_once(last_file_sp->GetChecksumOnceFlag(), [&]() {
+s->Printf("warning: source file checksum mismatch between the debug "

adrian-prantl wrote:

I agree. Wherever we hardcode the string "error:" or "warning:" we should 
probably use a more high-level API.

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


[Lldb-commits] [lldb] [lldb] Print a warning on checksum mismatch (PR #71459)

2023-11-07 Thread Adrian Prantl via lldb-commits


@@ -300,6 +300,16 @@ size_t 
SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
 break;
   }
 }
+
+Checksum checksum = last_file_sp->GetFileSpec().GetChecksum();
+if (checksum && checksum != last_file_sp->GetChecksum()) {
+  llvm::call_once(last_file_sp->GetChecksumOnceFlag(), [&]() {
+s->Printf("warning: source file checksum mismatch between the debug "

adrian-prantl wrote:

CC: @PortalPete 

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


[Lldb-commits] [lldb] [lldb] Replace some register handling asserts with lldbassert (PR #71175)

2023-11-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> It seems like there's enough different opinions on this topic that might 
> warrant a proper RFC.

I'll post something shortly.

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/71559

I received a couple of nullptr-deref crash reports with no line numbers in this 
function. The way the function was written it was a bit diffucult to keep track 
of when result_sp could be null, so this patch simplifies the function to make 
it more obvious when a nullptr can be contained in the variable.

>From 5181bfab3fad13f6fce1425db5a93e2ab6e1fcd5 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 7 Nov 2023 08:25:34 -0800
Subject: [PATCH] Simplify
 ValueObject::GetQualifiedRepresentationIfAvailable().

I received a couple of nullptr-deref crash reports with no line
numbers in this function. The way the function was written it was a
bit diffucult to keep track of when result_sp could be null, so this
patch simplifies the function to make it more obvious when a nullptr
can be contained in the variable.
---
 lldb/source/Core/ValueObject.cpp | 36 ++--
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index bdb1bef633d8fb1..a7f7ee64282d891 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -2594,34 +2594,30 @@ ValueObjectSP 
ValueObject::CreateConstantValue(ConstString name) {
 
 ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable(
 lldb::DynamicValueType dynValue, bool synthValue) {
-  ValueObjectSP result_sp(GetSP());
-
+  ValueObjectSP result_sp;
   switch (dynValue) {
   case lldb::eDynamicCanRunTarget:
   case lldb::eDynamicDontRunTarget: {
-if (!result_sp->IsDynamic()) {
-  if (result_sp->GetDynamicValue(dynValue))
-result_sp = result_sp->GetDynamicValue(dynValue);
-}
+if (!IsDynamic())
+  result_sp = GetDynamicValue(dynValue);
   } break;
   case lldb::eNoDynamicValues: {
-if (result_sp->IsDynamic()) {
-  if (result_sp->GetStaticValue())
-result_sp = result_sp->GetStaticValue();
-}
+if (IsDynamic())
+  result_sp = GetStaticValue();
   } break;
   }
+  if (!result_sp)
+result_sp = GetSP();
+  assert(result_sp);
 
-  if (synthValue) {
-if (!result_sp->IsSynthetic()) {
-  if (result_sp->GetSyntheticValue())
-result_sp = result_sp->GetSyntheticValue();
-}
-  } else {
-if (result_sp->IsSynthetic()) {
-  if (result_sp->GetNonSyntheticValue())
-result_sp = result_sp->GetNonSyntheticValue();
-}
+  bool is_synthetic = result_sp->IsSynthetic();
+  if (synthValue && !is_synthetic) {
+if (auto synth_sp = result_sp->GetSyntheticValue())
+  return synth_sp;
+  }
+  if (!synthValue && is_synthetic) {
+if (auto non_synth_sp = result_sp->GetNonSyntheticValue())
+  return non_synth_sp;
   }
 
   return result_sp;

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

I received a couple of nullptr-deref crash reports with no line numbers in this 
function. The way the function was written it was a bit diffucult to keep track 
of when result_sp could be null, so this patch simplifies the function to make 
it more obvious when a nullptr can be contained in the variable.

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


1 Files Affected:

- (modified) lldb/source/Core/ValueObject.cpp (+16-20) 


``diff
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index bdb1bef633d8fb1..a7f7ee64282d891 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -2594,34 +2594,30 @@ ValueObjectSP 
ValueObject::CreateConstantValue(ConstString name) {
 
 ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable(
 lldb::DynamicValueType dynValue, bool synthValue) {
-  ValueObjectSP result_sp(GetSP());
-
+  ValueObjectSP result_sp;
   switch (dynValue) {
   case lldb::eDynamicCanRunTarget:
   case lldb::eDynamicDontRunTarget: {
-if (!result_sp->IsDynamic()) {
-  if (result_sp->GetDynamicValue(dynValue))
-result_sp = result_sp->GetDynamicValue(dynValue);
-}
+if (!IsDynamic())
+  result_sp = GetDynamicValue(dynValue);
   } break;
   case lldb::eNoDynamicValues: {
-if (result_sp->IsDynamic()) {
-  if (result_sp->GetStaticValue())
-result_sp = result_sp->GetStaticValue();
-}
+if (IsDynamic())
+  result_sp = GetStaticValue();
   } break;
   }
+  if (!result_sp)
+result_sp = GetSP();
+  assert(result_sp);
 
-  if (synthValue) {
-if (!result_sp->IsSynthetic()) {
-  if (result_sp->GetSyntheticValue())
-result_sp = result_sp->GetSyntheticValue();
-}
-  } else {
-if (result_sp->IsSynthetic()) {
-  if (result_sp->GetNonSyntheticValue())
-result_sp = result_sp->GetNonSyntheticValue();
-}
+  bool is_synthetic = result_sp->IsSynthetic();
+  if (synthValue && !is_synthetic) {
+if (auto synth_sp = result_sp->GetSyntheticValue())
+  return synth_sp;
+  }
+  if (!synthValue && is_synthetic) {
+if (auto non_synth_sp = result_sp->GetNonSyntheticValue())
+  return non_synth_sp;
   }
 
   return result_sp;

``




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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

rdar://118018930

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Michael Buch via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Replace some register handling asserts with lldbassert (PR #71175)

2023-11-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> I'll post something shortly.

https://discourse.llvm.org/t/rfc-fatal-error-handling-in-release-builds-aka-can-i-use-lldbassert-or-not/74738

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


[Lldb-commits] [lldb] [clang] [flang] [clang-tools-extra] [llvm] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-11-07 Thread Markos Horro via lldb-commits

https://github.com/markoshorro updated 
https://github.com/llvm/llvm-project/pull/71072

>From 0c5299adb30888aa0dfd7c3106547a69606d5ab1 Mon Sep 17 00:00:00 2001
From: Marcos Horro 
Date: Thu, 2 Nov 2023 15:35:07 +
Subject: [PATCH 1/2] [IndVars] Truncation also considered as bitcast
 optimization

---
 llvm/lib/Transforms/Utils/SimplifyIndVar.cpp  |  5 ++--
 .../Transforms/IndVarSimplify/casted-trunc.ll | 28 +++
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/Transforms/IndVarSimplify/casted-trunc.ll

diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index a23ac41acaa58aa..740f726cb06b148 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -908,8 +908,9 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, 
IVVisitor *V) {
 if (replaceIVUserWithLoopInvariant(UseInst))
   continue;
 
-// Go further for the bitcast ''prtoint ptr to i64'
-if (isa(UseInst))
+// Go further for the bitcast 'prtoint ptr to i64' or if the cast is done
+// by truncation
+if ((isa(UseInst)) || (isa(UseInst)))
   for (Use &U : UseInst->uses()) {
 Instruction *User = cast(U.getUser());
 if (replaceIVUserWithLoopInvariant(User))
diff --git a/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll 
b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
new file mode 100644
index 000..ef9db0b5774dada
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=indvars -S | FileCheck %s
+
+declare void @foo(i16 noundef)
+
+; Function Attrs: mustprogress noreturn uwtable
+define void @bar(i64 noundef %ptr) {
+; CHECK-LABEL: @bar(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = trunc i64 [[PTR:%.*]] to i4
+; CHECK-NEXT:[[TMP1:%.*]] = zext i4 [[TMP0]] to i16
+; CHECK-NEXT:br label [[WHILE_BODY:%.*]]
+; CHECK:   while.body:
+; CHECK-NEXT:tail call void @foo(i16 noundef signext [[TMP1]])
+; CHECK-NEXT:br label [[WHILE_BODY]]
+;
+entry:
+  br label %while.body
+
+while.body:   ; preds = %entry, %while.body
+  %0 = phi i64 [ %ptr, %entry ], [ %add.ptr, %while.body ]
+  %1 = trunc i64 %0 to i16
+  %and = and i16 %1, 15   ; loop invariant
+  tail call void @foo(i16 noundef signext %and)
+  %add.ptr = add nsw i64 %0,  16
+  br label %while.body
+}
+

>From 6586977812ed9e5f9f99fecf2d0881e788fe06ea Mon Sep 17 00:00:00 2001
From: Marcos Horro 
Date: Tue, 7 Nov 2023 17:20:48 +
Subject: [PATCH 2/2] Fixing test on X86

---
 llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll 
b/llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll
index e0c31fdbaa4fb62..e16f429b757987b 100644
--- a/llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll
+++ b/llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll
@@ -503,8 +503,7 @@ define void @test_11() {
 ; CHECK:   bb4:
 ; CHECK-NEXT:br label [[BB6]]
 ; CHECK:   bb5:
-; CHECK-NEXT:[[_TMP24:%.*]] = icmp slt i16 poison, 0
-; CHECK-NEXT:br i1 [[_TMP24]], label [[BB5:%.*]], label [[BB5]]
+; CHECK-NEXT:br i1 poison, label [[BB5:%.*]], label [[BB5]]
 ; CHECK:   bb6:
 ; CHECK-NEXT:br i1 false, label [[BB1]], label [[BB7:%.*]]
 ; CHECK:   bb7:

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


[Lldb-commits] [lldb] [lldb] Fix calls to Type::getInt8PtrTy (PR #71561)

2023-11-07 Thread Paulo Matos via lldb-commits

https://github.com/pmatos created 
https://github.com/llvm/llvm-project/pull/71561

These have been removed in 7b9d73c2f90c0ed8497339a16fc39785349d9610. This is a 
followup patch to apply the changes to lldb.

>From 7971aa9ebf887eefb5bfd67f78319b0811be Mon Sep 17 00:00:00 2001
From: Paulo Matos 
Date: Tue, 7 Nov 2023 18:27:54 +0100
Subject: [PATCH] [lldb] Fix calls to Type::getInt8PtrTy

These have been removed in 7b9d73c2f90c0ed8497339a16fc39785349d9610.
This is a followup patch to apply the changes to lldb.
---
 .../Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp  | 2 +-
 lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index cd7d1ff6148b3b7..bc0f5993aad0d6a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -273,7 +273,7 @@ class Instrumenter {
 
   PointerType *GetI8PtrTy() {
 if (!m_i8ptr_ty)
-  m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext());
+  m_i8ptr_ty = llvm::PointerType::getUnqual(m_module.getContext());
 
 return m_i8ptr_ty;
   }
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 81bb0e73e91f9f9..33e5dd0015aebf8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -404,7 +404,7 @@ bool 
IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
 
   Type *ns_str_ty = ns_str->getType();
 
-  Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext());
+  Type *i8_ptr_ty = PointerType::getUnqual(m_module->getContext());
   Type *i32_ty = Type::getInt32Ty(m_module->getContext());
   Type *i8_ty = Type::getInt8Ty(m_module->getContext());
 
@@ -801,11 +801,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction 
*selector_load) {
 // is uint8_t*
 // Type *sel_type = StructType::get(m_module->getContext());
 // Type *sel_ptr_type = PointerType::getUnqual(sel_type);
-Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext());
+Type *sel_ptr_type = PointerType::getUnqual(m_module->getContext());
 
 Type *type_array[1];
 
-type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext());
+type_array[0] = llvm::PointerType::getUnqual(m_module->getContext());
 
 ArrayRef srN_arg_types(type_array, 1);
 

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


[Lldb-commits] [lldb] [lldb] Fix calls to Type::getInt8PtrTy (PR #71561)

2023-11-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Paulo Matos (pmatos)


Changes

These have been removed in 7b9d73c2f90c0ed8497339a16fc39785349d9610. This is a 
followup patch to apply the changes to lldb.

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


2 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (+3-3) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index cd7d1ff6148b3b7..bc0f5993aad0d6a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -273,7 +273,7 @@ class Instrumenter {
 
   PointerType *GetI8PtrTy() {
 if (!m_i8ptr_ty)
-  m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext());
+  m_i8ptr_ty = llvm::PointerType::getUnqual(m_module.getContext());
 
 return m_i8ptr_ty;
   }
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 81bb0e73e91f9f9..33e5dd0015aebf8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -404,7 +404,7 @@ bool 
IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
 
   Type *ns_str_ty = ns_str->getType();
 
-  Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext());
+  Type *i8_ptr_ty = PointerType::getUnqual(m_module->getContext());
   Type *i32_ty = Type::getInt32Ty(m_module->getContext());
   Type *i8_ty = Type::getInt8Ty(m_module->getContext());
 
@@ -801,11 +801,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction 
*selector_load) {
 // is uint8_t*
 // Type *sel_type = StructType::get(m_module->getContext());
 // Type *sel_ptr_type = PointerType::getUnqual(sel_type);
-Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext());
+Type *sel_ptr_type = PointerType::getUnqual(m_module->getContext());
 
 Type *type_array[1];
 
-type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext());
+type_array[0] = llvm::PointerType::getUnqual(m_module->getContext());
 
 ArrayRef srN_arg_types(type_array, 1);
 

``




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


[Lldb-commits] [lldb] [lldb] Fix calls to Type::getInt8PtrTy (PR #71561)

2023-11-07 Thread Yingwei Zheng via lldb-commits

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

LGTM.
BTW, I found other uses of `Type::getInt8PtrTy` in 
`llvm-project/llvm/include/llvm/ProfileData/InstrProfData.inc` and 
`llvm-project/compiler-rt/include/profile/InstrProfData.inc`.

https://github.com/llvm/llvm-project/pull/71561
___
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 Scripted*Interface base class abstract (PR #71465)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/71465

>From 2267c5fe10ceea0d16deb9a41508b698aa1aeecb Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 6 Nov 2023 16:12:36 -0800
Subject: [PATCH] [lldb/Interpreter] Make Scripted*Interface base class
 abstract

This patch makes the various Scripted Interface base class abstract by
making the `CreatePluginObject` method pure virtual.

This means that we cannot construct a Scripted Interface base class
instance, so this patch also updates the various
`ScriptedInterpreter::CreateScripted*Interface` methods to return a
`nullptr` instead.`

This patch also removes the `ScriptedPlatformInterface` member from the
`ScriptInterpreter` class since it the interpreter can be owned by the
`ScriptedPlatform` instance itself, like we do for `ScriptedProcess` objects.

Signed-off-by: Med Ismail Bennani 
---
 .../Interfaces/ScriptedPlatformInterface.h   |  4 +---
 .../Interfaces/ScriptedProcessInterface.h|  4 +---
 .../Interfaces/ScriptedThreadInterface.h |  4 +---
 .../include/lldb/Interpreter/ScriptInterpreter.h | 16 ++--
 lldb/source/Interpreter/ScriptInterpreter.cpp|  9 +++--
 .../Python/ScriptInterpreterPython.cpp   |  2 --
 6 files changed, 12 insertions(+), 27 deletions(-)

diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 2dcbb47ffa6de85..7feaa01fe89b860 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -22,9 +22,7 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }
 
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index a429cacd862f121..10203b1f8baa7aa 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -24,9 +24,7 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
 
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index 107e593b5561ef7..a7cfc690b67dc74 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -23,9 +23,7 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
 
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 0146eeb86262003..b941f6012a117b6 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -151,10 +151,7 @@ class ScriptInterpreter : public PluginInterface {
 eScriptReturnTypeOpaqueObject
   };
 
-  ScriptInterpreter(
-  Debugger &debugger, lldb::ScriptLanguage script_lang,
-  lldb::ScriptedPlatformInterfaceUP scripted_platform_interface_up =
-  std::make_unique());
+  ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang);
 
   virtual StructuredData::DictionarySP GetInterpreterInfo();
 
@@ -559,19 +556,19 @@ class ScriptInterpreter : public PluginInterface {
   lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
 
   virtual lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInterface() {
-return std::make_unique();
+return {};
   }
 
   virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
-return std::make_shared();

[Lldb-commits] [lldb] [lldb] Fix calls to Type::getInt8PtrTy (PR #71561)

2023-11-07 Thread Paulo Matos via lldb-commits

pmatos wrote:

> LGTM. BTW, I found other uses of `Type::getInt8PtrTy` in 
> `llvm-project/llvm/include/llvm/ProfileData/InstrProfData.inc` and 
> `llvm-project/compiler-rt/include/profile/InstrProfData.inc`.

Thanks, will fix those separately. Lets get lldb to build.

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


[Lldb-commits] [lldb] 3267cd3 - [lldb] Fix calls to Type::getInt8PtrTy (#71561)

2023-11-07 Thread via lldb-commits

Author: Paulo Matos
Date: 2023-11-07T18:49:11+01:00
New Revision: 3267cd3fa10651b46e9d1ce66940301e784c0533

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

LOG: [lldb] Fix calls to Type::getInt8PtrTy (#71561)

These have been removed in 7b9d73c2f90c0ed8497339a16fc39785349d9610.
This is a followup patch to apply the changes to lldb.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index cd7d1ff6148b3b7..bc0f5993aad0d6a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -273,7 +273,7 @@ class Instrumenter {
 
   PointerType *GetI8PtrTy() {
 if (!m_i8ptr_ty)
-  m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext());
+  m_i8ptr_ty = llvm::PointerType::getUnqual(m_module.getContext());
 
 return m_i8ptr_ty;
   }

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 81bb0e73e91f9f9..33e5dd0015aebf8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -404,7 +404,7 @@ bool 
IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
 
   Type *ns_str_ty = ns_str->getType();
 
-  Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext());
+  Type *i8_ptr_ty = PointerType::getUnqual(m_module->getContext());
   Type *i32_ty = Type::getInt32Ty(m_module->getContext());
   Type *i8_ty = Type::getInt8Ty(m_module->getContext());
 
@@ -801,11 +801,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction 
*selector_load) {
 // is uint8_t*
 // Type *sel_type = StructType::get(m_module->getContext());
 // Type *sel_ptr_type = PointerType::getUnqual(sel_type);
-Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext());
+Type *sel_ptr_type = PointerType::getUnqual(m_module->getContext());
 
 Type *type_array[1];
 
-type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext());
+type_array[0] = llvm::PointerType::getUnqual(m_module->getContext());
 
 ArrayRef srN_arg_types(type_array, 1);
 



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


[Lldb-commits] [lldb] [lldb] Fix calls to Type::getInt8PtrTy (PR #71561)

2023-11-07 Thread Paulo Matos via lldb-commits

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


[Lldb-commits] [openmp] [clang] [lldb] [llvm] [compiler-rt] [clang-tools-extra] [libcxx] [flang] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)

2023-11-07 Thread via lldb-commits

https://github.com/nmustakin updated 
https://github.com/llvm/llvm-project/pull/70667

>From 153c6d812939cd23bb71e53c71378117ed5b23c7 Mon Sep 17 00:00:00 2001
From: Nafis Mustakin 
Date: Mon, 30 Oct 2023 07:50:59 -0700
Subject: [PATCH 1/6] Add memory diff dump for kernel record-replay

---
 .../PluginInterface/PluginInterface.cpp   | 65 +++
 1 file changed, 54 insertions(+), 11 deletions(-)

diff --git 
a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
 
b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 0243f0205dbf0e5..8469e8eaf1593cd 100644
--- 
a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ 
b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -83,7 +83,7 @@ struct RecordReplayTy {
 return Plugin::success();
   }
 
-  void dumpDeviceMemory(StringRef Filename) {
+  void dumpDeviceMemory(StringRef Filename, bool saveDiff) {
 ErrorOr> DeviceMemoryMB =
 WritableMemoryBuffer::getNewUninitMemBuffer(MemorySize);
 if (!DeviceMemoryMB)
@@ -93,15 +93,58 @@ struct RecordReplayTy {
 MemoryStart, MemorySize, nullptr);
 if (Err)
   report_fatal_error("Error retrieving data for target pointer");
-
-StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize);
-std::error_code EC;
-raw_fd_ostream OS(Filename, EC);
-if (EC)
+
+std::error_code EC; 
+raw_fd_ostream OS(Filename, EC); 
+if(EC)
   report_fatal_error("Error dumping memory to file " + Filename + " :" +
  EC.message());
-OS << DeviceMemory;
-OS.close();
+
+if (saveDiff){
+  //Get the pre-record memory filename  
+  SmallString<128> InputFilename = {Filename.split('.').first, ".memory"};
+  //read the pre-record memorydump
+  auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); 
+  if(std::error_code EC = InputFileBuffer.getError())
+report_fatal_error("Error reading pre-record device memory");
+  
+  StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); 
+  if(InputBufferContents.size() != MemorySize) 
+report_fatal_error("Error: Pre-record device memory size mismatch");
+  
+  //get current memory contents
+  StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(),
+ DeviceMemoryMB.get()->getBuffer().size());
+  
+  //compare pre-record memorydump to current contents
+  size_t i = 0;
+  while(i < MemorySize){
+//if mismatch found, create a new diff line
+//current format - location, size, differences ...
+if(InputBufferContents[i] != DeviceMemoryContents[i]){
+  OS << i << " "; //marks the start offset
+  SmallVector modified; 
+  modified.push_back(DeviceMemoryContents[i]);
+  size_t j = 1;
+  //loop until next match is found
+  while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){
+modified.push_back(DeviceMemoryContents[i+j]);
+j++;
+  }
+  OS << j << " "; //marks the length of the mismatching sequence
+  for(const auto &value : modified)
+OS << value << " ";
+  OS << "\n"; 
+  i+=j+1; 
+}
+else i++; 
+  }
+}
+else {
+  StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), 
MemorySize);
+  OS << DeviceMemory;
+}
+OS.close();  
   }
 
 public:
@@ -209,7 +252,7 @@ struct RecordReplayTy {
 JsonKernelInfo["ArgOffsets"] = json::Value(std::move(JsonArgOffsets));
 
 SmallString<128> MemoryFilename = {Name, ".memory"};
-dumpDeviceMemory(MemoryFilename);
+dumpDeviceMemory(MemoryFilename, false);
 
 SmallString<128> GlobalsFilename = {Name, ".globals"};
 dumpGlobals(GlobalsFilename, Image);
@@ -227,7 +270,7 @@ struct RecordReplayTy {
   void saveKernelOutputInfo(const char *Name) {
 SmallString<128> OutputFilename = {
 Name, (isRecording() ? ".original.output" : ".replay.output")};
-dumpDeviceMemory(OutputFilename);
+dumpDeviceMemory(OutputFilename, true);
   }
 
   void *alloc(uint64_t Size) {
@@ -1307,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void 
**ArgPtrs,
 GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets,
 KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0],
 KernelArgs.Tripcount);
-
+   
   if (RecordReplay.isRecording())
 RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage());
 

>From 8daffad57074dd09287d321acd79c74a667eb65f Mon Sep 17 00:00:00 2001
From: Nafis Mustakin 
Date: Mon, 30 Oct 2023 08:39:40 -0700
Subject: [PATCH 2/6] Fix clang-formatting issues, accept reviewed suggestions

---
 .../PluginInterface/PluginInterface.cpp   | 78 

[Lldb-commits] [lldb] 7991412 - [lldb/Interpreter] Make Scripted*Interface base class abstract (#71465)

2023-11-07 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2023-11-07T09:56:22-08:00
New Revision: 7991412270ce1147ca0ab286e2479b5381a564ad

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

LOG: [lldb/Interpreter] Make Scripted*Interface base class abstract (#71465)

This patch makes the various Scripted Interface base class abstract by
making the `CreatePluginObject` method pure virtual.

This means that we cannot construct a Scripted Interface base class
instance, so this patch also updates the various
`ScriptedInterpreter::CreateScripted*Interface` methods to return a
`nullptr` instead.`

This patch also removes the `ScriptedPlatformInterface` member from the
`ScriptInterpreter` class since it the interpreter can be owned by the
`ScriptedPlatform` instance itself, like we do for `ScriptedProcess`
objects.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 2dcbb47ffa6de85..7feaa01fe89b860 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -22,9 +22,7 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }
 

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index a429cacd862f121..10203b1f8baa7aa 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -24,9 +24,7 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
 

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index 107e593b5561ef7..a7cfc690b67dc74 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -23,9 +23,7 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
   virtual llvm::Expected
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
- StructuredData::Generic *script_obj = nullptr) {
-return {llvm::make_error()};
-  }
+ StructuredData::Generic *script_obj = nullptr) = 0;
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
 

diff  --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 0146eeb86262003..b941f6012a117b6 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -151,10 +151,7 @@ class ScriptInterpreter : public PluginInterface {
 eScriptReturnTypeOpaqueObject
   };
 
-  ScriptInterpreter(
-  Debugger &debugger, lldb::ScriptLanguage script_lang,
-  lldb::ScriptedPlatformInterfaceUP scripted_platform_interface_up =
-  std::make_unique());
+  ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang);
 
   virtual StructuredData::DictionarySP GetInterpreterInfo();
 
@@ -559,19 +556,19 @@ class ScriptInterpreter : public PluginInterface {
   lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
 
   virtual lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInte

[Lldb-commits] [lldb] [lldb/Interpreter] Make Scripted*Interface base class abstract (PR #71465)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lld] [llvm] [clang] [lldb] [libc] [compiler-rt] [mlir] [flang] [libcxx] [libc][bazel] Add powf target and fix bazel overlay. (PR #71464)

2023-11-07 Thread via lldb-commits

https://github.com/michaelrj-google commented:

LGTM, sorry I missed this yesterday.

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Alex Langford via lldb-commits


@@ -2594,34 +2594,30 @@ ValueObjectSP 
ValueObject::CreateConstantValue(ConstString name) {
 
 ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable(
 lldb::DynamicValueType dynValue, bool synthValue) {
-  ValueObjectSP result_sp(GetSP());
-
+  ValueObjectSP result_sp;
   switch (dynValue) {
   case lldb::eDynamicCanRunTarget:
   case lldb::eDynamicDontRunTarget: {
-if (!result_sp->IsDynamic()) {
-  if (result_sp->GetDynamicValue(dynValue))
-result_sp = result_sp->GetDynamicValue(dynValue);
-}
+if (!IsDynamic())
+  result_sp = GetDynamicValue(dynValue);
   } break;
   case lldb::eNoDynamicValues: {
-if (result_sp->IsDynamic()) {
-  if (result_sp->GetStaticValue())
-result_sp = result_sp->GetStaticValue();
-}
+if (IsDynamic())
+  result_sp = GetStaticValue();
   } break;
   }
+  if (!result_sp)
+result_sp = GetSP();
+  assert(result_sp);
 
-  if (synthValue) {
-if (!result_sp->IsSynthetic()) {
-  if (result_sp->GetSyntheticValue())
-result_sp = result_sp->GetSyntheticValue();
-}
-  } else {
-if (result_sp->IsSynthetic()) {
-  if (result_sp->GetNonSyntheticValue())
-result_sp = result_sp->GetNonSyntheticValue();
-}
+  bool is_synthetic = result_sp->IsSynthetic();

bulbazord wrote:

const-ify?

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


[Lldb-commits] [lldb] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (PR #71559)

2023-11-07 Thread Alex Langford via lldb-commits

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

LGTM

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


[Lldb-commits] [llvm] [lldb] [lldb][AArch64][Linux] Add SME2 release notes and usage docs (PR #70935)

2023-11-07 Thread Alex Langford via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Read Checksum from DWARF line tables (PR #71458)

2023-11-07 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Read Checksum from DWARF line tables (PR #71458)

2023-11-07 Thread Greg Clayton via lldb-commits

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

I would love to see if we can do this without increasing the size of FileSpec 
objects. Can we have the DWARF line tables store a FileSpec + checksum and do 
its warning without making every file object contain a checksum object that 
most people will never use?

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


[Lldb-commits] [lldb] [lldb] Read Checksum from DWARF line tables (PR #71458)

2023-11-07 Thread Greg Clayton via lldb-commits


@@ -443,6 +455,9 @@ class FileSpec {
   /// The unique'd filename path.
   ConstString m_filename;
 
+  /// The optional MD5 checksum of the file.
+  Checksum m_checksum;
+

clayborg wrote:

We are increasing the size of all FileSpec objects by 16 bytes here. Is. it 
possible to do these checks another way? The FileSpec is already 24 bytes, now 
it will be 40.  

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


[Lldb-commits] [lldb] [lldb] BreakpointResolver{*}::CreateFromStructuredData should return shared pointers (PR #71477)

2023-11-07 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] 03a92f0 - [lldb] BreakpointResolver{*}::CreateFromStructuredData should return shared pointers (#71477)

2023-11-07 Thread via lldb-commits

Author: Alex Langford
Date: 2023-11-07T11:22:23-08:00
New Revision: 03a92f0ecabdf8065f4458a780484db92f032d14

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

LOG: [lldb] BreakpointResolver{*}::CreateFromStructuredData should return 
shared pointers (#71477)

BreakpointResolver::CreateFromStructuredData returns a
BreakpointResolverSP, but all of the subclasses return raw pointers.
Instead of creating a raw pointer and shoving it into a shared pointer,
it seems reasonable to just create the shared pointer directly.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
lldb/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Breakpoint/BreakpointResolverAddress.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Breakpoint/BreakpointResolverScripted.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
index 5454487e51a234c..03ae69acae4c4fd 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -30,7 +30,7 @@ class BreakpointResolverAddress : public BreakpointResolver {
 
   ~BreakpointResolverAddress() override = default;
 
-  static BreakpointResolver *
+  static lldb::BreakpointResolverSP
   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &options_dict,
Status &error);

diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index 3747e6d2d9a22ad..7635729c50a6e06 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -27,7 +27,7 @@ class BreakpointResolverFileLine : public BreakpointResolver {
   const SourceLocationSpec &location_spec,
   std::optional removed_prefix_opt = std::nullopt);
 
-  static BreakpointResolver *
+  static lldb::BreakpointResolverSP
   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &data_dict,
Status &error);

diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index 138d555e2230743..43e1217c13d5ef6 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -27,7 +27,7 @@ class BreakpointResolverFileRegex : public BreakpointResolver 
{
   const lldb::BreakpointSP &bkpt, RegularExpression regex,
   const std::unordered_set &func_name_set, bool exact_match);
 
-  static BreakpointResolver *
+  static lldb::BreakpointResolverSP
   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &options_dict,
Status &error);

diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index cbfcbc9af0ea1cb..94b19db3085d768 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -50,7 +50,7 @@ class BreakpointResolverName : public BreakpointResolver {
  lldb::LanguageType language, lldb::addr_t offset,
  bool skip_prologue);
 
-  static BreakpointResolver *
+  static lldb::BreakpointResolverSP
   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &data_dict,
Status &error);

diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
index cecd0f92a21a86c..c0bbc1c2bafb704 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
@@ -30,7 +30,7 @@ class BreakpointResolverScripted : public BreakpointResolver {
 
   ~BreakpointResolverScripted() override = default;
 
-  static BreakpointResolver *
+  static lldb::BreakpointResolverSP
   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dict

[Lldb-commits] [lldb] [lldb][test] Implement getting thread ID on OpenBSD (PR #71129)

2023-11-07 Thread Brad Smith via lldb-commits

brad0 wrote:

Ping.

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


[Lldb-commits] [lldb] [lldb] Check for abstract methods implementation in Scripted Plugin Objects (PR #71260)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/71260

>From a98cf851f5947546eb76196ef945ce1fa8d9bfaa Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Mon, 6 Nov 2023 14:15:12 -0800
Subject: [PATCH] [lldb] Check for abstract methods implementation in Scripted
 Plugin Objects

This patch enforces that every scripted object implements all the
necessary abstract methods.

Every scripted affordance language interface can implement a list of
abstract methods name that checked when the object is instanciated.

Since some scripting affordances implementations can be derived from
template base classes, we can't check the object dictionary since it
will contain the definition of the base class, so instead, this checks
the scripting class dictionary.

Previously, for the various python interfaces, we used `ABC.abstractmethod`
decorators but this is too language specific and doesn't work for
scripting affordances that are not derived from template base classes
(i.e OperatingSystem, ScriptedThreadPlan, ...), so this patch provides
generic/language-agnostic checks for every scripted affordance.

Signed-off-by: Med Ismail Bennani 
---
 .../Interfaces/ScriptedInterface.h|   2 +
 .../Interfaces/ScriptedPlatformInterface.h|   4 +
 .../Interfaces/ScriptedProcessInterface.h |   4 +
 .../Interfaces/ScriptedThreadInterface.h  |   4 +
 .../OperatingSystemPythonInterface.h  |   7 +
 .../ScriptedPlatformPythonInterface.h |   6 +
 .../ScriptedProcessPythonInterface.h  |   5 +
 .../Interfaces/ScriptedPythonInterface.h  | 156 ++
 .../ScriptedThreadPythonInterface.h   |   5 +
 .../Python/PythonDataObjects.cpp  |  14 ++
 .../Python/PythonDataObjects.h|   2 +
 .../scripted_process/TestScriptedProcess.py   |  49 ++
 .../missing_methods_scripted_process.py   |  19 +++
 .../Python/PythonDataObjectsTests.cpp |   3 +
 14 files changed, 251 insertions(+), 29 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/scripted_process/missing_methods_scripted_process.py

diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index e4816352daa5db6..9753a916243b7be 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -30,6 +30,8 @@ class ScriptedInterface {
 return m_object_instance_sp;
   }
 
+  virtual llvm::SmallVector GetAbstractMethods() const = 
0;
+
   template 
   static Ret ErrorWithMessage(llvm::StringRef caller_name,
   llvm::StringRef error_msg, Status &error,
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 7feaa01fe89b860..167149cbf5b8f89 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -24,6 +24,10 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return {};
+  }
+
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }
 
   virtual StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) {
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index 10203b1f8baa7aa..e41f488d201e2cb 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -26,6 +26,10 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return {};
+  }
+
   virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
 
   virtual Status Attach(const ProcessAttachInfo &attach_info) {
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index a7cfc690b67dc74..0520b6905e2501f 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -25,6 +25,10 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return {};
+  }
+
   virtu

[Lldb-commits] [lldb] [lldb] Check for abstract methods implementation in Scripted Plugin Objects (PR #71260)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] cc9ad72 - [lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)

2023-11-07 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2023-11-07T12:07:16-08:00
New Revision: cc9ad72713405ef8f2468c7a714a137b4a3343ba

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

LOG: [lldb] Check for abstract methods implementation in Scripted Plugin 
Objects (#71260)

This patch enforces that every scripted object implements all the
necessary abstract methods.

Every scripted affordance language interface can implement a list of
abstract methods name that checked when the object is instanciated.

Since some scripting affordances implementations can be derived from
template base classes, we can't check the object dictionary since it
will contain the definition of the base class, so instead, this checks
the scripting class dictionary.

Previously, for the various python interfaces, we used
`ABC.abstractmethod` decorators but this is too language specific and
doesn't work for scripting affordances that are not derived from
template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so
this patch provides generic/language-agnostic checks for every scripted
affordance.

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/API/functionalities/scripted_process/missing_methods_scripted_process.py

Modified: 
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/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h

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

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index e4816352daa5db6..9753a916243b7be 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -30,6 +30,8 @@ class ScriptedInterface {
 return m_object_instance_sp;
   }
 
+  virtual llvm::SmallVector GetAbstractMethods() const = 
0;
+
   template 
   static Ret ErrorWithMessage(llvm::StringRef caller_name,
   llvm::StringRef error_msg, Status &error,

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 7feaa01fe89b860..167149cbf5b8f89 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -24,6 +24,10 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return {};
+  }
+
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }
 
   virtual StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) {

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index 10203b1f8baa7aa..e41f488d201e2cb 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -26,6 +26,10 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return {};
+  }
+
   virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
 
   virtual Status Attach(const ProcessAttachInfo &attach_info) {

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index a7cfc690b67dc74..0520b6905e2501f 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb

[Lldb-commits] [lldb] [lldb] Add Checksum to FileSpec (PR #71457)

2023-11-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

So I debugged lldb with lldb and adding a counter into the FileSpec constructor 
and came up a max of 721833 files after trying to set a breakpoint in 
Driver.cpp, so that storage is about 16.5MB which isn't too bad. This goes up 
to 27.5MB with the FileSpec being 40 bytes, so not too bad. Hopefully this 
won't overwhelm some larger targets in LLDB memory wise

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


[Lldb-commits] [flang] [llvm] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [clang] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-07 Thread Alexey Bataev via lldb-commits


@@ -229,6 +230,9 @@ class Parser : public CodeCompletionHandler {
   /// Parsing OpenMP directive mode.
   bool OpenMPDirectiveParsing = false;
 
+  /// Parsing OpenACC directive mode.
+  bool OpenACCDirectiveParsing = false;

alexey-bataev wrote:

It is unused, need to remove it for now.

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


[Lldb-commits] [lldb] [clang] [libc] [llvm] [clang-tools-extra] [libcxx] [lld] [flang] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-07 Thread Alexey Bataev via lldb-commits


@@ -0,0 +1,14 @@
+// RUN: %clang -S -### -fopenacc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DRIVER
+// CHECK-DRIVER: "-cc1" {{.*}} "-fopenacc"
+
+// RUN: %clang -S -### -fopenacc -fexperimental-openacc-macro-override=202211 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-MACRO-OVERRIDE
+// RUN: %clang -S -### -fopenacc -fexperimental-openacc-macro-override 202211 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-MACRO-OVERRIDE

alexey-bataev wrote:

Why do you need this new option fexperimental-openacc-macro-override? Can you 
just rely on -D_OPENACC instead?

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


[Lldb-commits] [lldb] c2ad9f8 - Revert "[lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)"

2023-11-07 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-11-07T13:04:01-08:00
New Revision: c2ad9f8b607931430e86da7420493599c48e62a0

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

LOG: Revert "[lldb] Check for abstract methods implementation in Scripted 
Plugin Objects (#71260)"

This reverts commit cc9ad72713405ef8f2468c7a714a137b4a3343ba since it
breaks some tests upstream:

https://lab.llvm.org/buildbot/#/builders/68/builds/63112


Failed Tests (4):
  lldb-api :: functionalities/gdb_remote_client/TestThreadSelectionBug.py
  lldb-api :: functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
  lldb-api :: 
functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
  lldb-api :: functionalities/postmortem/mach-core/TestMachCore.py

Added: 


Modified: 
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/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h

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

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Removed: 

lldb/test/API/functionalities/scripted_process/missing_methods_scripted_process.py



diff  --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 9753a916243b7be..e4816352daa5db6 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -30,8 +30,6 @@ class ScriptedInterface {
 return m_object_instance_sp;
   }
 
-  virtual llvm::SmallVector GetAbstractMethods() const = 
0;
-
   template 
   static Ret ErrorWithMessage(llvm::StringRef caller_name,
   llvm::StringRef error_msg, Status &error,

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 167149cbf5b8f89..7feaa01fe89b860 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -24,10 +24,6 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
-  llvm::SmallVector GetAbstractMethods() const override {
-return {};
-  }
-
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }
 
   virtual StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) {

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index e41f488d201e2cb..10203b1f8baa7aa 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -26,10 +26,6 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
-  llvm::SmallVector GetAbstractMethods() const override {
-return {};
-  }
-
   virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
 
   virtual Status Attach(const ProcessAttachInfo &attach_info) {

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index 0520b6905e2501f..a7cfc690b67dc74 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -25,10 +25,6 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) = 0;
 
-  llvm::SmallVector GetAbstractMethods() const override {

[Lldb-commits] [llvm] [lldb] [lldb][AArch64][Linux] Add SME2 release notes and usage docs (PR #70935)

2023-11-07 Thread Jason Molenda via lldb-commits

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

looks good.

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


[Lldb-commits] [lldb] [lldb] Add Checksum to FileSpec (PR #71457)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> So I debugged lldb with lldb and adding a counter into the FileSpec 
> constructor and came up a max of 721833 files after trying to set a 
> breakpoint in Driver.cpp, so that storage is about 16.5MB which isn't too 
> bad. This goes up to 27.5MB with the FileSpec being 40 bytes, so not too bad. 
> Hopefully this won't overwhelm some larger targets in LLDB memory wise

@clayborg I think it would be worth having that stat for FileSpecs in-tree so 
everyone can have access to it using `statistics dump` for instance.

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


[Lldb-commits] [lldb] [lldb][split-dwarf] implement GetSeparateDebugInfo for SymbolFileOnDemand (PR #71230)

2023-11-07 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Looks good to me.

FYI: here is how you might be able to try cross compiling by editing the 
Makefile and removing the `@skipIf*`. The compile command for cross compiling 
looks like:
```
clang++ -target x86_64-pc-linux-elf -g -gsplit-dwarf -c main.cpp
```
You will want to try adding a bogus `-target x86_64--carp` and make sure the 
test stops or can handle not compiling correctly. This will help you figure out 
what will happen if `-target x86_64-pc-linux-elf` doesn't work because ELF or 
linux support isn't compiled into clang. If you can't gracefully handle this 
case, then just leave the `@skip` decorators as is

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread Jason Molenda via lldb-commits

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

LGTM fwiw.

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread Jason Molenda via lldb-commits


@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;

jasonmolenda wrote:

I've never used `mutable`, but declaring an ivar `mutable const` doesn't make 
sense to me.  I understand that marking an ivar `mutable` means a method marked 
`const` can still modify it, fine I'm sure that's useful.  But I don't see why 
marking this `mutable const` is about?

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-11-07 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add Checksum to FileSpec (PR #71457)

2023-11-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

> > So I debugged lldb with lldb and adding a counter into the FileSpec 
> > constructor and came up a max of 721833 files after trying to set a 
> > breakpoint in Driver.cpp, so that storage is about 16.5MB which isn't too 
> > bad. This goes up to 27.5MB with the FileSpec being 40 bytes, so not too 
> > bad. Hopefully this won't overwhelm some larger targets in LLDB memory wise
> 
> @clayborg I think it would be worth having that stat for FileSpecs in-tree so 
> everyone can have access to it using `statistics dump` for instance.

I agree. Easy to add a static variable into FileSpec to do the counting and 
then hookup to stats. Might be nice to make a mix in class that any internal 
objects can inherit from that wouldn't change the size of any objects, but on 
construction would add to a count, and on destruction would decrement. It would 
be nice to track FileSpec, Symbol and other common objects in a debugger 
process.

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


[Lldb-commits] [lldb] [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsString (PR #71613)

2023-11-07 Thread Alex Langford via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/71613

This patch changes the interface of
StructuredData::Array::GetItemAtIndexAsString to return a 
`std::optional` instead of taking an out parameter. More 
generally, this commit serves as proposal that we change all of the sibling 
APIs (`GetItemAtIndexAs`) to do the same thing. The reason this isn't one giant 
patch is because it is rather unwieldy changing just one of these, so if this 
is approved, I will do all of the other ones as individual follow-ups.

>From 5081b19801932866997fe19719df0184a68694d6 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 7 Nov 2023 16:56:35 -0800
Subject: [PATCH] [lldb] Change interface of
 StructuredData::Array::GetItemAtIndexAsString

This patch changes the interface of
StructuredData::Array::GetItemAtIndexAsString to return a
`std::optional` instead of taking an out parameter.
More generally, this commit serves as proposal that we change all of the
sibling APIs (`GetItemAtIndexAs`) to do the same thing. The reason this
isn't one giant patch is because it is rather unwieldy changing just one
of these, so if this is approved, I will do all of the other ones as
individual follow-ups.
---
 lldb/include/lldb/Utility/StructuredData.h| 22 -
 lldb/source/Breakpoint/Breakpoint.cpp | 16 --
 lldb/source/Breakpoint/BreakpointOptions.cpp  |  7 ++--
 .../BreakpointResolverFileRegex.cpp   |  8 ++---
 .../Breakpoint/BreakpointResolverName.cpp |  9 +++---
 .../Commands/CommandObjectBreakpoint.cpp  |  6 ++--
 lldb/source/Core/SearchFilter.cpp | 32 +--
 lldb/source/Target/DynamicRegisterInfo.cpp| 26 ---
 .../lldb-server/tests/MessageObjects.cpp  |  8 +++--
 9 files changed, 63 insertions(+), 71 deletions(-)

diff --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index 279238f9af76e01..6e39bcff2c0af0b 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -247,23 +248,12 @@ class StructuredData {
   return success;
 }
 
-bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const {
-  ObjectSP value_sp = GetItemAtIndex(idx);
-  if (value_sp.get()) {
-if (auto string_value = value_sp->GetAsString()) {
-  result = string_value->GetValue();
-  return true;
-}
+std::optional GetItemAtIndexAsString(size_t idx) const {
+  if (auto item_sp = GetItemAtIndex(idx)) {
+if (auto *string_value = item_sp->GetAsString())
+  return string_value->GetValue();
   }
-  return false;
-}
-
-bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result,
-llvm::StringRef default_val) const {
-  bool success = GetItemAtIndexAsString(idx, result);
-  if (!success)
-result = default_val;
-  return success;
+  return {};
 }
 
 bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const {
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ff4f195ea30909e..28a6a16d45907ef 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -205,10 +205,9 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
   if (success && names_array) {
 size_t num_names = names_array->GetSize();
 for (size_t i = 0; i < num_names; i++) {
-  llvm::StringRef name;
-  Status error;
-  success = names_array->GetItemAtIndexAsString(i, name);
-  target.AddNameToBreakpoint(result_sp, name.str().c_str(), error);
+  if (std::optional maybe_name =
+  names_array->GetItemAtIndexAsString(i))
+target.AddNameToBreakpoint(result_sp, *maybe_name, error);
 }
   }
 
@@ -238,11 +237,10 @@ bool Breakpoint::SerializedBreakpointMatchesNames(
   size_t num_names = names_array->GetSize();
 
   for (size_t i = 0; i < num_names; i++) {
-llvm::StringRef name;
-if (names_array->GetItemAtIndexAsString(i, name)) {
-  if (llvm::is_contained(names, name))
-return true;
-}
+std::optional maybe_name =
+names_array->GetItemAtIndexAsString(i);
+if (maybe_name && llvm::is_contained(names, *maybe_name))
+  return true;
   }
   return false;
 }
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 268c52341dfed6e..6c6037dd9edd3a4 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -88,10 +88,9 @@ BreakpointOptions::CommandData::CreateFromStructuredData(
   if (success) {
 size_t num_elems = user_source->GetSize();
 for (size_t i = 0; i < num_elems; i++) {
-  llvm::StringRef elem_string;
-  success = user_source-

[Lldb-commits] [lldb] [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsString (PR #71613)

2023-11-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

This patch changes the interface of
StructuredData::Array::GetItemAtIndexAsString to return a 
`std::optional` instead of taking an out parameter. More 
generally, this commit serves as proposal that we change all of the sibling 
APIs (`GetItemAtIndexAs`) to do the same thing. The reason this isn't one giant 
patch is because it is rather unwieldy changing just one of these, so if this 
is approved, I will do all of the other ones as individual follow-ups.

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


9 Files Affected:

- (modified) lldb/include/lldb/Utility/StructuredData.h (+6-16) 
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+7-9) 
- (modified) lldb/source/Breakpoint/BreakpointOptions.cpp (+3-4) 
- (modified) lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp (+4-4) 
- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+4-5) 
- (modified) lldb/source/Commands/CommandObjectBreakpoint.cpp (+3-3) 
- (modified) lldb/source/Core/SearchFilter.cpp (+16-16) 
- (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+14-12) 
- (modified) lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp (+6-2) 


``diff
diff --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index 279238f9af76e01..6e39bcff2c0af0b 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -247,23 +248,12 @@ class StructuredData {
   return success;
 }
 
-bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const {
-  ObjectSP value_sp = GetItemAtIndex(idx);
-  if (value_sp.get()) {
-if (auto string_value = value_sp->GetAsString()) {
-  result = string_value->GetValue();
-  return true;
-}
+std::optional GetItemAtIndexAsString(size_t idx) const {
+  if (auto item_sp = GetItemAtIndex(idx)) {
+if (auto *string_value = item_sp->GetAsString())
+  return string_value->GetValue();
   }
-  return false;
-}
-
-bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result,
-llvm::StringRef default_val) const {
-  bool success = GetItemAtIndexAsString(idx, result);
-  if (!success)
-result = default_val;
-  return success;
+  return {};
 }
 
 bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const {
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ff4f195ea30909e..28a6a16d45907ef 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -205,10 +205,9 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
   if (success && names_array) {
 size_t num_names = names_array->GetSize();
 for (size_t i = 0; i < num_names; i++) {
-  llvm::StringRef name;
-  Status error;
-  success = names_array->GetItemAtIndexAsString(i, name);
-  target.AddNameToBreakpoint(result_sp, name.str().c_str(), error);
+  if (std::optional maybe_name =
+  names_array->GetItemAtIndexAsString(i))
+target.AddNameToBreakpoint(result_sp, *maybe_name, error);
 }
   }
 
@@ -238,11 +237,10 @@ bool Breakpoint::SerializedBreakpointMatchesNames(
   size_t num_names = names_array->GetSize();
 
   for (size_t i = 0; i < num_names; i++) {
-llvm::StringRef name;
-if (names_array->GetItemAtIndexAsString(i, name)) {
-  if (llvm::is_contained(names, name))
-return true;
-}
+std::optional maybe_name =
+names_array->GetItemAtIndexAsString(i);
+if (maybe_name && llvm::is_contained(names, *maybe_name))
+  return true;
   }
   return false;
 }
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 268c52341dfed6e..6c6037dd9edd3a4 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -88,10 +88,9 @@ BreakpointOptions::CommandData::CreateFromStructuredData(
   if (success) {
 size_t num_elems = user_source->GetSize();
 for (size_t i = 0; i < num_elems; i++) {
-  llvm::StringRef elem_string;
-  success = user_source->GetItemAtIndexAsString(i, elem_string);
-  if (success)
-data_up->user_source.AppendString(elem_string);
+  if (std::optional maybe_elem_string =
+  user_source->GetItemAtIndexAsString(i))
+data_up->user_source.AppendString(*maybe_elem_string);
 }
   }
 
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 38de16a56155e96..13c7f17fd807ee5 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint

[Lldb-commits] [lldb] [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsString (PR #71613)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] 0a21144 - [lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)

2023-11-07 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-11-07T22:01:41-08:00
New Revision: 0a21144614950ce063d8dac6394307bd3be604cd

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

LOG: [lldb] Check for abstract methods implementation in Scripted Plugin 
Objects (#71260)

This patch enforces that every scripted object implements all the
necessary abstract methods.

Every scripted affordance language interface can implement a list of
abstract methods name that checked when the object is instanciated.

Since some scripting affordances implementations can be derived from
template base classes, we can't check the object dictionary since it
will contain the definition of the base class, so instead, this checks
the scripting class dictionary.

Previously, for the various python interfaces, we used
`ABC.abstractmethod` decorators but this is too language specific and
doesn't work for scripting affordances that are not derived from
template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so
this patch provides generic/language-agnostic checks for every scripted
affordance.

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/API/functionalities/scripted_process/missing_methods_scripted_process.py

Modified: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h

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

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

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index e4816352daa5db6..9753a916243b7be 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -30,6 +30,8 @@ class ScriptedInterface {
 return m_object_instance_sp;
   }
 
+  virtual llvm::SmallVector GetAbstractMethods() const = 
0;
+
   template 
   static Ret ErrorWithMessage(llvm::StringRef caller_name,
   llvm::StringRef error_msg, Status &error,

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
index ee24e0ee30f91b3..da7bbf13b1d5556 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
@@ -29,6 +29,10 @@ class OperatingSystemPythonInterface
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return llvm::SmallVector({"get_thread_info"});
+  }
+
   StructuredData::DictionarySP CreateThread(lldb::tid_t tid,
 lldb::addr_t context) override;
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
index e04f2d02ab1d120..0842d3a00342914 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
@@ -28,6 +28,12 @@ class ScriptedPlatformPythonInterface : public 
ScriptedPlatformInterface,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  llvm::SmallVector GetAbstractMethods() const override {
+return llvm::SmallVector(
+{"list_processes", "attach_to_process", "launch_process",
+ "kill_process"});
+  }
+
   StructuredData::DictionarySP ListProcesses() override;
 
   StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) override;

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h
index f3cff619f6624f0.

[Lldb-commits] [lldb] c9bfe04 - [lldb/test] Fix TestScriptedProcess.py failures on arm linux bots

2023-11-07 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-11-07T23:24:02-08:00
New Revision: c9bfe0411f1d3f1f7261675e972bf223f9167548

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

LOG: [lldb/test] Fix TestScriptedProcess.py failures on arm linux bots

This patch tentatively fixes TestScriptedProcess.py which has been
failing on the `lldb-arm-ubuntu` & `lldb-aarch64-ubuntu` bots:

- https://lab.llvm.org/buildbot/#/builders/17/builds/44965
- https://lab.llvm.org/buildbot/#/builders/96/builds/48152

According to the test log, on those systems, the clang driver that build
the test binary doesn't have the `-m` flag to specify the architure so
this patch replaces it with the `-target` flag using `clang -dumpmachine`
to get the host triple.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/functionalities/scripted_process/Makefile

Removed: 




diff  --git a/lldb/test/API/functionalities/scripted_process/Makefile 
b/lldb/test/API/functionalities/scripted_process/Makefile
index c23310226d8752f..ba739451fc7ef3e 100644
--- a/lldb/test/API/functionalities/scripted_process/Makefile
+++ b/lldb/test/API/functionalities/scripted_process/Makefile
@@ -2,12 +2,14 @@ CXX_SOURCES := main.cpp
 ENABLE_THREADS := YES
 LD_EXTRAS := -L. -lbaz -I.
 
-override ARCH := $(shell uname -m)
+override TRIPLE := $(shell $(CC) -dumpmachine)
+
+CXXFLAGS_EXTRAS := -target $(TRIPLE)
 
 all: libbaz.dylib a.out
 
 libbaz.dylib: baz.cpp
-   $(MAKE) -f $(MAKEFILE_RULES) ARCH=$(ARCH) \
+   $(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=baz DYLIB_CXX_SOURCES=baz.cpp
 
 include Makefile.rules



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