[Lldb-commits] [lldb] [lldb] Have lldb-server assign ports to children in platform mode (PR #88845)

2024-07-13 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Here is the log of lldb-server processes (parent and child) on remote Linux
```
/home/ubuntu/lldb-server p --log-channels lldb all --listen *:1234 --server 
--min-gdbserver-port 1236 --max-gdbserver-port 1240
/home/ubuntu/lldb-server gdbserver tcp://[10.1.1.170]:0 --native-regs --pipe 6
```
Note the port `0` in the url  `tcp://[10.1.1.170]:0` is a bug now. but any port 
in this url will be ignored.

I don't see where `--min-gdbserver-port`, `--max-gdbserver-port` and 
`--gdbserver-port` values are really used. Do we still need them?
`--port-offset` is not used too.

Probably it is better to revert #88845 since the port mapping does not work as 
expected anyway. But #88845 caused test failures on cross builds.

See https://github.com/llvm/llvm-project/issues/97537#issuecomment-2226588550 
for more details.

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


[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)

2024-07-13 Thread Michael Buch via lldb-commits

Michael137 wrote:

@jimingham @JDevlieghere @clayborg just to confirm, are you still ok with me 
landing this and address the question of a common `CLanguageRuntime` plugin as 
a follow-up? 

https://github.com/llvm/llvm-project/pull/80368
___
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, fixed (PR #98795)

2024-07-13 Thread via lldb-commits

https://github.com/temyurchenko created 
https://github.com/llvm/llvm-project/pull/98795

Relanding of #93913. Now, it also fixes incorrect declaration context in 
function parameters creation.

>From 410c7ba9fb7667dabdfbc48fdbda427401ca8df0 Mon Sep 17 00:00:00 2001
From: Artem Yurchenko <44875844+temyurche...@users.noreply.github.com>
Date: Thu, 30 May 2024 16:18:47 -0400
Subject: [PATCH 1/3] [clang][AST] fix ast-print of `extern ` with >=2
 declarators (#93131)

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,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
QualType T,
llvm::raw_ostream &Out) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
   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 @@

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

2024-07-13 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (temyurchenko)


Changes

Relanding of #93913. Now, it also fixes incorrect declaration context 
in function parameters creation.

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


7 Files Affected:

- (modified) clang/lib/AST/Decl.cpp (+21-6) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+41-14) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (added) clang/test/AST/ast-print-language-linkage.cpp (+31) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+1-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp 
(+5-5) 


``diff
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1f19dadafa44e..35973d99f906d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -576,13 +576,16 @@ template  static bool 
isFirstInExternCContext(T *D) {
   return First->isInExternCContext();
 }
 
-static bool isSingleLineLanguageLinkage(const Decl &D) {
-  if (const auto *SD = dyn_cast(D.getDeclContext()))
-if (!SD->hasBraces())
-  return true;
+static bool isUnbracedLanguageLinkage(const DeclContext *DC) {
+  if (const auto *SD = dyn_cast_if_present(DC))
+return !SD->hasBraces();
   return false;
 }
 
+static bool hasUnbracedLanguageLinkage(const Decl &D) {
+  return isUnbracedLanguageLinkage(D.getDeclContext());
+}
+
 static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) {
   if (auto *M = D->getOwningModule())
 return M->isInterfaceOrPartition();
@@ -644,7 +647,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl 
*D,
 
   if (Var->getStorageClass() != SC_Extern &&
   Var->getStorageClass() != SC_PrivateExtern &&
-  !isSingleLineLanguageLinkage(*Var))
+  !hasUnbracedLanguageLinkage(*Var))
 return LinkageInfo::internal();
 }
 
@@ -2133,6 +2136,12 @@ VarDecl::VarDecl(Kind DK, ASTContext &C, DeclContext *DC,
 "ParmVarDeclBitfields too large!");
   static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned),
 "NonParmVarDeclBitfields too large!");
+
+  // The unbraced `extern "C"` invariant is that the storage class
+  // specifier is omitted in the source code, i.e. SC_None (but is,
+  // implicitly, `extern`).
+  assert(!isUnbracedLanguageLinkage(DC) || SC == SC_None);
+
   AllBits = 0;
   VarDeclBits.SClass = SC;
   // Everything else is implicitly initialized to false.
@@ -2316,7 +2325,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) 
const {
   //   A declaration directly contained in a linkage-specification is treated
   //   as if it contains the extern specifier for the purpose of determining
   //   the linkage of the declared name and whether it is a definition.
-  if (isSingleLineLanguageLinkage(*this))
+  if (hasUnbracedLanguageLinkage(*this))
 return DeclarationOnly;
 
   // C99 6.9.2p2:
@@ -3041,6 +3050,12 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, 
DeclContext *DC,
   DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0),
   EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
   assert(T.isNull() || T->isFunctionType());
+
+  // The unbraced `extern "C"` invariant is that the storage class
+  // specifier is omitted in the source code, i.e. SC_None (but is,
+  // implicitly, `extern`).
+  assert(!isUnbracedLanguageLinkage(DC) || S == SC_None);
+
   FunctionDeclBits.SClass = S;
   FunctionDeclBits.IsInline = isInlineSpecified;
   FunctionDeclBits.IsInlineSpecified = isInlineSpecified;
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,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
QualType T,
llvm::raw_ostream &Out) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
   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 &&
+ "unknow

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

2024-07-13 Thread via lldb-commits

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

>From 410c7ba9fb7667dabdfbc48fdbda427401ca8df0 Mon Sep 17 00:00:00 2001
From: Artem Yurchenko <44875844+temyurche...@users.noreply.github.com>
Date: Thu, 30 May 2024 16:18:47 -0400
Subject: [PATCH 1/4] [clang][AST] fix ast-print of `extern ` with >=2
 declarators (#93131)

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,
   Out << Proto;
 }
 
-static void MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
+static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
QualType T,
llvm::raw_ostream &Out) {
   StringRef prefix = T->isClassType()   ? "class "
@@ -643,6 +643,22 @@ static void 
MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
   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(Li

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

2024-07-13 Thread via lldb-commits

temyurchenko wrote:

@AaronBallman could you please review? 

I've fixed at least the LLDB tests. There was an actual bug in function 
parameters construction that was revealed by the invariant check. 

However, I can't run the whole LLDB suite. Even among the reported failing 
tests, some are «unsupported» on my machine. Even without my changes, a lot of 
LLDB tests are unsupported or failing, I guess some were killed by oom-killer.
On the first attempt, @gulfemsavrun suggested to run the LLDB test suite on 
this PR. I would be glad, if that offer is still on.

Regarding the orc-rt test failures: I tried building one of the failing objects 
and I can't reproduce the failure. Perhaps, because the tests are run on 
Windows? It would be very helpful if @Prabhuk could run the failing command on 
a debug build.

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