[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] Fix SyntaxWarning messages from python 3.12 (PR #86806)

2024-03-28 Thread via lldb-commits


@@ -101,7 +101,7 @@ def extract_result_types(comment):
 
 
 def strip_doxygen(comment):
-"""Returns the given comment without \-escaped words."""
+"""Returns the given comment without \\-escaped words."""

AngryLoki wrote:

No, `'''\-'''` is still SyntaxWarning in Python 3.12. It is possible to not 
escape with raw literals, but raw literals are used mostly to indicate that 
string is actually _raw_ (I've never seen raw docblocks). Also there is some 
consensus between highlighting tools that raw literals use regexp highlighting 
(in vscode, dandavison/delta, sharkdp/bat), that's why I escaped some strings 
selectively (e. g. in runCmd I did not use raw literals).
https://github.com/llvm/llvm-project/assets/108563/deb36005-b0e5-459d-b936-cf644243774f";>


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


[Lldb-commits] [clang] [lldb] [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (PR #84387)

2024-03-28 Thread Daniil Kovalev via lldb-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/84387

>From 728f5644aebfafd2114e7e47a9b83ef057423997 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 20 Feb 2024 10:57:54 -0800
Subject: [PATCH 01/10] Upstream ptrauth changes to DWARFASTParserClang

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 54d06b1115a229..67fe830e1aa70d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -495,6 +495,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext &sc,
   case DW_TAG_const_type:
   case DW_TAG_restrict_type:
   case DW_TAG_volatile_type:
+  case DW_TAG_LLVM_ptrauth_type:
   case DW_TAG_atomic_type:
   case DW_TAG_unspecified_type: {
 type_sp = ParseTypeModifier(sc, die, attrs);
@@ -676,6 +677,62 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
&sc,
   case DW_TAG_volatile_type:
 encoding_data_type = Type::eEncodingIsVolatileUID;
 break;
+  case DW_TAG_LLVM_ptrauth_type: {
+DWARFDIE ptr_die = die.GetReferencedDIE(DW_AT_type);
+// FIXME: Fully resolving the type here may affect performance.
+Type *res_type = dwarf->ResolveType(ptr_die);
+if (!res_type)
+  break;
+attrs.type.Clear();
+encoding_data_type = Type::eEncodingIsUID;
+resolve_state = Type::ResolveState::Full;
+
+// Apply the ptrauth qualifier to the resolved type.
+auto *ptr_type =
+(clang::Type *)res_type->GetForwardCompilerType().GetOpaqueQualType();
+auto getAttr = [&](llvm::dwarf::Attribute Attr, unsigned defaultValue = 0) 
{
+  return die.GetAttributeValueAsUnsigned(Attr, defaultValue);
+};
+const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
+const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
+const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
+const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
+const bool authenticates_null_values =
+getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values, 0);
+const bool is_restricted_integral = !ptr_type->isPointerType();
+const unsigned authentication_mode_int = getAttr(
+DW_AT_LLVM_ptrauth_authentication_mode,
+static_cast(clang::PointerAuthenticationMode::SignAndAuth));
+clang::PointerAuthenticationMode authentication_mode =
+clang::PointerAuthenticationMode::SignAndAuth;
+if (authentication_mode_int >=
+static_cast(clang::PointerAuthenticationMode::None) &&
+authentication_mode_int <=
+static_cast(
+clang::PointerAuthenticationMode::SignAndAuth)) {
+  authentication_mode = static_cast(
+  authentication_mode_int);
+} else {
+  dwarf->GetObjectFile()->GetModule()->ReportError(
+  "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
+  die.GetOffset(), authentication_mode_int);
+}
+
+// FIXME: Use these variables when PointerAuthQualifier is more complete
+// upstream.
+(void)is_restricted_integral;
+
+clang::Qualifiers qualifiers;
+auto ptr_auth = clang::PointerAuthQualifier::Create(
+key, addr_disc, extra, authentication_mode, isapointer,
+authenticates_null_values);
+qualifiers.setPointerAuth(ptr_auth);
+auto &ctx = m_ast.getASTContext();
+auto qual_type = ctx.getQualifiedType(ptr_type, qualifiers);
+clang_type =
+CompilerType(m_ast.weak_from_this(), qual_type.getAsOpaquePtr());
+break;
+  }
   case DW_TAG_atomic_type:
 encoding_data_type = Type::eEncodingIsAtomicUID;
 break;

>From 8aa1ba0b05362b8960faac1945bb25c68ecb4b98 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Thu, 7 Mar 2024 16:34:09 +0300
Subject: [PATCH 02/10] [PAC][lldb] Use `eEncodingIsLLVMPtrAuthUID` for
 `__ptrauth`-qualified types

---
 lldb/include/lldb/Symbol/Type.h   | 4 +++-
 .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp  | 2 +-
 lldb/source/Symbol/Type.cpp   | 8 +++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index acd1a769f13cd6..d55280b58bc4f7 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -401,7 +401,9 @@ class Type : public std::enable_shared_from_this, 
public UserID {
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
 /// This type is the synthetic type whose UID is m_encoding_uid.
-eEncodingIsSyntheticUID
+eEncodingIsSyntheticUID,
+/// This type is a signed pointer.
+eEncodingIsLLVMPtrAuthUID
   };
 
   enum class ResolveState : 

[Lldb-commits] [lldb] [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (PR #84387)

2024-03-28 Thread Daniil Kovalev via lldb-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/84387

>From 728f5644aebfafd2114e7e47a9b83ef057423997 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 20 Feb 2024 10:57:54 -0800
Subject: [PATCH 1/6] Upstream ptrauth changes to DWARFASTParserClang

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 54d06b1115a229..67fe830e1aa70d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -495,6 +495,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext &sc,
   case DW_TAG_const_type:
   case DW_TAG_restrict_type:
   case DW_TAG_volatile_type:
+  case DW_TAG_LLVM_ptrauth_type:
   case DW_TAG_atomic_type:
   case DW_TAG_unspecified_type: {
 type_sp = ParseTypeModifier(sc, die, attrs);
@@ -676,6 +677,62 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
&sc,
   case DW_TAG_volatile_type:
 encoding_data_type = Type::eEncodingIsVolatileUID;
 break;
+  case DW_TAG_LLVM_ptrauth_type: {
+DWARFDIE ptr_die = die.GetReferencedDIE(DW_AT_type);
+// FIXME: Fully resolving the type here may affect performance.
+Type *res_type = dwarf->ResolveType(ptr_die);
+if (!res_type)
+  break;
+attrs.type.Clear();
+encoding_data_type = Type::eEncodingIsUID;
+resolve_state = Type::ResolveState::Full;
+
+// Apply the ptrauth qualifier to the resolved type.
+auto *ptr_type =
+(clang::Type *)res_type->GetForwardCompilerType().GetOpaqueQualType();
+auto getAttr = [&](llvm::dwarf::Attribute Attr, unsigned defaultValue = 0) 
{
+  return die.GetAttributeValueAsUnsigned(Attr, defaultValue);
+};
+const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
+const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
+const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
+const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
+const bool authenticates_null_values =
+getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values, 0);
+const bool is_restricted_integral = !ptr_type->isPointerType();
+const unsigned authentication_mode_int = getAttr(
+DW_AT_LLVM_ptrauth_authentication_mode,
+static_cast(clang::PointerAuthenticationMode::SignAndAuth));
+clang::PointerAuthenticationMode authentication_mode =
+clang::PointerAuthenticationMode::SignAndAuth;
+if (authentication_mode_int >=
+static_cast(clang::PointerAuthenticationMode::None) &&
+authentication_mode_int <=
+static_cast(
+clang::PointerAuthenticationMode::SignAndAuth)) {
+  authentication_mode = static_cast(
+  authentication_mode_int);
+} else {
+  dwarf->GetObjectFile()->GetModule()->ReportError(
+  "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
+  die.GetOffset(), authentication_mode_int);
+}
+
+// FIXME: Use these variables when PointerAuthQualifier is more complete
+// upstream.
+(void)is_restricted_integral;
+
+clang::Qualifiers qualifiers;
+auto ptr_auth = clang::PointerAuthQualifier::Create(
+key, addr_disc, extra, authentication_mode, isapointer,
+authenticates_null_values);
+qualifiers.setPointerAuth(ptr_auth);
+auto &ctx = m_ast.getASTContext();
+auto qual_type = ctx.getQualifiedType(ptr_type, qualifiers);
+clang_type =
+CompilerType(m_ast.weak_from_this(), qual_type.getAsOpaquePtr());
+break;
+  }
   case DW_TAG_atomic_type:
 encoding_data_type = Type::eEncodingIsAtomicUID;
 break;

>From 8aa1ba0b05362b8960faac1945bb25c68ecb4b98 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Thu, 7 Mar 2024 16:34:09 +0300
Subject: [PATCH 2/6] [PAC][lldb] Use `eEncodingIsLLVMPtrAuthUID` for
 `__ptrauth`-qualified types

---
 lldb/include/lldb/Symbol/Type.h   | 4 +++-
 .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp  | 2 +-
 lldb/source/Symbol/Type.cpp   | 8 +++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index acd1a769f13cd6..d55280b58bc4f7 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -401,7 +401,9 @@ class Type : public std::enable_shared_from_this, 
public UserID {
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
 /// This type is the synthetic type whose UID is m_encoding_uid.
-eEncodingIsSyntheticUID
+eEncodingIsSyntheticUID,
+/// This type is a signed pointer.
+eEncodingIsLLVMPtrAuthUID
   };
 
   enum class ResolveState : unsi

[Lldb-commits] [lldb] [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (PR #84387)

2024-03-28 Thread Daniil Kovalev via lldb-commits


@@ -664,6 +685,17 @@ CompilerType CompilerType::GetPointerType() const {
   return CompilerType();
 }
 
+CompilerType
+CompilerType::AddPtrAuthModifier(unsigned key, bool isAddressDiscriminated,

kovdan01 wrote:

> Also, whose this user of this API?

I've updated this PR with eecbb370d3d0257a5a4ffb68219d41aa5426 which 
implements lazy resolve of ptrauth types. Since then, 
`CompilerType::AddPtrAuthModifier` is used in `Type::ResolveCompilerType`. So, 
this API is "indirectly" tested in DWARFASTParserClangTests.TestPtrAuthParsing 
unit test.

> Can we add an API test that tests this API? E.g., running `frame var`/`expr` 
> on ptrauth types?

Probably later, when `__ptrauth` qualifier support in upstream llvm is more 
complete. As far as I see from existing API tests (e.g. 
API/lang/c/const_variables/TestConstVariables.py), we need to compile code with 
desired features first, and then run it under debugger and test stuff that we 
want to. Since the compiler does not seem to fully support `__ptrauth`-related 
features yet, implementing the corresponding API test does not currently seem 
viable.

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


[Lldb-commits] [lldb] [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (PR #84387)

2024-03-28 Thread Daniil Kovalev via lldb-commits


@@ -216,6 +216,16 @@ class TypeSystem : public PluginInterface,
 
   virtual uint32_t GetPointerByteSize() = 0;
 
+  // TODO: are we allowed to insert virtual functions in the middle of the 
class
+  // interface and break ABI?

kovdan01 wrote:

Thanks, deleted TODOs in ced59fd6d4fcaa1a4158708fde3a4b0e9af2e5c2

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


[Lldb-commits] [lldb] [PAC][lldb][Dwarf] Support `__ptrauth`-qualified types in user expressions (PR #84387)

2024-03-28 Thread Daniil Kovalev via lldb-commits


@@ -676,6 +677,62 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
&sc,
   case DW_TAG_volatile_type:
 encoding_data_type = Type::eEncodingIsVolatileUID;
 break;
+  case DW_TAG_LLVM_ptrauth_type: {
+DWARFDIE ptr_die = die.GetReferencedDIE(DW_AT_type);

kovdan01 wrote:

Done, thanks, see eecbb370d3d0257a5a4ffb68219d41aa5426

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


[Lldb-commits] [lldb] [lldb][FreeBSD] Add FreeBSD specific AT_HWCAP value (PR #84147)

2024-03-28 Thread Ed Maste via lldb-commits

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

(Assuming the comment removal gets squashed into one commit)

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


[Lldb-commits] [lldb] [lldb] clang-format AuxVector.h (PR #85057)

2024-03-28 Thread Ed Maste via lldb-commits

https://github.com/emaste commented:

It looks like the commit messages and content are mismatched - the commit 
message references AT_HWCAP2 but it doesn't look like that's included here?

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


[Lldb-commits] [lldb] [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (PR #86962)

2024-03-28 Thread Jordan Rupprecht via lldb-commits

https://github.com/rupprecht created 
https://github.com/llvm/llvm-project/pull/86962

The commit 8bed754c2f965c8cbbb050be6f650b78f7fd78a6 was intended to support the 
use case where users want to run all the LLDB tests in an environment where 
pexpect is not installed. Those users can build with 
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to skip pexpect tests, *but* 
because we still fail in cmake configuration, they must use 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` to avoid failing due to pexpect not being 
available.

I would like to remove `LLDB_TEST_USE_VENDOR_PACKAGES` now, but first I'd like 
to make sure users w/o pexpect can pass CI with 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=OFF 
-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`. Once that is done, I am not 
aware of any other issues caused by the previous commits, so the third party 
tree should be safe to remove.

>From cb71bea376843d4f34fbf18726411942142bbe8f Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Thu, 28 Mar 2024 15:04:58 +
Subject: [PATCH] [lldb] Remove cmake check for pexpect when
 LLDB_TEST_USE_VENDOR_PACKAGES is off

The commit 8bed754c2f965c8cbbb050be6f650b78f7fd78a6 was intended to support the 
use case where users want to run all the LLDB tests in an environment where 
pexpect is not installed. Those users can build with 
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to skip pexpect tests, *but* 
because we still fail in cmake configuration, they must use 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` to avoid failing due to pexpect not being 
available.

I would like to remove `LLDB_TEST_USE_VENDOR_PACKAGES` now, but first I'd like 
to make sure users w/o pexpect can pass CI with 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=OFF 
-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`.
---
 lldb/test/CMakeLists.txt | 17 -
 1 file changed, 17 deletions(-)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 0ef2eb1c42ce06..b6ec5bc4d819e3 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -31,23 +31,6 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 endif()
 
-# The "pexpect" package should come from the system environment, not from the
-# LLDB tree. However, we delay the deletion of it from the tree in case
-# users/buildbots don't have the package yet and need some time to install it.
-# Windows is configured to skip all pexpect tests, and guards all
-# "import pexpect" calls, so we do not need pexpect installed there.
-if (NOT LLDB_TEST_USE_VENDOR_PACKAGES AND NOT WIN32)
-  unset(PY_pexpect_FOUND CACHE)
-  lldb_find_python_module(pexpect)
-  if (NOT PY_pexpect_FOUND)
-message(FATAL_ERROR
-  "Python module 'pexpect' not found. Please install it via pip or via "
-  "your operating system's package manager. For a temporary workaround, "
-  "use a version from the LLDB tree with "
-  "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
-  endif()
-endif()
-
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
   # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,

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


[Lldb-commits] [lldb] [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (PR #86962)

2024-03-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jordan Rupprecht (rupprecht)


Changes

The commit 8bed754c2f965c8cbbb050be6f650b78f7fd78a6 was intended to support the 
use case where users want to run all the LLDB tests in an environment where 
pexpect is not installed. Those users can build with 
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to skip pexpect tests, *but* 
because we still fail in cmake configuration, they must use 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` to avoid failing due to pexpect not being 
available.

I would like to remove `LLDB_TEST_USE_VENDOR_PACKAGES` now, but first I'd like 
to make sure users w/o pexpect can pass CI with 
`-DLLDB_TEST_USE_VENDOR_PACKAGES=OFF 
-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`. Once that is done, I am not 
aware of any other issues caused by the previous commits, so the third party 
tree should be safe to remove.

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


1 Files Affected:

- (modified) lldb/test/CMakeLists.txt (-17) 


``diff
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 0ef2eb1c42ce06..b6ec5bc4d819e3 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -31,23 +31,6 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 endif()
 
-# The "pexpect" package should come from the system environment, not from the
-# LLDB tree. However, we delay the deletion of it from the tree in case
-# users/buildbots don't have the package yet and need some time to install it.
-# Windows is configured to skip all pexpect tests, and guards all
-# "import pexpect" calls, so we do not need pexpect installed there.
-if (NOT LLDB_TEST_USE_VENDOR_PACKAGES AND NOT WIN32)
-  unset(PY_pexpect_FOUND CACHE)
-  lldb_find_python_module(pexpect)
-  if (NOT PY_pexpect_FOUND)
-message(FATAL_ERROR
-  "Python module 'pexpect' not found. Please install it via pip or via "
-  "your operating system's package manager. For a temporary workaround, "
-  "use a version from the LLDB tree with "
-  "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
-  endif()
-endif()
-
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
   # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,

``




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


[Lldb-commits] [lldb] [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (PR #86962)

2024-03-28 Thread Jonas Devlieghere via lldb-commits

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

Works for us!

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


[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)

2024-03-28 Thread Daniil Kovalev via lldb-commits

kovdan01 wrote:

@jasonmolenda Would be glad to see your feedback - see answers to your previous 
comments above

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


[Lldb-commits] [lldb] a834076 - [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (#86962)

2024-03-28 Thread via lldb-commits

Author: Jordan Rupprecht
Date: 2024-03-28T15:57:09-05:00
New Revision: a8340767de71b8c7d10de74019622592b39e3704

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

LOG: [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES 
(#86962)

The commit 8bed754c2f965c8cbbb050be6f650b78f7fd78a6 was intended to
support the use case where users want to run all the LLDB tests in an
environment where pexpect is not installed. Those users can build with
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to skip pexpect tests,
*but* because we still fail in cmake configuration, they must use
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` to avoid failing due to pexpect not
being available.

I would like to remove `LLDB_TEST_USE_VENDOR_PACKAGES` now, but first
I'd like to make sure users w/o pexpect can pass CI with
`-DLLDB_TEST_USE_VENDOR_PACKAGES=OFF
-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`. Once that is done, I am
not aware of any other issues caused by the previous commits, so the
third party tree should be safe to remove.

Added: 


Modified: 
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 0ef2eb1c42ce06..b6ec5bc4d819e3 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -31,23 +31,6 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 endif()
 
-# The "pexpect" package should come from the system environment, not from the
-# LLDB tree. However, we delay the deletion of it from the tree in case
-# users/buildbots don't have the package yet and need some time to install it.
-# Windows is configured to skip all pexpect tests, and guards all
-# "import pexpect" calls, so we do not need pexpect installed there.
-if (NOT LLDB_TEST_USE_VENDOR_PACKAGES AND NOT WIN32)
-  unset(PY_pexpect_FOUND CACHE)
-  lldb_find_python_module(pexpect)
-  if (NOT PY_pexpect_FOUND)
-message(FATAL_ERROR
-  "Python module 'pexpect' not found. Please install it via pip or via "
-  "your operating system's package manager. For a temporary workaround, "
-  "use a version from the LLDB tree with "
-  "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
-  endif()
-endif()
-
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
   # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,



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


[Lldb-commits] [lldb] [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (PR #86962)

2024-03-28 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread via lldb-commits

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

>From 03ef6db02f49ab4cc4f63b32553015b4f3801b5b Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Wed, 27 Mar 2024 10:09:45 -0700
Subject: [PATCH 1/4] [LLDB] Add APFloat helper functions to Scalar class.

This adds the ability to create a Scalar from an APFloat, and to
create an APFloat from an APSInt or another APFloat.
---
 lldb/include/lldb/Utility/Scalar.h |  6 +
 lldb/source/Utility/Scalar.cpp | 42 ++
 2 files changed, 48 insertions(+)

diff --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 8e087a5ddeb855..d5e70fdf203001 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -71,6 +71,8 @@ class Scalar {
   : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
   Scalar(llvm::APSInt v)
   : m_type(e_int), m_integer(std::move(v)), m_float(0.0f) {}
+  Scalar(llvm::APFloat v)
+  : m_integer(0), m_float(v) {}
 
   bool SignExtend(uint32_t bit_pos);
 
@@ -186,6 +188,10 @@ class Scalar {
   Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding,
   size_t byte_size);
 
+  llvm::APFloat CreateAPFloatFromAPSInt(lldb::BasicType basic_type);
+
+  llvm::APFloat CreateAPFloatFromAPFloat(lldb::BasicType basic_type);
+
 protected:
   Scalar::Type m_type = e_void;
   llvm::APSInt m_integer;
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 5ad68065bce1b7..afcb204d8f95a5 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -813,6 +813,48 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t 
bit_offset) {
   return false;
 }
 
+llvm::APFloat Scalar::CreateAPFloatFromAPSInt(lldb::BasicType basic_type) {
+  switch (basic_type) {
+case lldb::eBasicTypeFloat:
+  return llvm::APFloat(m_integer.isSigned()
+   ? llvm::APIntOps::RoundSignedAPIntToFloat(m_integer)
+   : llvm::APIntOps::RoundAPIntToFloat(m_integer));
+case lldb::eBasicTypeDouble:
+  // No way to get more precision at the moment.
+case lldb::eBasicTypeLongDouble:
+  return llvm::APFloat(m_integer.isSigned()
+   ? llvm::APIntOps::RoundSignedAPIntToDouble(
+   m_integer)
+   : 
llvm::APIntOps::RoundAPIntToDouble(m_integer));
+default:
+  const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+  return llvm::APFloat::getNaN(sem);
+  }
+}
+
+llvm::APFloat Scalar::CreateAPFloatFromAPFloat(lldb::BasicType basic_type) {
+  switch (basic_type) {
+case lldb::eBasicTypeFloat: {
+  bool loses_info;
+  m_float.convert(llvm::APFloat::IEEEsingle(),
+  llvm::APFloat::rmNearestTiesToEven, &loses_info);
+  return m_float;
+}
+case lldb::eBasicTypeDouble:
+  // No way to get more precision at the moment.
+case lldb::eBasicTypeLongDouble: {
+  bool loses_info;
+  m_float.convert(llvm::APFloat::IEEEdouble(),
+llvm::APFloat::rmNearestTiesToEven, &loses_info);
+  return m_float;
+}
+default:
+  const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+  return llvm::APFloat::getNaN(sem);
+  }
+}
+
+
 bool lldb_private::operator==(Scalar lhs, Scalar rhs) {
   // If either entry is void then we can just compare the types
   if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)

>From 8de923d01dca34061f6a5ea7dad995ad754426ca Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Wed, 27 Mar 2024 13:17:23 -0700
Subject: [PATCH 2/4] [LLDB] Add APFloat helper functions to Scalar class.

Fix clang-format issues.
---
 lldb/include/lldb/Utility/Scalar.h |  3 +-
 lldb/source/Utility/Scalar.cpp | 62 +++---
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index d5e70fdf203001..c89566f5e9d01a 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -71,8 +71,7 @@ class Scalar {
   : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
   Scalar(llvm::APSInt v)
   : m_type(e_int), m_integer(std::move(v)), m_float(0.0f) {}
-  Scalar(llvm::APFloat v)
-  : m_integer(0), m_float(v) {}
+  Scalar(llvm::APFloat v) : m_integer(0), m_float(v) {}
 
   bool SignExtend(uint32_t bit_pos);
 
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index afcb204d8f95a5..e94fd459623665 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -815,46 +815,46 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t 
bit_offset) {
 
 llvm::APFloat Scalar::CreateAPFloatFromAPSInt(lldb::BasicType basic_type) {
   switch (basic_type) {
-case lldb::eBasicTypeFloat:
-  return llvm::APFloat

[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread via lldb-commits

cmtice wrote:

> Could you add a test for these new methods in 
> `unittests/Utility/ScalarTest.cpp`?

Done. :-)

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


[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread Alex Langford via lldb-commits

bulbazord wrote:

> > Could you add a test for these new methods in 
> > `unittests/Utility/ScalarTest.cpp`?
> 
> Done. :-)

Thank you! :)

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


[Lldb-commits] [lldb] ba6b2d2 - [LLDB] Add APFloat helper functions to Scalar class. (#86862)

2024-03-28 Thread via lldb-commits

Author: cmtice
Date: 2024-03-28T21:39:58-07:00
New Revision: ba6b2d22af177a72b132cdb8e9350a708f282d2c

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

LOG: [LLDB] Add APFloat helper functions to Scalar class. (#86862)

This adds the ability to create a Scalar from an APFloat, and to create
an APFloat from an APSInt or another APFloat.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 8e087a5ddeb855..d7155884c6d1b8 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -71,6 +71,7 @@ class Scalar {
   : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
   Scalar(llvm::APSInt v)
   : m_type(e_int), m_integer(std::move(v)), m_float(0.0f) {}
+  Scalar(llvm::APFloat v) : m_type(e_float), m_integer(0), m_float(v) {}
 
   bool SignExtend(uint32_t bit_pos);
 
@@ -186,6 +187,10 @@ class Scalar {
   Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding,
   size_t byte_size);
 
+  llvm::APFloat CreateAPFloatFromAPSInt(lldb::BasicType basic_type);
+
+  llvm::APFloat CreateAPFloatFromAPFloat(lldb::BasicType basic_type);
+
 protected:
   Scalar::Type m_type = e_void;
   llvm::APSInt m_integer;

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 5ad68065bce1b7..e94fd459623665 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -813,6 +813,48 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t 
bit_offset) {
   return false;
 }
 
+llvm::APFloat Scalar::CreateAPFloatFromAPSInt(lldb::BasicType basic_type) {
+  switch (basic_type) {
+  case lldb::eBasicTypeFloat:
+return llvm::APFloat(
+m_integer.isSigned()
+? llvm::APIntOps::RoundSignedAPIntToFloat(m_integer)
+: llvm::APIntOps::RoundAPIntToFloat(m_integer));
+  case lldb::eBasicTypeDouble:
+// No way to get more precision at the moment.
+  case lldb::eBasicTypeLongDouble:
+return llvm::APFloat(
+m_integer.isSigned()
+? llvm::APIntOps::RoundSignedAPIntToDouble(m_integer)
+: llvm::APIntOps::RoundAPIntToDouble(m_integer));
+  default:
+const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+return llvm::APFloat::getNaN(sem);
+  }
+}
+
+llvm::APFloat Scalar::CreateAPFloatFromAPFloat(lldb::BasicType basic_type) {
+  switch (basic_type) {
+  case lldb::eBasicTypeFloat: {
+bool loses_info;
+m_float.convert(llvm::APFloat::IEEEsingle(),
+llvm::APFloat::rmNearestTiesToEven, &loses_info);
+return m_float;
+  }
+  case lldb::eBasicTypeDouble:
+// No way to get more precision at the moment.
+  case lldb::eBasicTypeLongDouble: {
+bool loses_info;
+m_float.convert(llvm::APFloat::IEEEdouble(),
+llvm::APFloat::rmNearestTiesToEven, &loses_info);
+return m_float;
+  }
+  default:
+const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+return llvm::APFloat::getNaN(sem);
+  }
+}
+
 bool lldb_private::operator==(Scalar lhs, Scalar rhs) {
   // If either entry is void then we can just compare the types
   if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)

diff  --git a/lldb/unittests/Utility/ScalarTest.cpp 
b/lldb/unittests/Utility/ScalarTest.cpp
index 29a4bcd356f113..8d957d16593ee7 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -402,3 +402,61 @@ TEST(ScalarTest, TruncOrExtendTo) {
   S.TruncOrExtendTo(16, false);
   EXPECT_EQ(S.UInt128(APInt()), APInt(16, 0xu));
 }
+
+TEST(ScalarTest, APFloatConstructor) {
+  llvm::APFloat my_single(llvm::APFloatBase::IEEEsingle(), "3.14159");
+  llvm::APFloat my_double(llvm::APFloatBase::IEEEdouble(), "3.14159");
+  Scalar S(my_single);
+  Scalar D(my_double);
+
+  EXPECT_EQ(S.GetType(), Scalar::e_float);
+  EXPECT_EQ(D.GetType(), Scalar::e_float);
+  ASSERT_TRUE(S != D);
+}
+
+TEST(ScalarTest, CreateAPFloats) {
+  llvm::APFloat ap_float(llvm::APFloatBase::IEEEsingle(), "3.14159");
+  llvm::APFloat ap_nan = llvm::APFloat::getNaN(llvm::APFloat::IEEEsingle());
+  llvm::APSInt int1("12");
+  llvm::APSInt int2("-4");
+  Scalar I1(int1);
+  Scalar I2(int2);
+  Scalar F(ap_float);
+
+  llvm::APFloat out1_float = I1.CreateAPFloatFromAPSInt(lldb::eBasicTypeFloat);
+  llvm::APFloat out1_double =
+  I1.CreateAPFloatFromAPSInt(lldb::eBasicTypeDouble);
+  llvm::APFloat out1_longdouble =
+  I1.CreateAPFloatFromAPSInt(lldb::eBasicTypeLongDouble);
+  llvm::APFloat out1_nan =
+  I1.CreateAPFloatFromAPSInt(lldb::eBasicTypeFloatComplex);
+  EXPECT_

[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

2024-03-28 Thread via lldb-commits

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