Index: lldb/trunk/source/API/SystemInitializerFull.cpp =================================================================== --- lldb/trunk/source/API/SystemInitializerFull.cpp +++ lldb/trunk/source/API/SystemInitializerFull.cpp @@ -42,9 +42,9 @@ #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" -#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" +#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" #include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h" @@ -62,8 +62,16 @@ #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" -#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" #include "Plugins/OperatingSystem/Go/OperatingSystemGo.h" +#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" +#include "Plugins/Platform/Android/PlatformAndroid.h" +#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" +#include "Plugins/Platform/Kalimba/PlatformKalimba.h" +#include "Plugins/Platform/Linux/PlatformLinux.h" +#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" +#include "Plugins/Platform/NetBSD/PlatformNetBSD.h" +#include "Plugins/Platform/Windows/PlatformWindows.h" #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" #include "Plugins/Process/elf-core/ProcessElfCore.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" @@ -78,14 +86,16 @@ #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" #if defined(__APPLE__) -#include "Plugins/Process/mach-core/ProcessMachCore.h" -#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" -#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" +#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" #include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h" #include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h" +#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h" -#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" +#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" +#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" +#include "Plugins/Process/mach-core/ProcessMachCore.h" +#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" #endif #if defined(__FreeBSD__) @@ -281,6 +291,19 @@ ScriptInterpreterPython::Initialize(); #endif + platform_freebsd::PlatformFreeBSD::Initialize(); + platform_linux::PlatformLinux::Initialize(); + platform_netbsd::PlatformNetBSD::Initialize(); + PlatformWindows::Initialize(); + PlatformKalimba::Initialize(); + platform_android::PlatformAndroid::Initialize(); + PlatformRemoteiOS::Initialize(); + PlatformMacOSX::Initialize(); +#if defined(__APPLE__) + PlatformiOSSimulator::Initialize(); + PlatformDarwinKernel::Initialize(); +#endif + // Initialize LLVM and Clang llvm::InitializeAllTargets(); llvm::InitializeAllAsmPrinters(); @@ -492,6 +515,19 @@ #endif OperatingSystemGo::Terminate(); + platform_freebsd::PlatformFreeBSD::Terminate(); + platform_linux::PlatformLinux::Terminate(); + platform_netbsd::PlatformNetBSD::Terminate(); + PlatformWindows::Terminate(); + PlatformKalimba::Terminate(); + platform_android::PlatformAndroid::Terminate(); + PlatformMacOSX::Terminate(); + PlatformRemoteiOS::Terminate(); +#if defined(__APPLE__) + PlatformiOSSimulator::Terminate(); + PlatformDarwinKernel::Terminate(); +#endif + // Now shutdown the common parts, in reverse order. SystemInitializerCommon::Terminate(); } Index: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp =================================================================== --- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp +++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp @@ -20,20 +20,10 @@ #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" -#include "Plugins/Platform/Android/PlatformAndroid.h" -#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" -#include "Plugins/Platform/Kalimba/PlatformKalimba.h" -#include "Plugins/Platform/Linux/PlatformLinux.h" -#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" -#include "Plugins/Platform/NetBSD/PlatformNetBSD.h" -#include "Plugins/Platform/Windows/PlatformWindows.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" #if defined(__APPLE__) -#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" -#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" #endif #if defined(__linux__) @@ -99,12 +89,6 @@ ObjectContainerBSDArchive::Initialize(); ObjectFileELF::Initialize(); ObjectFilePECOFF::Initialize(); - platform_freebsd::PlatformFreeBSD::Initialize(); - platform_linux::PlatformLinux::Initialize(); - platform_netbsd::PlatformNetBSD::Initialize(); - PlatformWindows::Initialize(); - PlatformKalimba::Initialize(); - platform_android::PlatformAndroid::Initialize(); EmulateInstructionARM::Initialize(); EmulateInstructionMIPS::Initialize(); @@ -115,12 +99,8 @@ //---------------------------------------------------------------------- ObjectContainerUniversalMachO::Initialize(); - PlatformRemoteiOS::Initialize(); - PlatformMacOSX::Initialize(); #if defined(__APPLE__) - PlatformiOSSimulator::Initialize(); - PlatformDarwinKernel::Initialize(); ObjectFileMachO::Initialize(); #endif #if defined(__linux__) @@ -139,24 +119,14 @@ ObjectContainerBSDArchive::Terminate(); ObjectFileELF::Terminate(); ObjectFilePECOFF::Terminate(); - platform_freebsd::PlatformFreeBSD::Terminate(); - platform_linux::PlatformLinux::Terminate(); - platform_netbsd::PlatformNetBSD::Terminate(); - PlatformWindows::Terminate(); - PlatformKalimba::Terminate(); - platform_android::PlatformAndroid::Terminate(); - ObjectContainerUniversalMachO::Terminate(); - PlatformMacOSX::Terminate(); - PlatformRemoteiOS::Terminate(); EmulateInstructionARM::Terminate(); EmulateInstructionMIPS::Terminate(); EmulateInstructionMIPS64::Terminate(); + ObjectContainerUniversalMachO::Terminate(); #if defined(__APPLE__) - PlatformiOSSimulator::Terminate(); ObjectFileMachO::Terminate(); - PlatformDarwinKernel::Terminate(); #endif #if defined(_MSC_VER) Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -40,7 +40,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - GDBRemoteCommunicationServerLLGS(const lldb::PlatformSP& platform_sp, MainLoop &mainloop); + GDBRemoteCommunicationServerLLGS(MainLoop &mainloop); //------------------------------------------------------------------ /// Specify the program to launch and its arguments. @@ -114,7 +114,6 @@ InitializeConnection (std::unique_ptr &&connection); protected: - lldb::PlatformSP m_platform_sp; MainLoop &m_mainloop; MainLoop::ReadHandleUP m_network_handle_up; lldb::tid_t m_current_tid; Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -39,7 +39,6 @@ #include "lldb/Host/TimeValue.h" #include "lldb/Target/FileAction.h" #include "lldb/Target/MemoryRegionInfo.h" -#include "lldb/Target/Platform.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeThreadProtocol.h" @@ -76,10 +75,8 @@ //---------------------------------------------------------------------- // GDBRemoteCommunicationServerLLGS constructor //---------------------------------------------------------------------- -GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(const lldb::PlatformSP &platform_sp, - MainLoop &mainloop) +GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(MainLoop &mainloop) : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), - m_platform_sp(platform_sp), m_mainloop(mainloop), m_current_tid(LLDB_INVALID_THREAD_ID), m_continue_tid(LLDB_INVALID_THREAD_ID), @@ -93,7 +90,6 @@ m_next_saved_registers_id(1), m_handshake_completed(false) { - assert(platform_sp); RegisterPacketHandlers(); } Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -85,7 +85,6 @@ const std::string m_socket_scheme; std::recursive_mutex m_spawned_pids_mutex; std::set m_spawned_pids; - lldb::PlatformSP m_platform_sp; PortMap m_port_map; uint16_t m_port_offset; Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -53,7 +53,6 @@ m_socket_protocol(socket_protocol), m_socket_scheme(socket_scheme), m_spawned_pids_mutex(), - m_platform_sp(Platform::GetHostPlatform()), m_port_map(), m_port_offset(0) { @@ -463,7 +462,7 @@ std::bind(&GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped, this, std::placeholders::_1), false); - Error error = m_platform_sp->LaunchProcess (m_process_launch_info); + Error error = Host::LaunchProcess(m_process_launch_info); if (!error.Success ()) { fprintf (stderr, "%s: failed to launch executable %s", __FUNCTION__, m_process_launch_info.GetArguments ().GetArgumentAtIndex (0)); Index: lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp =================================================================== --- lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp +++ lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp @@ -32,7 +32,6 @@ #include "lldb/Host/Pipe.h" #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" -#include "lldb/Target/Platform.h" #include "Acceptor.h" #include "LLDBServerUtilities.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h" @@ -62,7 +61,6 @@ static struct option g_long_options[] = { { "debug", no_argument, &g_debug, 1 }, - { "platform", required_argument, NULL, 'p' }, { "verbose", no_argument, &g_verbose, 1 }, { "log-file", required_argument, NULL, 'l' }, { "log-channels", required_argument, NULL, 'c' }, @@ -121,7 +119,6 @@ fprintf(stderr, "Usage:\n %s %s " "[--log-file log-file-name] " "[--log-channels log-channel-list] " - "[--platform platform_name] " "[--setsid] " "[--named-pipe named-pipe-path] " "[--native-regs] " @@ -131,66 +128,6 @@ exit(0); } -static void -dump_available_platforms (FILE *output_file) -{ - fprintf (output_file, "Available platform plugins:\n"); - for (int i = 0; ; ++i) - { - const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex (i); - const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex (i); - - if (!plugin_name || !plugin_desc) - break; - - fprintf (output_file, "%s\t%s\n", plugin_name, plugin_desc); - } - - if ( Platform::GetHostPlatform () ) - { - // add this since the default platform doesn't necessarily get registered by - // the plugin name (e.g. 'host' doesn't show up as a - // registered platform plugin even though it's the default). - fprintf (output_file, "%s\tDefault platform for this host.\n", Platform::GetHostPlatform ()->GetPluginName ().AsCString ()); - } -} - -static lldb::PlatformSP -setup_platform (const std::string &platform_name) -{ - lldb::PlatformSP platform_sp; - - if (platform_name.empty()) - { - printf ("using the default platform: "); - platform_sp = Platform::GetHostPlatform (); - printf ("%s\n", platform_sp->GetPluginName ().AsCString ()); - return platform_sp; - } - - Error error; - platform_sp = Platform::Create (lldb_private::ConstString(platform_name), error); - if (error.Fail ()) - { - // the host platform isn't registered with that name (at - // least, not always. Check if the given name matches - // the default platform name. If so, use it. - if ( Platform::GetHostPlatform () && ( Platform::GetHostPlatform ()->GetPluginName () == ConstString (platform_name.c_str()) ) ) - { - platform_sp = Platform::GetHostPlatform (); - } - else - { - fprintf (stderr, "error: failed to create platform with name '%s'\n", platform_name.c_str()); - dump_available_platforms (stderr); - exit (1); - } - } - printf ("using platform: %s\n", platform_name.c_str ()); - - return platform_sp; -} - void handle_attach_to_pid (GDBRemoteCommunicationServerLLGS &gdb_server, lldb::pid_t pid) { @@ -421,7 +358,6 @@ argv++; int long_option_index = 0; int ch; - std::string platform_name; std::string attach_target; std::string named_pipe_path; std::string log_file; @@ -460,11 +396,6 @@ log_channels = StringRef(optarg); break; - case 'p': // platform name - if (optarg && optarg[0]) - platform_name = optarg; - break; - case 'N': // named pipe if (optarg && optarg[0]) named_pipe_path = optarg; @@ -548,10 +479,7 @@ exit(255); } - // Setup the platform that GDBRemoteCommunicationServerLLGS will use. - lldb::PlatformSP platform_sp = setup_platform (platform_name); - - GDBRemoteCommunicationServerLLGS gdb_server (platform_sp, mainloop); + GDBRemoteCommunicationServerLLGS gdb_server(mainloop); const char *const host_and_port = argv[0]; argc -= 1;