[Lldb-commits] [clang] [lldb] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2024-05-26 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread Chuanqi Xu via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread Chuanqi Xu via lldb-commits

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

I don't like the PR since I don't feel it makes the code cleaner and it may 
make the downstream suffering backporting.

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


[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via lldb-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/5] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module );
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module );
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via lldb-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/4] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module );
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module );
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff faef8b4aa245a671e2013319e8073a9fc52ae12e 
9be7409d8d246a24432faf7d5c238d6c0e1763d9 -- 
clang/include/clang/Basic/ASTSourceDescriptor.h 
clang/include/clang/Basic/Module/ASTSourceDescriptor.h 
clang/lib/Basic/Module/ASTSourceDescriptor.cpp 
clang/lib/Basic/Module/Module.cpp 
clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
clang/include/clang/APINotes/APINotesManager.h 
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h 
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h 
clang/include/clang/Lex/ModuleLoader.h clang/include/clang/Lex/ModuleMap.h 
clang/include/clang/Lex/Preprocessor.h clang/include/clang/Sema/Sema.h 
clang/include/clang/Serialization/ASTWriter.h 
clang/include/clang/Serialization/ModuleFile.h 
clang/include/clang/Serialization/ModuleManager.h 
clang/include/clang/Serialization/PCHContainerOperations.h 
clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/Decl.cpp 
clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclPrinter.cpp 
clang/lib/AST/ExternalASTSource.cpp clang/lib/AST/ItaniumMangle.cpp 
clang/lib/AST/ODRDiagsEmitter.cpp clang/lib/AST/TextNodeDumper.cpp 
clang/lib/Basic/Module.cpp clang/lib/CodeGen/CGDebugInfo.h 
clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h 
clang/lib/ExtractAPI/API.cpp 
clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp 
clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/FrontendActions.cpp 
clang/lib/Lex/HeaderSearch.cpp clang/lib/Lex/ModuleMap.cpp 
clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/Pragma.cpp 
clang/lib/Lex/Preprocessor.cpp clang/lib/Serialization/ASTReader.cpp 
clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp 
libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h 
clang/include/clang/Basic/Module/Module.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Basic/Module/Module.h 
b/clang/include/clang/Basic/Module/Module.h
index e86f4303d7..f71595c23b 100644
--- a/clang/include/clang/Basic/Module/Module.h
+++ b/clang/include/clang/Basic/Module/Module.h
@@ -230,7 +230,7 @@ private:
   std::vector TopHeaderNames;
 
   /// Cache of modules visible to lookup in this module.
-  mutable llvm::DenseSet VisibleModulesCache;
+  mutable llvm::DenseSet VisibleModulesCache;
 
   /// The ID used when referencing this module within a VisibleModuleSet.
   unsigned VisibilityID;
@@ -545,10 +545,8 @@ public:
   ///
   /// \param ShadowingModule If this module is unavailable because it is
   /// shadowed, this parameter will be set to the shadowing module.
-  bool isAvailable(const LangOptions ,
-   const TargetInfo ,
-   Requirement ,
-   UnresolvedHeaderDirective ,
+  bool isAvailable(const LangOptions , const TargetInfo ,
+   Requirement , UnresolvedHeaderDirective ,
Module *) const;
 
   /// Determine whether this module is a submodule.
@@ -665,7 +663,7 @@ public:
   /// be this module.
   Module *getTopLevelModule() {
 return const_cast(
- const_cast(this)->getTopLevelModule());
+const_cast(this)->getTopLevelModule());
   }
 
   /// Retrieve the top-level module for this (sub)module, which may
@@ -673,9 +671,7 @@ public:
   const Module *getTopLevelModule() const;
 
   /// Retrieve the name of the top-level module.
-  StringRef getTopLevelModuleName() const {
-return getTopLevelModule()->Name;
-  }
+  StringRef getTopLevelModuleName() const { return getTopLevelModule()->Name; }
 
   /// The serialized AST file for this module, if one was created.
   OptionalFileEntryRef getASTFile() const {
@@ -739,8 +735,7 @@ public:
   /// \param Target The target options that will be used to evaluate the
   /// availability of this feature.
   void addRequirement(StringRef Feature, bool RequiredState,
-  const LangOptions ,
-  const TargetInfo );
+  const LangOptions , const TargetInfo );
 
   /// Mark this module and all of its submodules as unavailable.
   void markUnavailable(bool Unimportable);
@@ -793,9 +788,7 @@ public:
   /// directly exported), not the complete set of exported modules.
   void getExportedModules(SmallVectorImpl ) const;
 
-  static StringRef getModuleInputBufferName() {
-return "";
-  }
+  static StringRef getModuleInputBufferName() { return ""; }
 
   /// Print the module map for this module to the given stream.
   void print(raw_ostream , unsigned Indent = 0, bool Dump = false) const;
@@ -832,9 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via lldb-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/3] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module );
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module );
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Stone (davidstone)


Changes

Depends on https://github.com/llvm/llvm-project/pull/67930

---

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


49 Files Affected:

- (modified) .github/new-prs-labeler.yml (+1-1) 
- (modified) clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp (+1-1) 
- (modified) clang/docs/Modules.rst (+1-1) 
- (modified) clang/include/clang/APINotes/APINotesManager.h (+1-1) 
- (added) clang/include/clang/Basic/ASTSourceDescriptor.h (+52) 
- (added) clang/include/clang/Basic/Module/ASTSourceDescriptor.h (+52) 
- (renamed) clang/include/clang/Basic/Module/Module.h (-26) 
- (modified) clang/include/clang/ExtractAPI/ExtractAPIVisitor.h (+1-1) 
- (modified) 
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h (+1-1) 
- (modified) clang/include/clang/Lex/ModuleLoader.h (+1-1) 
- (modified) clang/include/clang/Lex/ModuleMap.h (+1-1) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+1-1) 
- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+1-1) 
- (modified) clang/include/clang/Serialization/ModuleFile.h (+1-1) 
- (modified) clang/include/clang/Serialization/ModuleManager.h (+1-1) 
- (modified) clang/include/clang/Serialization/PCHContainerOperations.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 
- (modified) clang/lib/AST/ASTDumper.cpp (+1-1) 
- (modified) clang/lib/AST/Decl.cpp (+1-1) 
- (modified) clang/lib/AST/DeclBase.cpp (+1-1) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+1-1) 
- (modified) clang/lib/AST/ExternalASTSource.cpp (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/ODRDiagsEmitter.cpp (+1-1) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+1-1) 
- (modified) clang/lib/Basic/CMakeLists.txt (+7-6) 
- (modified) clang/lib/Basic/Module.cpp (+1-16) 
- (added) clang/lib/Basic/Module/ASTSourceDescriptor.cpp (+33) 
- (added) clang/lib/Basic/Module/Module.cpp (+726) 
- (modified) clang/lib/CodeGen/CGDebugInfo.h (+2-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+1-1) 
- (modified) clang/lib/ExtractAPI/API.cpp (+1-1) 
- (modified) clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp (+1-1) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+1-1) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+1-1) 
- (modified) clang/lib/Lex/HeaderSearch.cpp (+1-1) 
- (modified) clang/lib/Lex/ModuleMap.cpp (+1-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+1-1) 
- (modified) clang/lib/Lex/Pragma.cpp (+1-1) 
- (modified) clang/lib/Lex/Preprocessor.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+2-1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) 
libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp (+1-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h (+7-1) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp 
(+1) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h 
(+7-1) 


``diff
diff --git a/.github/new-prs-labeler.yml b/.github/new-prs-labeler.yml
index a57ba28faf160..41325b2ff2e24 100644
--- a/.github/new-prs-labeler.yml
+++ b/.github/new-prs-labeler.yml
@@ -345,7 +345,7 @@ clang:modules:
   - clang/include/clang/AST/PropertiesBase.td
   - clang/include/clang/AST/ODRHash.h
   - clang/include/clang/AST/TypeProperties.td
-  - clang/include/clang/Basic/Module.h
+  - clang/include/clang/Basic/Module/**
   - clang/include/clang/Frontend/PrecompiledPreamble.h
   - clang/include/clang/Lex/ModuleLoader.h
   - clang/include/clang/Lex/ModuleMap.h
diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
index 147d9abe69137..c650f9b8440c2 100644
--- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
@@ -25,7 +25,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
+#include "clang/Basic/Module/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
diff --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst
index 06294e3c58a4f..79c87250ad0d5 100644
--- a/clang/docs/Modules.rst
+++ b/clang/docs/Modules.rst
@@ -1126,7 +1126,7 @@ The Clang source code provides additional information 
about modules:
 ``clang/test/Modules/``
   Tests specifically related to modules functionality.
 
-``clang/include/clang/Basic/Module.h``
+``clang/include/clang/Basic/Module/Module.h``
   The ``Module`` class in this header describes a module, and is used 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: David Stone (davidstone)


Changes

Depends on https://github.com/llvm/llvm-project/pull/67930

---

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


49 Files Affected:

- (modified) .github/new-prs-labeler.yml (+1-1) 
- (modified) clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp (+1-1) 
- (modified) clang/docs/Modules.rst (+1-1) 
- (modified) clang/include/clang/APINotes/APINotesManager.h (+1-1) 
- (added) clang/include/clang/Basic/ASTSourceDescriptor.h (+52) 
- (added) clang/include/clang/Basic/Module/ASTSourceDescriptor.h (+52) 
- (renamed) clang/include/clang/Basic/Module/Module.h (-26) 
- (modified) clang/include/clang/ExtractAPI/ExtractAPIVisitor.h (+1-1) 
- (modified) 
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h (+1-1) 
- (modified) clang/include/clang/Lex/ModuleLoader.h (+1-1) 
- (modified) clang/include/clang/Lex/ModuleMap.h (+1-1) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+1-1) 
- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+1-1) 
- (modified) clang/include/clang/Serialization/ModuleFile.h (+1-1) 
- (modified) clang/include/clang/Serialization/ModuleManager.h (+1-1) 
- (modified) clang/include/clang/Serialization/PCHContainerOperations.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 
- (modified) clang/lib/AST/ASTDumper.cpp (+1-1) 
- (modified) clang/lib/AST/Decl.cpp (+1-1) 
- (modified) clang/lib/AST/DeclBase.cpp (+1-1) 
- (modified) clang/lib/AST/DeclPrinter.cpp (+1-1) 
- (modified) clang/lib/AST/ExternalASTSource.cpp (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/ODRDiagsEmitter.cpp (+1-1) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+1-1) 
- (modified) clang/lib/Basic/CMakeLists.txt (+7-6) 
- (modified) clang/lib/Basic/Module.cpp (+1-16) 
- (added) clang/lib/Basic/Module/ASTSourceDescriptor.cpp (+33) 
- (added) clang/lib/Basic/Module/Module.cpp (+726) 
- (modified) clang/lib/CodeGen/CGDebugInfo.h (+2-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+1-1) 
- (modified) clang/lib/ExtractAPI/API.cpp (+1-1) 
- (modified) clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp (+1-1) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+1-1) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+1-1) 
- (modified) clang/lib/Lex/HeaderSearch.cpp (+1-1) 
- (modified) clang/lib/Lex/ModuleMap.cpp (+1-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+1-1) 
- (modified) clang/lib/Lex/Pragma.cpp (+1-1) 
- (modified) clang/lib/Lex/Preprocessor.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+2-1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) 
libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp (+1-1) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h (+7-1) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp 
(+1) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h 
(+7-1) 


``diff
diff --git a/.github/new-prs-labeler.yml b/.github/new-prs-labeler.yml
index a57ba28faf160..41325b2ff2e24 100644
--- a/.github/new-prs-labeler.yml
+++ b/.github/new-prs-labeler.yml
@@ -345,7 +345,7 @@ clang:modules:
   - clang/include/clang/AST/PropertiesBase.td
   - clang/include/clang/AST/ODRHash.h
   - clang/include/clang/AST/TypeProperties.td
-  - clang/include/clang/Basic/Module.h
+  - clang/include/clang/Basic/Module/**
   - clang/include/clang/Frontend/PrecompiledPreamble.h
   - clang/include/clang/Lex/ModuleLoader.h
   - clang/include/clang/Lex/ModuleMap.h
diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
index 147d9abe69137..c650f9b8440c2 100644
--- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
@@ -25,7 +25,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
+#include "clang/Basic/Module/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
diff --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst
index 06294e3c58a4f..79c87250ad0d5 100644
--- a/clang/docs/Modules.rst
+++ b/clang/docs/Modules.rst
@@ -1126,7 +1126,7 @@ The Clang source code provides additional information 
about modules:
 ``clang/test/Modules/``
   Tests specifically related to modules functionality.
 
-``clang/include/clang/Basic/Module.h``
+``clang/include/clang/Basic/Module/Module.h``
   The ``Module`` class in this header describes a module, and is used 

[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via lldb-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/93388

Depends on https://github.com/llvm/llvm-project/pull/67930

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/2] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module );
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module );
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"

[Lldb-commits] [clang] [lldb] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2024-05-25 Thread David Stone via lldb-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67930

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH] [clang][Modules] Move `ASTSourceDescriptor` into its own file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module );
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module );
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include 

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-25 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-25 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,27 @@
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+  return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+
+def __getitem__(self, idx):
+  '''Get the address range at a given index in an lldb.SBAddressRangeList 
object.'''
+  if type(idx) == int:
+if idx >= self.GetSize():

clayborg wrote:

`idx` can be negative. If we want to support the typical python indexing 
negative numbers start at the end, so `-1` is the last entry, `-2` is the 
second to last entry as well. So either check if `idx >= 0` or add support for 
negative indexes.

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-25 Thread Greg Clayton via lldb-commits

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

On nit in the getitem python, but looks good! Thanks for all of the changes.

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-05-25 Thread Michael Kruse via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Revise IDE folder structure (PR #89748)

2024-05-25 Thread Michael Kruse via lldb-commits

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


[Lldb-commits] [lldb] c3efb57 - [lldb] Revise IDE folder structure (#89748)

2024-05-25 Thread via lldb-commits

Author: Michael Kruse
Date: 2024-05-25T17:29:18+02:00
New Revision: c3efb57655001896fac955f4d42657db42c836b0

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

LOG: [lldb] Revise IDE folder structure (#89748)

Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET  PROPERTY FOLDER "")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.

Added: 


Modified: 
lldb/CMakeLists.txt
lldb/cmake/modules/AddLLDB.cmake
lldb/cmake/modules/LLDBConfig.cmake
lldb/cmake/modules/LLDBFramework.cmake
lldb/cmake/modules/LLDBStandalone.cmake
lldb/docs/CMakeLists.txt
lldb/source/API/CMakeLists.txt
lldb/test/API/CMakeLists.txt
lldb/test/CMakeLists.txt
lldb/test/Shell/CMakeLists.txt
lldb/test/Unit/CMakeLists.txt
lldb/tools/driver/CMakeLists.txt
lldb/tools/lldb-fuzzer/lldb-commandinterpreter-fuzzer/CMakeLists.txt
lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt
lldb/tools/lldb-server/CMakeLists.txt
lldb/unittests/CMakeLists.txt
lldb/unittests/tools/lldb-server/CMakeLists.txt
lldb/utils/TableGen/CMakeLists.txt
lldb/utils/lit-cpuid/CMakeLists.txt
lldb/utils/lldb-dotest/CMakeLists.txt
lldb/utils/lldb-repro/CMakeLists.txt

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index b0764f1053277..59cdc4593463c 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "LLDB")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)

diff  --git a/lldb/cmake/modules/AddLLDB.cmake 
b/lldb/cmake/modules/AddLLDB.cmake
index fdc4ee0c05d75..538029037dd46 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -29,7 +29,6 @@ function(lldb_tablegen)
 
   if(LTG_TARGET)
 add_public_tablegen_target(${LTG_TARGET})
-set_target_properties( ${LTG_TARGET} PROPERTIES FOLDER "LLDB tablegenning")
 set_property(GLOBAL APPEND PROPERTY LLDB_TABLEGEN_TARGETS ${LTG_TARGET})
   endif()
 endfunction(lldb_tablegen)
@@ -165,10 +164,10 @@ function(add_lldb_library name)
 get_property(parent_dir DIRECTORY PROPERTY PARENT_DIRECTORY)
 if(EXISTS ${parent_dir})
   get_filename_component(category ${parent_dir} NAME)
-  set_target_properties(${name} PROPERTIES FOLDER "lldb 
plugins/${category}")
+  set_target_properties(${name} PROPERTIES FOLDER 
"LLDB/Plugins/${category}")
 endif()
   else()
-set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
+set_target_properties(${name} PROPERTIES FOLDER "LLDB/Libraries")
   endif()
 
   # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
@@ -208,7 +207,6 @@ function(add_lldb_executable name)
   else()
 target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})
   endif()
-  set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if (ARG_BUILD_RPATH)
 set_target_properties(${name} PROPERTIES BUILD_RPATH "${ARG_BUILD_RPATH}")

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 6458f2e174643..f2afced7403bd 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -266,7 +266,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 )
 
   add_custom_target(lldb-headers)
-  set_target_properties(lldb-headers PROPERTIES FOLDER "lldb misc")
+  set_target_properties(lldb-headers PROPERTIES FOLDER "LLDB/Resources")
 
   if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-lldb-headers

diff  --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index dd8c36bba0e97..471aeaaad3c0d 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -106,7 +106,7 @@ endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
-set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")

[Lldb-commits] [lldb] [llvm] [lldb] Revise IDE folder structure (PR #89748)

2024-05-25 Thread Michael Kruse via lldb-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/89748

>From 6f39beb9ee58d7c377dce6ba8ce69e71da5b8e09 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 12:55:15 +0200
Subject: [PATCH 1/7] [llvm] Revise IDE folder structure

---
 llvm/CMakeLists.txt   | 12 ++-
 llvm/cmake/modules/AddLLVM.cmake  | 83 ++-
 llvm/cmake/modules/AddOCaml.cmake |  5 +-
 llvm/cmake/modules/AddSphinxTarget.cmake  |  3 +
 llvm/cmake/modules/CrossCompile.cmake |  4 +
 .../modules/LLVMDistributionSupport.cmake |  8 ++
 .../modules/LLVMExternalProjectUtils.cmake| 25 +-
 llvm/cmake/modules/TableGen.cmake |  7 +-
 llvm/docs/CMakeLists.txt  |  1 +
 llvm/examples/Kaleidoscope/CMakeLists.txt |  2 +-
 llvm/include/llvm/Support/CMakeLists.txt  |  2 +-
 llvm/lib/Support/BLAKE3/CMakeLists.txt|  1 +
 llvm/runtimes/CMakeLists.txt  | 23 +
 llvm/test/CMakeLists.txt  |  6 +-
 llvm/tools/opt-viewer/CMakeLists.txt  |  1 +
 .../InlineAdvisorPlugin/CMakeLists.txt|  3 +-
 .../Analysis/InlineOrderPlugin/CMakeLists.txt |  2 +-
 llvm/unittests/CMakeLists.txt |  2 +-
 llvm/unittests/DebugInfo/BTF/CMakeLists.txt   |  2 -
 .../DebugInfo/CodeView/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/DWARF/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/GSYM/CMakeLists.txt  |  2 -
 llvm/unittests/DebugInfo/MSF/CMakeLists.txt   |  2 -
 llvm/unittests/DebugInfo/PDB/CMakeLists.txt   |  2 -
 llvm/unittests/ExecutionEngine/CMakeLists.txt |  2 -
 .../ExecutionEngine/JITLink/CMakeLists.txt|  2 -
 .../ExecutionEngine/MCJIT/CMakeLists.txt  |  2 -
 .../ExecutionEngine/Orc/CMakeLists.txt|  2 -
 .../Support/CommandLineInit/CMakeLists.txt|  4 -
 .../Support/DynamicLibrary/CMakeLists.txt |  4 +-
 llvm/unittests/Target/AArch64/CMakeLists.txt  |  2 -
 llvm/unittests/Target/AMDGPU/CMakeLists.txt   |  2 -
 llvm/unittests/Target/ARM/CMakeLists.txt  |  2 -
 llvm/unittests/Target/CMakeLists.txt  |  3 -
 .../unittests/Target/LoongArch/CMakeLists.txt |  2 -
 llvm/unittests/Target/PowerPC/CMakeLists.txt  |  2 -
 llvm/unittests/Target/RISCV/CMakeLists.txt|  2 -
 .../Target/WebAssembly/CMakeLists.txt |  2 -
 llvm/unittests/Target/X86/CMakeLists.txt  |  2 -
 .../Transforms/Coroutines/CMakeLists.txt  |  2 -
 llvm/unittests/Transforms/IPO/CMakeLists.txt  |  2 -
 .../Transforms/Scalar/CMakeLists.txt  |  2 -
 .../unittests/Transforms/Utils/CMakeLists.txt |  2 -
 .../Transforms/Vectorize/CMakeLists.txt   |  2 -
 .../tools/llvm-cfi-verify/CMakeLists.txt  |  2 -
 .../tools/llvm-exegesis/CMakeLists.txt|  2 -
 llvm/unittests/tools/llvm-mca/CMakeLists.txt  |  2 -
 .../tools/llvm-profdata/CMakeLists.txt|  2 -
 .../tools/llvm-profgen/CMakeLists.txt |  2 -
 llvm/utils/LLVMVisualizers/CMakeLists.txt |  2 +-
 llvm/utils/TableGen/Basic/CMakeLists.txt  |  1 -
 llvm/utils/TableGen/CMakeLists.txt|  2 -
 llvm/utils/TableGen/Common/CMakeLists.txt |  1 -
 llvm/utils/lit/CMakeLists.txt |  4 +-
 llvm/utils/llvm-locstats/CMakeLists.txt   |  2 +-
 llvm/utils/mlgo-utils/CMakeLists.txt  |  2 +-
 56 files changed, 159 insertions(+), 112 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 43181af3bc195..48a6ab7d21f48 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1124,7 +1124,7 @@ configure_file(
 add_custom_target(srpm
   COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B 
${LLVM_SRPM_DIR}/SOURCES
   COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' 
${LLVM_SRPM_BINARY_SPECFILE})
-set_target_properties(srpm PROPERTIES FOLDER "Misc")
+set_target_properties(srpm PROPERTIES FOLDER "LLVM/Misc")
 
 if(APPLE AND DARWIN_LTO_LIBRARY)
   set(CMAKE_EXE_LINKER_FLAGS
@@ -1222,7 +1222,9 @@ if( LLVM_INCLUDE_UTILS )
   add_subdirectory(utils/split-file)
   add_subdirectory(utils/mlgo-utils)
   if( LLVM_INCLUDE_TESTS )
+set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest 
${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+set(LLVM_SUBPROJECT_TITLE) 
   endif()
 else()
   if ( LLVM_INCLUDE_TESTS )
@@ -1286,7 +1288,7 @@ if( LLVM_INCLUDE_TESTS )
   if(LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS)
 add_dependencies(test-depends ${LLVM_ALL_LIT_DEPENDS} 
${LLVM_ALL_ADDITIONAL_TEST_DEPENDS})
   endif()
-  set_target_properties(test-depends PROPERTIES FOLDER "Tests")
+  set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests")
   add_dependencies(check-all test-depends)
 endif()
 
@@ -1343,7 +1345,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   # Installing the headers needs to depend on generating any public
   # tablegen'd headers.
   add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
-  

[Lldb-commits] [lldb] [llvm] [lldb] Revise IDE folder structure (PR #89748)

2024-05-25 Thread Michael Kruse via lldb-commits

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


[Lldb-commits] [lldb] 9da81ce - lldb unused var fix for NetBSD < 10. (#93377)

2024-05-25 Thread via lldb-commits

Author: David CARLIER
Date: 2024-05-25T15:49:42+01:00
New Revision: 9da81cee219da78ab44357310a3bcf481bdba26c

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

LOG: lldb unused var fix for NetBSD < 10. (#93377)

Added: 


Modified: 
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index f561c21b9d91c..77b4301ea22e5 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -180,8 +180,6 @@ void NativeThreadNetBSD::SetStepping() {
 }
 
 std::string NativeThreadNetBSD::GetName() {
-  Log *log = GetLog(POSIXLog::Thread);
-
 #ifdef PT_LWPSTATUS
   struct ptrace_lwpstatus info = {};
   info.pl_lwpid = m_tid;
@@ -193,6 +191,8 @@ std::string NativeThreadNetBSD::GetName() {
   return info.pl_name;
 #else
   std::vector infos;
+  Log *log = GetLog(POSIXLog::Thread);
+
   int mib[5] = {CTL_KERN, KERN_LWP, static_cast(m_process.GetID()),
 sizeof(struct kinfo_lwp), 0};
   size_t size;



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


[Lldb-commits] [lldb] lldb unused var fix for NetBSD < 10. (PR #93377)

2024-05-25 Thread David CARLIER via lldb-commits

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


[Lldb-commits] [lldb] lldb unused var fix for NetBSD < 10. (PR #93377)

2024-05-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David CARLIER (devnexen)


Changes



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


1 Files Affected:

- (modified) lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp (+2-2) 


``diff
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index f561c21b9d91c..77b4301ea22e5 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -180,8 +180,6 @@ void NativeThreadNetBSD::SetStepping() {
 }
 
 std::string NativeThreadNetBSD::GetName() {
-  Log *log = GetLog(POSIXLog::Thread);
-
 #ifdef PT_LWPSTATUS
   struct ptrace_lwpstatus info = {};
   info.pl_lwpid = m_tid;
@@ -193,6 +191,8 @@ std::string NativeThreadNetBSD::GetName() {
   return info.pl_name;
 #else
   std::vector infos;
+  Log *log = GetLog(POSIXLog::Thread);
+
   int mib[5] = {CTL_KERN, KERN_LWP, static_cast(m_process.GetID()),
 sizeof(struct kinfo_lwp), 0};
   size_t size;

``




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


[Lldb-commits] [lldb] lldb unused var fix for NetBSD < 10. (PR #93377)

2024-05-25 Thread David CARLIER via lldb-commits

https://github.com/devnexen created 
https://github.com/llvm/llvm-project/pull/93377

None

>From 9dcd8be919582006b5ade0b6c1f3074678f50bed Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Sat, 25 May 2024 10:59:54 +
Subject: [PATCH] lldb unused var fix for NetBSD < 10.

---
 lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index f561c21b9d91c..77b4301ea22e5 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -180,8 +180,6 @@ void NativeThreadNetBSD::SetStepping() {
 }
 
 std::string NativeThreadNetBSD::GetName() {
-  Log *log = GetLog(POSIXLog::Thread);
-
 #ifdef PT_LWPSTATUS
   struct ptrace_lwpstatus info = {};
   info.pl_lwpid = m_tid;
@@ -193,6 +191,8 @@ std::string NativeThreadNetBSD::GetName() {
   return info.pl_name;
 #else
   std::vector infos;
+  Log *log = GetLog(POSIXLog::Thread);
+
   int mib[5] = {CTL_KERN, KERN_LWP, static_cast(m_process.GetID()),
 sizeof(struct kinfo_lwp), 0};
   size_t size;

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


[Lldb-commits] [flang] [lldb] [llvm] [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (PR #93260)

2024-05-25 Thread Stephan T. Lavavej via lldb-commits

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


[Lldb-commits] [lldb] 25f4ead - [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (#93260)

2024-05-25 Thread via lldb-commits

Author: Stephan T. Lavavej
Date: 2024-05-24T23:57:12-07:00
New Revision: 25f4ead96618dd5d54072689d2f399b8189b574f

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

LOG: [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (#93260)

Added: 


Modified: 
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
lldb/include/lldb/Target/Process.h
llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
llvm/test/Transforms/Coroutines/no-suspend.ll

Removed: 




diff  --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp 
b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 11196353b07c7..218b38e9ba79d 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -1115,7 +1115,7 @@ mlir::LogicalResult
 hlfir::MatmulOp::canonicalize(MatmulOp matmulOp,
   mlir::PatternRewriter ) {
   // the only two uses of the transposed matrix should be for the hlfir.matmul
-  // and hlfir.destory
+  // and hlfir.destroy
   auto isOtherwiseUnused = [&](hlfir::TransposeOp transposeOp) -> bool {
 std::size_t numUses = 0;
 for (mlir::Operation *user : transposeOp.getResult().getUsers()) {

diff  --git a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp 
b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
index 06d0518763848..6c8e3e1193747 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
@@ -32,7 +32,7 @@ namespace hlfir {
 } // namespace hlfir
 
 /// If the elemental has only two uses and those two are an apply operation and
-/// a destory operation, return those two, otherwise return {}
+/// a destroy operation, return those two, otherwise return {}
 static std::optional>
 getTwoUses(hlfir::ElementalOp elemental) {
   mlir::Operation::user_range users = elemental->getUsers();

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index aac0cf51680a9..637d34c29715c 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -915,8 +915,8 @@ class Process : public 
std::enable_shared_from_this,
   /// \param[in] force_kill
   /// Whether lldb should force a kill (instead of a detach) from
   /// the inferior process.  Normally if lldb launched a binary and
-  /// Destory is called, lldb kills it.  If lldb attached to a
-  /// running process and Destory is called, lldb detaches.  If
+  /// Destroy is called, lldb kills it.  If lldb attached to a
+  /// running process and Destroy is called, lldb detaches.  If
   /// this behavior needs to be over-ridden, this is the bool that
   /// can be used.
   ///

diff  --git 
a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp 
b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
index 4da031716e32a..3cdffb8cd0615 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
@@ -75,7 +75,7 @@ Error 
SimpleExecutorMemoryManager::finalize(tpctypes::FinalizeRequest ) {
   auto BailOut = [&](Error Err) {
 std::pair AllocToDestroy;
 
-// Get allocation to destory.
+// Get allocation to destroy.
 {
   std::lock_guard Lock(M);
   auto I = Allocations.find(Base.toPtr());
@@ -153,7 +153,7 @@ Error SimpleExecutorMemoryManager::deallocate(
   std::vector> AllocPairs;
   AllocPairs.reserve(Bases.size());
 
-  // Get allocation to destory.
+  // Get allocation to destroy.
   Error Err = Error::success();
   {
 std::lock_guard Lock(M);

diff  --git a/llvm/test/Transforms/Coroutines/no-suspend.ll 
b/llvm/test/Transforms/Coroutines/no-suspend.ll
index 53eb98f1273a9..fd8c5ac990958 100644
--- a/llvm/test/Transforms/Coroutines/no-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/no-suspend.ll
@@ -325,7 +325,7 @@ body:
   %save = call token @llvm.coro.save(ptr %hdl)
   %subfn = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
   call fastcc void %subfn(ptr %hdl)
-  ; memcpy separates destory from suspend, therefore cannot simplify.
+  ; memcpy separates destroy from suspend, therefore cannot simplify.
   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false)
   %0 = call i8 @llvm.coro.suspend(token %save, i1 false)
   switch i8 %0, label %suspend [i8 0, label %resume



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


[Lldb-commits] [lldb] [lldb] Allow specific 'make' tool for LLDB testsuite. (PR #93367)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladimir Vereschaka (vvereschaka)


Changes

Because the 'make' tool is required to run the lldb testsuite a detection of 
this program was added to the CMake script. If 'make' tool is missed on the 
host CMake raises a fatal error now.

It is possible to provide a full path to the 'make' tool via 'Make_EXECUTABLE' 
CMake variable through the command line:

```
  cmake -DMake_EXECUTABLE=c:\path\to\make.exe ...
```

The found tool gets passed into the lldb testsuite scripts using a newly added 
argument --make. This option also can be used directly via LLDB_TEST_USER_ARGS 
CMake configuraion parameter:

```
  cmake ...
-DLLDB_TEST_USER_ARGS="...;--make;C:\\Path\\to\\make.exe;..."
...
```

These options are useful on the Windows build hosts.

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


11 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/builders/builder.py (+3-1) 
- (modified) lldb/packages/Python/lldbsuite/test/configuration.py (+1) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+2) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest_args.py (+6) 
- (modified) lldb/test/API/lit.cfg.py (+3) 
- (modified) lldb/test/API/lit.site.cfg.py.in (+1) 
- (modified) lldb/test/CMakeLists.txt (+10) 
- (modified) lldb/test/Shell/lit.site.cfg.py.in (+1) 
- (modified) lldb/test/Unit/lit.site.cfg.py.in (+1) 
- (modified) lldb/test/lit.site.cfg.py.in (+1) 
- (modified) lldb/utils/lldb-dotest/lldb-dotest.in (+3) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 21ea3530e24fc..178ce8bc3c490 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -40,7 +40,9 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+if configuration.make_path is not None:
+make = configuration.make_path
+elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index dbd4a2d72a15d..27eef040497d1 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -43,6 +43,7 @@
 compiler = None
 dsymutil = None
 sdkroot = None
+make_path = None
 
 # The overriden dwarf verison.
 dwarf_version = 0
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2e537e3fd3ce0..42b39bc6e2f7b 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -266,6 +266,8 @@ def parseOptionsAndInitTestdirs():
 configuration.compiler = candidate
 break
 
+if args.make:
+configuration.make_path = args.make
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
 elif platform_system == "Darwin":
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 8b00c7a4d56e7..a0a840416c567 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -87,6 +87,12 @@ def create_parser():
 ),
 )
 
+group.add_argument(
+"--make",
+metavar="make",
+dest="make",
+help=textwrap.dedent("Specify which make to use."),
+)
 group.add_argument(
 "--dsymutil",
 metavar="dsymutil",
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index d934349fe3ca3..ce8ae0c3b2341 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -227,6 +227,9 @@ def delete_module_cache(path):
 if is_configured("lldb_executable"):
 dotest_cmd += ["--executable", config.lldb_executable]
 
+if is_configured("make_executable"):
+dotest_cmd += ["--make", config.make_executable]
+
 if is_configured("test_compiler"):
 dotest_cmd += ["--compiler", config.test_compiler]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2..d4cadd5440a8a 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -21,6 +21,7 @@ config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.lua_executable = "@Lua_EXECUTABLE@"
+config.make_executable = "@Make_EXECUTABLE@"
 config.lua_test_entry = "TestLuaAPI.py"
 config.dotest_common_args_str 

[Lldb-commits] [lldb] [lldb] Allow specific 'make' tool for LLDB testsuite. (PR #93367)

2024-05-24 Thread Vladimir Vereschaka via lldb-commits

https://github.com/vvereschaka created 
https://github.com/llvm/llvm-project/pull/93367

Because the 'make' tool is required to run the lldb testsuite a detection of 
this program was added to the CMake script. If 'make' tool is missed on the 
host CMake raises a fatal error now.

It is possible to provide a full path to the 'make' tool via 'Make_EXECUTABLE' 
CMake variable through the command line:

```
  cmake -DMake_EXECUTABLE=c:\path\to\make.exe ...
```

The found tool gets passed into the lldb testsuite scripts using a newly added 
argument --make. This option also can be used directly via LLDB_TEST_USER_ARGS 
CMake configuraion parameter:

```
  cmake ...
-DLLDB_TEST_USER_ARGS="...;--make;C:\\Path\\to\\make.exe;..."
...
```

These options are useful on the Windows build hosts.

>From 427d6d5a7ce14204ea09ba12934e93b9cefc9d63 Mon Sep 17 00:00:00 2001
From: Vladimir Vereschaka 
Date: Fri, 24 May 2024 21:01:45 -0700
Subject: [PATCH] [lldb] Allow specific 'make' tool for LLDB testsuite.

Because the 'make' tool is required to run the lldb testsuite a detection of 
this
program was added to the CMake script. If 'make' tool is missed on the host
CMake raises a fatal error now.

It is possible to provide a full path to the 'make' tool via 'Make_EXECUTABLE'
CMake variable through the command line:

```
  cmake -DMake_EXECUTABLE=c:\path\to\make.exe ...
```

The found tool gets passed into the lldb testsuite scripts using a newly added
argument --make. This option also can be used directly via LLDB_TEST_USER_ARGS
CMake configuraion parameter:

```
  cmake ...
-DLLDB_TEST_USER_ARGS="...;--make;C:\\Path\\to\\make.exe;..."
...
```

These options are useful on the Windows build hosts.
---
 .../packages/Python/lldbsuite/test/builders/builder.py |  4 +++-
 lldb/packages/Python/lldbsuite/test/configuration.py   |  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py  |  2 ++
 lldb/packages/Python/lldbsuite/test/dotest_args.py |  6 ++
 lldb/test/API/lit.cfg.py   |  3 +++
 lldb/test/API/lit.site.cfg.py.in   |  1 +
 lldb/test/CMakeLists.txt   | 10 ++
 lldb/test/Shell/lit.site.cfg.py.in |  1 +
 lldb/test/Unit/lit.site.cfg.py.in  |  1 +
 lldb/test/lit.site.cfg.py.in   |  1 +
 lldb/utils/lldb-dotest/lldb-dotest.in  |  3 +++
 11 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 21ea3530e24fc..178ce8bc3c490 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -40,7 +40,9 @@ def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
 The first argument is a tuple of the relative path to the testcase
 and its filename stem."""
-if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
+if configuration.make_path is not None:
+make = configuration.make_path
+elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index dbd4a2d72a15d..27eef040497d1 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -43,6 +43,7 @@
 compiler = None
 dsymutil = None
 sdkroot = None
+make_path = None
 
 # The overriden dwarf verison.
 dwarf_version = 0
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2e537e3fd3ce0..42b39bc6e2f7b 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -266,6 +266,8 @@ def parseOptionsAndInitTestdirs():
 configuration.compiler = candidate
 break
 
+if args.make:
+configuration.make_path = args.make
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
 elif platform_system == "Darwin":
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 8b00c7a4d56e7..a0a840416c567 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -87,6 +87,12 @@ def create_parser():
 ),
 )
 
+group.add_argument(
+"--make",
+metavar="make",
+dest="make",
+help=textwrap.dedent("Specify which make to use."),
+)
 group.add_argument(
 "--dsymutil",
 metavar="dsymutil",
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index d934349fe3ca3..ce8ae0c3b2341 100644
--- 

[Lldb-commits] [lldb] [lldb][tests] Transfer some environment variables into API tests on Windows platform. (PR #93366)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladimir Vereschaka (vvereschaka)


Changes

These environment variables avoid some side effects during execution of the 
remote API tests on Windows platform.

One of the side effect is a creating of weird folders, such as 
`test-root-dir\%SystemDrive%\...`, within the test directory.

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


1 Files Affected:

- (modified) lldb/test/API/lit.cfg.py (+19) 


``diff
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index d934349fe3ca3..7d38ee0ec098c 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -313,3 +313,22 @@ def delete_module_cache(path):
 # Propagate XDG_CACHE_HOME
 if "XDG_CACHE_HOME" in os.environ:
 config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
+
+# Transfer some environment variables into the tests on Windows build host.
+if platform.system() == "Windows":
+for v in [
+"SystemDrive",
+"SystemRoot",
+"ALLUSERSPROFILE",
+"APPDATA",
+"LOCALAPPDATA",
+"USERDNSDOMAIN",
+"USERDOMAIN",
+"USERNAME",
+"USERPROFILE",
+"USERDOMAIN_ROAMINGPROFILE",
+"COMPUTERNAME",
+"ProgramData",
+]:
+if v in os.environ:
+config.environment[v] = os.environ[v]

``




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


[Lldb-commits] [lldb] [lldb][tests] Transfer some environment variables into API tests on Windows platform. (PR #93366)

2024-05-24 Thread Vladimir Vereschaka via lldb-commits

https://github.com/vvereschaka created 
https://github.com/llvm/llvm-project/pull/93366

These environment variables avoid some side effects during execution of the 
remote API tests on Windows platform.

One of the side effect is a creating of weird folders, such as 
`\%SystemDrive%\...`, within the test directory.

>From 5f79f5fbf6679da020266d655ced91389215d851 Mon Sep 17 00:00:00 2001
From: Vladimir Vereschaka 
Date: Fri, 24 May 2024 20:19:54 -0700
Subject: [PATCH] [lldb][tests] Transfer some environment variables into API
 tests on Windows platform.

These environment variables avoid some side effects during execution of the 
remote API tests
on Windows platform.

One of the side effect is a creating of weird folders, such as 
\%SystemDrive%\...,
within the test directory.
---
 lldb/test/API/lit.cfg.py | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index d934349fe3ca3..7d38ee0ec098c 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -313,3 +313,22 @@ def delete_module_cache(path):
 # Propagate XDG_CACHE_HOME
 if "XDG_CACHE_HOME" in os.environ:
 config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
+
+# Transfer some environment variables into the tests on Windows build host.
+if platform.system() == "Windows":
+for v in [
+"SystemDrive",
+"SystemRoot",
+"ALLUSERSPROFILE",
+"APPDATA",
+"LOCALAPPDATA",
+"USERDNSDOMAIN",
+"USERDOMAIN",
+"USERNAME",
+"USERPROFILE",
+"USERDOMAIN_ROAMINGPROFILE",
+"COMPUTERNAME",
+"ProgramData",
+]:
+if v in os.environ:
+config.environment[v] = os.environ[v]

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


[Lldb-commits] [lldb] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the Windows host (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the Windows host (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/93345

>From 8701bfc715168168ca04d86f134ef362d5e89173 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 25 May 2024 00:39:05 +0400
Subject: [PATCH] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the
 Windows host

Do not denormalize the path. This patch fixes #93092.

BTW, it would be great to be able to pass the style or triple to SBFileSpec. 
Currently it is impossible to create a posix FileSpec on the Windows host.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index b4f1b76c39dbe..588b19dac6165 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -678,8 +678,8 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 loaded_image->Clear();
 
   std::string path;
-  path = remote_file.GetPath();
-  
+  path = remote_file.GetPath(false);
+
   ThreadSP thread_sp = process->GetThreadList().GetExpressionExecutionThread();
   if (!thread_sp) {
 error.SetErrorString("dlopen error: no thread available to call dlopen.");

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),

jasonmolenda wrote:

I see in the aarch64 elf core plugin that it checks the size of the 
DataExtractor object before setting the buffer to its contents, with a "must be 
bigger than the smallest possible size", e.g. 

```
  DataExtractor mte_data = getRegset(notes, arch.GetTriple(), AARCH64_MTE_Desc);
  if (mte_data.GetByteSize() >= sizeof(uint64_t))
opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskMTE);
```

Is it possible this could be called without a floating point register context?  
I know in RISC-V nearly anything is possible :) but maybe realistically we're 
always going to have an fpr.

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Jason Molenda via lldb-commits

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

This looks good to me, I'd like to see the std::make_unique in 
`RegisterContextCorePOSIX_riscv64::Create` and a sanity check for fetching the 
fpr, but maybe that's just unnecessary I don't work with RV64 targets myself, 
if you're comfortable with it as-is, that's fine.

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the Windows host (PR #93345)

2024-05-24 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 b91b8fea8c58e9b414e291df677b12ca44197784 
76a35a6ca5302aef5033d5ae297667e416921d7d -- 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index edad606e2e..588b19dac6 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -679,7 +679,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 
   std::string path;
   path = remote_file.GetPath(false);
-  
+
   ThreadSP thread_sp = process->GetThreadList().GetExpressionExecutionThread();
   if (!thread_sp) {
 error.SetErrorString("dlopen error: no thread available to call dlopen.");

``




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


[Lldb-commits] [lldb] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the Windows host (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the Windows host (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test on the Linux AArch64 target (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/93345

>From 76a35a6ca5302aef5033d5ae297667e416921d7d Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 25 May 2024 00:39:05 +0400
Subject: [PATCH] [lldb] Fixed PlatformPOSIX::DoLoadImage() in case of the
 Windows host

Do not denormalize the path. This patch fixes #93092.

BTW, it would be great to be able to pass the style or triple to SBFileSpec. 
Currently it is impossible to create a posix FileSpec on the Windows host.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index b4f1b76c39dbe..edad606e2e105 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -678,7 +678,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 loaded_image->Clear();
 
   std::string path;
-  path = remote_file.GetPath();
+  path = remote_file.GetPath(false);
   
   ThreadSP thread_sp = process->GetThreadList().GetExpressionExecutionThread();
   if (!thread_sp) {

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(

jasonmolenda wrote:

Please make this return object a `std::make_unique` too, it will be shorter.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread via lldb-commits

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


[Lldb-commits] [lldb] ccde823 - Read and store gnu build id from loaded core file (#92492)

2024-05-24 Thread via lldb-commits

Author: GeorgeHuyubo
Date: 2024-05-24T17:54:56-04:00
New Revision: ccde823b1341503f4622b3e4d8e167cf937b5f2a

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

LOG: Read and store gnu build id from loaded core file (#92492)

As we have debuginfod as symbol locator available in lldb now, we want
to make full use of it.
In case of post mortem debugging, we don't always have the main
executable available.
However, the .note.gnu.build-id of the main executable(some other
modules too), should be available in the core file, as those binaries
are loaded in memory and dumped in the core file.

We try to iterate through the NT_FILE entries, read and store the gnu
build id if possible. This will be very useful as this id is the unique
key which is needed for querying the debuginfod server.

Test:
Build and run lldb. Breakpoint set to
https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp#L147
Verified after this commit, module_uuid is the correct gnu build id of
the main executable which caused the crash(first in the NT_FILE entry)

Previous PR: https://github.com/llvm/llvm-project/pull/92078 was
mistakenly merged. This PR is re-opening the commit.

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..30af9345999c4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -250,6 +250,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +261,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +275,12 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  for (NT_FILE_Entry  : m_nt_file_entries) {
+entry.uuid = FindBuidIdInCoreMemory(entry.start);
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -983,6 +993,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  std::vector elf_header_bytes;
+  elf_header_bytes.resize(elf_header_size);
+  Status error;
+  size_t byte_read =
+  ReadMemory(address, elf_header_bytes.data(), elf_header_size, error);
+  if (byte_read != elf_header_size ||
+  !elf::ELFHeader::MagicBytesMatch(elf_header_bytes.data()))
+return invalid_uuid;
+  DataExtractor elf_header_data(elf_header_bytes.data(), elf_header_size,
+GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  std::vector ph_bytes;
+  ph_bytes.resize(elf_header.e_phentsize);
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize,
+   ph_bytes.data(), elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+DataExtractor program_header_data(ph_bytes.data(), elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   

[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test on the Linux AArch64 target (PR #93345)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

PlatformPOSIX::DoLoadImage() failed on the Linux AArch64 target. It is related 
to the issue #93092. Disable the TestCompletion.test_process_unload 
test for now.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+3) 


``diff
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 15aeaf8d0e897..eadb510a3df26 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -97,6 +97,9 @@ def test_process_load(self):
 self.complete_from_to("process load Makef", "process load Makefile")
 
 @skipUnlessPlatform(["linux"])
+@expectedFailureAll(
+archs=["aarch64"], 
bugnumber="github.com/llvm/llvm-project/issues/93092"
+)
 def test_process_unload(self):
 """Test the completion for "process unload " """
 # This tab completion should not work without a running process.

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test on the Linux AArch64 target (PR #93345)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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

PlatformPOSIX::DoLoadImage() failed on the Linux AArch64 target. It is related 
to the issue #93092. Disable the TestCompletion.test_process_unload test for 
now.

>From 3dcd6665052b1090cb5365732a92aef0b7fa0915 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 25 May 2024 00:39:05 +0400
Subject: [PATCH] [lldb] Fixed the TestCompletion test on the Linux AArch64
 target

PlatformPOSIX::DoLoadImage() failed on the Linux AArch64 target. It is related 
to the issue #93092. Disable the TestCompletion.test_process_unload test for 
now.
---
 lldb/test/API/functionalities/completion/TestCompletion.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 15aeaf8d0e897..eadb510a3df26 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -97,6 +97,9 @@ def test_process_load(self):
 self.complete_from_to("process load Makef", "process load Makefile")
 
 @skipUnlessPlatform(["linux"])
+@expectedFailureAll(
+archs=["aarch64"], 
bugnumber="github.com/llvm/llvm-project/issues/93092"
+)
 def test_process_unload(self):
 """Test the completion for "process unload " """
 # This tab completion should not work without a running process.

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Jonas Devlieghere via lldb-commits


@@ -61,40 +61,37 @@ DAP::DAP()
 DAP::~DAP() = default;
 
 void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
   if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus});
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus});
   }
   if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC});
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC});
   }
   if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift});
-exception_breakpoints.emplace_back(
+exception_breakpoints->emplace_back(
 {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift});
   }
-
-  bp_initted = true;
 }
 
 ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string ) {
-  assert(bp_initted);
-  for (auto  : exception_breakpoints) {
+  for (auto  : *exception_breakpoints) {

JDevlieghere wrote:

You could keep the assert:

```
assert(exception_breakpoints.has_value() && "PopulateExceptionBreakpoints must 
be called first") 
```

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Jonas Devlieghere via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (PR #90580)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] 77369a7 - [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (#90580)

2024-05-24 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-24T23:19:51+04:00
New Revision: 77369a7f1a81f7991a3df2dad1bc8e277bc7559d

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

LOG: [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (#90580)

Disable the TestDebuggerAPI test in case of the remote target and
Windows host.

Added: 


Modified: 
lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Removed: 




diff  --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py 
b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
index 29b8cfadd947b..a007a87ca93e9 100644
--- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -91,6 +91,11 @@ def get_cache_line_size():
 # Test the local property again, is it set to new_cache_line_size?
 self.assertEqual(get_cache_line_size(), new_cache_line_size)
 
+@expectedFailureAll(
+hostoslist=["windows"],
+remote=True,
+bugnumber="github.com/llvm/llvm-project/issues/92419",
+)
 def test_CreateTarget_platform(self):
 exe = self.getBuildArtifact("a.out")
 self.yaml2obj("elf.yaml", exe)



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


[Lldb-commits] [lldb] [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (PR #90580)

2024-05-24 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via lldb-commits

rafaelauler wrote:

Oh I see, thanks!

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


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Amir Ayupov via lldb-commits

aaupov wrote:

The entries for deleted basic blocks won't participate in 
`BAT::getFallthroughsInTrace` because trace boundary is looked up by output 
offsets: 
https://github.com/llvm/llvm-project/blob/098c6dfa8157681699a71fce9e3d94515e66311f/bolt/lib/Profile/BoltAddressTranslation.cpp#L529-L540

But deleted blocks will be used in `writeBATYAML` where we lookup containing 
blocks by input offsets: 
https://github.com/llvm/llvm-project/blob/098c6dfa8157681699a71fce9e3d94515e66311f/bolt/lib/Profile/DataAggregator.cpp#L2358-L2367

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


[Lldb-commits] [lldb] [lldb] Remove lldbassert in AppleObjCTypeEncodingParser (PR #93332)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

AppleObjCTypeEncodingParser::BuildObjCObjectPointerType currently contains an 
lldbassert to detect situations where we have a forward declaration without a 
definition. According to the accompanying comment, its purpose is to catch 
"weird cases" during test suite runs.

However, because this is an lldbassert, we show a scary message to our users 
who think this is a problem and report the issue to us. Unfortunately those 
reports aren't very actionable without a way to know the name of the type.

This patch changes the lldbassert to a regular assert and emits a log message 
to the types log when this happens.

rdar://127439898

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


1 Files Affected:

- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
 (+10-5) 


``diff
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index ca582cb1d5a46..4871c59faefcc 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -13,6 +13,8 @@
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/StringLexer.h"
 
 #include "clang/Basic/TargetInfo.h"
@@ -234,12 +236,15 @@ clang::QualType 
AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
 
 auto types = decl_vendor->FindTypes(ConstString(name), /*max_matches*/ 1);
 
-// The user can forward-declare something that has no definition.  The 
runtime
-// doesn't prohibit this at all. This is a rare and very weird case.  We 
keep
-// this assert in debug builds so we catch other weird cases.
-lldbassert(!types.empty());
-if (types.empty())
+if (types.empty()) {
+  // The user can forward-declare something that has no definition. The
+  // runtime doesn't prohibit this at all. This is a rare and very weird
+  // case. Assert assert in debug builds so we catch other weird cases.
+  assert(false && "forward declaration without definition");
+  LLDB_LOG(GetLog(LLDBLog::Types),
+   "forward declaration without definition: {0}", name)
   return ast_ctx.getObjCIdType();
+}
 
 return ClangUtil::GetQualType(types.front().GetPointerType());
   } else {

``




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


[Lldb-commits] [lldb] [lldb] Remove lldbassert in AppleObjCTypeEncodingParser (PR #93332)

2024-05-24 Thread Jonas Devlieghere via lldb-commits

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

AppleObjCTypeEncodingParser::BuildObjCObjectPointerType currently contains an 
lldbassert to detect situations where we have a forward declaration without a 
definition. According to the accompanying comment, its purpose is to catch 
"weird cases" during test suite runs.

However, because this is an lldbassert, we show a scary message to our users 
who think this is a problem and report the issue to us. Unfortunately those 
reports aren't very actionable without a way to know the name of the type.

This patch changes the lldbassert to a regular assert and emits a log message 
to the types log when this happens.

rdar://127439898

>From 55fb6056564f156f83b387d05f23368e06b64b19 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 24 May 2024 11:24:09 -0700
Subject: [PATCH] [lldb] Remove lldbassert in AppleObjCTypeEncodingParser

AppleObjCTypeEncodingParser::BuildObjCObjectPointerType currently
contains an lldbassert to detect situations where we have a forward
declaration without a definition. According to the accompanying comment,
its purpose is to catch "weird cases" during test suite runs.

However, because this is an lldbassert, we show a scary message to our
users who think this is a problem and report the issue to us.
Unfortunately those reports aren't very actionable without a way to know
the name of the type.

This patch changes the lldbassert to a regular assert and emits a log
message to the types log when this happens.

rdar://127439898
---
 .../AppleObjCTypeEncodingParser.cpp   | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index ca582cb1d5a46..4871c59faefcc 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -13,6 +13,8 @@
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/StringLexer.h"
 
 #include "clang/Basic/TargetInfo.h"
@@ -234,12 +236,15 @@ clang::QualType 
AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
 
 auto types = decl_vendor->FindTypes(ConstString(name), /*max_matches*/ 1);
 
-// The user can forward-declare something that has no definition.  The 
runtime
-// doesn't prohibit this at all. This is a rare and very weird case.  We 
keep
-// this assert in debug builds so we catch other weird cases.
-lldbassert(!types.empty());
-if (types.empty())
+if (types.empty()) {
+  // The user can forward-declare something that has no definition. The
+  // runtime doesn't prohibit this at all. This is a rare and very weird
+  // case. Assert assert in debug builds so we catch other weird cases.
+  assert(false && "forward declaration without definition");
+  LLDB_LOG(GetLog(LLDBLog::Types),
+   "forward declaration without definition: {0}", name)
   return ast_ctx.getObjCIdType();
+}
 
 return ClangUtil::GetQualType(types.front().GetPointerType());
   } else {

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


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via lldb-commits

rafaelauler wrote:

Thanks for the detailed explanation.

So essentially the output offset is not important because these deleted blocks 
are only useful for their input offset, which will be used in 
BoltAddressTranslation::getFallthroughsInTrace() to create traffic in this 
to-be deleted block, is that right?

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


[Lldb-commits] [clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-05-24 Thread Aaron Siddhartha Mondal via lldb-commits

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


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

2024-05-24 Thread Vladimir Vereschaka via lldb-commits

vvereschaka wrote:

Hi @Awfa,

we start getting failures for some LLDB API tests after these changes. The 
tests are running on Jetson AGX/Cortex a78 (aarch64) board with Ubuntu Linux 
22.04 on it. The failed tests get failed with the following error message:
```
AssertionError: No value is not true : Could not create a valid process for 
a.out: unable to launch a GDB server on 'jetson-agx-2198'
```
We run these tests in 8 threads. The `lldb-server` is executing on the target 
board with the following arguments:
```
./lldb-server p --log-channels 'lldb all' --listen '*:1234' --server 
--min-gdbserver-port 1236 --max-gdbserver-port 1246
```

The build host is Windows, the remote target host is Ubuntu Linux.

Affected tests:

* lldb-api :: commands/process/handle/TestProcessHandle.py
* lldb-api :: commands/target/basic/TestTargetCommand.py
* lldb-api :: 
functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
* lldb-api :: 
functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
* lldb-api :: 
functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
* lldb-api :: 
functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
* lldb-api :: functionalities/rerun/TestRerun.py
* lldb-api :: functionalities/rerun_and_expr/TestRerunAndExpr.py
* lldb-api :: functionalities/signal/raise/TestRaise.py
* lldb-api :: source-manager/TestSourceManager.py

Reverting of these changes fixes the problem.

Thanks.
Vlad.

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] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From a9714b155a116e9b1d18434c0485ea2ad35680f3 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH 1/3] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 74 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 10 +++
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..0e0937b77f4b4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -250,6 +250,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +261,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +275,14 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry  : m_nt_file_entries) {
+  entry.uuid = FindBuidIdInCoreMemory(entry.start);
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -573,7 +585,6 @@ llvm::Expected>
 ProcessElfCore::parseSegment(const DataExtractor ) {
   lldb::offset_t offset = 0;
   std::vector result;
-
   while (offset < segment.GetByteSize()) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, ))
@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);
+DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
+   GetByteOrder(), addr_size);
+auto notes_or_error = parseSegment(segment_data);
+if (!notes_or_error)
+  return invalid_uuid;
+for (const CoreNote  : *notes_or_error) {
+  if (note.info.n_namesz == 4 &&
+  note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::ArrayRef(
+  note.data.GetDataStart(), note.info.n_descsz /*byte size*/));
+  }
+}
+  }
+  return invalid_uuid;
+}
+
 uint32_t ProcessElfCore::GetNumThreadContexts() {
   if (!m_thread_data_valid)
 DoLoadCore();
diff --git 

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From a9714b155a116e9b1d18434c0485ea2ad35680f3 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH 1/3] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 74 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 10 +++
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..0e0937b77f4b4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -250,6 +250,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +261,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +275,14 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry  : m_nt_file_entries) {
+  entry.uuid = FindBuidIdInCoreMemory(entry.start);
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -573,7 +585,6 @@ llvm::Expected>
 ProcessElfCore::parseSegment(const DataExtractor ) {
   lldb::offset_t offset = 0;
   std::vector result;
-
   while (offset < segment.GetByteSize()) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, ))
@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);
+DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
+   GetByteOrder(), addr_size);
+auto notes_or_error = parseSegment(segment_data);
+if (!notes_or_error)
+  return invalid_uuid;
+for (const CoreNote  : *notes_or_error) {
+  if (note.info.n_namesz == 4 &&
+  note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::ArrayRef(
+  note.data.GetDataStart(), note.info.n_descsz /*byte size*/));
+  }
+}
+  }
+  return invalid_uuid;
+}
+
 uint32_t ProcessElfCore::GetNumThreadContexts() {
   if (!m_thread_data_valid)
 DoLoadCore();
diff --git 

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits

labath wrote:

Thanks for your patience.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -271,6 +275,14 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {

labath wrote:

No need to explicitly check for emptyness. The loop will naturally do nothing 
if the array is empty.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -573,7 +585,6 @@ llvm::Expected>
 ProcessElfCore::parseSegment(const DataExtractor ) {
   lldb::offset_t offset = 0;
   std::vector result;
-

labath wrote:

I know why this came to be, but it'd be nice to revert it so the final patch 
does not contain a spurious newline edit.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH 1/2] [lldb]Clean up breakpoint filters  - added util function
 for querying whether a language is supported by the type system  - populate
 the breakpoint filters table based on the supported language(s)

---
 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   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 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..f7d14420fba69 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 plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 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),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  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] [clang] [flang] [libcxx] [lld] [lldb] [llvm] [mlir] [openmp] [BOLT] Fix unused variable warning (PR #93253)

2024-05-24 Thread Sayhaan Siddiqui via lldb-commits
Timm =?utf-8?q?Bäder?= ,Sven van Haastregt
 ,Kiran Chandramohan 
,Vyacheslav
 Levytskyy ,Alexey Bataev
 ,Simon Pilgrim ,Simon Pilgrim
 ,Shilei Tian ,Matheus Izvekov
 ,Teresa Johnson ,Matheus Izvekov
 ,Timm =?utf-8?q?Bäder?= ,Simon
 Pilgrim ,
Timm =?utf-8?q?Bäder?= ,Daniel Paoliello
 ,Shih-Po Hung ,Jacques Pienaar
 ,Simon Pilgrim ,Brendan Dahl
 ,tyb0807 ,Daniel Grumberg
 ,Christopher Bate ,Kazu Hirata
 ,Craig Topper ,Hui
 ,Ramkumar Ramachandra ,Peter Klausler
 <35819229+klaus...@users.noreply.github.com>
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From a9714b155a116e9b1d18434c0485ea2ad35680f3 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH 1/2] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 74 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 10 +++
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..0e0937b77f4b4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -250,6 +250,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +261,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +275,14 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry  : m_nt_file_entries) {
+  entry.uuid = FindBuidIdInCoreMemory(entry.start);
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -573,7 +585,6 @@ llvm::Expected>
 ProcessElfCore::parseSegment(const DataExtractor ) {
   lldb::offset_t offset = 0;
   std::vector result;
-
   while (offset < segment.GetByteSize()) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, ))
@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);
+DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
+   GetByteOrder(), addr_size);
+auto notes_or_error = parseSegment(segment_data);
+if (!notes_or_error)
+  return invalid_uuid;
+for (const CoreNote  : *notes_or_error) {
+  if (note.info.n_namesz == 4 &&
+  note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::ArrayRef(
+  note.data.GetDataStart(), note.info.n_descsz /*byte size*/));
+  }
+}
+  }
+  return invalid_uuid;
+}
+
 uint32_t ProcessElfCore::GetNumThreadContexts() {
   if (!m_thread_data_valid)
 DoLoadCore();
diff --git 

[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-24 Thread Santhosh Kumar Ellendula via lldb-commits

https://github.com/santhoshe447 updated 
https://github.com/llvm/llvm-project/pull/91570

>From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 17 Nov 2023 15:09:10 +0530
Subject: [PATCH 1/8] [lldb][test] Add the ability to extract the variable
 value out of the summary.

---
 .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py   | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 9d79872b029a3..0cf9d4fde4948 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -195,6 +195,9 @@ def collect_console(self, duration):
 
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
+# 'value' may have the variable value and summary.
+# Extract the variable value since summary can have nonnumeric 
characters.
+value = value.split(" ")[0]
 if value.startswith("0x"):
 return int(value, 16)
 elif value.startswith("0"):

>From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 3 May 2024 02:47:05 -0700
Subject: [PATCH 2/8] [lldb-dap] Added "port" property to vscode "attach"
 command.

Adding a "port" property to the VsCode "attach" command likely extends the 
functionality of the debugger configuratiuon to allow attaching to a process 
using PID or PORT number.
Currently, the "Attach" configuration lets the user specify a pid. We tell the 
user to use the attachCommands property to run "gdb-remote ".
Followed the below conditions for "attach" command with "port" and "pid"
We should add a "port" property. If port is specified and pid is not, use that 
port to attach. If both port and pid are specified, return an error saying that 
the user can't specify both pid and port.

Ex - launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb-dap Debug",
"type": "lldb-dap",
"request": "attach",
"port":1234,
"program": "${workspaceFolder}/a.out",
"args": [],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": [],

}
]
}
---
 lldb/include/lldb/lldb-defines.h  |   1 +
 .../Python/lldbsuite/test/lldbtest.py |   9 ++
 .../test/tools/lldb-dap/dap_server.py |   6 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  20 +++
 .../attach/TestDAP_attachByPortNum.py | 120 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  36 +-
 lldb/tools/lldb-dap/package.json  |  11 ++
 7 files changed, 199 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py

diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index c7bd019c5c90e..a1e6ee2ce468c 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -96,6 +96,7 @@
 #define LLDB_INVALID_QUEUE_ID 0
 #define LLDB_INVALID_CPU_ID UINT32_MAX
 #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX
+#define LLDB_INVALID_PORT_NUMBER 0
 
 /// CPU Type definitions
 #define LLDB_ARCH_DEFAULT "systemArch"
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..fb3cd22959df2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1572,6 +1572,15 @@ def findBuiltClang(self):
 
 return os.environ["CC"]
 
+def getBuiltServerTool(self, server_tool):
+# Tries to find simulation/lldb-server/gdbserver tool at the same 
folder as the lldb.
+lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
+path = shutil.which(server_tool, path=lldb_dir)
+if path is not None:
+return path
+
+return ""
+
 def yaml2obj(self, yaml_path, obj_path, max_size=None):
 """
 Create an object file at the given path from a yaml file.
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 5838281bcb1a1..96d312565f953 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -568,6 +568,8 @@ def request_attach(
 coreFile=None,
 postRunCommands=None,
 sourceMap=None,
+port=None,
+hostname=None
 ):
 args_dict = {}
 if pid is not None:
@@ -597,6 +599,10 @@ def request_attach(
 args_dict["postRunCommands"] = 

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-24 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/92014

>From 74ddb1e1cf40a388c1d57145fed3953ee4a5eab7 Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Fri, 10 May 2024 12:42:03 -0700
Subject: [PATCH] Add AddressRange to SB API

Summary:
This adds new SB API calls and classes to allow a user of the SB API to
obtain an address range from SBFunction and SBBlock.

Test Plan:
llvm-lit -sv 
llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py

Reviewers: clayborg

Subscribers: lldb-commits

Tasks:

Tags:
---
 lldb/bindings/headers.swig|   2 +
 .../interface/SBAddressRangeDocstrings.i  |   3 +
 .../interface/SBAddressRangeExtensions.i  |  11 +
 .../interface/SBAddressRangeListDocstrings.i  |   3 +
 .../interface/SBAddressRangeListExtensions.i  |  27 ++
 lldb/bindings/interfaces.swig |   6 +
 lldb/include/lldb/API/LLDB.h  |   2 +
 lldb/include/lldb/API/SBAddress.h |   1 +
 lldb/include/lldb/API/SBAddressRange.h|  66 +
 lldb/include/lldb/API/SBAddressRangeList.h|  54 
 lldb/include/lldb/API/SBBlock.h   |   4 +
 lldb/include/lldb/API/SBDefines.h |   2 +
 lldb/include/lldb/API/SBFunction.h|   3 +
 lldb/include/lldb/API/SBStream.h  |   2 +
 lldb/include/lldb/API/SBTarget.h  |   1 +
 lldb/include/lldb/Core/AddressRange.h |  14 +
 lldb/include/lldb/Core/AddressRangeListImpl.h |  51 
 lldb/include/lldb/Symbol/Block.h  |   2 +
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/API/CMakeLists.txt|   2 +
 lldb/source/API/SBAddressRange.cpp| 103 +++
 lldb/source/API/SBAddressRangeList.cpp|  94 +++
 lldb/source/API/SBBlock.cpp   |  10 +
 lldb/source/API/SBFunction.cpp|  14 +
 lldb/source/Core/AddressRange.cpp |  43 +++
 lldb/source/Core/AddressRangeListImpl.cpp |  50 
 lldb/source/Core/CMakeLists.txt   |   1 +
 lldb/source/Symbol/Block.cpp  |  16 ++
 .../API/python_api/address_range/Makefile |   3 +
 .../address_range/TestAddressRange.py | 251 ++
 .../API/python_api/address_range/main.cpp |   8 +
 31 files changed, 852 insertions(+)
 create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i
 create mode 100644 lldb/include/lldb/API/SBAddressRange.h
 create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h
 create mode 100644 lldb/include/lldb/Core/AddressRangeListImpl.h
 create mode 100644 lldb/source/API/SBAddressRange.cpp
 create mode 100644 lldb/source/API/SBAddressRangeList.cpp
 create mode 100644 lldb/source/Core/AddressRangeListImpl.cpp
 create mode 100644 lldb/test/API/python_api/address_range/Makefile
 create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py
 create mode 100644 lldb/test/API/python_api/address_range/main.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index ffdc3c31ec883..c91504604b6ac 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -8,6 +8,8 @@
 %{
 #include "lldb/lldb-public.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeDocstrings.i
new file mode 100644
index 0..650195704d73e
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"API clients can get address range information."
+) lldb::SBAddressRange;
diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i 
b/lldb/bindings/interface/SBAddressRangeExtensions.i
new file mode 100644
index 0..31bcfcb64590b
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeExtensions.i
@@ -0,0 +1,11 @@
+%extend lldb::SBAddressRange {
+#ifdef SWIGPYTHON
+%pythoncode%{
+  def __repr__(self):
+import lldb
+stream = lldb.SBStream()
+self.GetDescription(stream, lldb.target if lldb.target else 
lldb.SBTarget())
+return stream.GetData()
+%}
+#endif
+}
diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
new file mode 100644
index 0..e4b96b9ca5931
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"Represents a list of :py:class:`SBAddressRange`."
+) lldb::SBAddressRangeList;
diff --git 

[Lldb-commits] [flang] [lldb] [llvm] [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (PR #93260)

2024-05-24 Thread Jonas Devlieghere via lldb-commits

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

Normally I'd ask splitting upcross-project PRs, but this one is trivial and 
very unlikely to be cause churn :-) LGMT. 

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Jonas Devlieghere via lldb-commits


@@ -331,6 +333,7 @@ struct DAP {
   // "Content-Length:" field followed by the length, followed by the raw
   // JSON bytes.
   void SendJSON(const std::string _str);
+  bool bp_initted;

JDevlieghere wrote:

This should be next to `exception_breakpoints`, but I wouldn't bother with the 
boolean and instead make `exception_breakpoints` a `std::optional<...>` and 
initialize it in `PopulateExceptionBreakpoints` so that the two are inherently 
tied together. 

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Jonas Devlieghere via lldb-commits


@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();

JDevlieghere wrote:

`s/plugins/languages/`

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


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

2024-05-24 Thread Pavel Labath via lldb-commits


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

labath wrote:

SG

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] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-24 Thread Pavel Labath via lldb-commits

https://github.com/labath edited 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] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-24 Thread Pavel Labath via lldb-commits

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


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] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> I would be nice if we can detect if we support Swift dynamically. Internally 
> in LLDB, we can ask for a TypeSystem by language using:
> 
> ```
> llvm::Expected
> TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
> Module *module, bool can_create);
> llvm::Expected
> TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
> Target *target, bool can_create);
> ```
> 
> These functions will return respectively:
> 
> ```
> TypeSystem::CreateInstance(language, module);
> TypeSystem::CreateInstance(language, target);
> ```
> 
> We should be able to add a new static method to the TypeSystem.h/.cpp that 
> can answer if a language is supported with something like:
> 
> ```
> static bool TypeSystem::SupportsLanguage(lldb::LanguageType language);
> ```
> 
> Each TypeSystem plugin can register a new callback that can answer if they 
> support a language. Then we can add a static function on SBDebugger that 
> would expose this function with something like:
> 
> ```
> static bool SBDebugger::SupportsLanguage(lldb::LanguageType language);
> ```
> 
> I will make comments in the DAP.cpp where this would be used.

Done!

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH] [lldb]Clean up breakpoint filters  - added util function for
 querying whether a language is supported by the type system  - populate the
 breakpoint filters table based on the supported language(s)

---
 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   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 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..f7d14420fba69 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 plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 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),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  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});
+exception_breakpoints.emplace_back(

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From 7a0af7b0b5699abe4ac5fe5415c849ffe81aa2ee Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 3 Apr 2024 16:14:40 -0400
Subject: [PATCH] [lldb][lldb-dap] Cleanup breakpoint filters.

Details:
  - remove Swift breakpoint filter because this version of LLDB does not 
support Swift.
  - only return objc filters when working on macos.
---
 lldb/tools/lldb-dap/DAP.cpp  | 4 +---
 lldb/tools/lldb-dap/lldb-dap.cpp | 7 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index b254ddfef0d5f..52e607350407a 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -36,9 +36,7 @@ DAP::DAP()
   {{"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}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
   stop_at_entry(false), is_attach(false),
   enable_auto_variable_summaries(false),
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 55f8c920e6001..5f5014eaab90f 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1628,7 +1628,14 @@ void request_initialize(const llvm::json::Object 
) {
   body.try_emplace("supportsEvaluateForHovers", true);
   // Available filters or options for the setExceptionBreakpoints request.
   llvm::json::Array filters;
+  std::string triple =
+  std::string(g_dap.debugger.GetSelectedPlatform().GetTriple());
   for (const auto _bp : g_dap.exception_breakpoints) {
+// Skipping objc breakpoint filters if not working on macos.
+if (exc_bp.language == lldb::eLanguageTypeObjC &&
+triple.find("macos") == std::string::npos) {
+  continue;
+}
 filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp));
   }
   body.try_emplace("exceptionBreakpointFilters", std::move(filters));

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Alexey Merzlyakov via lldb-commits

https://github.com/AlexeyMerzlyakov updated 
https://github.com/llvm/llvm-project/pull/93297

>From d30c3b7017bd9f4b9f442ee728d7e3d7847c60cf Mon Sep 17 00:00:00 2001
From: Alexey Merzlyakov 
Date: Fri, 24 May 2024 11:54:16 +0300
Subject: [PATCH] Add RegisterContextPOSIXCore for RISC-V 64

Fix GetRegisterSetCount() method name misprint for RegisterContextPOSIX_riscv64
---
 .../Utility/RegisterContextPOSIX_riscv64.cpp  |  2 +-
 .../Plugins/Process/elf-core/CMakeLists.txt   |  1 +
 .../RegisterContextPOSIXCore_riscv64.cpp  | 84 +++
 .../RegisterContextPOSIXCore_riscv64.h| 60 +
 .../Process/elf-core/ThreadElfCore.cpp|  8 +-
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.h

diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
index 1834a94dc0260..035ce00e11626 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
@@ -58,7 +58,7 @@ RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t 
reg) {
 }
 
 size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() {
-  return m_register_info_up->GetRegisterCount();
+  return m_register_info_up->GetRegisterSetCount();
 }
 
 const lldb_private::RegisterSet *
diff --git a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt 
b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
index 8ddc671e3ae66..72925c835b5c8 100644
--- a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN
   RegisterContextPOSIXCore_ppc64le.cpp
   RegisterContextPOSIXCore_s390x.cpp
   RegisterContextPOSIXCore_x86_64.cpp
+  RegisterContextPOSIXCore_riscv64.cpp
   RegisterUtilities.cpp
 
   LINK_LIBS
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
new file mode 100644
index 0..2202be4d38082
--- /dev/null
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = 
default;
+
+bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::WriteGPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextCorePOSIX_riscv64::WriteFPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextCorePOSIX_riscv64::ReadRegister(
+const RegisterInfo *reg_info, RegisterValue ) {
+  const uint8_t *src = nullptr;
+  lldb::offset_t offset = reg_info->byte_offset;
+
+  if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+src = m_gpr.GetDataStart();
+  } else { // IsFPR
+src = m_fpr.GetDataStart();
+offset -= GetGPRSize();
+  }
+
+  Status error;
+  

[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alexey Merzlyakov (AlexeyMerzlyakov)


Changes

The PR adds the support of CoreDump debugging for RISC-V 64. It implements new 
`RegisterContextCorePOSIX_riscv64` class.

Also, the contribution fixes `GetRegisterCount()` - `GetRegisterSetCount()` 
misprint in `RegisterContextPOSIX_riscv64::GetRegisterSetCount()` method, which 
leaded to `set  "Register set should be valid."` assertion during 
`register info aX` command call.

The patch was tested (on coredumps generated for simple Integer/FP calculation 
code) for _cross x86_64 - RISCV_ and _native RISCV_ LLDB builds. There were 
performed basic LLDB functionality tests, such as:

 - CoreDump file load
 - Backtrace / frames
 - GP/FP registers read/info/list
 - Basic switch between threads
 - Disassembler code
 - Memory regions read / display

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


5 Files Affected:

- (modified) 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/elf-core/CMakeLists.txt (+1) 
- (added) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp (+84) 
- (added) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.h (+60) 
- (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+7-1) 


``diff
diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
index 1834a94dc0260..035ce00e11626 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
@@ -58,7 +58,7 @@ RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t 
reg) {
 }
 
 size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() {
-  return m_register_info_up->GetRegisterCount();
+  return m_register_info_up->GetRegisterSetCount();
 }
 
 const lldb_private::RegisterSet *
diff --git a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt 
b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
index 8ddc671e3ae66..72925c835b5c8 100644
--- a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN
   RegisterContextPOSIXCore_ppc64le.cpp
   RegisterContextPOSIXCore_s390x.cpp
   RegisterContextPOSIXCore_x86_64.cpp
+  RegisterContextPOSIXCore_riscv64.cpp
   RegisterUtilities.cpp
 
   LINK_LIBS
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
new file mode 100644
index 0..b0fd065e7cc62
--- /dev/null
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
@@ -0,0 +1,84 @@
+//===-- RegisterContextCorePOSIX_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = 
default;
+
+bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::WriteGPR() {
+  assert(0);
+  return false;
+}
+
+bool 

[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-24 Thread Alexey Merzlyakov via lldb-commits

https://github.com/AlexeyMerzlyakov created 
https://github.com/llvm/llvm-project/pull/93297

The PR adds the support of CoreDump debugging for RISC-V 64. It implements new 
`RegisterContextCorePOSIX_riscv64` class.

Also, the contribution fixes `GetRegisterCount()` -> `GetRegisterSetCount()` 
misprint in `RegisterContextPOSIX_riscv64::GetRegisterSetCount()` method, which 
leaded to `set && "Register set should be valid."` assertion during `register 
info aX` command call.

The patch was tested (on coredumps generated for simple Integer/FP calculation 
code) for _cross x86_64 -> RISCV_ and _native RISCV_ LLDB builds. There were 
performed basic LLDB functionality tests, such as:

 - CoreDump file load
 - Backtrace / frames
 - GP/FP registers read/info/list
 - Basic switch between threads
 - Disassembler code
 - Memory regions read / display

>From 9d375865a1dcbf706e2d02283072bfd0b41db410 Mon Sep 17 00:00:00 2001
From: Alexey Merzlyakov 
Date: Fri, 24 May 2024 11:54:16 +0300
Subject: [PATCH] Add RegisterContextPOSIXCore for RISC-V 64

Fix GetRegisterSetCount() method name misprint for RegisterContextPOSIX_riscv64
---
 .../Utility/RegisterContextPOSIX_riscv64.cpp  |  2 +-
 .../Plugins/Process/elf-core/CMakeLists.txt   |  1 +
 .../RegisterContextPOSIXCore_riscv64.cpp  | 84 +++
 .../RegisterContextPOSIXCore_riscv64.h| 60 +
 .../Process/elf-core/ThreadElfCore.cpp|  8 +-
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.h

diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
index 1834a94dc0260..035ce00e11626 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
@@ -58,7 +58,7 @@ RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t 
reg) {
 }
 
 size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() {
-  return m_register_info_up->GetRegisterCount();
+  return m_register_info_up->GetRegisterSetCount();
 }
 
 const lldb_private::RegisterSet *
diff --git a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt 
b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
index 8ddc671e3ae66..72925c835b5c8 100644
--- a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN
   RegisterContextPOSIXCore_ppc64le.cpp
   RegisterContextPOSIXCore_s390x.cpp
   RegisterContextPOSIXCore_x86_64.cpp
+  RegisterContextPOSIXCore_riscv64.cpp
   RegisterUtilities.cpp
 
   LINK_LIBS
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
new file mode 100644
index 0..b0fd065e7cc62
--- /dev/null
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
@@ -0,0 +1,84 @@
+//===-- RegisterContextCorePOSIX_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+

[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -195,17 +195,17 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
 if (!ref)
   continue;
 
-DWARFUnit *cu = m_debug_info.GetUnit(*ref);
-if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
-  incomplete_types.push_back(*ref);
-  continue;
-}
-
-DWARFDIE die = m_debug_info.GetDIE(*ref);
+SymbolFileDWARF  = *llvm::cast(
+m_module.GetSymbolFile()->GetBackingSymbolFile());

labath wrote:

See #93296 for the new implementation. I'll update this PR after that lands.

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


[Lldb-commits] [lldb] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (PR #93296)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -183,27 +181,22 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
 llvm::function_ref callback) {
   // Keep a list of incomplete types as fallback for when we don't find the
   // complete type.
-  DIEArray incomplete_types;
+  std::vector incomplete_types;

labath wrote:

This can force the parsing early parsing of some units (e.g., if we run into 
many incomplete types, followed by a complete definition). I don't know how 
often this happens, but if you think that's an issue, we can fix it by storing 
the incomplete types as a (DWARFUnit *, die_offset) pair here.

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


[Lldb-commits] [lldb] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (PR #93296)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

DebugNamesDWARFIndex was jumping through hoops to construct a DIERef from an 
index entry only to jump through them back a short while later to construct a 
DWARFDIE.

This used to be necessary as the index lookup was a two stage process, where we 
first enumerated all matches, and then examined them (so it was important that 
the enumeration was cheap -- does not trigger unnecessary parsing). However, 
now that the processing is callback based, we are always immediately examening 
the DWARFDIE right after finding the entry, and the DIERef just gets in the way.

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


5 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp (+6-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (+1-6) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h (+4-5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(+25-33) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (+1-1) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 33537df4f5076..1703597a7cd2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -284,8 +284,12 @@ void AppleDWARFIndex::GetFunctions(
   for (const auto  : m_apple_names_up->equal_range(name)) {
 DIERef die_ref(std::nullopt, DIERef::Section::DebugInfo,
*entry.getDIESectionOffset());
-if (!ProcessFunctionDIE(lookup_info, die_ref, dwarf, parent_decl_ctx,
-callback))
+DWARFDIE die = dwarf.GetDIE(die_ref);
+if (!die) {
+  ReportInvalidDIERef(die_ref, name);
+  continue;
+}
+if (!ProcessFunctionDIE(lookup_info, die, parent_decl_ctx, callback))
   return;
   }
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index 20c07a94b5076..30fb5d5ebdb0d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -24,16 +24,11 @@ using namespace lldb_private::plugin::dwarf;
 DWARFIndex::~DWARFIndex() = default;
 
 bool DWARFIndex::ProcessFunctionDIE(
-const Module::LookupInfo _info, DIERef ref, SymbolFileDWARF ,
+const Module::LookupInfo _info, DWARFDIE die,
 const CompilerDeclContext _decl_ctx,
 llvm::function_ref callback) {
   llvm::StringRef name = lookup_info.GetLookupName().GetStringRef();
   FunctionNameType name_type_mask = lookup_info.GetNameTypeMask();
-  DWARFDIE die = dwarf.GetDIE(ref);
-  if (!die) {
-ReportInvalidDIERef(ref, name);
-return true;
-  }
 
   if (!(name_type_mask & eFunctionNameTypeFull)) {
 ConstString name_to_match_against;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 0551b07100a96..cb3ae8a06d788 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -81,11 +81,10 @@ class DWARFIndex {
   StatsDuration m_index_time;
 
   /// Helper function implementing common logic for processing function dies. 
If
-  /// the function given by "ref" matches search criteria given by
-  /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
-  /// vector.
-  bool ProcessFunctionDIE(const Module::LookupInfo _info, DIERef ref,
-  SymbolFileDWARF ,
+  /// the function given by "die" matches search criteria given by
+  /// "parent_decl_ctx" and "name_type_mask", it calls the callback with the
+  /// given die.
+  bool ProcessFunctionDIE(const Module::LookupInfo _info, DWARFDIE die,
   const CompilerDeclContext _decl_ctx,
   llvm::function_ref callback);
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 79400e36e04f3..90e42be7202d8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -64,27 +64,25 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const 
DebugNames::Entry ) const {
   return cu ? >GetNonSkeletonUnit() : nullptr;
 }
 
-std::optional
-DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const {
+DWARFDIE DebugNamesDWARFIndex::GetDIE(const DebugNames::Entry ) const {
   DWARFUnit *unit = GetNonSkeletonUnit(entry);
-  if (!unit)
-return std::nullopt;
-  if (std::optional die_offset = entry.getDIEUnitOffset())
-return DIERef(unit->GetSymbolFileDWARF().GetFileIndex(),
-  DIERef::Section::DebugInfo, unit->GetOffset() + *die_offset);
-
-  return std::nullopt;
+  std::optional 

[Lldb-commits] [lldb] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (PR #93296)

2024-05-24 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93296

DebugNamesDWARFIndex was jumping through hoops to construct a DIERef from an 
index entry only to jump through them back a short while later to construct a 
DWARFDIE.

This used to be necessary as the index lookup was a two stage process, where we 
first enumerated all matches, and then examined them (so it was important that 
the enumeration was cheap -- does not trigger unnecessary parsing). However, 
now that the processing is callback based, we are always immediately examening 
the DWARFDIE right after finding the entry, and the DIERef just gets in the way.

>From 2621a2c474ae18bd71b897919e75f23f9526f72b Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 24 May 2024 08:14:27 +
Subject: [PATCH] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in
 debug_names

DebugNamesDWARFIndex was jumping through hoops to construct a DIERef
from an index entry only to jump through them back a short while later
to construct a DWARFDIE.

This used to be necessary as the index lookup was a two stage process,
where we first enumerated all matches, and then examined them (so it was
important that the enumeration was cheap -- does not trigger unnecessary
parsing). However, now that the processing is callback based, we are
always immediately examening the DWARFDIE right after finding the entry,
and the DIERef just gets in the way.
---
 .../SymbolFile/DWARF/AppleDWARFIndex.cpp  |  8 ++-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  7 +--
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  9 ++-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 58 ---
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  2 +-
 5 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 33537df4f5076..1703597a7cd2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -284,8 +284,12 @@ void AppleDWARFIndex::GetFunctions(
   for (const auto  : m_apple_names_up->equal_range(name)) {
 DIERef die_ref(std::nullopt, DIERef::Section::DebugInfo,
*entry.getDIESectionOffset());
-if (!ProcessFunctionDIE(lookup_info, die_ref, dwarf, parent_decl_ctx,
-callback))
+DWARFDIE die = dwarf.GetDIE(die_ref);
+if (!die) {
+  ReportInvalidDIERef(die_ref, name);
+  continue;
+}
+if (!ProcessFunctionDIE(lookup_info, die, parent_decl_ctx, callback))
   return;
   }
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index 20c07a94b5076..30fb5d5ebdb0d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -24,16 +24,11 @@ using namespace lldb_private::plugin::dwarf;
 DWARFIndex::~DWARFIndex() = default;
 
 bool DWARFIndex::ProcessFunctionDIE(
-const Module::LookupInfo _info, DIERef ref, SymbolFileDWARF ,
+const Module::LookupInfo _info, DWARFDIE die,
 const CompilerDeclContext _decl_ctx,
 llvm::function_ref callback) {
   llvm::StringRef name = lookup_info.GetLookupName().GetStringRef();
   FunctionNameType name_type_mask = lookup_info.GetNameTypeMask();
-  DWARFDIE die = dwarf.GetDIE(ref);
-  if (!die) {
-ReportInvalidDIERef(ref, name);
-return true;
-  }
 
   if (!(name_type_mask & eFunctionNameTypeFull)) {
 ConstString name_to_match_against;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 0551b07100a96..cb3ae8a06d788 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -81,11 +81,10 @@ class DWARFIndex {
   StatsDuration m_index_time;
 
   /// Helper function implementing common logic for processing function dies. 
If
-  /// the function given by "ref" matches search criteria given by
-  /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
-  /// vector.
-  bool ProcessFunctionDIE(const Module::LookupInfo _info, DIERef ref,
-  SymbolFileDWARF ,
+  /// the function given by "die" matches search criteria given by
+  /// "parent_decl_ctx" and "name_type_mask", it calls the callback with the
+  /// given die.
+  bool ProcessFunctionDIE(const Module::LookupInfo _info, DWARFDIE die,
   const CompilerDeclContext _decl_ctx,
   llvm::function_ref callback);
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 79400e36e04f3..90e42be7202d8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

2024-05-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

After a bug (the bug is that the functions don't handle DW_AT_signature, aka 
type units) led me to one of these similar-but-different functions, I started 
to realize that most of the differences between these two functions are 
actually bugs.

As a first step towards merging them, this patch rewrites both of them to 
follow the same pattern, while preserving all of their differences. The main 
change is that GetTypeLookupContext now also uses a `seen` list to avoid 
reference loops (currently that's not necessary because the function strictly 
follows parent links, but that will change with DW_AT_signatures).

I've also optimized both functions to avoid recursion by contructing starting 
with the deepest scope first (and then reversing it).

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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (+104-93) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 4884374ef9472..03e289bbf3300 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -13,6 +13,7 @@
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
+#include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
 
@@ -379,108 +380,118 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
   return result;
 }
 
-static std::vector
-GetDeclContextImpl(llvm::SmallSet , DWARFDIE die) {
-  std::vector context;
+static void GetDeclContextImpl(DWARFDIE die,
+   llvm::SmallSet ,
+   std::vector ) {
   // Stop if we hit a cycle.
-  if (!die || !seen.insert(die.GetID()).second)
-return context;
-
-  // Handle outline member function DIEs by following the specification.
-  if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification))
-return GetDeclContextImpl(seen, spec);
-
-  // Get the parent context chain.
-  context = GetDeclContextImpl(seen, die.GetParent());
+  while (die && seen.insert(die.GetID()).second) {
+// Handle outline member function DIEs by following the specification.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification)) {
+  die = spec;
+  continue;
+}
 
-  // Add this DIE's contribution at the end of the chain.
-  auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
-context.push_back({kind, ConstString(name)});
-  };
-  switch (die.Tag()) {
-  case DW_TAG_module:
-push_ctx(CompilerContextKind::Module, die.GetName());
-break;
-  case DW_TAG_namespace:
-push_ctx(CompilerContextKind::Namespace, die.GetName());
-break;
-  case DW_TAG_structure_type:
-push_ctx(CompilerContextKind::Struct, die.GetName());
-break;
-  case DW_TAG_union_type:
-push_ctx(CompilerContextKind::Union, die.GetName());
-break;
-  case DW_TAG_class_type:
-push_ctx(CompilerContextKind::Class, die.GetName());
-break;
-  case DW_TAG_enumeration_type:
-push_ctx(CompilerContextKind::Enum, die.GetName());
-break;
-  case DW_TAG_subprogram:
-push_ctx(CompilerContextKind::Function, die.GetName());
-break;
-  case DW_TAG_variable:
-push_ctx(CompilerContextKind::Variable, die.GetPubname());
-break;
-  case DW_TAG_typedef:
-push_ctx(CompilerContextKind::Typedef, die.GetName());
-break;
-  default:
-break;
+// Add this DIE's contribution at the end of the chain.
+auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
+  context.push_back({kind, ConstString(name)});
+};
+switch (die.Tag()) {
+case DW_TAG_module:
+  push_ctx(CompilerContextKind::Module, die.GetName());
+  break;
+case DW_TAG_namespace:
+  push_ctx(CompilerContextKind::Namespace, die.GetName());
+  break;
+case DW_TAG_structure_type:
+  push_ctx(CompilerContextKind::Struct, die.GetName());
+  break;
+case DW_TAG_union_type:
+  push_ctx(CompilerContextKind::Union, die.GetName());
+  break;
+case DW_TAG_class_type:
+  push_ctx(CompilerContextKind::Class, die.GetName());
+  break;
+case DW_TAG_enumeration_type:
+  push_ctx(CompilerContextKind::Enum, die.GetName());
+  break;
+case DW_TAG_subprogram:
+  push_ctx(CompilerContextKind::Function, die.GetName());
+  break;
+case DW_TAG_variable:
+  push_ctx(CompilerContextKind::Variable, die.GetPubname());
+  break;
+case DW_TAG_typedef:
+  push_ctx(CompilerContextKind::Typedef, die.GetName());
+  break;
+default:
+  break;
+}
+// Now process the parent.
+die = die.GetParent();
   }
-  return context;
 }
 
-std::vector DWARFDIE::GetDeclContext() const {
+std::vector DWARFDIE::GetDeclContext() const {
   llvm::SmallSet seen;
-  return GetDeclContextImpl(seen, 

[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

2024-05-24 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93291

After a bug (the bug is that the functions don't handle DW_AT_signature, aka 
type units) led me to one of these similar-but-different functions, I started 
to realize that most of the differences between these two functions are 
actually bugs.

As a first step towards merging them, this patch rewrites both of them to 
follow the same pattern, while preserving all of their differences. The main 
change is that GetTypeLookupContext now also uses a `seen` list to avoid 
reference loops (currently that's not necessary because the function strictly 
follows parent links, but that will change with DW_AT_signatures).

I've also optimized both functions to avoid recursion by contructing starting 
with the deepest scope first (and then reversing it).

>From 8463c2433609216499fe5d04c3397a3113071a49 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 24 May 2024 10:17:40 +
Subject: [PATCH] [lldb/DWARF] Refactor DWARFDIE::Get{Decl,TypeLookup}Context

After a bug (the bug is that the functions don't handle DW_AT_signature,
aka type units) led me to one of these similar-but-different functions,
I started to realize that most of the differences between these two
functions are actually bugs.

As a first step towards merging them, this patch rewrites both of them
to follow the same pattern, while preserving all of their differences.
The main change is that GetTypeLookupContext now also uses a `seen` list
to avoid reference loops (currently that's not necessary because the
function strictly follows parent links, but that will change with
DW_AT_signatures).

I've also optimized both functions to avoid recursion by contructing
starting with the deepest scope first (and then reversing it).
---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 197 +-
 1 file changed, 104 insertions(+), 93 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 4884374ef9472..03e289bbf3300 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -13,6 +13,7 @@
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
+#include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
 
@@ -379,108 +380,118 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
   return result;
 }
 
-static std::vector
-GetDeclContextImpl(llvm::SmallSet , DWARFDIE die) {
-  std::vector context;
+static void GetDeclContextImpl(DWARFDIE die,
+   llvm::SmallSet ,
+   std::vector ) {
   // Stop if we hit a cycle.
-  if (!die || !seen.insert(die.GetID()).second)
-return context;
-
-  // Handle outline member function DIEs by following the specification.
-  if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification))
-return GetDeclContextImpl(seen, spec);
-
-  // Get the parent context chain.
-  context = GetDeclContextImpl(seen, die.GetParent());
+  while (die && seen.insert(die.GetID()).second) {
+// Handle outline member function DIEs by following the specification.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification)) {
+  die = spec;
+  continue;
+}
 
-  // Add this DIE's contribution at the end of the chain.
-  auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
-context.push_back({kind, ConstString(name)});
-  };
-  switch (die.Tag()) {
-  case DW_TAG_module:
-push_ctx(CompilerContextKind::Module, die.GetName());
-break;
-  case DW_TAG_namespace:
-push_ctx(CompilerContextKind::Namespace, die.GetName());
-break;
-  case DW_TAG_structure_type:
-push_ctx(CompilerContextKind::Struct, die.GetName());
-break;
-  case DW_TAG_union_type:
-push_ctx(CompilerContextKind::Union, die.GetName());
-break;
-  case DW_TAG_class_type:
-push_ctx(CompilerContextKind::Class, die.GetName());
-break;
-  case DW_TAG_enumeration_type:
-push_ctx(CompilerContextKind::Enum, die.GetName());
-break;
-  case DW_TAG_subprogram:
-push_ctx(CompilerContextKind::Function, die.GetName());
-break;
-  case DW_TAG_variable:
-push_ctx(CompilerContextKind::Variable, die.GetPubname());
-break;
-  case DW_TAG_typedef:
-push_ctx(CompilerContextKind::Typedef, die.GetName());
-break;
-  default:
-break;
+// Add this DIE's contribution at the end of the chain.
+auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
+  context.push_back({kind, ConstString(name)});
+};
+switch (die.Tag()) {
+case DW_TAG_module:
+  push_ctx(CompilerContextKind::Module, die.GetName());
+  break;
+case DW_TAG_namespace:
+  push_ctx(CompilerContextKind::Namespace, die.GetName());
+  break;
+case DW_TAG_structure_type:
+  push_ctx(CompilerContextKind::Struct, die.GetName());
+  break;
+

[Lldb-commits] [lldb] [lldb] Fixed the TestDAP_repl_mode_detection test in case of a remote target (PR #93165)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Replaced by #93169.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDAP_repl_mode_detection test in case of a remote target (PR #93165)

2024-05-24 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] 77ae18b - [lldb-dap] Send terminated event only once (#93172)

2024-05-24 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-24T09:22:42+02:00
New Revision: 77ae18b0d99e1fc29b1e9345ce824dde2436c02c

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

LOG: [lldb-dap] Send terminated event only once (#93172)

This is a regression from #91591. Turns out std::mutex does not prevent
code from running twice. :facepalm:

Added: 


Modified: 
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index bbd9d46ba3a04..a88ee3e1dec6b 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -26,6 +26,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "lldb/API/SBAttachInfo.h"
@@ -169,6 +170,7 @@ struct DAP {
   std::optional last_launch_or_attach_request;
   lldb::tid_t focus_tid;
   bool disconnecting = false;
+  llvm::once_flag terminated_event_flag;
   bool stop_at_entry;
   bool is_attach;
   bool enable_auto_variable_summaries;

diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/lldb-dap.cpp
index 170fa88f1e8b8..7746afb6cbbf3 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -227,13 +227,12 @@ void SendContinuedEvent() {
 // debugged.
 void SendTerminatedEvent() {
   // Prevent races if the process exits while we're being asked to disconnect.
-  static std::mutex mutex;
-  std::lock_guard locker(mutex);
-
-  g_dap.RunTerminateCommands();
-  // Send a "terminated" event
-  llvm::json::Object event(CreateTerminatedEventObject());
-  g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  llvm::call_once(g_dap.terminated_event_flag, [&] {
+g_dap.RunTerminateCommands();
+// Send a "terminated" event
+llvm::json::Object event(CreateTerminatedEventObject());
+g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  });
 }
 
 // Send a thread stopped event for all threads as long as the process



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


[Lldb-commits] [lldb] [lldb-dap] Send terminated event only once (PR #93172)

2024-05-24 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);

labath wrote:

This could be a static_assert, but it might even be better to do declare the 
array as something like `char buf[sizeof(Elf64_Ehdr)] and avoid any doubt about 
it being large enough (then you also wouldn't need the comment above the array 
declaration).

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

Very close. Just a couple of details.

BTW, I believe the recommended workflow for working with pull requests is to 
put your new changes as additional commits on top and then squash them all 
together after merging. The GitHub UI just works better that way.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);
+DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
+   GetByteOrder(), addr_size);
+auto notes_or_error = parseSegment(segment_data);
+if (!notes_or_error)
+  return invalid_uuid;
+for (const CoreNote  : *notes_or_error) {
+  if (note.info.n_namesz == 4 &&
+  note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::ArrayRef(
+  note.data.GetDataStart(), note.info.n_descsz /*byte size*/));

labath wrote:

In case of a corrupted core file, `note.data` can contain less than `n_descsz` 
bytes, and this will create a invalid ArrayRef (and possibly crash lldb). 
Writing this like `return UUID(note.data.GetData())` will ensure that does not 
happen, although it could return a truncated UUID in that case. If you want to 
check that case explicitly, then I'd recommend something like:
```
if(note.data.ValidOffsetForDataOfSize(0, note.info.n_descsz))
  return UUID(note.data.GetData().take_front(note.info.n_descsz);
```

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-24 Thread Pavel Labath via lldb-commits


@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, );
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, );
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);

labath wrote:

This looks like an obsolete assertion as the program headers are read into a 
dynamically sized vector now.

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


[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

2024-05-24 Thread Pavel Labath via lldb-commits

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


  1   2   3   4   5   6   7   8   9   10   >