diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -10,7 +10,7 @@ #define LLDB_HOST_FILE_H #include "lldb/Host/PosixApi.h" -#include "lldb/Utility/IOObject.h" +#include "llvm/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include "llvm/ADT/BitmaskEnum.h" diff --git a/lldb/include/lldb/Host/MainLoopBase.h b/lldb/include/lldb/Host/MainLoopBase.h --- a/lldb/include/lldb/Host/MainLoopBase.h +++ b/lldb/include/lldb/Host/MainLoopBase.h @@ -9,9 +9,9 @@ #ifndef LLDB_HOST_MAINLOOPBASE_H #define LLDB_HOST_MAINLOOPBASE_H -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Utility/IOObject.h" #include namespace lldb_private { diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h --- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -17,8 +17,8 @@ #include "lldb/Host/Pipe.h" #include "lldb/Utility/Connection.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Predicate.h" +#include "llvm/Utility/IOObject.h" namespace lldb_private { diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -12,7 +12,7 @@ #include "lldb/Host/Host.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Host/StringConvert.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Host/common/UDPSocket.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -41,7 +41,7 @@ #endif #include "lldb/Host/Host.h" #include "lldb/Host/Socket.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Host/common/UDPSocket.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp --- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/common/TCPSocket.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UriParser.h" +#include "llvm/Host/common/TCPSocket.h" #include "PlatformAndroidRemoteGDBServer.h" diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -19,7 +19,7 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -24,7 +24,7 @@ #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" #include "lldb/Target/Platform.h" #include "lldb/Utility/Event.h" diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt --- a/lldb/source/Utility/CMakeLists.txt +++ b/lldb/source/Utility/CMakeLists.txt @@ -39,7 +39,6 @@ Event.cpp FileSpec.cpp GDBRemote.cpp - IOObject.cpp LLDBAssert.cpp Listener.cpp Log.cpp diff --git a/lldb/tools/lldb-server/Acceptor.cpp b/lldb/tools/lldb-server/Acceptor.cpp --- a/lldb/tools/lldb-server/Acceptor.cpp +++ b/lldb/tools/lldb-server/Acceptor.cpp @@ -12,9 +12,9 @@ #include "llvm/Support/ScopedPrinter.h" #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/common/TCPSocket.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UriParser.h" +#include "llvm/Host/common/TCPSocket.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp --- a/lldb/tools/lldb-server/lldb-platform.cpp +++ b/lldb/tools/lldb-server/lldb-platform.cpp @@ -32,7 +32,7 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/HostGetOpt.h" #include "lldb/Host/OptionParser.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" diff --git a/lldb/unittests/Host/MainLoopTest.cpp b/lldb/unittests/Host/MainLoopTest.cpp --- a/lldb/unittests/Host/MainLoopTest.cpp +++ b/lldb/unittests/Host/MainLoopTest.cpp @@ -10,7 +10,7 @@ #include "TestingSupport/SubsystemRAII.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/PseudoTerminal.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" #include diff --git a/lldb/unittests/Host/SocketTestUtilities.h b/lldb/unittests/Host/SocketTestUtilities.h --- a/lldb/unittests/Host/SocketTestUtilities.h +++ b/lldb/unittests/Host/SocketTestUtilities.h @@ -15,8 +15,8 @@ #include "lldb/Host/Config.h" #include "lldb/Host/Socket.h" -#include "lldb/Host/common/TCPSocket.h" #include "lldb/Host/common/UDPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Testing/Support/Error.h" diff --git a/lldb/unittests/debugserver/RNBSocketTest.cpp b/lldb/unittests/debugserver/RNBSocketTest.cpp --- a/lldb/unittests/debugserver/RNBSocketTest.cpp +++ b/lldb/unittests/debugserver/RNBSocketTest.cpp @@ -16,7 +16,7 @@ #include "RNBSocket.h" #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "llvm/Testing/Support/Error.h" using namespace lldb_private; diff --git a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp --- a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp +++ b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp @@ -8,10 +8,10 @@ #include "TestClient.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Host/common/TCPSocket.h" #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" #include "lldb/Utility/Args.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Host/common/TCPSocket.h" #include "llvm/Support/Path.h" #include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" diff --git a/lldb/include/lldb/Host/Socket.h b/llvm/include/llvm/Host/Socket.h rename from lldb/include/lldb/Host/Socket.h rename to llvm/include/llvm/Host/Socket.h --- a/lldb/include/lldb/Host/Socket.h +++ b/llvm/include/llvm/Host/Socket.h @@ -15,9 +15,9 @@ #include "lldb/lldb-private.h" #include "lldb/Host/SocketAddress.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" +#include "llvm/Utility/IOObject.h" #ifdef _WIN32 #include "lldb/Host/windows/windows.h" diff --git a/lldb/include/lldb/Host/SocketAddress.h b/llvm/include/llvm/Host/SocketAddress.h rename from lldb/include/lldb/Host/SocketAddress.h rename to llvm/include/llvm/Host/SocketAddress.h diff --git a/lldb/include/lldb/Host/common/TCPSocket.h b/llvm/include/llvm/Host/common/TCPSocket.h rename from lldb/include/lldb/Host/common/TCPSocket.h rename to llvm/include/llvm/Host/common/TCPSocket.h diff --git a/lldb/include/lldb/Utility/IOObject.h b/llvm/include/llvm/Utility/IOObject.h rename from lldb/include/lldb/Utility/IOObject.h rename to llvm/include/llvm/Utility/IOObject.h diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -36,6 +36,7 @@ add_subdirectory(TextAPI) add_subdirectory(ToolDrivers) add_subdirectory(XRay) +add_subdirectory(Host) if (LLVM_INCLUDE_TESTS) add_subdirectory(Testing) endif() diff --git a/llvm/lib/Host/CMakeLists.txt b/llvm/lib/Host/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/llvm/lib/Host/CMakeLists.txt @@ -0,0 +1,16 @@ +if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) + # The arpa/inet.h header used in the files here is providing a miscompiled + # htonl function on macOS <= 10.15 when local submodule visibility is active. + # Disabling modules in this directory until this is is fixed. + # See rdar://problem/62886385 + remove_module_flags() +endif() + +macro(add_host_subdirectory group) + list(APPEND HOST_SOURCES ${ARGN}) + source_group(${group} FILES ${ARGN}) +endmacro() + +add_host_subdirectory(common + common/TCPSocket.cpp +) diff --git a/lldb/source/Host/common/TCPSocket.cpp b/llvm/lib/Host/common/TCPSocket.cpp rename from lldb/source/Host/common/TCPSocket.cpp rename to llvm/lib/Host/common/TCPSocket.cpp --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/llvm/lib/Host/common/TCPSocket.cpp @@ -10,7 +10,7 @@ #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif -#include "lldb/Host/common/TCPSocket.h" +#include "llvm/Host/common/TCPSocket.h" #include "lldb/Host/Config.h" #include "lldb/Host/MainLoop.h" @@ -169,8 +169,9 @@ address.SetPort(port); - if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, - GetNativeSocket(), &address.sockaddr(), address.GetLength())) { + if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(), + &address.sockaddr(), + address.GetLength())) { CLOSE_SOCKET(GetNativeSocket()); continue; } @@ -214,7 +215,7 @@ sizeof(option_value)); SocketAddress listen_address = address; - if(!listen_address.IsLocalhost()) + if (!listen_address.IsLocalhost()) listen_address.SetToAnyAddress(address.GetFamily(), port); else listen_address.SetPort(port); @@ -268,14 +269,16 @@ auto inherit = this->m_child_processes_inherit; auto io_sp = IOObjectSP(new TCPSocket(socket.first, false, inherit)); handles.emplace_back(accept_loop.RegisterReadObject( - io_sp, [fd, inherit, &sock, &AcceptAddr, &error, - &listen_sock](MainLoopBase &loop) { + io_sp, + [fd, inherit, &sock, &AcceptAddr, &error, + &listen_sock](MainLoopBase &loop) { socklen_t sa_len = AcceptAddr.GetMaxLength(); - sock = AcceptSocket(fd, &AcceptAddr.sockaddr(), &sa_len, inherit, - error); + sock = + AcceptSocket(fd, &AcceptAddr.sockaddr(), &sa_len, inherit, error); listen_sock = fd; loop.RequestTermination(); - }, error)); + }, + error)); if (error.Fail()) return error; } @@ -287,7 +290,7 @@ accept_loop.Run(); if (error.Fail()) - return error; + return error; lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock]; if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) { diff --git a/lldb/source/Utility/IOObject.cpp b/llvm/lib/Utility/IOObject.cpp rename from lldb/source/Utility/IOObject.cpp rename to llvm/lib/Utility/IOObject.cpp --- a/lldb/source/Utility/IOObject.cpp +++ b/llvm/lib/Utility/IOObject.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Utility/IOObject.h" +#include "llvm/Utility/IOObject.h" using namespace lldb_private;