diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index d240050cc4c62..c377b64e9b9ea 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1765,6 +1765,19 @@ def cleanup(self, dictionary=None): "Don't know how to do cleanup with dictionary: " + dictionary) + def invoke(self, obj, name, trace=False): + """Use reflection to call a method dynamically with no argument.""" + trace = (True if traceAlways else trace) + + method = getattr(obj, name) + import inspect + self.assertTrue(inspect.ismethod(method), + name + "is a method name of object: " + str(obj)) + result = method() + with recording(self, trace) as sbuf: + print(str(method) + ":", result, file=sbuf) + return result + def getLLDBLibraryEnvVal(self): """ Returns the path that the OS-specific library search environment variable (self.dylibPath) should be set to in order for a program to find the LLDB @@ -2624,19 +2637,6 @@ def expect_var_path( value_check.check_value(self, eval_result, str(eval_result)) return eval_result - def invoke(self, obj, name, trace=False): - """Use reflection to call a method dynamically with no argument.""" - trace = (True if traceAlways else trace) - - method = getattr(obj, name) - import inspect - self.assertTrue(inspect.ismethod(method), - name + "is a method name of object: " + str(obj)) - result = method() - with recording(self, trace) as sbuf: - print(str(method) + ":", result, file=sbuf) - return result - def build( self, architecture=None, diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index a64ee2634e2b7..6a4275d249f6e 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -825,7 +825,7 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme, const char *hostname, uint16_t port, const char *path) { StreamString result; - result.Printf("%s://%s", scheme, hostname); + result.Printf("%s://[%s]", scheme, hostname); if (port != 0) result.Printf(":%u", port); if (path) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 4aa1534609415..3462fb7ec8b97 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -205,7 +205,7 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( platform_port, platform_path); UNUSED_IF_ASSERT_DISABLED(ok); assert(ok); - url << platform_ip.str() << ":" << *port; + url << '[' << platform_ip.str() << "]:" << *port; } else { socket_name = GetDomainSocketPath("gdbserver").GetPath(); url << socket_name; diff --git a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py index 177388fad5fc5..95a210059b6d5 100644 --- a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py +++ b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py @@ -1,44 +1,22 @@ - -import time - +import socket import gdbremote_testcase +import lldbgdbserverutils from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase): mydir = TestBase.compute_mydir(__file__) - @llgs_test - @no_debug_info_test - @skipIf(remote=False) + @skipIfRemote @expectedFailureAll(hostoslist=["windows"], triple='.*-android') def test_platform_process_connect(self): self.build() - working_dir = lldb.remote_platform.GetWorkingDirectory() - src = lldb.SBFileSpec(self.getBuildArtifact("a.out")) - dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out")) - err = lldb.remote_platform.Put(src, dest) - if err.Fail(): - raise RuntimeError( - "Unable copy '%s' to '%s'.\n>>> %s" % - (f, wd, err.GetCString())) + hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0] + listen_url = "[%s]:0"%hostname - m = re.search("^(.*)://([^:/]*)", configuration.lldb_platform_url) - protocol = m.group(1) - hostname = m.group(2) - unix_protocol = protocol.startswith("unix-") - if unix_protocol: - p = re.search("^(.*)-connect", protocol) - path = lldbutil.join_remote_paths(configuration.lldb_platform_working_dir, - self.getBuildDirBasename(), "platform-%d.sock" % int(time.time())) - listen_url = "%s://%s" % (p.group(1), path) - else: - listen_url = "*:0" - - port_file = "%s/port" % working_dir + port_file = self.getBuildArtifact("port") commandline_args = [ "platform", "--listen", @@ -46,25 +24,19 @@ def test_platform_process_connect(self): "--socket-file", port_file, "--", - "%s/a.out" % - working_dir, + self.getBuildArtifact("a.out"), "foo"] self.spawnSubprocess( - self.debug_monitor_exe, - commandline_args, - install_remote=False) + lldbgdbserverutils.get_lldb_server_exe(), + commandline_args) socket_id = lldbutil.wait_for_file_on_target(self, port_file) self.dbg.SetAsync(False) - - new_platform = lldb.SBPlatform(lldb.remote_platform.GetName()) + new_platform = lldb.SBPlatform("remote-" + self.getPlatform()) self.dbg.SetSelectedPlatform(new_platform) - if unix_protocol: - connect_url = "%s://%s%s" % (protocol, hostname, socket_id) - else: - connect_url = "%s://%s:%s" % (protocol, hostname, socket_id) + connect_url = "connect://[%s]:%s" % (hostname, socket_id) command = "platform connect %s" % (connect_url) result = lldb.SBCommandReturnObject() @@ -72,7 +44,7 @@ def test_platform_process_connect(self): self.assertTrue( result.Succeeded(), "platform process connect failed: %s" % - result.GetOutput()) + result.GetError()) target = self.dbg.GetSelectedTarget() process = target.GetProcess()