summaryrefslogtreecommitdiff
path: root/tools/debugserver
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-07-19 07:03:07 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-07-19 07:03:07 +0000
commita884e649599e13d58ce6d2b2a0ce8091ceb48dac (patch)
treef527514e113dd4f771eef3d39e5a5d2da36b8552 /tools/debugserver
parente75e363cb71a7339552b9d943e78ac62b737379b (diff)
Notes
Diffstat (limited to 'tools/debugserver')
-rw-r--r--tools/debugserver/CMakeLists.txt19
-rw-r--r--tools/debugserver/source/CMakeLists.txt20
-rw-r--r--tools/debugserver/source/MacOSX/CMakeLists.txt25
-rw-r--r--tools/debugserver/source/MacOSX/DarwinLog/CMakeLists.txt2
-rw-r--r--tools/debugserver/source/MacOSX/i386/CMakeLists.txt4
-rw-r--r--tools/debugserver/source/MacOSX/x86_64/CMakeLists.txt8
-rw-r--r--tools/debugserver/source/RNBSocket.cpp21
7 files changed, 73 insertions, 26 deletions
diff --git a/tools/debugserver/CMakeLists.txt b/tools/debugserver/CMakeLists.txt
index d8414e5a2fe07..ae436b8f07c3e 100644
--- a/tools/debugserver/CMakeLists.txt
+++ b/tools/debugserver/CMakeLists.txt
@@ -1,2 +1,19 @@
-project(C CXX ASM-ATT)
+cmake_minimum_required(VERSION 3.4.3)
+
+project(Debugserver LANGUAGES C CXX ASM-ATT)
+
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ set(CMAKE_MODULE_PATH
+ ${CMAKE_MODULE_PATH}
+ "${CMAKE_SOURCE_DIR}/../../cmake"
+ "${CMAKE_SOURCE_DIR}/../../cmake/modules"
+ )
+
+ include(LLDBStandalone)
+ include(AddLLDB)
+
+ set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
+ include_directories(${LLDB_SOURCE_DIR}/include)
+endif()
+
add_subdirectory(source)
diff --git a/tools/debugserver/source/CMakeLists.txt b/tools/debugserver/source/CMakeLists.txt
index 775a1a127b6fe..bdca1602f4a89 100644
--- a/tools/debugserver/source/CMakeLists.txt
+++ b/tools/debugserver/source/CMakeLists.txt
@@ -1,3 +1,4 @@
+include(CheckCXXCompilerFlag)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${LLDB_SOURCE_DIR}/source)
include_directories(MacOSX/DarwinLog)
@@ -25,7 +26,6 @@ if (CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
endif ()
-find_library(COCOA_LIBRARY Cocoa)
add_subdirectory(MacOSX)
set(generated_mach_interfaces
@@ -91,11 +91,23 @@ set(lldbDebugserverCommonSources
add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
+
+if (APPLE)
+ if(IOS)
+ find_library(COCOA_LIBRARY UIKit)
+ target_link_libraries(lldbDebugserverCommon INTERFACE ${COCOA_LIBRARY} ${CORE_FOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY})
+ else()
+ find_library(COCOA_LIBRARY Cocoa)
+ target_link_libraries(lldbDebugserverCommon INTERFACE ${COCOA_LIBRARY})
+ endif()
+endif()
+
target_link_libraries(lldbDebugserverCommon
INTERFACE ${COCOA_LIBRARY}
- lldbDebugserverMacOSX_I386
- lldbDebugserverMacOSX_X86_64
- lldbDebugserverMacOSX_DarwinLog)
+ ${CORE_FOUNDATION_LIBRARY}
+ ${FOUNDATION_LIBRARY}
+ lldbDebugserverArchSupport
+ lldbDebugserverDarwin_DarwinLog)
set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
diff --git a/tools/debugserver/source/MacOSX/CMakeLists.txt b/tools/debugserver/source/MacOSX/CMakeLists.txt
index 59b39a1bff639..28877d122d943 100644
--- a/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -1,8 +1,23 @@
-#add_subdirectory(arm64)
-#add_subdirectory(arm)
-add_subdirectory(i386)
-#add_subdirectory(ppc)
-add_subdirectory(x86_64)
+if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*arm.*")
+ list(APPEND SOURCES arm/DNBArchImpl.cpp arm64/DNBArchImplARM64.cpp)
+ include_directories(${CURRENT_SOURCE_DIR}/arm ${CURRENT_SOURCE_DIR}/arm64)
+endif()
+
+if(NOT CMAKE_OSX_ARCHITECTURES OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*86.*")
+ list(APPEND SOURCES i386/DNBArchImplI386.cpp x86_64/DNBArchImplX86_64.cpp)
+ include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64)
+endif()
+
+if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*ppc.*")
+ list(APPEND SOURCES ppc/DNBArchImpl.cpp)
+ include_directories(${CURRENT_SOURCE_DIR}/ppc)
+endif()
+
add_subdirectory(DarwinLog)
include_directories(..)
+
+include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
+add_library(lldbDebugserverArchSupport
+ ${SOURCES}
+ )
diff --git a/tools/debugserver/source/MacOSX/DarwinLog/CMakeLists.txt b/tools/debugserver/source/MacOSX/DarwinLog/CMakeLists.txt
index 47e7362f0d5e1..dffa357f1e680 100644
--- a/tools/debugserver/source/MacOSX/DarwinLog/CMakeLists.txt
+++ b/tools/debugserver/source/MacOSX/DarwinLog/CMakeLists.txt
@@ -3,7 +3,7 @@
# we must include the grandparent directory...
include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
-add_library(lldbDebugserverMacOSX_DarwinLog
+add_library(lldbDebugserverDarwin_DarwinLog
ActivityStore.cpp
DarwinLogCollector.cpp
LogFilter.cpp
diff --git a/tools/debugserver/source/MacOSX/i386/CMakeLists.txt b/tools/debugserver/source/MacOSX/i386/CMakeLists.txt
deleted file mode 100644
index dee2c1ea96b0e..0000000000000
--- a/tools/debugserver/source/MacOSX/i386/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
-add_library(lldbDebugserverMacOSX_I386
- DNBArchImplI386.cpp
- )
diff --git a/tools/debugserver/source/MacOSX/x86_64/CMakeLists.txt b/tools/debugserver/source/MacOSX/x86_64/CMakeLists.txt
deleted file mode 100644
index bb41b04d9d9e8..0000000000000
--- a/tools/debugserver/source/MacOSX/x86_64/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Due to sources including headers like:
-# #include "MacOSX/i386/DNBArchImplI386.h"
-# we must include the grandparent directory...
-include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source)
-
-add_library(lldbDebugserverMacOSX_X86_64
- DNBArchImplX86_64.cpp
- )
diff --git a/tools/debugserver/source/RNBSocket.cpp b/tools/debugserver/source/RNBSocket.cpp
index 62a3e4f9adf53..f1db5e419ff25 100644
--- a/tools/debugserver/source/RNBSocket.cpp
+++ b/tools/debugserver/source/RNBSocket.cpp
@@ -79,9 +79,17 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
return rnb_err;
}
+ bool any_addr = (strcmp(listen_host, "*") == 0);
+
+ // If the user wants to allow connections from any address we should create
+ // sockets on all families that can resolve localhost. This will allow us to
+ // listen for IPv6 and IPv4 connections from all addresses if those interfaces
+ // are available.
+ const char *local_addr = any_addr ? "localhost" : listen_host;
+
std::map<int, lldb_private::SocketAddress> sockets;
auto addresses = lldb_private::SocketAddress::GetAddressInfo(
- listen_host, NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
+ local_addr, NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
for (auto address : addresses) {
int sock_fd = ::socket(address.GetFamily(), SOCK_STREAM, IPPROTO_TCP);
@@ -90,9 +98,15 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
SetSocketOption(sock_fd, SOL_SOCKET, SO_REUSEADDR, 1);
- address.SetPort(port);
+ lldb_private::SocketAddress bind_address = address;
+
+ if(any_addr || !bind_address.IsLocalhost())
+ bind_address.SetToAnyAddress(bind_address.GetFamily(), port);
+ else
+ bind_address.SetPort(port);
- int error = ::bind(sock_fd, &address.sockaddr(), address.GetLength());
+ int error =
+ ::bind(sock_fd, &bind_address.sockaddr(), bind_address.GetLength());
if (error == -1) {
ClosePort(sock_fd, false);
continue;
@@ -179,6 +193,7 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
DNBLogThreaded("error: rejecting connection from %s (expecting %s)\n",
accept_addr.GetIPAddress().c_str(),
addr_in.GetIPAddress().c_str());
+ err.Clear();
}
}
}