[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-06-06 Thread Artem Yurchenko via lldb-commits

temyurchenko wrote:

This is a relanding of #93131. 

The first commit is the same, the second commit presents and fixes the issue 
from the linked discussion.

cc @erichkeane, @AaronBallman, @gulfemsavrun.
(I can't set the reviewers myself)

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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-06-06 Thread Artem Yurchenko via lldb-commits

https://github.com/temyurchenko updated 
https://github.com/llvm/llvm-project/pull/93913

>From fac45476736cd04f044f046fd0df9e59450a926b Mon Sep 17 00:00:00 2001
From: Artem Yurchenko 
Date: Wed, 22 May 2024 23:41:35 -0400
Subject: [PATCH 1/2] [clang][AST] fix ast-print of `extern ` with >=2
 declarators

Problem: the printer used to ignore all but the first declarator for
unbraced language linkage declarators. Furthemore, that one would
be printed without the final semicolon.

Solution: for unbraced case we traverse all declarators via
`VisitDeclContext`. Furthermore, in appropriate visitors we query
for whether they are a part of the unbraced extern language linkage
spec, and if so, print appropriately.
---
 clang/lib/AST/DeclPrinter.cpp | 55 ++-
 clang/test/AST/ast-print-language-linkage.cpp | 31 +++
 2 files changed, 72 insertions(+), 14 deletions(-)
 create mode 100644 clang/test/AST/ast-print-language-linkage.cpp

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0cf4e64f83b8d..9250a7f6eceb2 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, 
llvm::raw_ostream ,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
QualType T,
llvm::raw_ostream ) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
   Out << prefix;
 }
 
+/// Return the language of the linkage spec of `D`, if applicable.
+///
+/// \Return - "C" if `D` has been declared with unbraced `extern "C"`
+/// - "C++" if `D` has been declared with unbraced `extern "C++"`
+/// - nullptr in any other case
+static const char *tryGetUnbracedLinkageLanguage(const Decl *D) {
+  const auto *SD = dyn_cast(D->getDeclContext());
+  if (!SD || SD->hasBraces())
+return nullptr;
+  if (SD->getLanguage() == LinkageSpecLanguageIDs::C)
+return "C";
+  assert(SD->getLanguage() == LinkageSpecLanguageIDs::CXX &&
+ "unknown language in linkage specification");
+  return "C++";
+}
+
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   if (!D->getDescribedFunctionTemplate() &&
   !D->isFunctionTemplateSpecialization()) {
@@ -662,6 +678,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   CXXDeductionGuideDecl *GuideDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
+if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) {
+  // the "extern" specifier is implicit
+  assert(D->getStorageClass() == SC_None);
+  Out << "extern \"" << Lang << "\" ";
+}
 switch (D->getStorageClass()) {
 case SC_None: break;
 case SC_Extern: Out << "extern "; break;
@@ -807,7 +828,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   }
   if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
   !Policy.SuppressUnwrittenScope)
-MaybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(),
+maybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(),
Out);
   AFT->getReturnType().print(Out, Policy, Proto);
   Proto.clear();
@@ -932,6 +953,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
 : D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
 
   if (!Policy.SuppressSpecifiers) {
+if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) {
+  // the "extern" specifier is implicit
+  assert(D->getStorageClass() == SC_None);
+  Out << "extern \"" << Lang << "\" ";
+}
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
   Out << VarDecl::getStorageClassSpecifierString(SC) << " ";
@@ -961,7 +987,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
 
   if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
   !Policy.SuppressUnwrittenScope)
-MaybePrintTagKeywordIfSupressingScopes(Policy, T, Out);
+maybePrintTagKeywordIfSupressingScopes(Policy, T, Out);
 
   printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters &&
 D->getIdentifier())
@@ -1064,6 +1090,8 @@ void 
DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
 
 void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) {
   prettyPrintAttributes(D);
+  if (const char *Lang = tryGetUnbracedLinkageLanguage(D))
+Out << "extern \"" << Lang << "\";";
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
@@ -1136,22 +1164,21 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
 }
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
-  const char *l;
+  if (!D->hasBraces()) {
+

[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-06-06 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 5f243b3fffca42ed320529a54aefd86087aa85f8 
db1eb9b69f2ed961a586d15d165acd000bb728c4 -- 
clang/test/AST/ast-print-language-linkage.cpp clang/lib/AST/Decl.cpp 
clang/lib/AST/DeclPrinter.cpp clang/lib/Sema/SemaDecl.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
index 468e2b186c..e02b418b1e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
@@ -77,7 +77,8 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const 
CompilerType ,
 
   clang::FunctionDecl *func_decl = FunctionDecl::Create(
   ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type,
-  nullptr, SC_None, /*UsesFPIntrin=*/false, isInlineSpecified, 
hasWrittenPrototype,
+  nullptr, SC_None, /*UsesFPIntrin=*/false, isInlineSpecified,
+  hasWrittenPrototype,
   isConstexprSpecified ? ConstexprSpecKind::Constexpr
: ConstexprSpecKind::Unspecified);
 

``




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


[Lldb-commits] [clang] [lldb] [clang][AST] fix ast-print of extern with >=2 declarators, fixed (PR #93913)

2024-06-06 Thread Artem Yurchenko via lldb-commits

https://github.com/temyurchenko updated 
https://github.com/llvm/llvm-project/pull/93913

>From fac45476736cd04f044f046fd0df9e59450a926b Mon Sep 17 00:00:00 2001
From: Artem Yurchenko 
Date: Wed, 22 May 2024 23:41:35 -0400
Subject: [PATCH 1/2] [clang][AST] fix ast-print of `extern ` with >=2
 declarators

Problem: the printer used to ignore all but the first declarator for
unbraced language linkage declarators. Furthemore, that one would
be printed without the final semicolon.

Solution: for unbraced case we traverse all declarators via
`VisitDeclContext`. Furthermore, in appropriate visitors we query
for whether they are a part of the unbraced extern language linkage
spec, and if so, print appropriately.
---
 clang/lib/AST/DeclPrinter.cpp | 55 ++-
 clang/test/AST/ast-print-language-linkage.cpp | 31 +++
 2 files changed, 72 insertions(+), 14 deletions(-)
 create mode 100644 clang/test/AST/ast-print-language-linkage.cpp

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0cf4e64f83b8d..9250a7f6eceb2 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, 
llvm::raw_ostream ,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
QualType T,
llvm::raw_ostream ) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy ,
   Out << prefix;
 }
 
+/// Return the language of the linkage spec of `D`, if applicable.
+///
+/// \Return - "C" if `D` has been declared with unbraced `extern "C"`
+/// - "C++" if `D` has been declared with unbraced `extern "C++"`
+/// - nullptr in any other case
+static const char *tryGetUnbracedLinkageLanguage(const Decl *D) {
+  const auto *SD = dyn_cast(D->getDeclContext());
+  if (!SD || SD->hasBraces())
+return nullptr;
+  if (SD->getLanguage() == LinkageSpecLanguageIDs::C)
+return "C";
+  assert(SD->getLanguage() == LinkageSpecLanguageIDs::CXX &&
+ "unknown language in linkage specification");
+  return "C++";
+}
+
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   if (!D->getDescribedFunctionTemplate() &&
   !D->isFunctionTemplateSpecialization()) {
@@ -662,6 +678,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   CXXDeductionGuideDecl *GuideDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
+if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) {
+  // the "extern" specifier is implicit
+  assert(D->getStorageClass() == SC_None);
+  Out << "extern \"" << Lang << "\" ";
+}
 switch (D->getStorageClass()) {
 case SC_None: break;
 case SC_Extern: Out << "extern "; break;
@@ -807,7 +828,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   }
   if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
   !Policy.SuppressUnwrittenScope)
-MaybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(),
+maybePrintTagKeywordIfSupressingScopes(Policy, AFT->getReturnType(),
Out);
   AFT->getReturnType().print(Out, Policy, Proto);
   Proto.clear();
@@ -932,6 +953,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
 : D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
 
   if (!Policy.SuppressSpecifiers) {
+if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) {
+  // the "extern" specifier is implicit
+  assert(D->getStorageClass() == SC_None);
+  Out << "extern \"" << Lang << "\" ";
+}
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
   Out << VarDecl::getStorageClassSpecifierString(SC) << " ";
@@ -961,7 +987,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
 
   if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
   !Policy.SuppressUnwrittenScope)
-MaybePrintTagKeywordIfSupressingScopes(Policy, T, Out);
+maybePrintTagKeywordIfSupressingScopes(Policy, T, Out);
 
   printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters &&
 D->getIdentifier())
@@ -1064,6 +1090,8 @@ void 
DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
 
 void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) {
   prettyPrintAttributes(D);
+  if (const char *Lang = tryGetUnbracedLinkageLanguage(D))
+Out << "extern \"" << Lang << "\";";
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
@@ -1136,22 +1164,21 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
 }
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
-  const char *l;
+  if (!D->hasBraces()) {
+

[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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

>From 63fd7a008900fea3bb609ac018f8401f04f07703 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 6 Jun 2024 10:14:34 -0700
Subject: [PATCH 1/4] [lldb] Encode number of operands for DWARF operations

Add the number of operands to Dwarf.h as documented in Table 7.6 in the
DWARF 5 standard.
---
 llvm/include/llvm/BinaryFormat/Dwarf.def | 364 +++
 llvm/include/llvm/BinaryFormat/Dwarf.h   |   5 +-
 llvm/include/llvm/ObjectYAML/DWARFYAML.h |   2 +-
 llvm/lib/BinaryFormat/Dwarf.cpp  |  21 +-
 4 files changed, 204 insertions(+), 188 deletions(-)

diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def 
b/llvm/include/llvm/BinaryFormat/Dwarf.def
index adcf24eb83b03..bbc3bbcf02b5c 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -51,7 +51,7 @@
 #endif
 
 #ifndef HANDLE_DW_OP
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR)
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, VERSION, VENDOR)
 #endif
 
 #ifndef HANDLE_DW_OP_LLVM_USEROP
@@ -694,197 +694,197 @@ HANDLE_DW_FORM(0x1f21, GNU_strp_alt, 0, GNU)
 HANDLE_DW_FORM(0x2001, LLVM_addrx_offset, 0, LLVM)
 
 // DWARF Expression operators.
-HANDLE_DW_OP(0x03, addr, 2, DWARF)
-HANDLE_DW_OP(0x06, deref, 2, DWARF)
-HANDLE_DW_OP(0x08, const1u, 2, DWARF)
-HANDLE_DW_OP(0x09, const1s, 2, DWARF)
-HANDLE_DW_OP(0x0a, const2u, 2, DWARF)
-HANDLE_DW_OP(0x0b, const2s, 2, DWARF)
-HANDLE_DW_OP(0x0c, const4u, 2, DWARF)
-HANDLE_DW_OP(0x0d, const4s, 2, DWARF)
-HANDLE_DW_OP(0x0e, const8u, 2, DWARF)
-HANDLE_DW_OP(0x0f, const8s, 2, DWARF)
-HANDLE_DW_OP(0x10, constu, 2, DWARF)
-HANDLE_DW_OP(0x11, consts, 2, DWARF)
-HANDLE_DW_OP(0x12, dup, 2, DWARF)
-HANDLE_DW_OP(0x13, drop, 2, DWARF)
-HANDLE_DW_OP(0x14, over, 2, DWARF)
-HANDLE_DW_OP(0x15, pick, 2, DWARF)
-HANDLE_DW_OP(0x16, swap, 2, DWARF)
-HANDLE_DW_OP(0x17, rot, 2, DWARF)
-HANDLE_DW_OP(0x18, xderef, 2, DWARF)
-HANDLE_DW_OP(0x19, abs, 2, DWARF)
-HANDLE_DW_OP(0x1a, and, 2, DWARF)
-HANDLE_DW_OP(0x1b, div, 2, DWARF)
-HANDLE_DW_OP(0x1c, minus, 2, DWARF)
-HANDLE_DW_OP(0x1d, mod, 2, DWARF)
-HANDLE_DW_OP(0x1e, mul, 2, DWARF)
-HANDLE_DW_OP(0x1f, neg, 2, DWARF)
-HANDLE_DW_OP(0x20, not, 2, DWARF)
-HANDLE_DW_OP(0x21, or, 2, DWARF)
-HANDLE_DW_OP(0x22, plus, 2, DWARF)
-HANDLE_DW_OP(0x23, plus_uconst, 2, DWARF)
-HANDLE_DW_OP(0x24, shl, 2, DWARF)
-HANDLE_DW_OP(0x25, shr, 2, DWARF)
-HANDLE_DW_OP(0x26, shra, 2, DWARF)
-HANDLE_DW_OP(0x27, xor, 2, DWARF)
-HANDLE_DW_OP(0x28, bra, 2, DWARF)
-HANDLE_DW_OP(0x29, eq, 2, DWARF)
-HANDLE_DW_OP(0x2a, ge, 2, DWARF)
-HANDLE_DW_OP(0x2b, gt, 2, DWARF)
-HANDLE_DW_OP(0x2c, le, 2, DWARF)
-HANDLE_DW_OP(0x2d, lt, 2, DWARF)
-HANDLE_DW_OP(0x2e, ne, 2, DWARF)
-HANDLE_DW_OP(0x2f, skip, 2, DWARF)
-HANDLE_DW_OP(0x30, lit0, 2, DWARF)
-HANDLE_DW_OP(0x31, lit1, 2, DWARF)
-HANDLE_DW_OP(0x32, lit2, 2, DWARF)
-HANDLE_DW_OP(0x33, lit3, 2, DWARF)
-HANDLE_DW_OP(0x34, lit4, 2, DWARF)
-HANDLE_DW_OP(0x35, lit5, 2, DWARF)
-HANDLE_DW_OP(0x36, lit6, 2, DWARF)
-HANDLE_DW_OP(0x37, lit7, 2, DWARF)
-HANDLE_DW_OP(0x38, lit8, 2, DWARF)
-HANDLE_DW_OP(0x39, lit9, 2, DWARF)
-HANDLE_DW_OP(0x3a, lit10, 2, DWARF)
-HANDLE_DW_OP(0x3b, lit11, 2, DWARF)
-HANDLE_DW_OP(0x3c, lit12, 2, DWARF)
-HANDLE_DW_OP(0x3d, lit13, 2, DWARF)
-HANDLE_DW_OP(0x3e, lit14, 2, DWARF)
-HANDLE_DW_OP(0x3f, lit15, 2, DWARF)
-HANDLE_DW_OP(0x40, lit16, 2, DWARF)
-HANDLE_DW_OP(0x41, lit17, 2, DWARF)
-HANDLE_DW_OP(0x42, lit18, 2, DWARF)
-HANDLE_DW_OP(0x43, lit19, 2, DWARF)
-HANDLE_DW_OP(0x44, lit20, 2, DWARF)
-HANDLE_DW_OP(0x45, lit21, 2, DWARF)
-HANDLE_DW_OP(0x46, lit22, 2, DWARF)
-HANDLE_DW_OP(0x47, lit23, 2, DWARF)
-HANDLE_DW_OP(0x48, lit24, 2, DWARF)
-HANDLE_DW_OP(0x49, lit25, 2, DWARF)
-HANDLE_DW_OP(0x4a, lit26, 2, DWARF)
-HANDLE_DW_OP(0x4b, lit27, 2, DWARF)
-HANDLE_DW_OP(0x4c, lit28, 2, DWARF)
-HANDLE_DW_OP(0x4d, lit29, 2, DWARF)
-HANDLE_DW_OP(0x4e, lit30, 2, DWARF)
-HANDLE_DW_OP(0x4f, lit31, 2, DWARF)
-HANDLE_DW_OP(0x50, reg0, 2, DWARF)
-HANDLE_DW_OP(0x51, reg1, 2, DWARF)
-HANDLE_DW_OP(0x52, reg2, 2, DWARF)
-HANDLE_DW_OP(0x53, reg3, 2, DWARF)
-HANDLE_DW_OP(0x54, reg4, 2, DWARF)
-HANDLE_DW_OP(0x55, reg5, 2, DWARF)
-HANDLE_DW_OP(0x56, reg6, 2, DWARF)
-HANDLE_DW_OP(0x57, reg7, 2, DWARF)
-HANDLE_DW_OP(0x58, reg8, 2, DWARF)
-HANDLE_DW_OP(0x59, reg9, 2, DWARF)
-HANDLE_DW_OP(0x5a, reg10, 2, DWARF)
-HANDLE_DW_OP(0x5b, reg11, 2, DWARF)
-HANDLE_DW_OP(0x5c, reg12, 2, DWARF)
-HANDLE_DW_OP(0x5d, reg13, 2, DWARF)
-HANDLE_DW_OP(0x5e, reg14, 2, DWARF)
-HANDLE_DW_OP(0x5f, reg15, 2, DWARF)
-HANDLE_DW_OP(0x60, reg16, 2, DWARF)
-HANDLE_DW_OP(0x61, reg17, 2, DWARF)
-HANDLE_DW_OP(0x62, reg18, 2, DWARF)
-HANDLE_DW_OP(0x63, reg19, 2, DWARF)
-HANDLE_DW_OP(0x64, reg20, 2, DWARF)
-HANDLE_DW_OP(0x65, reg21, 2, DWARF)
-HANDLE_DW_OP(0x66, reg22, 2, DWARF)
-HANDLE_DW_OP(0x67, reg23, 2, DWARF)
-HANDLE_DW_OP(0x68, reg24, 2, DWARF)
-HANDLE_DW_OP(0x69, reg25, 2, DWARF)
-HANDLE_DW_OP(0x6a, reg26, 2, DWARF)
-HANDLE_DW_OP(0x6b, reg27, 2, DWARF)

[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread Jonas Devlieghere via lldb-commits


@@ -694,197 +694,197 @@ HANDLE_DW_FORM(0x1f21, GNU_strp_alt, 0, GNU)
 HANDLE_DW_FORM(0x2001, LLVM_addrx_offset, 0, LLVM)
 
 // DWARF Expression operators.
-HANDLE_DW_OP(0x03, addr, 2, DWARF)
-HANDLE_DW_OP(0x06, deref, 2, DWARF)
-HANDLE_DW_OP(0x08, const1u, 2, DWARF)
-HANDLE_DW_OP(0x09, const1s, 2, DWARF)
-HANDLE_DW_OP(0x0a, const2u, 2, DWARF)
-HANDLE_DW_OP(0x0b, const2s, 2, DWARF)
-HANDLE_DW_OP(0x0c, const4u, 2, DWARF)
-HANDLE_DW_OP(0x0d, const4s, 2, DWARF)
-HANDLE_DW_OP(0x0e, const8u, 2, DWARF)
-HANDLE_DW_OP(0x0f, const8s, 2, DWARF)
-HANDLE_DW_OP(0x10, constu, 2, DWARF)
-HANDLE_DW_OP(0x11, consts, 2, DWARF)
-HANDLE_DW_OP(0x12, dup, 2, DWARF)
-HANDLE_DW_OP(0x13, drop, 2, DWARF)
-HANDLE_DW_OP(0x14, over, 2, DWARF)
-HANDLE_DW_OP(0x15, pick, 2, DWARF)
-HANDLE_DW_OP(0x16, swap, 2, DWARF)
-HANDLE_DW_OP(0x17, rot, 2, DWARF)
-HANDLE_DW_OP(0x18, xderef, 2, DWARF)
-HANDLE_DW_OP(0x19, abs, 2, DWARF)
-HANDLE_DW_OP(0x1a, and, 2, DWARF)
-HANDLE_DW_OP(0x1b, div, 2, DWARF)
-HANDLE_DW_OP(0x1c, minus, 2, DWARF)
-HANDLE_DW_OP(0x1d, mod, 2, DWARF)
-HANDLE_DW_OP(0x1e, mul, 2, DWARF)
-HANDLE_DW_OP(0x1f, neg, 2, DWARF)
-HANDLE_DW_OP(0x20, not, 2, DWARF)
-HANDLE_DW_OP(0x21, or, 2, DWARF)
-HANDLE_DW_OP(0x22, plus, 2, DWARF)
-HANDLE_DW_OP(0x23, plus_uconst, 2, DWARF)
-HANDLE_DW_OP(0x24, shl, 2, DWARF)
-HANDLE_DW_OP(0x25, shr, 2, DWARF)
-HANDLE_DW_OP(0x26, shra, 2, DWARF)
-HANDLE_DW_OP(0x27, xor, 2, DWARF)
-HANDLE_DW_OP(0x28, bra, 2, DWARF)
-HANDLE_DW_OP(0x29, eq, 2, DWARF)
-HANDLE_DW_OP(0x2a, ge, 2, DWARF)
-HANDLE_DW_OP(0x2b, gt, 2, DWARF)
-HANDLE_DW_OP(0x2c, le, 2, DWARF)
-HANDLE_DW_OP(0x2d, lt, 2, DWARF)
-HANDLE_DW_OP(0x2e, ne, 2, DWARF)
-HANDLE_DW_OP(0x2f, skip, 2, DWARF)
-HANDLE_DW_OP(0x30, lit0, 2, DWARF)
-HANDLE_DW_OP(0x31, lit1, 2, DWARF)
-HANDLE_DW_OP(0x32, lit2, 2, DWARF)
-HANDLE_DW_OP(0x33, lit3, 2, DWARF)
-HANDLE_DW_OP(0x34, lit4, 2, DWARF)
-HANDLE_DW_OP(0x35, lit5, 2, DWARF)
-HANDLE_DW_OP(0x36, lit6, 2, DWARF)
-HANDLE_DW_OP(0x37, lit7, 2, DWARF)
-HANDLE_DW_OP(0x38, lit8, 2, DWARF)
-HANDLE_DW_OP(0x39, lit9, 2, DWARF)
-HANDLE_DW_OP(0x3a, lit10, 2, DWARF)
-HANDLE_DW_OP(0x3b, lit11, 2, DWARF)
-HANDLE_DW_OP(0x3c, lit12, 2, DWARF)
-HANDLE_DW_OP(0x3d, lit13, 2, DWARF)
-HANDLE_DW_OP(0x3e, lit14, 2, DWARF)
-HANDLE_DW_OP(0x3f, lit15, 2, DWARF)
-HANDLE_DW_OP(0x40, lit16, 2, DWARF)
-HANDLE_DW_OP(0x41, lit17, 2, DWARF)
-HANDLE_DW_OP(0x42, lit18, 2, DWARF)
-HANDLE_DW_OP(0x43, lit19, 2, DWARF)
-HANDLE_DW_OP(0x44, lit20, 2, DWARF)
-HANDLE_DW_OP(0x45, lit21, 2, DWARF)
-HANDLE_DW_OP(0x46, lit22, 2, DWARF)
-HANDLE_DW_OP(0x47, lit23, 2, DWARF)
-HANDLE_DW_OP(0x48, lit24, 2, DWARF)
-HANDLE_DW_OP(0x49, lit25, 2, DWARF)
-HANDLE_DW_OP(0x4a, lit26, 2, DWARF)
-HANDLE_DW_OP(0x4b, lit27, 2, DWARF)
-HANDLE_DW_OP(0x4c, lit28, 2, DWARF)
-HANDLE_DW_OP(0x4d, lit29, 2, DWARF)
-HANDLE_DW_OP(0x4e, lit30, 2, DWARF)
-HANDLE_DW_OP(0x4f, lit31, 2, DWARF)
-HANDLE_DW_OP(0x50, reg0, 2, DWARF)
-HANDLE_DW_OP(0x51, reg1, 2, DWARF)
-HANDLE_DW_OP(0x52, reg2, 2, DWARF)
-HANDLE_DW_OP(0x53, reg3, 2, DWARF)
-HANDLE_DW_OP(0x54, reg4, 2, DWARF)
-HANDLE_DW_OP(0x55, reg5, 2, DWARF)
-HANDLE_DW_OP(0x56, reg6, 2, DWARF)
-HANDLE_DW_OP(0x57, reg7, 2, DWARF)
-HANDLE_DW_OP(0x58, reg8, 2, DWARF)
-HANDLE_DW_OP(0x59, reg9, 2, DWARF)
-HANDLE_DW_OP(0x5a, reg10, 2, DWARF)
-HANDLE_DW_OP(0x5b, reg11, 2, DWARF)
-HANDLE_DW_OP(0x5c, reg12, 2, DWARF)
-HANDLE_DW_OP(0x5d, reg13, 2, DWARF)
-HANDLE_DW_OP(0x5e, reg14, 2, DWARF)
-HANDLE_DW_OP(0x5f, reg15, 2, DWARF)
-HANDLE_DW_OP(0x60, reg16, 2, DWARF)
-HANDLE_DW_OP(0x61, reg17, 2, DWARF)
-HANDLE_DW_OP(0x62, reg18, 2, DWARF)
-HANDLE_DW_OP(0x63, reg19, 2, DWARF)
-HANDLE_DW_OP(0x64, reg20, 2, DWARF)
-HANDLE_DW_OP(0x65, reg21, 2, DWARF)
-HANDLE_DW_OP(0x66, reg22, 2, DWARF)
-HANDLE_DW_OP(0x67, reg23, 2, DWARF)
-HANDLE_DW_OP(0x68, reg24, 2, DWARF)
-HANDLE_DW_OP(0x69, reg25, 2, DWARF)
-HANDLE_DW_OP(0x6a, reg26, 2, DWARF)
-HANDLE_DW_OP(0x6b, reg27, 2, DWARF)
-HANDLE_DW_OP(0x6c, reg28, 2, DWARF)
-HANDLE_DW_OP(0x6d, reg29, 2, DWARF)
-HANDLE_DW_OP(0x6e, reg30, 2, DWARF)
-HANDLE_DW_OP(0x6f, reg31, 2, DWARF)
-HANDLE_DW_OP(0x70, breg0, 2, DWARF)
-HANDLE_DW_OP(0x71, breg1, 2, DWARF)
-HANDLE_DW_OP(0x72, breg2, 2, DWARF)
-HANDLE_DW_OP(0x73, breg3, 2, DWARF)
-HANDLE_DW_OP(0x74, breg4, 2, DWARF)
-HANDLE_DW_OP(0x75, breg5, 2, DWARF)
-HANDLE_DW_OP(0x76, breg6, 2, DWARF)
-HANDLE_DW_OP(0x77, breg7, 2, DWARF)
-HANDLE_DW_OP(0x78, breg8, 2, DWARF)
-HANDLE_DW_OP(0x79, breg9, 2, DWARF)
-HANDLE_DW_OP(0x7a, breg10, 2, DWARF)
-HANDLE_DW_OP(0x7b, breg11, 2, DWARF)
-HANDLE_DW_OP(0x7c, breg12, 2, DWARF)
-HANDLE_DW_OP(0x7d, breg13, 2, DWARF)
-HANDLE_DW_OP(0x7e, breg14, 2, DWARF)
-HANDLE_DW_OP(0x7f, breg15, 2, DWARF)
-HANDLE_DW_OP(0x80, breg16, 2, DWARF)
-HANDLE_DW_OP(0x81, breg17, 2, DWARF)
-HANDLE_DW_OP(0x82, breg18, 2, DWARF)
-HANDLE_DW_OP(0x83, breg19, 2, DWARF)
-HANDLE_DW_OP(0x84, breg20, 2, DWARF)
-HANDLE_DW_OP(0x85, breg21, 2, DWARF)
-HANDLE_DW_OP(0x86, breg22, 2, DWARF)
-HANDLE_DW_OP(0x87, breg23, 2, DWARF)
-HANDLE_DW_OP(0x88, breg24, 2, DWARF)

[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> I'm also not sure the number of operands is ever useful without having the 
> encoding ready, but maybe for DIExpression it actually is (because there we 
> always use the same encoding).

Yeah, I came to the same conclusion, which is why LLDB isn't using the data. I 
primarily added it to avoid mistakes where someone confuses the number of 
operands with the arity. 

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


[Lldb-commits] [lldb] ba7f52c - [lldb] Fix TestStatisticsAPI after 9293fc798152 (#94683)

2024-06-06 Thread via lldb-commits

Author: Alex Langford
Date: 2024-06-06T14:25:53-07:00
New Revision: ba7f52ccf42fd481a1b309fe76863729fdd18c1c

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

LOG: [lldb] Fix TestStatisticsAPI after 9293fc798152 (#94683)

Added: 


Modified: 
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Removed: 




diff  --git a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py 
b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
index 851097bdfecf2..f06c9ae14bb7a 100644
--- a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -85,14 +85,15 @@ def test_stats_api(self):
 stats_summary.GetAsJSON(stream_summary)
 debug_stats_summary = json.loads(stream_summary.GetData())
 self.assertNotIn("modules", debug_stats_summary)
-self.assertNotIn("memory", debug_stats_summary)
 self.assertNotIn("commands", debug_stats_summary)
 
 # Summary values should be the same as in full statistics.
-# Except the parse time on Mac OS X is not deterministic.
+# The exceptions to this are:
+# - The parse time on Mac OS X is not deterministic.
+# - Memory usage may grow over time due to the use of ConstString.
 for key, value in debug_stats_summary.items():
 self.assertIn(key, debug_stats)
-if key != "targets" and not key.endswith("Time"):
+if key != "memory" and key != "targets" and not 
key.endswith("Time"):
 self.assertEqual(debug_stats[key], value)
 
 def test_command_stats_api(self):



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


[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

The number of operands comes directly from Table 7.6 in the DWARF 5 spec. I'm 
less confident in the _arity_ which required me to consult the description of 
the operations. I think I got them right and everything covered by the LLDB 
test suite still passes, but I would definitely appreciate a second pair of 
eyes on this. 

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -1089,6 +1089,154 @@ int64_t ValueObject::GetValueAsSigned(int64_t 
fail_value, bool *success) {
   return fail_value;
 }
 
+llvm::Expected ValueObject::GetValueAsAPSInt() {
+  // Make sure the type can be converted to an APSInt.
+  if (!GetCompilerType().IsInteger() &&
+  !GetCompilerType().IsScopedEnumerationType() &&
+  !GetCompilerType().IsEnumerationType() &&
+  !GetCompilerType().IsPointerType() &&
+  !GetCompilerType().IsNullPtrType() &&
+  !GetCompilerType().IsReferenceType() && !GetCompilerType().IsBoolean())
+return llvm::make_error(
+"type cannot be converted to APSInt", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPSInt();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APSInt",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsAPFloat() {
+  if (!GetCompilerType().IsFloat())
+return llvm::make_error(
+"type cannot be converted to APFloat", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPFloat();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APFloat",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsBool() {
+  CompilerType val_type = GetCompilerType();
+  if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() ||
+  val_type.IsPointerType()) {
+auto value_or_err = GetValueAsAPSInt();
+if (value_or_err)
+  return value_or_err->getBoolValue();
+  }
+  if (val_type.IsFloat()) {
+auto value_or_err = GetValueAsAPFloat();
+if (value_or_err)
+  return value_or_err->isNonZero();
+  }
+  if (val_type.IsArrayType())
+return GetAddressOf() != 0;
+
+  return llvm::make_error("type cannot be converted to 
bool",
+ llvm::inconvertibleErrorCode());
+}
+
+void ValueObject::SetValueFromInteger(const llvm::APInt , Status ) 
{
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right size.
+  lldb::TargetSP target = GetTargetSP();
+  uint64_t byte_size = 0;
+  if (auto temp = GetCompilerType().GetByteSize(target.get()))
+byte_size = temp.value();
+  if (value.getBitWidth() != byte_size * CHAR_BIT) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  lldb::DataExtractorSP data_sp;
+  data_sp->SetData(value.getRawData(), byte_size,
+   target->GetArchitecture().GetByteOrder());
+  data_sp->SetAddressByteSize(
+  static_cast(target->GetArchitecture().GetAddressByteSize()));
+  SetData(*data_sp, error);
+}
+
+void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
+  Status ) {
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right type.
+  CompilerType new_val_type = new_val_sp->GetCompilerType();
+  if (!new_val_type.IsInteger() && !new_val_type.IsFloat() &&
+  !new_val_type.IsPointerType()) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  if (new_val_type.IsInteger()) {
+auto value_or_err = new_val_sp->GetValueAsAPSInt();
+if (value_or_err)
+  SetValueFromInteger(*value_or_err, error);
+else
+  error.SetErrorString("error getting APSInt from new_val_sp");
+  } else if (new_val_type.IsFloat()) {
+auto value_or_err = new_val_sp->GetValueAsAPFloat();
+if (value_or_err)
+  SetValueFromInteger(value_or_err->bitcastToAPInt(), error);
+else
+  error.SetErrorString("error getting APFloat from new_val_sp");
+  } else if (new_val_type.IsPointerType()) {
+bool success = true;
+uint64_t 

[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

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

>From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 31 Mar 2024 10:59:38 -0700
Subject: [PATCH 1/9] [LLDB] Add more helper functions to ValueObject class.

Create additional helper functions for the ValueObject class, for:
  - returning the value as an APSInt or APFloat
  - additional type casting options
  - additional ways to create ValueObjects from various types of data
  - dereferencing a ValueObject

These helper functions are needed for implementing the Data Inspection
Language, described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893
---
 lldb/include/lldb/Core/ValueObject.h |  61 
 lldb/source/Core/ValueObject.cpp | 405 +++
 2 files changed, 466 insertions(+)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e7e35e2b2bffc..0c8dbf384a326 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -441,6 +441,19 @@ class ValueObject {
 
   virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = 
nullptr);
 
+  llvm::APSInt GetValueAsAPSInt();
+
+  llvm::APFloat GetValueAsFloat();
+
+  bool GetValueAsBool();
+
+  /// Update the value of the current object to be the integer in the 'value'
+  /// parameter.
+  void UpdateIntegerValue(const llvm::APInt );
+
+  /// Assign the integer value 'new_val_sp' to the current object.
+  void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp);
+
   virtual bool SetValueFromCString(const char *value_str, Status );
 
   /// Return the module associated with this value object in case the value is
@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP _sp);
 
+  /// Return the target load address assocaited with this value object.
+  lldb::addr_t GetLoadAddress();
+
+  lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type,
+const std::vector );
+
+  lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t 
offset);
+
+  lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status );
+
+  lldb::ValueObjectSP CastEnumToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastPointerToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type);
+
+  lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status );
+
   /// If this object represents a C++ class with a vtable, return an object
   /// that represents the virtual function table. If the object isn't a class
   /// with a vtable, return a valid ValueObject with the error set correctly.
@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor ,
 const ExecutionContext _ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt ,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat ,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,
+  CompilerType type);
+
   lldb::ValueObjectSP Persist();
 
   /// Returns true if this is a char* or a char[] if it is a char* and
@@ -719,6 +776,10 @@ class ValueObject {
 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
   }
 
+  void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
+
+  ValueObject *GetDerefValobj() { return m_deref_valobj; }
+
   void SetValueFormat(lldb::TypeFormatImplSP format) {
 m_type_format_sp = std::move(format);
 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 

[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -1089,6 +1089,154 @@ int64_t ValueObject::GetValueAsSigned(int64_t 
fail_value, bool *success) {
   return fail_value;
 }
 
+llvm::Expected ValueObject::GetValueAsAPSInt() {
+  // Make sure the type can be converted to an APSInt.
+  if (!GetCompilerType().IsInteger() &&
+  !GetCompilerType().IsScopedEnumerationType() &&
+  !GetCompilerType().IsEnumerationType() &&
+  !GetCompilerType().IsPointerType() &&
+  !GetCompilerType().IsNullPtrType() &&
+  !GetCompilerType().IsReferenceType() && !GetCompilerType().IsBoolean())
+return llvm::make_error(
+"type cannot be converted to APSInt", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPSInt();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APSInt",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsAPFloat() {
+  if (!GetCompilerType().IsFloat())
+return llvm::make_error(
+"type cannot be converted to APFloat", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPFloat();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APFloat",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsBool() {
+  CompilerType val_type = GetCompilerType();
+  if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() ||
+  val_type.IsPointerType()) {
+auto value_or_err = GetValueAsAPSInt();
+if (value_or_err)
+  return value_or_err->getBoolValue();
+  }
+  if (val_type.IsFloat()) {
+auto value_or_err = GetValueAsAPFloat();
+if (value_or_err)
+  return value_or_err->isNonZero();
+  }
+  if (val_type.IsArrayType())
+return GetAddressOf() != 0;
+
+  return llvm::make_error("type cannot be converted to 
bool",
+ llvm::inconvertibleErrorCode());
+}
+
+void ValueObject::SetValueFromInteger(const llvm::APInt , Status ) 
{
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right size.
+  lldb::TargetSP target = GetTargetSP();
+  uint64_t byte_size = 0;
+  if (auto temp = GetCompilerType().GetByteSize(target.get()))
+byte_size = temp.value();
+  if (value.getBitWidth() != byte_size * CHAR_BIT) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  lldb::DataExtractorSP data_sp;
+  data_sp->SetData(value.getRawData(), byte_size,
+   target->GetArchitecture().GetByteOrder());
+  data_sp->SetAddressByteSize(
+  static_cast(target->GetArchitecture().GetAddressByteSize()));
+  SetData(*data_sp, error);
+}
+
+void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
+  Status ) {
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right type.
+  CompilerType new_val_type = new_val_sp->GetCompilerType();
+  if (!new_val_type.IsInteger() && !new_val_type.IsFloat() &&
+  !new_val_type.IsPointerType()) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  if (new_val_type.IsInteger()) {
+auto value_or_err = new_val_sp->GetValueAsAPSInt();
+if (value_or_err)
+  SetValueFromInteger(*value_or_err, error);
+else
+  error.SetErrorString("error getting APSInt from new_val_sp");
+  } else if (new_val_type.IsFloat()) {
+auto value_or_err = new_val_sp->GetValueAsAPFloat();
+if (value_or_err)
+  SetValueFromInteger(value_or_err->bitcastToAPInt(), error);
+else
+  error.SetErrorString("error getting APFloat from new_val_sp");
+  } else if (new_val_type.IsPointerType()) {
+bool success = true;
+uint64_t 

[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Alex Langford via lldb-commits

bulbazord wrote:

Fix: https://github.com/llvm/llvm-project/pull/94683

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


[Lldb-commits] [lldb] [lldb] Fix TestStatisticsAPI after 9293fc798152 (PR #94683)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes



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


1 Files Affected:

- (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py 
(+4-3) 


``diff
diff --git a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py 
b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
index 851097bdfecf2..f06c9ae14bb7a 100644
--- a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -85,14 +85,15 @@ def test_stats_api(self):
 stats_summary.GetAsJSON(stream_summary)
 debug_stats_summary = json.loads(stream_summary.GetData())
 self.assertNotIn("modules", debug_stats_summary)
-self.assertNotIn("memory", debug_stats_summary)
 self.assertNotIn("commands", debug_stats_summary)
 
 # Summary values should be the same as in full statistics.
-# Except the parse time on Mac OS X is not deterministic.
+# The exceptions to this are:
+# - The parse time on Mac OS X is not deterministic.
+# - Memory usage may grow over time due to the use of ConstString.
 for key, value in debug_stats_summary.items():
 self.assertIn(key, debug_stats)
-if key != "targets" and not key.endswith("Time"):
+if key != "memory" and key != "targets" and not 
key.endswith("Time"):
 self.assertEqual(debug_stats[key], value)
 
 def test_command_stats_api(self):

``




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


[Lldb-commits] [lldb] [lldb] Fix TestStatisticsAPI after 9293fc798152 (PR #94683)

2024-06-06 Thread Alex Langford via lldb-commits

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

None

>From fe74a42c27731098c00f563d2f080e07003d888e Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Thu, 6 Jun 2024 13:47:50 -0700
Subject: [PATCH] [lldb] Fix TestStatisticsAPI after 9293fc798152

---
 .../API/functionalities/stats_api/TestStatisticsAPI.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py 
b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
index 851097bdfecf2..f06c9ae14bb7a 100644
--- a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -85,14 +85,15 @@ def test_stats_api(self):
 stats_summary.GetAsJSON(stream_summary)
 debug_stats_summary = json.loads(stream_summary.GetData())
 self.assertNotIn("modules", debug_stats_summary)
-self.assertNotIn("memory", debug_stats_summary)
 self.assertNotIn("commands", debug_stats_summary)
 
 # Summary values should be the same as in full statistics.
-# Except the parse time on Mac OS X is not deterministic.
+# The exceptions to this are:
+# - The parse time on Mac OS X is not deterministic.
+# - Memory usage may grow over time due to the use of ConstString.
 for key, value in debug_stats_summary.items():
 self.assertIn(key, debug_stats)
-if key != "targets" and not key.endswith("Time"):
+if key != "memory" and key != "targets" and not 
key.endswith("Time"):
 self.assertEqual(debug_stats[key], value)
 
 def test_command_stats_api(self):

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


[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

This PR extends Dwarf.def to include the number of operands and the arity (the 
number of entries on the DWARF stack) and use it from the LLDB DWARF expression 
evaluator.

---

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


5 Files Affected:

- (modified) lldb/source/Expression/DWARFExpression.cpp (+126-249) 
- (modified) llvm/include/llvm/BinaryFormat/Dwarf.def (+182-182) 
- (modified) llvm/include/llvm/BinaryFormat/Dwarf.h (+10-1) 
- (modified) llvm/include/llvm/ObjectYAML/DWARFYAML.h (+1-1) 
- (modified) llvm/lib/BinaryFormat/Dwarf.cpp (+30-4) 


``diff
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 4681dbafb6f9c..b10c3d4ac5ad9 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -912,6 +912,14 @@ llvm::Expected DWARFExpression::Evaluate(
 DW_OP_value_to_name(op));
 }
 
+if (std::optional arity =
+llvm::dwarf::OperationArity(static_cast(op))) {
+  if (stack.size() < *arity)
+return llvm::createStringError(
+"%s needs at least %d stack entries (stack has %d entries)",
+DW_OP_value_to_name(op), *arity, stack.size());
+}
+
 switch (op) {
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
@@ -1280,11 +1288,7 @@ llvm::Expected DWARFExpression::Evaluate(
 // DESCRIPTION: Duplicates the entry currently second in the stack at
 // the top of the stack.
 case DW_OP_over:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_over");
-  } else
-stack.push_back(stack[stack.size() - 2]);
+  stack.push_back(stack[stack.size() - 2]);
   break;
 
 // OPCODE: DW_OP_pick
@@ -1307,14 +1311,9 @@ llvm::Expected DWARFExpression::Evaluate(
 // of the stack becomes the second stack entry, and the second entry
 // becomes the top of the stack
 case DW_OP_swap:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_swap");
-  } else {
-tmp = stack.back();
-stack.back() = stack[stack.size() - 2];
-stack[stack.size() - 2] = tmp;
-  }
+  tmp = stack.back();
+  stack.back() = stack[stack.size() - 2];
+  stack[stack.size() - 2] = tmp;
   break;
 
 // OPCODE: DW_OP_rot
@@ -1323,18 +1322,13 @@ llvm::Expected DWARFExpression::Evaluate(
 // the top of the stack becomes the third stack entry, the second entry
 // becomes the top of the stack, and the third entry becomes the second
 // entry.
-case DW_OP_rot:
-  if (stack.size() < 3) {
-return llvm::createStringError(
-"expression stack needs at least 3 items for DW_OP_rot");
-  } else {
-size_t last_idx = stack.size() - 1;
-Value old_top = stack[last_idx];
-stack[last_idx] = stack[last_idx - 1];
-stack[last_idx - 1] = stack[last_idx - 2];
-stack[last_idx - 2] = old_top;
-  }
-  break;
+case DW_OP_rot: {
+  size_t last_idx = stack.size() - 1;
+  Value old_top = stack[last_idx];
+  stack[last_idx] = stack[last_idx - 1];
+  stack[last_idx - 1] = stack[last_idx - 2];
+  stack[last_idx - 2] = old_top;
+} break;
 
 // OPCODE: DW_OP_abs
 // OPERANDS: none
@@ -1342,10 +1336,7 @@ llvm::Expected DWARFExpression::Evaluate(
 // value and pushes its absolute value. If the absolute value can not be
 // represented, the result is undefined.
 case DW_OP_abs:
-  if (stack.empty()) {
-return llvm::createStringError(
-"expression stack needs at least 1 item for DW_OP_abs");
-  } else if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) {
+  if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) {
 return llvm::createStringError(
 "failed to take the absolute value of the first stack item");
   }
@@ -1356,15 +1347,10 @@ llvm::Expected DWARFExpression::Evaluate(
 // DESCRIPTION: pops the top two stack values, performs a bitwise and
 // operation on the two, and pushes the result.
 case DW_OP_and:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_and");
-  } else {
-tmp = stack.back();
-stack.pop_back();
-stack.back().ResolveValue(exe_ctx) =
-stack.back().ResolveValue(exe_ctx) & tmp.ResolveValue(exe_ctx);
-  }
+  tmp = stack.back();
+  stack.pop_back();
+  stack.back().ResolveValue(exe_ctx) =
+  

[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-objectyaml

Author: Jonas Devlieghere (JDevlieghere)


Changes

This PR extends Dwarf.def to include the number of operands and the arity (the 
number of entries on the DWARF stack) and use it from the LLDB DWARF expression 
evaluator.

---

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


5 Files Affected:

- (modified) lldb/source/Expression/DWARFExpression.cpp (+126-249) 
- (modified) llvm/include/llvm/BinaryFormat/Dwarf.def (+182-182) 
- (modified) llvm/include/llvm/BinaryFormat/Dwarf.h (+10-1) 
- (modified) llvm/include/llvm/ObjectYAML/DWARFYAML.h (+1-1) 
- (modified) llvm/lib/BinaryFormat/Dwarf.cpp (+30-4) 


``diff
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 4681dbafb6f9c..b10c3d4ac5ad9 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -912,6 +912,14 @@ llvm::Expected DWARFExpression::Evaluate(
 DW_OP_value_to_name(op));
 }
 
+if (std::optional arity =
+llvm::dwarf::OperationArity(static_cast(op))) {
+  if (stack.size() < *arity)
+return llvm::createStringError(
+"%s needs at least %d stack entries (stack has %d entries)",
+DW_OP_value_to_name(op), *arity, stack.size());
+}
+
 switch (op) {
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
@@ -1280,11 +1288,7 @@ llvm::Expected DWARFExpression::Evaluate(
 // DESCRIPTION: Duplicates the entry currently second in the stack at
 // the top of the stack.
 case DW_OP_over:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_over");
-  } else
-stack.push_back(stack[stack.size() - 2]);
+  stack.push_back(stack[stack.size() - 2]);
   break;
 
 // OPCODE: DW_OP_pick
@@ -1307,14 +1311,9 @@ llvm::Expected DWARFExpression::Evaluate(
 // of the stack becomes the second stack entry, and the second entry
 // becomes the top of the stack
 case DW_OP_swap:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_swap");
-  } else {
-tmp = stack.back();
-stack.back() = stack[stack.size() - 2];
-stack[stack.size() - 2] = tmp;
-  }
+  tmp = stack.back();
+  stack.back() = stack[stack.size() - 2];
+  stack[stack.size() - 2] = tmp;
   break;
 
 // OPCODE: DW_OP_rot
@@ -1323,18 +1322,13 @@ llvm::Expected DWARFExpression::Evaluate(
 // the top of the stack becomes the third stack entry, the second entry
 // becomes the top of the stack, and the third entry becomes the second
 // entry.
-case DW_OP_rot:
-  if (stack.size() < 3) {
-return llvm::createStringError(
-"expression stack needs at least 3 items for DW_OP_rot");
-  } else {
-size_t last_idx = stack.size() - 1;
-Value old_top = stack[last_idx];
-stack[last_idx] = stack[last_idx - 1];
-stack[last_idx - 1] = stack[last_idx - 2];
-stack[last_idx - 2] = old_top;
-  }
-  break;
+case DW_OP_rot: {
+  size_t last_idx = stack.size() - 1;
+  Value old_top = stack[last_idx];
+  stack[last_idx] = stack[last_idx - 1];
+  stack[last_idx - 1] = stack[last_idx - 2];
+  stack[last_idx - 2] = old_top;
+} break;
 
 // OPCODE: DW_OP_abs
 // OPERANDS: none
@@ -1342,10 +1336,7 @@ llvm::Expected DWARFExpression::Evaluate(
 // value and pushes its absolute value. If the absolute value can not be
 // represented, the result is undefined.
 case DW_OP_abs:
-  if (stack.empty()) {
-return llvm::createStringError(
-"expression stack needs at least 1 item for DW_OP_abs");
-  } else if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) {
+  if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) {
 return llvm::createStringError(
 "failed to take the absolute value of the first stack item");
   }
@@ -1356,15 +1347,10 @@ llvm::Expected DWARFExpression::Evaluate(
 // DESCRIPTION: pops the top two stack values, performs a bitwise and
 // operation on the two, and pushes the result.
 case DW_OP_and:
-  if (stack.size() < 2) {
-return llvm::createStringError(
-"expression stack needs at least 2 items for DW_OP_and");
-  } else {
-tmp = stack.back();
-stack.pop_back();
-stack.back().ResolveValue(exe_ctx) =
-stack.back().ResolveValue(exe_ctx) & tmp.ResolveValue(exe_ctx);
-  }
+  tmp = stack.back();
+  stack.pop_back();
+  stack.back().ResolveValue(exe_ctx) =
+  

[Lldb-commits] [lldb] [lldb] Fix inconsistencies in DWARFExpression errors (PR #94554)

2024-06-06 Thread Jonas Devlieghere via lldb-commits


@@ -1657,7 +1650,7 @@ llvm::Expected DWARFExpression::Evaluate(
 case DW_OP_eq:
   if (stack.size() < 2) {
 return llvm::createStringError(
-"Expression stack needs at least 2 items for DW_OP_eq.");
+"expression stack needs at least 2 items for DW_OP_eq");

JDevlieghere wrote:

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

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


[Lldb-commits] [lldb] [llvm] [lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (PR #94679)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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

This PR extends Dwarf.def to include the number of operands and the arity (the 
number of entries on the DWARF stack) and use it from the LLDB DWARF expression 
evaluator.

>From 63fd7a008900fea3bb609ac018f8401f04f07703 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 6 Jun 2024 10:14:34 -0700
Subject: [PATCH 1/3] [lldb] Encode number of operands for DWARF operations

Add the number of operands to Dwarf.h as documented in Table 7.6 in the
DWARF 5 standard.
---
 llvm/include/llvm/BinaryFormat/Dwarf.def | 364 +++
 llvm/include/llvm/BinaryFormat/Dwarf.h   |   5 +-
 llvm/include/llvm/ObjectYAML/DWARFYAML.h |   2 +-
 llvm/lib/BinaryFormat/Dwarf.cpp  |  21 +-
 4 files changed, 204 insertions(+), 188 deletions(-)

diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.def 
b/llvm/include/llvm/BinaryFormat/Dwarf.def
index adcf24eb83b03..bbc3bbcf02b5c 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -51,7 +51,7 @@
 #endif
 
 #ifndef HANDLE_DW_OP
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR)
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, VERSION, VENDOR)
 #endif
 
 #ifndef HANDLE_DW_OP_LLVM_USEROP
@@ -694,197 +694,197 @@ HANDLE_DW_FORM(0x1f21, GNU_strp_alt, 0, GNU)
 HANDLE_DW_FORM(0x2001, LLVM_addrx_offset, 0, LLVM)
 
 // DWARF Expression operators.
-HANDLE_DW_OP(0x03, addr, 2, DWARF)
-HANDLE_DW_OP(0x06, deref, 2, DWARF)
-HANDLE_DW_OP(0x08, const1u, 2, DWARF)
-HANDLE_DW_OP(0x09, const1s, 2, DWARF)
-HANDLE_DW_OP(0x0a, const2u, 2, DWARF)
-HANDLE_DW_OP(0x0b, const2s, 2, DWARF)
-HANDLE_DW_OP(0x0c, const4u, 2, DWARF)
-HANDLE_DW_OP(0x0d, const4s, 2, DWARF)
-HANDLE_DW_OP(0x0e, const8u, 2, DWARF)
-HANDLE_DW_OP(0x0f, const8s, 2, DWARF)
-HANDLE_DW_OP(0x10, constu, 2, DWARF)
-HANDLE_DW_OP(0x11, consts, 2, DWARF)
-HANDLE_DW_OP(0x12, dup, 2, DWARF)
-HANDLE_DW_OP(0x13, drop, 2, DWARF)
-HANDLE_DW_OP(0x14, over, 2, DWARF)
-HANDLE_DW_OP(0x15, pick, 2, DWARF)
-HANDLE_DW_OP(0x16, swap, 2, DWARF)
-HANDLE_DW_OP(0x17, rot, 2, DWARF)
-HANDLE_DW_OP(0x18, xderef, 2, DWARF)
-HANDLE_DW_OP(0x19, abs, 2, DWARF)
-HANDLE_DW_OP(0x1a, and, 2, DWARF)
-HANDLE_DW_OP(0x1b, div, 2, DWARF)
-HANDLE_DW_OP(0x1c, minus, 2, DWARF)
-HANDLE_DW_OP(0x1d, mod, 2, DWARF)
-HANDLE_DW_OP(0x1e, mul, 2, DWARF)
-HANDLE_DW_OP(0x1f, neg, 2, DWARF)
-HANDLE_DW_OP(0x20, not, 2, DWARF)
-HANDLE_DW_OP(0x21, or, 2, DWARF)
-HANDLE_DW_OP(0x22, plus, 2, DWARF)
-HANDLE_DW_OP(0x23, plus_uconst, 2, DWARF)
-HANDLE_DW_OP(0x24, shl, 2, DWARF)
-HANDLE_DW_OP(0x25, shr, 2, DWARF)
-HANDLE_DW_OP(0x26, shra, 2, DWARF)
-HANDLE_DW_OP(0x27, xor, 2, DWARF)
-HANDLE_DW_OP(0x28, bra, 2, DWARF)
-HANDLE_DW_OP(0x29, eq, 2, DWARF)
-HANDLE_DW_OP(0x2a, ge, 2, DWARF)
-HANDLE_DW_OP(0x2b, gt, 2, DWARF)
-HANDLE_DW_OP(0x2c, le, 2, DWARF)
-HANDLE_DW_OP(0x2d, lt, 2, DWARF)
-HANDLE_DW_OP(0x2e, ne, 2, DWARF)
-HANDLE_DW_OP(0x2f, skip, 2, DWARF)
-HANDLE_DW_OP(0x30, lit0, 2, DWARF)
-HANDLE_DW_OP(0x31, lit1, 2, DWARF)
-HANDLE_DW_OP(0x32, lit2, 2, DWARF)
-HANDLE_DW_OP(0x33, lit3, 2, DWARF)
-HANDLE_DW_OP(0x34, lit4, 2, DWARF)
-HANDLE_DW_OP(0x35, lit5, 2, DWARF)
-HANDLE_DW_OP(0x36, lit6, 2, DWARF)
-HANDLE_DW_OP(0x37, lit7, 2, DWARF)
-HANDLE_DW_OP(0x38, lit8, 2, DWARF)
-HANDLE_DW_OP(0x39, lit9, 2, DWARF)
-HANDLE_DW_OP(0x3a, lit10, 2, DWARF)
-HANDLE_DW_OP(0x3b, lit11, 2, DWARF)
-HANDLE_DW_OP(0x3c, lit12, 2, DWARF)
-HANDLE_DW_OP(0x3d, lit13, 2, DWARF)
-HANDLE_DW_OP(0x3e, lit14, 2, DWARF)
-HANDLE_DW_OP(0x3f, lit15, 2, DWARF)
-HANDLE_DW_OP(0x40, lit16, 2, DWARF)
-HANDLE_DW_OP(0x41, lit17, 2, DWARF)
-HANDLE_DW_OP(0x42, lit18, 2, DWARF)
-HANDLE_DW_OP(0x43, lit19, 2, DWARF)
-HANDLE_DW_OP(0x44, lit20, 2, DWARF)
-HANDLE_DW_OP(0x45, lit21, 2, DWARF)
-HANDLE_DW_OP(0x46, lit22, 2, DWARF)
-HANDLE_DW_OP(0x47, lit23, 2, DWARF)
-HANDLE_DW_OP(0x48, lit24, 2, DWARF)
-HANDLE_DW_OP(0x49, lit25, 2, DWARF)
-HANDLE_DW_OP(0x4a, lit26, 2, DWARF)
-HANDLE_DW_OP(0x4b, lit27, 2, DWARF)
-HANDLE_DW_OP(0x4c, lit28, 2, DWARF)
-HANDLE_DW_OP(0x4d, lit29, 2, DWARF)
-HANDLE_DW_OP(0x4e, lit30, 2, DWARF)
-HANDLE_DW_OP(0x4f, lit31, 2, DWARF)
-HANDLE_DW_OP(0x50, reg0, 2, DWARF)
-HANDLE_DW_OP(0x51, reg1, 2, DWARF)
-HANDLE_DW_OP(0x52, reg2, 2, DWARF)
-HANDLE_DW_OP(0x53, reg3, 2, DWARF)
-HANDLE_DW_OP(0x54, reg4, 2, DWARF)
-HANDLE_DW_OP(0x55, reg5, 2, DWARF)
-HANDLE_DW_OP(0x56, reg6, 2, DWARF)
-HANDLE_DW_OP(0x57, reg7, 2, DWARF)
-HANDLE_DW_OP(0x58, reg8, 2, DWARF)
-HANDLE_DW_OP(0x59, reg9, 2, DWARF)
-HANDLE_DW_OP(0x5a, reg10, 2, DWARF)
-HANDLE_DW_OP(0x5b, reg11, 2, DWARF)
-HANDLE_DW_OP(0x5c, reg12, 2, DWARF)
-HANDLE_DW_OP(0x5d, reg13, 2, DWARF)
-HANDLE_DW_OP(0x5e, reg14, 2, DWARF)
-HANDLE_DW_OP(0x5f, reg15, 2, DWARF)
-HANDLE_DW_OP(0x60, reg16, 2, DWARF)
-HANDLE_DW_OP(0x61, reg17, 2, DWARF)
-HANDLE_DW_OP(0x62, reg18, 2, DWARF)
-HANDLE_DW_OP(0x63, reg19, 2, DWARF)
-HANDLE_DW_OP(0x64, reg20, 2, DWARF)
-HANDLE_DW_OP(0x65, reg21, 2, DWARF)
-HANDLE_DW_OP(0x66, reg22, 2, DWARF)
-HANDLE_DW_OP(0x67, 

[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Alex Langford via lldb-commits

bulbazord wrote:

Ah, I see there was a test for this that I missed. I've gotten an email about 
it, taking a look now.

```
Failed Tests (1):
  lldb-api :: functionalities/stats_api/TestStatisticsAPI.py
```

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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] 9293fc7 - [lldb] Include memory stats in statistics summary (#94671)

2024-06-06 Thread via lldb-commits

Author: Alex Langford
Date: 2024-06-06T13:18:06-07:00
New Revision: 9293fc7981526eaca0a28012f2e5963fff1b830b

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

LOG: [lldb] Include memory stats in statistics summary (#94671)

The summary already includes other size information, e.g. total debug
info size in bytes. The only other way I can get this information is by
dumping all statistics which can be quite large. Adding it to the
summary seems fair.

Added: 


Modified: 
lldb/source/Target/Statistics.cpp

Removed: 




diff  --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index be0848573f812..2a5300012511a 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -355,14 +355,14 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   }
   global_stats.try_emplace("targets", std::move(json_targets));
 
+  ConstStringStats const_string_stats;
+  json::Object json_memory{
+  {"strings", const_string_stats.ToJSON()},
+  };
+  global_stats.try_emplace("memory", std::move(json_memory));
   if (!summary_only) {
-ConstStringStats const_string_stats;
-json::Object json_memory{
-{"strings", const_string_stats.ToJSON()},
-};
 json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
 global_stats.try_emplace("modules", std::move(json_modules));
-global_stats.try_emplace("memory", std::move(json_memory));
 global_stats.try_emplace("commands", std::move(cmd_stats));
   }
 



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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more). As example, Linux x86_64 host shows the 
following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 (+2-2) 


``diff
diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

``




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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-06 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/94672

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more). As example, Linux x86_64 host shows the 
following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH] [lldb] Fix TestModuleLoadedNotifys API test to work correctly
 on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

The summary already includes other size information, e.g. total debug info size 
in bytes. The only other way I can get this information is by dumping all 
statistics which can be quite large. Adding it to the summary seems fair.

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


1 Files Affected:

- (modified) lldb/source/Target/Statistics.cpp (+5-5) 


``diff
diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index be0848573f812..2a5300012511a 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -355,14 +355,14 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   }
   global_stats.try_emplace("targets", std::move(json_targets));
 
+  ConstStringStats const_string_stats;
+  json::Object json_memory{
+  {"strings", const_string_stats.ToJSON()},
+  };
+  global_stats.try_emplace("memory", std::move(json_memory));
   if (!summary_only) {
-ConstStringStats const_string_stats;
-json::Object json_memory{
-{"strings", const_string_stats.ToJSON()},
-};
 json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
 global_stats.try_emplace("modules", std::move(json_modules));
-global_stats.try_emplace("memory", std::move(json_memory));
 global_stats.try_emplace("commands", std::move(cmd_stats));
   }
 

``




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


[Lldb-commits] [lldb] [lldb] Include memory stats in statistics summary (PR #94671)

2024-06-06 Thread Alex Langford via lldb-commits

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

The summary already includes other size information, e.g. total debug info size 
in bytes. The only other way I can get this information is by dumping all 
statistics which can be quite large. Adding it to the summary seems fair.

>From 13df49b8bfedd470138c95d99f4db61b7dac83a2 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Thu, 6 Jun 2024 12:36:35 -0700
Subject: [PATCH] [lldb] Include memory stats in statistics summary

The summary already includes other size information, e.g. total debug
info size in bytes. The only other way I can get this information is by
dumping all statistics which can be quite large. Adding it to the
summary seems fair.
---
 lldb/source/Target/Statistics.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index be0848573f812..2a5300012511a 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -355,14 +355,14 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   }
   global_stats.try_emplace("targets", std::move(json_targets));
 
+  ConstStringStats const_string_stats;
+  json::Object json_memory{
+  {"strings", const_string_stats.ToJSON()},
+  };
+  global_stats.try_emplace("memory", std::move(json_memory));
   if (!summary_only) {
-ConstStringStats const_string_stats;
-json::Object json_memory{
-{"strings", const_string_stats.ToJSON()},
-};
 json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
 global_stats.try_emplace("modules", std::move(json_modules));
-global_stats.try_emplace("memory", std::move(json_memory));
 global_stats.try_emplace("commands", std::move(cmd_stats));
   }
 

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

jimingham wrote:

There was one comment that should probably be removed.  This looks okay to me 
at this stage.

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


[Lldb-commits] [lldb] [lldb/crashlog] Remove aarch64 requirement on crashlog tests (PR #94553)

2024-06-06 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] d09231a - [lldb/crashlog] Remove aarch64 requirement on crashlog tests (#94553)

2024-06-06 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-06-06T12:17:00-07:00
New Revision: d09231a422f052d6f6f44913fad610728a7c266b

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

LOG: [lldb/crashlog] Remove aarch64 requirement on crashlog tests (#94553)

This PR removes the `target-aarch64` requirement on the crashlog tests
to exercice them on Intel bots and make image loading single-threaded
temporarily while implementing a fix for a deadlock issue when loading
the images in parallel.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/lit.local.cfg

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 5281d6d949baf..1c0d717ce455c 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1814,6 +1814,9 @@ def SymbolicateCrashLogs(debugger, command_args, result, 
is_command):
 )
 )
 
+if "NO_PARALLEL_IMG_LOADING" in os.environ:
+options.no_parallel_image_loading = True
+
 if options.version:
 print(debugger.GetVersionString())
 return

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
index 430febb096252..9c0510c34ccae 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
index abd1e7c3da53d..eb1f5f456a2dc 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
 # RUN: -o 'crashlog -V' \

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
index fccd71ce31f73..684be2846f78d 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
index 6e2826e88aedf..271a4c2aa90f4 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
index fa857ac0e84f1..a17b7ac18a620 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
@@ -1,4 +1,4 

[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -1089,6 +1089,154 @@ int64_t ValueObject::GetValueAsSigned(int64_t 
fail_value, bool *success) {
   return fail_value;
 }
 
+llvm::Expected ValueObject::GetValueAsAPSInt() {
+  // Make sure the type can be converted to an APSInt.
+  if (!GetCompilerType().IsInteger() &&
+  !GetCompilerType().IsScopedEnumerationType() &&
+  !GetCompilerType().IsEnumerationType() &&
+  !GetCompilerType().IsPointerType() &&
+  !GetCompilerType().IsNullPtrType() &&
+  !GetCompilerType().IsReferenceType() && !GetCompilerType().IsBoolean())
+return llvm::make_error(
+"type cannot be converted to APSInt", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPSInt();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APSInt",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsAPFloat() {
+  if (!GetCompilerType().IsFloat())
+return llvm::make_error(
+"type cannot be converted to APFloat", llvm::inconvertibleErrorCode());
+
+  if (CanProvideValue()) {
+Scalar scalar;
+if (ResolveValue(scalar))
+  return scalar.GetAPFloat();
+  }
+
+  return llvm::make_error(
+  "error occurred; unable to convert to APFloat",
+  llvm::inconvertibleErrorCode());
+}
+
+llvm::Expected ValueObject::GetValueAsBool() {
+  CompilerType val_type = GetCompilerType();
+  if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() ||
+  val_type.IsPointerType()) {
+auto value_or_err = GetValueAsAPSInt();
+if (value_or_err)
+  return value_or_err->getBoolValue();
+  }
+  if (val_type.IsFloat()) {
+auto value_or_err = GetValueAsAPFloat();
+if (value_or_err)
+  return value_or_err->isNonZero();
+  }
+  if (val_type.IsArrayType())
+return GetAddressOf() != 0;
+
+  return llvm::make_error("type cannot be converted to 
bool",
+ llvm::inconvertibleErrorCode());
+}
+
+void ValueObject::SetValueFromInteger(const llvm::APInt , Status ) 
{
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right size.
+  lldb::TargetSP target = GetTargetSP();
+  uint64_t byte_size = 0;
+  if (auto temp = GetCompilerType().GetByteSize(target.get()))
+byte_size = temp.value();
+  if (value.getBitWidth() != byte_size * CHAR_BIT) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  lldb::DataExtractorSP data_sp;
+  data_sp->SetData(value.getRawData(), byte_size,
+   target->GetArchitecture().GetByteOrder());
+  data_sp->SetAddressByteSize(
+  static_cast(target->GetArchitecture().GetAddressByteSize()));
+  SetData(*data_sp, error);
+}
+
+void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
+  Status ) {
+  // Verify the current object is an integer object
+  CompilerType val_type = GetCompilerType();
+  if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
+  !val_type.IsFloat() && !val_type.IsPointerType() &&
+  !val_type.IsScalarType()) {
+error.SetErrorString("current value object is not an integer objet");
+return;
+  }
+
+  // Verify the current object is not actually associated with any program
+  // variable.
+  if (GetVariable()) {
+error.SetErrorString("current value object is not a temporary object");
+return;
+  }
+
+  // Verify the proposed new value is the right type.
+  CompilerType new_val_type = new_val_sp->GetCompilerType();
+  if (!new_val_type.IsInteger() && !new_val_type.IsFloat() &&
+  !new_val_type.IsPointerType()) {
+error.SetErrorString(
+"illegal argument: new value should be of the same size");
+return;
+  }
+
+  if (new_val_type.IsInteger()) {
+auto value_or_err = new_val_sp->GetValueAsAPSInt();
+if (value_or_err)
+  SetValueFromInteger(*value_or_err, error);
+else
+  error.SetErrorString("error getting APSInt from new_val_sp");
+  } else if (new_val_type.IsFloat()) {
+auto value_or_err = new_val_sp->GetValueAsAPFloat();
+if (value_or_err)
+  SetValueFromInteger(value_or_err->bitcastToAPInt(), error);
+else
+  error.SetErrorString("error getting APFloat from new_val_sp");
+  } else if (new_val_type.IsPointerType()) {
+bool success = true;
+uint64_t 

[Lldb-commits] [lldb] [lldb/crashlog] Remove aarch64 requirement on crashlog tests (PR #94553)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [llvm] [lldb] Return an llvm::Expected from DWARFExpression::Evaluate (NFCI) (PR #94420)

2024-06-06 Thread David Blaikie via lldb-commits


@@ -2341,9 +2198,7 @@ bool DWARFExpression::Evaluate(
 // the stack by the called expression may be used as return values by prior
 // agreement between the calling and called expressions.
 case DW_OP_call2:
-  if (error_ptr)
-error_ptr->SetErrorString("Unimplemented opcode DW_OP_call2.");
-  return false;
+  return llvm::createStringError("Unimplemented opcode DW_OP_call2.");

dwblaikie wrote:

and probably drop the uppercase at the start too?

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -3141,15 +3141,15 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 val_byte_size = temp.value();
 
   if (is_pointer) {
+if (!type.IsInteger()) {
+  m_error.SetErrorString("target type must be an integer");
+  return GetSP();
+}
 if (!type.IsBoolean() && type_byte_size < val_byte_size) {

cmtice wrote:

Whoops! Good catch; I've fixed that now.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -2809,6 +2919,243 @@ ValueObjectSP ValueObject::CastPointerType(const char 
*name, TypeSP _sp) {
   return valobj_sp;
 }
 
+lldb::addr_t ValueObject::GetLoadAddress() {
+  lldb::addr_t addr_value = LLDB_INVALID_ADDRESS;
+  lldb::TargetSP target_sp = GetTargetSP();
+  if (target_sp) {
+const bool scalar_is_load_address = true;
+AddressType addr_type;
+addr_value = GetAddressOf(scalar_is_load_address, _type);
+if (addr_type == eAddressTypeFile) {
+  lldb::ModuleSP module_sp(GetModule());
+  if (!module_sp)
+addr_value = LLDB_INVALID_ADDRESS;
+  else {
+Address tmp_addr;
+module_sp->ResolveFileAddress(addr_value, tmp_addr);
+addr_value = tmp_addr.GetLoadAddress(target_sp.get());
+  }
+} else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeHost)
+  addr_value = LLDB_INVALID_ADDRESS;
+  }
+  return addr_value;
+}
+
+lldb::ValueObjectSP
+ValueObject::CastDerivedToBaseType(CompilerType type,
+   const std::vector ) {
+
+  lldb::TargetSP target = GetTargetSP();
+  assert((type.IsPointerType() || type.IsReferenceType()) &&
+ "invalid ast: target type should be a pointer or a reference");
+  assert(!idx.empty() && "invalid ast: children sequence should be non-empty");
+
+  // The `value` can be a pointer, but GetChildAtIndex works for pointers too.
+  lldb::ValueObjectSP inner_value;
+
+  for (const uint32_t i : idx) {
+// Force static value, otherwise we can end up with the "real" type.
+inner_value = GetChildAtIndex(i, /*can_create_synthetic*/ false);
+  }
+
+  // At this point type of `inner_value` should be the dereferenced target 
type.
+  CompilerType inner_value_type = inner_value->GetCompilerType();
+  if (type.IsPointerType()) {
+assert(inner_value_type.CompareTypes(type.GetPointeeType()) &&
+   "casted value doesn't match the desired type");
+
+uintptr_t addr = inner_value->GetLoadAddress();
+return ValueObject::CreateValueObjectFromPointer(target, addr, type);
+  }
+
+  // At this point the target type should be a reference.
+  assert(inner_value_type.CompareTypes(type.GetNonReferenceType()) &&
+ "casted value doesn't match the desired type");
+
+  return lldb::ValueObjectSP(inner_value->Cast(type.GetNonReferenceType()));
+}
+
+lldb::ValueObjectSP ValueObject::CastBaseToDerivedType(CompilerType type,
+   uint64_t offset) {
+  lldb::TargetSP target = GetTargetSP();
+
+  assert((type.IsPointerType() || type.IsReferenceType()) &&
+ "invalid ast: target type should be a pointer or a reference");
+
+  auto pointer_type =
+  type.IsPointerType() ? type : 
type.GetNonReferenceType().GetPointerType();
+
+  uintptr_t addr =
+  type.IsPointerType() ? GetValueAsUnsigned(0) : GetLoadAddress();
+
+  lldb::ValueObjectSP value = ValueObject::CreateValueObjectFromPointer(
+  target, addr - offset, pointer_type);
+
+  if (type.IsPointerType()) {
+return value;
+  }
+
+  // At this point the target type is a reference. Since `value` is a pointer,
+  // it has to be dereferenced.
+  Status error;
+  return value->Dereference(error);
+}
+
+lldb::ValueObjectSP ValueObject::CastScalarToBasicType(CompilerType type,
+   Status ) {
+  assert(type.IsScalarType() && "target type must be an scalar");
+  assert(GetCompilerType().IsScalarType() && "argument must be a scalar");
+
+  lldb::TargetSP target = GetTargetSP();
+  if (type.IsBoolean()) {
+if (GetCompilerType().IsInteger()) {
+  return ValueObject::CreateValueObjectFromBool(target,
+GetValueAsUnsigned(0) != 
0);
+}
+if (GetCompilerType().IsFloat()) {
+  return ValueObject::CreateValueObjectFromBool(
+  target, !GetValueAsFloat().isZero());
+}
+  }
+  if (type.IsInteger()) {
+if (GetCompilerType().IsInteger()) {
+  uint64_t byte_size = 0;
+  if (auto temp = type.GetByteSize(target.get()))
+byte_size = temp.value();
+  llvm::APSInt ext = GetValueAsAPSInt().extOrTrunc(byte_size * CHAR_BIT);
+  return ValueObject::CreateValueObjectFromAPInt(target, ext, type);
+}
+if (GetCompilerType().IsFloat()) {
+  uint64_t byte_size = 0;
+  if (auto temp = type.GetByteSize(target.get()))
+byte_size = temp.value();
+  llvm::APSInt integer(byte_size * CHAR_BIT, !type.IsSigned());
+  bool is_exact;
+  llvm::APFloatBase::opStatus status = GetValueAsFloat().convertToInteger(
+  integer, llvm::APFloat::rmTowardZero, _exact);
+
+  // Casting floating point values that are out of bounds of the target 
type
+  // is undefined behaviour.
+  if (status & llvm::APFloatBase::opInvalidOp) {
+error.SetErrorString("invalid type cast detected");
+  }
+
+  return ValueObject::CreateValueObjectFromAPInt(target, integer, 

[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

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

>From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 31 Mar 2024 10:59:38 -0700
Subject: [PATCH 1/8] [LLDB] Add more helper functions to ValueObject class.

Create additional helper functions for the ValueObject class, for:
  - returning the value as an APSInt or APFloat
  - additional type casting options
  - additional ways to create ValueObjects from various types of data
  - dereferencing a ValueObject

These helper functions are needed for implementing the Data Inspection
Language, described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893
---
 lldb/include/lldb/Core/ValueObject.h |  61 
 lldb/source/Core/ValueObject.cpp | 405 +++
 2 files changed, 466 insertions(+)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e7e35e2b2bffc..0c8dbf384a326 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -441,6 +441,19 @@ class ValueObject {
 
   virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = 
nullptr);
 
+  llvm::APSInt GetValueAsAPSInt();
+
+  llvm::APFloat GetValueAsFloat();
+
+  bool GetValueAsBool();
+
+  /// Update the value of the current object to be the integer in the 'value'
+  /// parameter.
+  void UpdateIntegerValue(const llvm::APInt );
+
+  /// Assign the integer value 'new_val_sp' to the current object.
+  void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp);
+
   virtual bool SetValueFromCString(const char *value_str, Status );
 
   /// Return the module associated with this value object in case the value is
@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP _sp);
 
+  /// Return the target load address assocaited with this value object.
+  lldb::addr_t GetLoadAddress();
+
+  lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type,
+const std::vector );
+
+  lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t 
offset);
+
+  lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status );
+
+  lldb::ValueObjectSP CastEnumToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastPointerToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type);
+
+  lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status );
+
   /// If this object represents a C++ class with a vtable, return an object
   /// that represents the virtual function table. If the object isn't a class
   /// with a vtable, return a valid ValueObject with the error set correctly.
@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor ,
 const ExecutionContext _ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt ,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat ,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,
+  CompilerType type);
+
   lldb::ValueObjectSP Persist();
 
   /// Returns true if this is a char* or a char[] if it is a char* and
@@ -719,6 +776,10 @@ class ValueObject {
 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
   }
 
+  void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
+
+  ValueObject *GetDerefValobj() { return m_deref_valobj; }
+
   void SetValueFormat(lldb::TypeFormatImplSP format) {
 m_type_format_sp = std::move(format);
 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Chelsea Cassanova via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already

chelcassanova wrote:

I'm not opposed to that, this same message appears for the other 2 callbacks.

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Chelsea Cassanova via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::CommandOverrideCallback callback,
+

chelcassanova wrote:

Yup, I kind of wish that SWIG had a formatter like `clang-format`.

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::CommandOverrideCallback callback,
+

bulbazord wrote:

stray line?

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already

bulbazord wrote:

I'd say remove the FIXME entirely, it shouldn't apply to this.
As a side note, I think in the LLVM project we generally discourage the pattern 
of `FIXME (name)` and `TODO (name)`. Maybe we should go clean up the original 
instance too? :p

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -1099,6 +1099,19 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool b = false;

bulbazord wrote:

Can you change the name `b` to something with more meaning? Maybe something 
like `ret_val`?

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -0,0 +1,30 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class CommandOverrideCallback(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.line = line_number("main.c", "Hello world.")
+
+def test_command_override_callback(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Retrieve the associated command interpreter from our debugger.

bulbazord wrote:

Same for this comment.

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -0,0 +1,30 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class CommandOverrideCallback(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.line = line_number("main.c", "Hello world.")
+
+def test_command_override_callback(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.

bulbazord wrote:

I don't think this comment is helpful because it's telling me what the code is 
doing, not why it's doing it. I'd suggest removing it because pretty much every 
test does this.

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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-06 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb/crashlog] Make interactive mode the new default (PR #94575)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -1794,8 +1803,36 @@ def SymbolicateCrashLogs(debugger, command_args, result, 
is_command):
 result.SetError(str(e))
 return
 
+# To avoid breaking previous users, we should keep supporting previous flag
+# even if we don't use them / advertise them anymore.
+if options.interactive:
+options.mode = CrashLogLoadingMode.interactive
+elif options.batch:
+options.mode = CrashLogLoadingMode.batch
+
+if (
+options.mode
+and options.mode != CrashLogLoadingMode.interactive
+and (options.target_path or options.skip_status)
+):
+print(
+"Target path (-t) and skipping process status (-s) options can 
only used in intercative mode (-m=interactive)."

bulbazord wrote:

typo: `intercative` -> `interactive`

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


[Lldb-commits] [lldb] [lldb/crashlog] Make interactive mode the new default (PR #94575)

2024-06-06 Thread Alex Langford via lldb-commits


@@ -3,7 +3,7 @@
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test
 # RUN: %lldb -b -o 'command script import lldb.macosx.crashlog' \
-# RUN: -o 'crashlog -a -i -s -t %t.dir/multithread-test 
%S/Inputs/interactive_crashlog/multithread-test.ips' \
+# RUN: -o 'crashlog -a -s --mode interactive -t %t.dir/multithread-test 
%S/Inputs/interactive_crashlog/multithread-test.ips' \

bulbazord wrote:

If interactive mode is the new default, should we drop the `--mode interactive` 
and have the test rely on the default behavior? :)

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


[Lldb-commits] [lldb] [lldb/crashlog] Remove aarch64 requirement on crashlog tests (PR #94553)

2024-06-06 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb/crashlog] Remove aarch64 requirement on crashlog tests (PR #94553)

2024-06-06 Thread Med Ismail Bennani via lldb-commits

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

>From 46eb924da3dcee4b43f22f0002cc21d3c01fb2f3 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Tue, 4 Jun 2024 20:36:53 -0700
Subject: [PATCH 1/2] [lldb/crashlog] Remove aarch64 requirement on crashlog
 tests

This patch removes the `target-aarch64` requirement on the crashlog
tests.

Signed-off-by: Med Ismail Bennani 
---
 .../Python/Crashlog/app_specific_backtrace_crashlog.test| 2 +-
 .../Python/Crashlog/interactive_crashlog_invalid_target.test| 2 +-
 .../Python/Crashlog/interactive_crashlog_json.test  | 2 +-
 .../Python/Crashlog/interactive_crashlog_legacy.test| 2 +-
 .../Python/Crashlog/last_exception_backtrace_crashlog.test  | 2 +-
 .../Python/Crashlog/skipped_status_interactive_crashlog.test| 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
index 430febb096252..9c0510c34ccae 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
index abd1e7c3da53d..eb1f5f456a2dc 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
 # RUN: -o 'crashlog -V' \
diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
index fccd71ce31f73..684be2846f78d 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test
diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
index 6e2826e88aedf..271a4c2aa90f4 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_legacy.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test
diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
index fa857ac0e84f1..a17b7ac18a620 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
diff --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
index 81e06868eaee7..64cd0904371aa 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -1,4 +1,4 @@
-# REQUIRES: python, native && target-aarch64 && system-darwin
+# REQUIRES: python, native && system-darwin
 
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > 
%t.dir/multithread-test

>From dd9c8265fa320443e0a9db332118193ed2aa4cf4 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 6 Jun 2024 09:58:24 -0700
Subject: 

[Lldb-commits] [lldb] [lldb/crashlog] Remove aarch64 requirement on crashlog tests (PR #94553)

2024-06-06 Thread Alex Langford via lldb-commits

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

Makes sense to me. Removing the aarch64 requirement is an excellent change 
since many testing machines are x86_64  

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -3141,15 +3141,15 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 val_byte_size = temp.value();
 
   if (is_pointer) {
+if (!type.IsInteger()) {
+  m_error.SetErrorString("target type must be an integer");
+  return GetSP();
+}
 if (!type.IsBoolean() && type_byte_size < val_byte_size) {

jimingham wrote:

That's better, but now the `type.IsBoolean` is entirely pointless, since you 
would never get to this code in that case.

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-06-06 Thread via lldb-commits

jimingham wrote:

I will get to this, WWDC is close upon us so we're all rather busy at present.

Jim


> On Jun 6, 2024, at 8:27 AM, jeffreytan81 ***@***.***> wrote:
> 
> 
> @jimingham  , let me know any other 
> comments/thoughts you have.
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you were mentioned.
> 



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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-06 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/94625

>From bbaa8ef4434a1d97a31a5dd7cbfc3cdfebcbe41d Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 6 Jun 2024 10:17:06 -0400
Subject: [PATCH 1/4] Reapply "[lldb][lldb-dap] Cleanup breakpoint filters."
 (#93739)

This reverts commit 6595e7fa1b5588f860aa057aac47c43623169584.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 39 ---
 lldb/tools/lldb-dap/DAP.h |  4 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 +++--
 7 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..807d27c2c869d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,32 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+lldb::eLanguageTypeSwift);
+

[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-06-06 Thread Pavel Labath via lldb-commits


@@ -2345,11 +2345,6 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const 
DWARFDIE ,
 
   if (!die)
 return false;
-  ParsedDWARFTypeAttributes attrs(die);

labath wrote:

In case anyone's wondering, Putting this check back in would prevent the crash 
from 7fdbc30b445286f03203e16d0be067c25c6f0df0, but it would not actually make 
the code correct -- lldb would now just say the class has no definition instead 
of crashing.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-06-06 Thread Pavel Labath via lldb-commits

labath wrote:

PSA: I've reverted Zequan's patch due to other bugs, so this change is now 
uncommitted again. Since this could go in as a separate change, I'm going to 
recreate a patch for it tomorrow (running out of time today), including the fix 
from #94400, if someone doesn't beat me to it. I'm sorry about all the back and 
forth.

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


[Lldb-commits] [lldb] 7fdbc30 - Revert "[lldb][DebugNames] Only skip processing of DW_AT_declarations for class/union types"

2024-06-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-06-06T16:08:58Z
New Revision: 7fdbc30b445286f03203e16d0be067c25c6f0df0

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

LOG: Revert "[lldb][DebugNames] Only skip processing of DW_AT_declarations for 
class/union types"

and two follow-up commits. The reason is the crash we've discovered when
processing -gsimple-template-names binaries. I'm committing a minimal
reproducer as a separate patch.

This reverts the following commits:
- 51dd4eaaa29683c16151f5168e7f8645acbd6e6c (#92328)
- 3d9d48523977af3590f7dd0edfd258454cb9e9cf (#93839)
- afe6ab7586f7078cc410f6162bd9851e48e2a286 (#94400)

Added: 


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

Removed: 
lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index e144cf0f9bd94..66db396279e06 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -60,8 +60,6 @@ class DWARFASTParser {
 
   virtual ConstString GetDIEClassTemplateParams(const DWARFDIE ) = 0;
 
-  virtual lldb_private::Type *FindDefinitionTypeForDIE(const DWARFDIE ) = 
0;
-
   static std::optional
   ParseChildArrayInfo(const DWARFDIE _die,
   const ExecutionContext *exe_ctx = nullptr);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 7d7e835c3d732..579a538af3634 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -154,26 +154,6 @@ static bool TagIsRecordType(dw_tag_t tag) {
   }
 }
 
-static bool IsForwardDeclaration(const DWARFDIE ,
- const ParsedDWARFTypeAttributes ,
- LanguageType cu_language) {
-  if (attrs.is_forward_declaration)
-return true;
-
-  // Work around an issue with clang at the moment where forward
-  // declarations for objective C classes are emitted as:
-  //  DW_TAG_structure_type [2]
-  //  DW_AT_name( "ForwardObjcClass" )
-  //  DW_AT_byte_size( 0x00 )
-  //  DW_AT_decl_file( "..." )
-  //  DW_AT_decl_line( 1 )
-  //
-  // Note that there is no DW_AT_declaration and there are no children,
-  // and the byte size is zero.
-  return attrs.byte_size && *attrs.byte_size == 0 && attrs.name &&
- !die.HasChildren() && cu_language == eLanguageTypeObjC;
-}
-
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext ,
  const DWARFDIE ,
  Log *log) {
@@ -269,9 +249,11 @@ static void ForcefullyCompleteType(CompilerType type) {
 /// This function serves a similar purpose as RequireCompleteType above, but it
 /// avoids completing the type if it is not immediately necessary. It only
 /// ensures we _can_ complete the type later.
-void DWARFASTParserClang::PrepareContextToReceiveMembers(
-clang::DeclContext *decl_ctx, const DWARFDIE _ctx_die,
-const DWARFDIE , const char *type_name_cstr) {
+static void PrepareContextToReceiveMembers(TypeSystemClang ,
+   ClangASTImporter _importer,
+   clang::DeclContext *decl_ctx,
+   DWARFDIE die,
+   const char *type_name_cstr) {
   auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
   if (!tag_decl_ctx)
 return; // Non-tag context are always ready.
@@ -286,8 +268,7 @@ void DWARFASTParserClang::PrepareContextToReceiveMembers(
   // gmodules case), we can complete the type by doing a full import.
 
   // If this type was not imported from an external AST, there's nothing to do.
-  CompilerType type = m_ast.GetTypeForDecl(tag_decl_ctx);
-  ClangASTImporter _importer = GetClangASTImporter();
+  CompilerType type = ast.GetTypeForDecl(tag_decl_ctx);
   if (type && 

[Lldb-commits] [lldb] de3f1b6 - [lldb] Test case for the bug in #92328

2024-06-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-06-06T16:10:22Z
New Revision: de3f1b6d68ab8a0e827db84b328803857a4f60df

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

LOG: [lldb] Test case for the bug in #92328

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp

Modified: 


Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp
new file mode 100644
index 0..a8a4d3b8fbd5f
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp
@@ -0,0 +1,44 @@
+// Test that we can correctly resolve forward declared types when they only
+// 
diff er in the template arguments of the surrounding context. The reproducer
+// is sensitive to the order of declarations, so we test in both directions.
+
+// REQUIRES: lld
+
+// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-a.o -g 
-gsimple-template-names -DFILE_A
+// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-b.o -g 
-gsimple-template-names -DFILE_B
+// RUN: ld.lld %t-a.o %t-b.o -o %t
+// RUN: %lldb %t -o "target variable --ptr-depth 1 --show-types both_a both_b" 
-o exit | FileCheck %s
+
+// CHECK: (lldb) target variable
+// CHECK-NEXT: (ReferencesBoth<'A'>) both_a = {
+// CHECK-NEXT:   (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
+// CHECK-NEXT:   (Outer<'A'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
+// CHECK-NEXT: }
+// CHECK-NEXT: (ReferencesBoth<'B'>) both_b = {
+// CHECK-NEXT:   (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
+// CHECK-NEXT:   (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
+// CHECK-NEXT: }
+
+template
+struct Outer {
+  struct Inner {};
+};
+
+template
+struct ReferencesBoth {
+  Outer<'A'>::Inner *a;
+  Outer<'B'>::Inner *b;
+};
+
+#ifdef FILE_A
+Outer<'A'>::Inner inner_a;
+extern Outer<'B'>::Inner inner_b;
+
+ReferencesBoth<'A'> both_a{_a, _b};
+
+#else
+extern Outer<'A'>::Inner inner_a;
+Outer<'B'>::Inner inner_b;
+
+ReferencesBoth<'B'> both_b{_a, _b};
+#endif



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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP _sp);
 
+  /// Return the target load address assocaited with this value object.

cmtice wrote:

Done

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


[Lldb-commits] [lldb] 67aaa9f - [lldb] Refactor ResolveLoadAddress to return an llvm::Expected (NFC) (#94558)

2024-06-06 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-06-06T08:54:37-07:00
New Revision: 67aaa9f9974993f360cc0dabffd73b51c030d775

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

LOG: [lldb] Refactor ResolveLoadAddress to return an llvm::Expected (NFC) 
(#94558)

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 622b36b855e34..05767a8d02ff2 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -769,7 +769,6 @@ void UpdateValueTypeFromLocationDescription(Log *log, const 
DWARFUnit *dwarf_cu,
 ///
 /// \param exe_ctx Pointer to the execution context
 /// \param module_sp shared_ptr contains the module if we have one
-/// \param error_ptr pointer to Status object if we have one
 /// \param dw_op_type C-style string used to vary the error output
 /// \param file_addr the file address we are trying to resolve and turn into a
 ///  load address
@@ -780,32 +779,22 @@ void UpdateValueTypeFromLocationDescription(Log *log, 
const DWARFUnit *dwarf_cu,
 ///  the load address succeed or an empty Optinal otherwise. If
 ///  check_sectionoffset is true we consider LLDB_INVALID_ADDRESS a
 ///  success if so_addr.IsSectionOffset() is true.
-static std::optional
+static llvm::Expected
 ResolveLoadAddress(ExecutionContext *exe_ctx, lldb::ModuleSP _sp,
-   Status *error_ptr, const char *dw_op_type,
-   lldb::addr_t file_addr, Address _addr,
-   bool check_sectionoffset = false) {
-  if (!module_sp) {
-if (error_ptr)
-  error_ptr->SetErrorStringWithFormat(
-  "need module to resolve file address for %s", dw_op_type);
-return {};
-  }
+   const char *dw_op_type, lldb::addr_t file_addr,
+   Address _addr, bool check_sectionoffset = false) {
+  if (!module_sp)
+return llvm::createStringError("need module to resolve file address for 
%s",
+   dw_op_type);
 
-  if (!module_sp->ResolveFileAddress(file_addr, so_addr)) {
-if (error_ptr)
-  error_ptr->SetErrorString("failed to resolve file address in module");
-return {};
-  }
+  if (!module_sp->ResolveFileAddress(file_addr, so_addr))
+return llvm::createStringError("failed to resolve file address in module");
 
-  addr_t load_addr = so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
+  const addr_t load_addr = so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
 
   if (load_addr == LLDB_INVALID_ADDRESS &&
-  (check_sectionoffset && !so_addr.IsSectionOffset())) {
-if (error_ptr)
-  error_ptr->SetErrorString("failed to resolve load address");
-return {};
-  }
+  (check_sectionoffset && !so_addr.IsSectionOffset()))
+return llvm::createStringError("failed to resolve load address");
 
   return load_addr;
 }
@@ -975,12 +964,11 @@ llvm::Expected DWARFExpression::Evaluate(
 LLDB_INVALID_ADDRESS);
 
 Address so_addr;
-Status load_err;
 auto maybe_load_addr = ResolveLoadAddress(
-exe_ctx, module_sp, _err, "DW_OP_deref", file_addr, so_addr);
+exe_ctx, module_sp, "DW_OP_deref", file_addr, so_addr);
 
 if (!maybe_load_addr)
-  return load_err.ToError();
+  return maybe_load_addr.takeError();
 
 stack.back().GetScalar() = *maybe_load_addr;
 // Fall through to load address promotion code below.
@@ -1092,14 +1080,12 @@ llvm::Expected DWARFExpression::Evaluate(
 auto file_addr =
 stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 Address so_addr;
-Status resolve_err;
-auto maybe_load_addr =
-ResolveLoadAddress(exe_ctx, module_sp, _err,
-   "DW_OP_deref_size", file_addr, so_addr,
-   /*check_sectionoffset=*/true);
+auto maybe_load_addr = ResolveLoadAddress(
+exe_ctx, module_sp, "DW_OP_deref_size", file_addr, so_addr,
+/*check_sectionoffset=*/true);
 
 if (!maybe_load_addr)
-  return resolve_err.ToError();
+  return maybe_load_addr.takeError();
 
 addr_t load_addr = *maybe_load_addr;
 



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


[Lldb-commits] [lldb] [lldb] Refactor ResolveLoadAddress to return an llvm::Expected (NFC) (PR #94558)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Refactor ReadRegisterValueAsScalar to return an llvm::Error (NFC) (PR #94556)

2024-06-06 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] a76290d - [lldb] Refactor ReadRegisterValueAsScalar to return an llvm::Error (NFC) (#94556)

2024-06-06 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-06-06T08:54:20-07:00
New Revision: a76290d6acedb4dcdd431cdd21f057255117f8d3

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

LOG: [lldb] Refactor ReadRegisterValueAsScalar to return an llvm::Error (NFC) 
(#94556)

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 4681dbafb6f9c..622b36b855e34 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -94,51 +94,38 @@ void DWARFExpression::SetRegisterKind(RegisterKind 
reg_kind) {
   m_reg_kind = reg_kind;
 }
 
-
-static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
-  lldb::RegisterKind reg_kind,
-  uint32_t reg_num, Status *error_ptr,
-  Value ) {
-  if (reg_ctx == nullptr) {
-if (error_ptr)
-  error_ptr->SetErrorString("No register context in frame.\n");
-  } else {
-uint32_t native_reg =
-reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
-if (native_reg == LLDB_INVALID_REGNUM) {
-  if (error_ptr)
-error_ptr->SetErrorStringWithFormat("Unable to convert register "
-"kind=%u reg_num=%u to a native "
-"register number.\n",
-reg_kind, reg_num);
-} else {
-  const RegisterInfo *reg_info =
-  reg_ctx->GetRegisterInfoAtIndex(native_reg);
-  RegisterValue reg_value;
-  if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-if (reg_value.GetScalarValue(value.GetScalar())) {
-  value.SetValueType(Value::ValueType::Scalar);
-  value.SetContext(Value::ContextType::RegisterInfo,
-   const_cast(reg_info));
-  if (error_ptr)
-error_ptr->Clear();
-  return true;
-} else {
-  // If we get this error, then we need to implement a value buffer in
-  // the dwarf expression evaluation function...
-  if (error_ptr)
-error_ptr->SetErrorStringWithFormat(
-"register %s can't be converted to a scalar value",
-reg_info->name);
-}
-  } else {
-if (error_ptr)
-  error_ptr->SetErrorStringWithFormat("register %s is not available",
-  reg_info->name);
-  }
+static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
+ lldb::RegisterKind reg_kind,
+ uint32_t reg_num, Value ) {
+  if (reg_ctx == nullptr)
+return llvm::createStringError("no register context in frame");
+
+  const uint32_t native_reg =
+  reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
+  if (native_reg == LLDB_INVALID_REGNUM)
+return llvm::createStringError(
+"unable to convert register kind=%u reg_num=%u to a native "
+"register number",
+reg_kind, reg_num);
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(native_reg);
+  RegisterValue reg_value;
+  if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+if (reg_value.GetScalarValue(value.GetScalar())) {
+  value.SetValueType(Value::ValueType::Scalar);
+  value.SetContext(Value::ContextType::RegisterInfo,
+   const_cast(reg_info));
+  return llvm::Error::success();
 }
+
+// If we get this error, then we need to implement a value buffer in
+// the dwarf expression evaluation function...
+return llvm::createStringError(
+"register %s can't be converted to a scalar value", reg_info->name);
   }
-  return false;
+
+  return llvm::createStringError("register %s is not available",
+ reg_info->name);
 }
 
 /// Return the length in bytes of the set of operands for \p op. No guarantees
@@ -1832,11 +1819,10 @@ llvm::Expected DWARFExpression::Evaluate(
   dwarf4_location_description_kind = Register;
   reg_num = op - DW_OP_reg0;
 
-  Status read_err;
-  if (ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, _err, 
tmp))
-stack.push_back(tmp);
-  else
-return read_err.ToError();
+  if (llvm::Error err =
+  ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, tmp))
+return err;
+  stack.push_back(tmp);
 } break;
 // OPCODE: DW_OP_regx
 // OPERANDS:
@@ -1846,10 +1832,10 @@ llvm::Expected DWARFExpression::Evaluate(
   dwarf4_location_description_kind = Register;

[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-06-06 Thread via lldb-commits

jeffreytan81 wrote:

@jimingham , let me know any other comments/thoughts you have. 

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


[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Thanks for the fix! These small mistakes are always annoying when you're going 
through a complicated log.

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


[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] d9e6a56 - [lldb] Fix ThreadPlanStepOverRange name in log message (#94611)

2024-06-06 Thread via lldb-commits

Author: Marianne Mailhot-Sarrasin
Date: 2024-06-06T15:05:55+01:00
New Revision: d9e6a563206cea4e682d4c52eccf24178d7d8343

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

LOG: [lldb] Fix ThreadPlanStepOverRange name in log message (#94611)

Co-authored-by: Marianne Mailhot-Sarrasin 


Added: 


Modified: 
lldb/source/Target/ThreadPlanStepOverRange.cpp

Removed: 




diff  --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp 
b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index 84f282f1de520..3fe02e0bf4faf 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -355,7 +355,7 @@ bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event 
*event_ptr) {
   return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
 } else {
   if (log)
-log->PutCString("ThreadPlanStepInRange got asked if it explains the "
+log->PutCString("ThreadPlanStepOverRange got asked if it explains the "
 "stop for some reason other than step.");
   return_value = false;
 }



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


[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Ah ignore that, the function is in fact `DoPlanExplainsStop`, I was looking at 
the class name.

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


[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread David Spickett via lldb-commits

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

I think there a `LOG` macro that adds the function name but I forget exactly 
what, this LGTM as is.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -3015,11 +3017,12 @@ llvm::Expected 
ValueObject::CastDerivedToBaseType(
 
   lldb::TargetSP target = GetTargetSP();
   // The `value` can be a pointer, but GetChildAtIndex works for pointers too.
-  lldb::ValueObjectSP inner_value;
+  lldb::ValueObjectSP inner_value = GetSP();
 
   for (const uint32_t i : base_type_indices)
 // Force static value, otherwise we can end up with the "real" type.
-inner_value = GetChildAtIndex(i, /*can_create_synthetic*/ false);

cmtice wrote:

Done.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits


@@ -3138,13 +3141,13 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 val_byte_size = temp.value();
 
   if (is_pointer) {
-if (type.IsBoolean() && type_byte_size < val_byte_size) {
+if (!type.IsBoolean() && type_byte_size < val_byte_size) {

cmtice wrote:

Done.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

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

>From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 31 Mar 2024 10:59:38 -0700
Subject: [PATCH 1/7] [LLDB] Add more helper functions to ValueObject class.

Create additional helper functions for the ValueObject class, for:
  - returning the value as an APSInt or APFloat
  - additional type casting options
  - additional ways to create ValueObjects from various types of data
  - dereferencing a ValueObject

These helper functions are needed for implementing the Data Inspection
Language, described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893
---
 lldb/include/lldb/Core/ValueObject.h |  61 
 lldb/source/Core/ValueObject.cpp | 405 +++
 2 files changed, 466 insertions(+)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e7e35e2b2bffc..0c8dbf384a326 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -441,6 +441,19 @@ class ValueObject {
 
   virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = 
nullptr);
 
+  llvm::APSInt GetValueAsAPSInt();
+
+  llvm::APFloat GetValueAsFloat();
+
+  bool GetValueAsBool();
+
+  /// Update the value of the current object to be the integer in the 'value'
+  /// parameter.
+  void UpdateIntegerValue(const llvm::APInt );
+
+  /// Assign the integer value 'new_val_sp' to the current object.
+  void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp);
+
   virtual bool SetValueFromCString(const char *value_str, Status );
 
   /// Return the module associated with this value object in case the value is
@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP _sp);
 
+  /// Return the target load address assocaited with this value object.
+  lldb::addr_t GetLoadAddress();
+
+  lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type,
+const std::vector );
+
+  lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t 
offset);
+
+  lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status );
+
+  lldb::ValueObjectSP CastEnumToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastPointerToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type);
+
+  lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status );
+
   /// If this object represents a C++ class with a vtable, return an object
   /// that represents the virtual function table. If the object isn't a class
   /// with a vtable, return a valid ValueObject with the error set correctly.
@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor ,
 const ExecutionContext _ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt ,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat ,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,
+  CompilerType type);
+
   lldb::ValueObjectSP Persist();
 
   /// Returns true if this is a char* or a char[] if it is a char* and
@@ -719,6 +776,10 @@ class ValueObject {
 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
   }
 
+  void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
+
+  ValueObject *GetDerefValobj() { return m_deref_valobj; }
+
   void SetValueFormat(lldb::TypeFormatImplSP format) {
 m_type_format_sp = std::move(format);
 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 

[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Marianne Mailhot-Sarrasin (mariannems)


Changes



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


1 Files Affected:

- (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+1-1) 


``diff
diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp 
b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index 84f282f1de520..3fe02e0bf4faf 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -355,7 +355,7 @@ bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event 
*event_ptr) {
   return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
 } else {
   if (log)
-log->PutCString("ThreadPlanStepInRange got asked if it explains the "
+log->PutCString("ThreadPlanStepOverRange got asked if it explains the "
 "stop for some reason other than step.");
   return_value = false;
 }

``




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


[Lldb-commits] [lldb] [lldb] Fix ThreadPlanStepOverRange name in log message (PR #94611)

2024-06-06 Thread Marianne Mailhot-Sarrasin via lldb-commits

https://github.com/mariannems created 
https://github.com/llvm/llvm-project/pull/94611

None

>From b17a12f78f19e59bce7ee52308502f2eeea4e8cd Mon Sep 17 00:00:00 2001
From: Marianne Mailhot-Sarrasin 
Date: Wed, 5 Jun 2024 15:56:12 -0400
Subject: [PATCH] [lldb] Fix ThreadPlanStepOverRange name in log message

---
 lldb/source/Target/ThreadPlanStepOverRange.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp 
b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index 84f282f1de520..3fe02e0bf4faf 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -355,7 +355,7 @@ bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event 
*event_ptr) {
   return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
 } else {
   if (log)
-log->PutCString("ThreadPlanStepInRange got asked if it explains the "
+log->PutCString("ThreadPlanStepOverRange got asked if it explains the "
 "stop for some reason other than step.");
   return_value = false;
 }

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-06-06 Thread via lldb-commits

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

>From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 31 Mar 2024 10:59:38 -0700
Subject: [PATCH 1/6] [LLDB] Add more helper functions to ValueObject class.

Create additional helper functions for the ValueObject class, for:
  - returning the value as an APSInt or APFloat
  - additional type casting options
  - additional ways to create ValueObjects from various types of data
  - dereferencing a ValueObject

These helper functions are needed for implementing the Data Inspection
Language, described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893
---
 lldb/include/lldb/Core/ValueObject.h |  61 
 lldb/source/Core/ValueObject.cpp | 405 +++
 2 files changed, 466 insertions(+)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e7e35e2b2bffc..0c8dbf384a326 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -441,6 +441,19 @@ class ValueObject {
 
   virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = 
nullptr);
 
+  llvm::APSInt GetValueAsAPSInt();
+
+  llvm::APFloat GetValueAsFloat();
+
+  bool GetValueAsBool();
+
+  /// Update the value of the current object to be the integer in the 'value'
+  /// parameter.
+  void UpdateIntegerValue(const llvm::APInt );
+
+  /// Assign the integer value 'new_val_sp' to the current object.
+  void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp);
+
   virtual bool SetValueFromCString(const char *value_str, Status );
 
   /// Return the module associated with this value object in case the value is
@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP _sp);
 
+  /// Return the target load address assocaited with this value object.
+  lldb::addr_t GetLoadAddress();
+
+  lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type,
+const std::vector );
+
+  lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t 
offset);
+
+  lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status );
+
+  lldb::ValueObjectSP CastEnumToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastPointerToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type);
+
+  lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status );
+
   /// If this object represents a C++ class with a vtable, return an object
   /// that represents the virtual function table. If the object isn't a class
   /// with a vtable, return a valid ValueObject with the error set correctly.
@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor ,
 const ExecutionContext _ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt ,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat ,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,
+  CompilerType type);
+
   lldb::ValueObjectSP Persist();
 
   /// Returns true if this is a char* or a char[] if it is a char* and
@@ -719,6 +776,10 @@ class ValueObject {
 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
   }
 
+  void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
+
+  ValueObject *GetDerefValobj() { return m_deref_valobj; }
+
   void SetValueFormat(lldb::TypeFormatImplSP format) {
 m_type_format_sp = std::move(format);
 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 

[Lldb-commits] [lldb] [lldb] Refactor ResolveLoadAddress to return an llvm::Expected (NFC) (PR #94558)

2024-06-06 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Refactor ReadRegisterValueAsScalar to return an llvm::Error (NFC) (PR #94556)

2024-06-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Refactor ReadRegisterValueAsScalar to return an llvm::Error (NFC) (PR #94556)

2024-06-06 Thread David Spickett via lldb-commits

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

LGTM

Thanks for working on this. Last time I tried to do this sort of conversion I 
went for llvm::Expected, and it quickly spiraled into a mountain of changes 
that I gave up on in the end.

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


[Lldb-commits] [lldb] a6cc363 - [lldb] Disable TestPtyServer API test when remote testing (#94587)

2024-06-06 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-06-06T10:02:27+01:00
New Revision: a6cc363b2743a264eb06e46cac05c3c9c92e3ef7

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

LOG: [lldb] Disable TestPtyServer API test when remote testing (#94587)

The local PTY is not available for the remotely executed lldb-server to
pass the test. Also, in general, we cannot execute the local lldb-server
instance because it could be compiled for the different system/cpu
target.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestPtyServer.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py 
b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index 4bfcf70bfa01b..345f68f6d87d3 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -7,6 +7,7 @@
 import xml.etree.ElementTree as ET
 
 
+@skipIfRemote
 @skipIf(hostoslist=["windows"])
 class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 def setUp(self):



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


[Lldb-commits] [lldb] [lldb] Disable TestPtyServer API test when remote testing (PR #94587)

2024-06-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable TestPtyServer API test when remote testing (PR #94587)

2024-06-06 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Disable TestPtyServer API test when remote testing (PR #94587)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

The local PTY is not available for the remotely executed lldb-server to pass 
the test. Also, in general, we cannot execute the local lldb-server instance 
because it could be compiled for the different system/cpu target.

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


1 Files Affected:

- (modified) lldb/test/API/tools/lldb-server/TestPtyServer.py (+1) 


``diff
diff --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py 
b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index 4bfcf70bfa01b..345f68f6d87d3 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -7,6 +7,7 @@
 import xml.etree.ElementTree as ET
 
 
+@skipIfRemote
 @skipIf(hostoslist=["windows"])
 class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 def setUp(self):

``




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


[Lldb-commits] [lldb] [lldb] Disable TestPtyServer API test when remote testing (PR #94587)

2024-06-06 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/94587

The local PTY is not available for the remotely executed lldb-server to pass 
the test. Also, in general, we cannot execute the local lldb-server instance 
because it could be compiled for the different system/cpu target.

>From 9288b9a59290a4ded37928f2f553f4c334ebacad Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 11:32:13 +0400
Subject: [PATCH] [lldb] Disable TestPtyServer API test when remote testing

The local PTY is not available for the remotely executed lldb-server to pass 
the test. Also, in general, we cannot execute the local lldb-server instance 
because it could be compiled for the different system/cpu target.
---
 lldb/test/API/tools/lldb-server/TestPtyServer.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py 
b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index 4bfcf70bfa01b..345f68f6d87d3 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -7,6 +7,7 @@
 import xml.etree.ElementTree as ET
 
 
+@skipIfRemote
 @skipIf(hostoslist=["windows"])
 class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 def setUp(self):

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