Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -68,6 +68,10 @@ void SetPendingGdbServer(lldb::pid_t pid, uint16_t port, const std::string &socket_name); + // Whether to allow all hosts to connect to the debug server + // Can be used in network-constrained and firewalled environments such as Docker containers + void SetAllowAllHosts(bool allow_all_hosts); + protected: const Socket::SocketProtocol m_socket_protocol; const std::string m_socket_scheme; @@ -76,6 +80,7 @@ PortMap m_port_map; uint16_t m_port_offset; + bool m_allow_all_hosts; struct { lldb::pid_t pid; uint16_t port; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -141,7 +141,10 @@ #endif uint16_t *port_ptr = &port; if (m_socket_protocol == Socket::ProtocolTcp) - url << platform_ip.str() << ":" << port; + if (m_allow_all_hosts) + url << "0.0.0.0:" << port; + else + url << platform_ip.str() << ":" << port; else { socket_name = GetDomainSocketPath("gdbserver").GetPath(); url << socket_name; @@ -566,3 +569,7 @@ m_pending_gdb_server.port = port; m_pending_gdb_server.socket_name = socket_name; } + +void GDBRemoteCommunicationServerPlatform::SetAllowAllHosts(bool allow_all_hosts) { + m_allow_all_hosts = allow_all_hosts; +} Index: tools/lldb-server/lldb-platform.cpp =================================================================== --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -50,8 +50,10 @@ static int g_debug = 0; static int g_verbose = 0; static int g_server = 0; +static int g_allow_all_hosts = 0; static struct option g_long_options[] = { + {"allow-all-hosts", no_argument, &g_allow_all_hosts, 1}, {"debug", no_argument, &g_debug, 1}, {"verbose", no_argument, &g_verbose, 1}, {"log-file", required_argument, NULL, 'l'}, @@ -309,6 +311,8 @@ platform.SetPortMap(std::move(gdbserver_portmap)); } + platform.SetAllowAllHosts(g_allow_all_hosts); + const bool children_inherit_accept_socket = true; Connection *conn = nullptr; error = acceptor_up->Accept(children_inherit_accept_socket, conn);