diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt index 7308374c8bfba..77a560541fcb1 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt @@ -1,7 +1,16 @@ +lldb_tablegen(DynamicLoaderDarwinProperties.inc -gen-lldb-property-defs + SOURCE DynamicLoaderDarwinProperties.td + TARGET LLDBPluginDynamicLoaderDarwinPropertiesGen) + +lldb_tablegen(DynamicLoaderDarwinPropertiesEnum.inc -gen-lldb-property-enum-defs + SOURCE DynamicLoaderDarwinProperties.td + TARGET LLDBPluginDynamicLoaderDarwinPropertiesEnumGen) + add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN DynamicLoaderMacOSXDYLD.cpp DynamicLoaderMacOS.cpp DynamicLoaderDarwin.cpp + DynamicLoaderDarwinProperties.cpp LINK_LIBS lldbBreakpoint @@ -16,3 +25,7 @@ add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN Support TargetParser ) + +add_dependencies(lldbPluginDynamicLoaderMacOSXDYLD + LLDBPluginDynamicLoaderDarwinPropertiesGen + LLDBPluginDynamicLoaderDarwinPropertiesEnumGen) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 30242038a5f66..3659dfcd3c4ca 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -8,6 +8,7 @@ #include "DynamicLoaderDarwin.h" +#include "DynamicLoaderDarwinProperties.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -31,6 +32,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" +#include "llvm/Support/ThreadPool.h" #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" @@ -77,6 +79,17 @@ void DynamicLoaderDarwin::DidLaunch() { SetNotificationBreakpoint(); } +void DynamicLoaderDarwin::CreateSettings(lldb_private::Debugger &debugger) { + if (!PluginManager::GetSettingForDynamicLoaderPlugin( + debugger, DynamicLoaderDarwinProperties::GetSettingName())) { + const bool is_global_setting = true; + PluginManager::CreateSettingForDynamicLoaderPlugin( + debugger, + DynamicLoaderDarwinProperties::GetGlobal().GetValueProperties(), + "Properties for the DynamicLoaderDarwin plug-in.", is_global_setting); + } +} + // Clear out the state of this class. void DynamicLoaderDarwin::Clear(bool clear_process) { std::lock_guard guard(m_mutex); @@ -88,7 +101,7 @@ void DynamicLoaderDarwin::Clear(bool clear_process) { } ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo( - ImageInfo &image_info, bool can_create, bool *did_create_ptr) { + const ImageInfo &image_info, bool can_create, bool *did_create_ptr) { if (did_create_ptr) *did_create_ptr = false; @@ -517,8 +530,8 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo( return true; } -void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos( - ImageInfo::collection &image_infos) { +void DynamicLoaderDarwin::UpdateSpecialBinariesFromPreloadedModules( + std::vector> &images) { uint32_t exe_idx = UINT32_MAX; uint32_t dyld_idx = UINT32_MAX; Target &target = m_process->GetTarget(); @@ -526,35 +539,34 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos( ConstString g_dyld_sim_filename("dyld_sim"); ArchSpec target_arch = target.GetArchitecture(); - const size_t image_infos_size = image_infos.size(); - for (size_t i = 0; i < image_infos_size; i++) { - if (image_infos[i].header.filetype == llvm::MachO::MH_DYLINKER) { + const size_t images_size = images.size(); + for (size_t i = 0; i < images_size; i++) { + const auto &image_info = images[i].first; + if (image_info.header.filetype == llvm::MachO::MH_DYLINKER) { // In a "simulator" process we will have two dyld modules -- // a "dyld" that we want to keep track of, and a "dyld_sim" which // we don't need to keep track of here. dyld_sim will have a non-macosx // OS. if (target_arch.GetTriple().getEnvironment() == llvm::Triple::Simulator && - image_infos[i].os_type != llvm::Triple::OSType::MacOSX) { + image_info.os_type != llvm::Triple::OSType::MacOSX) { continue; } dyld_idx = i; } - if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) { + if (image_info.header.filetype == llvm::MachO::MH_EXECUTE) { exe_idx = i; } } // Set the target executable if we haven't found one so far. if (exe_idx != UINT32_MAX && !target.GetExecutableModule()) { - const bool can_create = true; - ModuleSP exe_module_sp(FindTargetModuleForImageInfo(image_infos[exe_idx], - can_create, nullptr)); + ModuleSP exe_module_sp = images[exe_idx].second; if (exe_module_sp) { LLDB_LOGF(log, "Found executable module: %s", exe_module_sp->GetFileSpec().GetPath().c_str()); target.GetImages().AppendIfNeeded(exe_module_sp); - UpdateImageLoadAddress(exe_module_sp.get(), image_infos[exe_idx]); + UpdateImageLoadAddress(exe_module_sp.get(), images[exe_idx].first); if (exe_module_sp.get() != target.GetExecutableModulePointer()) target.SetExecutableModule(exe_module_sp, eLoadDependentsNo); @@ -581,14 +593,12 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos( } if (dyld_idx != UINT32_MAX) { - const bool can_create = true; - ModuleSP dyld_sp = FindTargetModuleForImageInfo(image_infos[dyld_idx], - can_create, nullptr); + ModuleSP dyld_sp = images[dyld_idx].second; if (dyld_sp.get()) { LLDB_LOGF(log, "Found dyld module: %s", dyld_sp->GetFileSpec().GetPath().c_str()); target.GetImages().AppendIfNeeded(dyld_sp); - UpdateImageLoadAddress(dyld_sp.get(), image_infos[dyld_idx]); + UpdateImageLoadAddress(dyld_sp.get(), images[dyld_idx].first); SetDYLDModule(dyld_sp); } } @@ -642,26 +652,58 @@ ModuleSP DynamicLoaderDarwin::GetDYLDModule() { void DynamicLoaderDarwin::ClearDYLDModule() { m_dyld_module_wp.reset(); } +std::vector> +DynamicLoaderDarwin::PreloadModulesFromImageInfos( + const ImageInfo::collection &image_infos) { + const auto size = image_infos.size(); + std::vector> images(size); + auto LoadImage = [&](size_t i, ImageInfo::collection::const_iterator it) { + const auto &image_info = *it; + images[i] = std::make_pair( + image_info, FindTargetModuleForImageInfo(image_info, true, nullptr)); + }; + auto it = image_infos.begin(); + bool is_parallel_load = + DynamicLoaderDarwinProperties::GetGlobal().GetEnableParallelImageLoad(); + if (is_parallel_load) { + llvm::ThreadPoolTaskGroup taskGroup(Debugger::GetThreadPool()); + for (size_t i = 0; i < size; ++i, ++it) { + taskGroup.async(LoadImage, i, it); + } + taskGroup.wait(); + } else { + for (size_t i = 0; i < size; ++i, ++it) { + LoadImage(i, it); + } + } + return images; +} + bool DynamicLoaderDarwin::AddModulesUsingImageInfos( ImageInfo::collection &image_infos) { std::lock_guard guard(m_mutex); + auto images = PreloadModulesFromImageInfos(image_infos); + return AddModulesUsingPreloadedModules(images); +} + +bool DynamicLoaderDarwin::AddModulesUsingPreloadedModules( + std::vector> &images) { + std::lock_guard guard(m_mutex); // Now add these images to the main list. ModuleList loaded_module_list; Log *log = GetLog(LLDBLog::DynamicLoader); Target &target = m_process->GetTarget(); ModuleList &target_images = target.GetImages(); - for (uint32_t idx = 0; idx < image_infos.size(); ++idx) { + for (uint32_t idx = 0; idx < images.size(); ++idx) { + auto &image_info = images[idx].first; + const auto &image_module_sp = images[idx].second; if (log) { LLDB_LOGF(log, "Adding new image at address=0x%16.16" PRIx64 ".", - image_infos[idx].address); - image_infos[idx].PutToLog(log); + image_info.address); + image_info.PutToLog(log); } - - m_dyld_image_infos.push_back(image_infos[idx]); - - ModuleSP image_module_sp( - FindTargetModuleForImageInfo(image_infos[idx], true, nullptr)); + m_dyld_image_infos.push_back(image_info); if (image_module_sp) { ObjectFile *objfile = image_module_sp->GetObjectFile(); @@ -673,7 +715,7 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos( sections->FindSectionByName(commpage_dbstr).get(); if (commpage_section) { ModuleSpec module_spec(objfile->GetFileSpec(), - image_infos[idx].GetArchitecture()); + image_info.GetArchitecture()); module_spec.GetObjectName() = commpage_dbstr; ModuleSP commpage_image_module_sp( target_images.FindFirstModule(module_spec)); @@ -686,17 +728,17 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos( if (!commpage_image_module_sp || commpage_image_module_sp->GetObjectFile() == nullptr) { commpage_image_module_sp = m_process->ReadModuleFromMemory( - image_infos[idx].file_spec, image_infos[idx].address); + image_info.file_spec, image_info.address); // Always load a memory image right away in the target in case // we end up trying to read the symbol table from memory... The // __LINKEDIT will need to be mapped so we can figure out where // the symbol table bits are... bool changed = false; UpdateImageLoadAddress(commpage_image_module_sp.get(), - image_infos[idx]); + image_info); target.GetImages().Append(commpage_image_module_sp); if (changed) { - image_infos[idx].load_stop_id = m_process->GetStopID(); + image_info.load_stop_id = m_process->GetStopID(); loaded_module_list.AppendIfNeeded(commpage_image_module_sp); } } @@ -709,14 +751,14 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos( // address. We need to check this so we don't mention that all loaded // shared libraries are newly loaded each time we hit out dyld breakpoint // since dyld will list all shared libraries each time. - if (UpdateImageLoadAddress(image_module_sp.get(), image_infos[idx])) { + if (UpdateImageLoadAddress(image_module_sp.get(), image_info)) { target_images.AppendIfNeeded(image_module_sp); loaded_module_list.AppendIfNeeded(image_module_sp); } // To support macCatalyst and legacy iOS simulator, // update the module's platform with the DYLD info. - ArchSpec dyld_spec = image_infos[idx].GetArchitecture(); + ArchSpec dyld_spec = image_info.GetArchitecture(); auto &dyld_triple = dyld_spec.GetTriple(); if ((dyld_triple.getEnvironment() == llvm::Triple::MacABI && dyld_triple.getOS() == llvm::Triple::IOS) || diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h index 45c693163f810..bc5464d76b950 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -58,6 +58,8 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader { std::optional GetStartAddress() override; + static void CreateSettings(lldb_private::Debugger &debugger); + protected: void PrivateInitialize(lldb_private::Process *process); @@ -174,7 +176,7 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader { bool UnloadModuleSections(lldb_private::Module *module, ImageInfo &info); - lldb::ModuleSP FindTargetModuleForImageInfo(ImageInfo &image_info, + lldb::ModuleSP FindTargetModuleForImageInfo(const ImageInfo &image_info, bool can_create, bool *did_create_ptr); @@ -201,11 +203,18 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader { lldb_private::StructuredData::ObjectSP image_details, ImageInfo::collection &image_infos); - // If image_infos contains / may contain dyld or executable image, call this - // method - // to keep our internal record keeping of the special binaries up-to-date. - void - UpdateSpecialBinariesFromNewImageInfos(ImageInfo::collection &image_infos); + // Finds/loads modules for a given `image_infos` and returns pairs + // (ImageInfo, ModuleSP). + // Prefer using this method rather than calling `FindTargetModuleForImageInfo` + // directly as this method may load the modules in parallel. + std::vector> + PreloadModulesFromImageInfos(const ImageInfo::collection &image_infos); + + // If `images` contains / may contain dyld or executable image, call this + // method to keep our internal record keeping of the special binaries + // up-to-date. + void UpdateSpecialBinariesFromPreloadedModules( + std::vector> &images); // if image_info is a dyld binary, call this method bool UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info); @@ -215,6 +224,8 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader { void AddExecutableModuleIfInImageInfos(ImageInfo::collection &image_infos); bool AddModulesUsingImageInfos(ImageInfo::collection &image_infos); + bool AddModulesUsingPreloadedModules( + std::vector> &images); // Whether we should use the new dyld SPI to get shared library information, // or read diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp new file mode 100644 index 0000000000000..f4d8a071e6d5d --- /dev/null +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp @@ -0,0 +1,53 @@ +//===-- DynamicLoaderDarwinProperties.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 "DynamicLoaderDarwinProperties.h" + +using namespace lldb_private; + +#define LLDB_PROPERTIES_dynamicloaderdarwin_experimental +#include "DynamicLoaderDarwinProperties.inc" + +enum { +#define LLDB_PROPERTIES_dynamicloaderdarwin_experimental +#include "DynamicLoaderDarwinPropertiesEnum.inc" +}; + +llvm::StringRef DynamicLoaderDarwinProperties::GetSettingName() { + static constexpr llvm::StringLiteral g_setting_name("darwin"); + return g_setting_name; +} + +DynamicLoaderDarwinProperties::ExperimentalProperties::ExperimentalProperties() + : Properties(std::make_shared( + GetExperimentalSettingsName())) { + m_collection_sp->Initialize(g_dynamicloaderdarwin_experimental_properties); +} + +DynamicLoaderDarwinProperties::DynamicLoaderDarwinProperties() + : Properties(std::make_shared(GetSettingName())), + m_experimental_properties(std::make_unique()) { + m_collection_sp->AppendProperty( + Properties::GetExperimentalSettingsName(), + "Experimental settings - setting these won't produce errors if the " + "setting is not present.", + true, m_experimental_properties->GetValueProperties()); +} + +bool DynamicLoaderDarwinProperties::GetEnableParallelImageLoad() const { + return m_experimental_properties->GetPropertyAtIndexAs( + ePropertyEnableParallelImageLoad, + g_dynamicloaderdarwin_experimental_properties + [ePropertyEnableParallelImageLoad] + .default_uint_value != 0); +} + +DynamicLoaderDarwinProperties &DynamicLoaderDarwinProperties::GetGlobal() { + static DynamicLoaderDarwinProperties g_settings; + return g_settings; +} diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.h new file mode 100644 index 0000000000000..4c5e800c4f3e4 --- /dev/null +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.h @@ -0,0 +1,34 @@ +//===-- DynamicLoaderDarwinProperties.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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_MACOSX_DYLD_DYNAMICLOADERDARWINPROPERTIES_H +#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_MACOSX_DYLD_DYNAMICLOADERDARWINPROPERTIES_H + +#include "lldb/Core/UserSettingsController.h" + +namespace lldb_private { + +class DynamicLoaderDarwinProperties : public Properties { +public: + class ExperimentalProperties : public Properties { + public: + ExperimentalProperties(); + }; + static llvm::StringRef GetSettingName(); + static DynamicLoaderDarwinProperties &GetGlobal(); + DynamicLoaderDarwinProperties(); + ~DynamicLoaderDarwinProperties() override = default; + bool GetEnableParallelImageLoad() const; + +private: + std::unique_ptr m_experimental_properties; +}; + +} // namespace lldb_private + +#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_MACOSX_DYLD_DYNAMICLOADERDARWINPROPERTIES_H diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.td b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.td new file mode 100644 index 0000000000000..c54580ce34729 --- /dev/null +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.td @@ -0,0 +1,8 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "dynamicloaderdarwin_experimental" in { + def EnableParallelImageLoad: Property<"enable-parallel-image-load", "Boolean">, + Global, + DefaultTrue, + Desc<"Load images in parallel.">; +} diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp index a038b65d47283..82555d1e028b4 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -215,8 +215,9 @@ void DynamicLoaderMacOS::DoInitialImageFetch() { LLDB_LOGF(log, "Initial module fetch: Adding %" PRId64 " modules.\n", (uint64_t)image_infos.size()); - UpdateSpecialBinariesFromNewImageInfos(image_infos); - AddModulesUsingImageInfos(image_infos); + auto images = PreloadModulesFromImageInfos(image_infos); + UpdateSpecialBinariesFromPreloadedModules(images); + AddModulesUsingPreloadedModules(images); } } @@ -425,8 +426,9 @@ void DynamicLoaderMacOS::AddBinaries( ->GetAsArray() ->GetSize() == load_addresses.size()) { if (JSONImageInformationIntoImageInfo(binaries_info_sp, image_infos)) { - UpdateSpecialBinariesFromNewImageInfos(image_infos); - AddModulesUsingImageInfos(image_infos); + auto images = PreloadModulesFromImageInfos(image_infos); + UpdateSpecialBinariesFromPreloadedModules(images); + AddModulesUsingPreloadedModules(images); } m_dyld_image_infos_stop_id = m_process->GetStopID(); } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index debd0f6ee83f4..8fc77cbe11701 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -572,8 +572,9 @@ bool DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfosAddress( ->GetSize() == image_infos_count) { bool return_value = false; if (JSONImageInformationIntoImageInfo(image_infos_json_sp, image_infos)) { - UpdateSpecialBinariesFromNewImageInfos(image_infos); - return_value = AddModulesUsingImageInfos(image_infos); + auto images = PreloadModulesFromImageInfos(image_infos); + UpdateSpecialBinariesFromPreloadedModules(images); + return_value = AddModulesUsingPreloadedModules(images); } m_dyld_image_infos_stop_id = m_process->GetStopID(); return return_value; @@ -1147,7 +1148,8 @@ bool DynamicLoaderMacOSXDYLD::IsFullyInitialized() { void DynamicLoaderMacOSXDYLD::Initialize() { PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), CreateInstance); + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); DynamicLoaderMacOS::Initialize(); } @@ -1156,6 +1158,11 @@ void DynamicLoaderMacOSXDYLD::Terminate() { PluginManager::UnregisterPlugin(CreateInstance); } +void DynamicLoaderMacOSXDYLD::DebuggerInitialize( + lldb_private::Debugger &debugger) { + CreateSettings(debugger); +} + llvm::StringRef DynamicLoaderMacOSXDYLD::GetPluginDescriptionStatic() { return "Dynamic loader plug-in that watches for shared library loads/unloads " "in MacOSX user processes."; diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h index ae7451722a8d7..924e2fc107743 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -50,6 +50,8 @@ class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoaderDarwin { static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force); + static void DebuggerInitialize(lldb_private::Debugger &debugger); + /// Called after attaching a process. /// /// Allow DynamicLoader plug-ins to execute some code after diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar.swift b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar.swift deleted file mode 100644 index b706f7b674856..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar.swift +++ /dev/null @@ -1,11 +0,0 @@ -import CBar -import Foundation - -func use(_ t: T) {} - -@objc public class Bar : NSObject { - @objc public func f() { - let baz = Baz(i_am_from_Bar: 42) - use(baz) // break here - } -} diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/Baz.h b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/Baz.h deleted file mode 100644 index 2b21083f03074..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/Baz.h +++ /dev/null @@ -1 +0,0 @@ -struct Baz { int i_am_from_Bar; }; diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/CBar.h b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/CBar.h deleted file mode 100644 index 62919726ece0d..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/CBar.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/module.modulemap b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/module.modulemap deleted file mode 100644 index 5ffee037b15a7..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Bar/module.modulemap +++ /dev/null @@ -1,3 +0,0 @@ -module CBar { - header "CBar.h" -} diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo.swift b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo.swift deleted file mode 100644 index a76caada9c246..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo.swift +++ /dev/null @@ -1,11 +0,0 @@ -import CFoo -import Foundation - -func use(_ t: T) {} - -@objc public class Foo : NSObject { - @objc public func f() { - let baz = Baz(i_am_from_Foo: 23) - use(baz) // break here - } -} diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/Baz.h b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/Baz.h deleted file mode 100644 index a7e2b34c330f0..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/Baz.h +++ /dev/null @@ -1 +0,0 @@ -struct Baz { int i_am_from_Foo; }; diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/CFoo.h b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/CFoo.h deleted file mode 100644 index 62919726ece0d..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/CFoo.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/module.modulemap b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/module.modulemap deleted file mode 100644 index 37c147ae4662f..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Foo/module.modulemap +++ /dev/null @@ -1,3 +0,0 @@ -module CFoo { - header "CFoo.h" -} diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Makefile b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Makefile deleted file mode 100644 index ad5c5a9472be1..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -SWIFT_OBJC_INTEROP := 1 - -# This test builds an Objective-C main program that imports two Swift -# .dylibs with conflicting ClangImporter search paths. - -include Makefile.rules - -a.out: main.m libFoo.dylib libBar.dylib - $(CC) $(CFLAGS) $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(shell pwd) -lFoo -lBar -L$(shell pwd) -o $@ $< -ifneq "$(CODESIGN)" "" - $(CODESIGN) -s - "$@" -endif - -lib%.dylib: %.swift - mkdir -p $(BUILDDIR)/$(shell basename $< .swift) - "$(MAKE)" MAKE_DSYM=YES \ - DYLIB_NAME=$(shell basename $< .swift) \ - VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all - -clean:: - rm -rf *.swiftmodule *.swiftdoc *.dSYM *~ lib*.dylib a.out *.o diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/TestSwiftObjCMainConflictingDylibs.py b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/TestSwiftObjCMainConflictingDylibs.py deleted file mode 100644 index fa1368c4f2364..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/TestSwiftObjCMainConflictingDylibs.py +++ /dev/null @@ -1,56 +0,0 @@ -# TestSwiftObjCMainConflictingDylibs.py -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2018 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ------------------------------------------------------------------------------ - -import lldb -from lldbsuite.test.lldbtest import * -from lldbsuite.test.decorators import * -import lldbsuite.test.lldbutil as lldbutil -import os -import shutil - -class TestSwiftObjCMainConflictingDylibs(TestBase): - # Don't run ClangImporter tests if Clangimporter is disabled. - @skipIf(setting=('symbols.use-swift-clangimporter', 'false')) - @skipUnlessDarwin - @swiftTest - def test(self): - # To ensure we hit the rebuild problem remove the cache to avoid caching. - mod_cache = self.getBuildArtifact("my-clang-modules-cache") - if os.path.isdir(mod_cache): - shutil.rmtree(mod_cache) - - self.runCmd('settings set symbols.clang-modules-cache-path "%s"' - % mod_cache) - self.build() - target, process, _, foo_breakpoint = lldbutil.run_to_source_breakpoint( - self, 'break here', lldb.SBFileSpec('Foo.swift'), - extra_images=['Foo', 'Bar']) - - # Prime the module cache with the Foo variant. - self.expect("fr var baz", "correct baz", substrs=["i_am_from_Foo"]) - self.assertTrue(os.path.isdir(mod_cache), "module cache exists") - - bar_breakpoint = target.BreakpointCreateBySourceRegex( - 'break here', lldb.SBFileSpec('Bar.swift')) - - # Restart. - process = target.LaunchSimple(None, None, os.getcwd()) - # This is failing because the Target-SwiftASTContext uses the - # amalgamated target header search options from all dylibs. - self.expect("expression baz", "wrong baz", substrs=["i_am_from_Foo"]) - self.expect("fr var baz", "wrong baz", substrs=["i_am_from_Foo"]) - - - process.Continue() - self.expect("expression baz", "correct baz", substrs=["i_am_from_Foo"]) - self.expect("fr var baz", "correct baz", substrs=["i_am_from_Foo"]) - diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/dylib.mk b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/dylib.mk deleted file mode 100644 index 3df5de7cf022f..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/dylib.mk +++ /dev/null @@ -1,6 +0,0 @@ -DYLIB_ONLY := YES -DYLIB_SWIFT_SOURCES := $(DYLIB_NAME).swift -SWIFT_OBJC_HEADER = $(DYLIB_NAME).h -SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR) -I$(SRCDIR)/$(DYLIB_NAME) - -include Makefile.rules diff --git a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/main.m b/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/main.m deleted file mode 100644 index 38cb0697ff709..0000000000000 --- a/lldb/test/API/lang/swift/clangimporter/objcmain_conflicting_dylibs/main.m +++ /dev/null @@ -1,9 +0,0 @@ -@import Foundation; -#include "Foo.h" -#include "Bar.h" - -int main(int argc, char **argv) { - [[[Bar alloc] init] f]; - [[[Foo alloc] init] f]; - return 0; -}