git: a5822f2391aa - stable/12 - Reapply r327151 (partially):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 10:05:35 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=a5822f2391aa141c8c4d27f633053c87b9e6d749

commit a5822f2391aa141c8c4d27f633053c87b9e6d749
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-06 15:46:39 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-22 09:58:16 +0000

    Reapply r327151 (partially):
    
    For our lldb customizations, instead of commenting out lines, use #ifdef
    LLDB_ENABLE_ALL / #endif preprocess directives instead, so our diffs
    against upstream only consist of added lines.
    
    (Note that upstream has largely reshuffled the way optional lldb plugins
    are handled, so we need a lot less of these #ifdefs. However, not all of
    them can be dropped, unless we re-import several sources that we have
    always skipped.)
    
    (cherry picked from commit 580012d60438215d86a9e6b2a8038de964867163)
---
 .../lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp           |  6 ++++++
 contrib/llvm-project/lldb/source/Plugins/ABI/ARM/ABIARM.cpp  |  6 ++++++
 contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIX86.cpp  | 12 ++++++++++++
 .../lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp       |  7 ++++++-
 .../lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp   |  8 ++++++++
 .../source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp   |  4 ++++
 .../lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp |  4 ++++
 .../lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h   |  4 ++++
 8 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/contrib/llvm-project/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp b/contrib/llvm-project/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 5cf9fb4ad37f..8dee6b48453a 100644
--- a/contrib/llvm-project/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -7,7 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "ABIAArch64.h"
+#ifdef LLDB_ENABLE_ALL
 #include "ABIMacOSX_arm64.h"
+#endif // LLDB_ENABLE_ALL
 #include "ABISysV_arm64.h"
 #include "Utility/ARM64_DWARF_Registers.h"
 #include "lldb/Core/PluginManager.h"
@@ -16,12 +18,16 @@ LLDB_PLUGIN_DEFINE(ABIAArch64)
 
 void ABIAArch64::Initialize() {
   ABISysV_arm64::Initialize();
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_arm64::Initialize();
+#endif // LLDB_ENABLE_ALL
 }
 
 void ABIAArch64::Terminate() {
   ABISysV_arm64::Terminate();
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_arm64::Terminate();
+#endif // LLDB_ENABLE_ALL
 }
 
 std::pair<uint32_t, uint32_t>
diff --git a/contrib/llvm-project/lldb/source/Plugins/ABI/ARM/ABIARM.cpp b/contrib/llvm-project/lldb/source/Plugins/ABI/ARM/ABIARM.cpp
index 882c14d386e3..01138b449215 100644
--- a/contrib/llvm-project/lldb/source/Plugins/ABI/ARM/ABIARM.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/ABI/ARM/ABIARM.cpp
@@ -7,7 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "ABIARM.h"
+#ifdef LLDB_ENABLE_ALL
 #include "ABIMacOSX_arm.h"
+#endif // LLDB_ENABLE_ALL
 #include "ABISysV_arm.h"
 #include "lldb/Core/PluginManager.h"
 
@@ -15,10 +17,14 @@ LLDB_PLUGIN_DEFINE(ABIARM)
 
 void ABIARM::Initialize() {
   ABISysV_arm::Initialize();
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_arm::Initialize();
+#endif // LLDB_ENABLE_ALL
 }
 
 void ABIARM::Terminate() {
   ABISysV_arm::Terminate();
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_arm::Terminate();
+#endif // LLDB_ENABLE_ALL
 }
diff --git a/contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIX86.cpp b/contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index bf5ab669417e..643365f72a79 100644
--- a/contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -7,26 +7,38 @@
 //===----------------------------------------------------------------------===//
 
 #include "ABIX86.h"
+#ifdef LLDB_ENABLE_ALL
 #include "ABIMacOSX_i386.h"
+#endif // LLDB_ENABLE_ALL
 #include "ABISysV_i386.h"
 #include "ABISysV_x86_64.h"
+#ifdef LLDB_ENABLE_ALL
 #include "ABIWindows_x86_64.h"
+#endif // LLDB_ENABLE_ALL
 #include "lldb/Core/PluginManager.h"
 
 LLDB_PLUGIN_DEFINE(ABIX86)
 
 void ABIX86::Initialize() {
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_i386::Initialize();
+#endif // LLDB_ENABLE_ALL
   ABISysV_i386::Initialize();
   ABISysV_x86_64::Initialize();
+#ifdef LLDB_ENABLE_ALL
   ABIWindows_x86_64::Initialize();
+#endif // LLDB_ENABLE_ALL
 }
 
 void ABIX86::Terminate() {
+#ifdef LLDB_ENABLE_ALL
   ABIMacOSX_i386::Terminate();
+#endif // LLDB_ENABLE_ALL
   ABISysV_i386::Terminate();
   ABISysV_x86_64::Terminate();
+#ifdef LLDB_ENABLE_ALL
   ABIWindows_x86_64::Terminate();
+#endif // LLDB_ENABLE_ALL
 }
 
 uint32_t ABIX86::GetGenericNum(llvm::StringRef name) {
diff --git a/contrib/llvm-project/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/contrib/llvm-project/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index cbeef600ba9b..74d65b3caaf0 100644
--- a/contrib/llvm-project/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -7,7 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "JITLoaderGDB.h"
+#ifdef LLDB_ENABLE_ALL
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#endif // LLDB_ENABLE_ALL
 #include "lldb/Breakpoint/Breakpoint.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -338,6 +340,7 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
         module_sp->GetObjectFile()->GetSymtab();
 
         m_jit_objects.insert(std::make_pair(symbolfile_addr, module_sp));
+#ifdef LLDB_ENABLE_ALL
         if (auto image_object_file =
                 llvm::dyn_cast<ObjectFileMachO>(module_sp->GetObjectFile())) {
           const SectionList *section_list = image_object_file->GetSectionList();
@@ -349,7 +352,9 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
                                      symbolfile_size, vmaddrheuristic, lower,
                                      upper);
           }
-        } else {
+        } else
+#endif // LLDB_ENABLE_ALL
+        {
           bool changed = false;
           module_sp->SetLoadAddress(target, 0, true, changed);
         }
diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 6b5acfa4bc1b..9083ee060f07 100644
--- a/contrib/llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -20,7 +20,9 @@
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#ifdef LLDB_ENABLE_ALL
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
+#endif // LLDB_ENABLE_ALL
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
 #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
@@ -34,7 +36,9 @@
 #include "RegisterContextPOSIXCore_mips64.h"
 #include "RegisterContextPOSIXCore_powerpc.h"
 #include "RegisterContextPOSIXCore_ppc64le.h"
+#ifdef LLDB_ENABLE_ALL
 #include "RegisterContextPOSIXCore_s390x.h"
+#endif // LLDB_ENABLE_ALL
 #include "RegisterContextPOSIXCore_x86_64.h"
 #include "ThreadElfCore.h"
 
@@ -138,9 +142,11 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
       case llvm::Triple::ppc64le:
         reg_interface = new RegisterInfoPOSIX_ppc64le(arch);
         break;
+#ifdef LLDB_ENABLE_ALL
       case llvm::Triple::systemz:
         reg_interface = new RegisterContextLinux_s390x(arch);
         break;
+#endif // LLDB_ENABLE_ALL
       case llvm::Triple::x86:
         reg_interface = new RegisterContextLinux_i386(arch);
         break;
@@ -211,10 +217,12 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
       m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_ppc64le>(
           *this, reg_interface, m_gpregset_data, m_notes);
       break;
+#ifdef LLDB_ENABLE_ALL
     case llvm::Triple::systemz:
       m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_s390x>(
           *this, reg_interface, m_gpregset_data, m_notes);
       break;
+#endif // LLDB_ENABLE_ALL
     case llvm::Triple::x86:
     case llvm::Triple::x86_64:
       m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 1fed8e064267..b03184b41abb 100644
--- a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -73,7 +73,9 @@
 #include "lldb/Utility/Timer.h"
 
 #include "GDBRemoteRegisterContext.h"
+#ifdef LLDB_ENABLE_ALL
 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
+#endif // LLDB_ENABLE_ALL
 #include "Plugins/Process/Utility/GDBRemoteSignals.h"
 #include "Plugins/Process/Utility/InferiorCallPOSIX.h"
 #include "Plugins/Process/Utility/StopInfoMachException.h"
@@ -2424,6 +2426,7 @@ Status ProcessGDBRemote::DoDestroy() {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
   LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()");
 
+#ifdef LLDB_ENABLE_ALL // XXX Currently no iOS target support on FreeBSD
   // There is a bug in older iOS debugservers where they don't shut down the
   // process they are debugging properly.  If the process is sitting at a
   // breakpoint or an exception, this can cause problems with restarting.  So
@@ -2527,6 +2530,7 @@ Status ProcessGDBRemote::DoDestroy() {
       }
     }
   }
+#endif // LLDB_ENABLE_ALL
 
   // Interrupt if our inferior is running...
   int exit_status = SIGABRT;
diff --git a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index bc06ea8164d4..7491d0609e52 100644
--- a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9092,11 +9092,13 @@ DWARFASTParser *TypeSystemClang::GetDWARFParser() {
   return m_dwarf_ast_parser_up.get();
 }
 
+#ifdef LLDB_ENABLE_ALL
 PDBASTParser *TypeSystemClang::GetPDBParser() {
   if (!m_pdb_ast_parser_up)
     m_pdb_ast_parser_up = std::make_unique<PDBASTParser>(*this);
   return m_pdb_ast_parser_up.get();
 }
+#endif // LLDB_ENABLE_ALL
 
 bool TypeSystemClang::LayoutRecordType(
     const clang::RecordDecl *record_decl, uint64_t &bit_size,
@@ -9109,8 +9111,10 @@ bool TypeSystemClang::LayoutRecordType(
   lldb_private::ClangASTImporter *importer = nullptr;
   if (m_dwarf_ast_parser_up)
     importer = &m_dwarf_ast_parser_up->GetClangASTImporter();
+#ifdef LLDB_ENABLE_ALL
   if (!importer && m_pdb_ast_parser_up)
     importer = &m_pdb_ast_parser_up->GetClangASTImporter();
+#endif // LLDB_ENABLE_ALL
   if (!importer)
     return false;
 
diff --git a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 9475e4d9f442..659d48812353 100644
--- a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -465,7 +465,9 @@ public:
 
   // TypeSystem methods
   DWARFASTParser *GetDWARFParser() override;
+#ifdef LLDB_ENABLE_ALL
   PDBASTParser *GetPDBParser() override;
+#endif // LLDB_ENABLE_ALL
 
   // TypeSystemClang callbacks for external source lookups.
   void CompleteTagDecl(clang::TagDecl *);
@@ -1084,7 +1086,9 @@ private:
   std::unique_ptr<clang::HeaderSearch> m_header_search_up;
   std::unique_ptr<clang::ModuleMap> m_module_map_up;
   std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
+#ifdef LLDB_ENABLE_ALL
   std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
+#endif // LLDB_ENABLE_ALL
   std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
   uint32_t m_pointer_byte_size = 0;
   bool m_ast_owned = false;