1import socket 2import gdbremote_testcase 3import lldbgdbserverutils 4from lldbsuite.test.decorators import * 5from lldbsuite.test.lldbtest import * 6from lldbsuite.test import lldbutil 7 8class TestPlatformProcessConnect(TestBase): 9 NO_DEBUG_INFO_TESTCASE = True 10 11 @skipIfRemote 12 @expectedFailureAll(hostoslist=["windows"], triple='.*-android') 13 @skipIfDarwin # lldb-server not found correctly 14 @expectedFailureAll(oslist=["windows"]) # process modules not loaded 15 @add_test_categories(["lldb-server"]) 16 def test_platform_process_connect(self): 17 self.build() 18 19 hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0] 20 listen_url = "[%s]:0"%hostname 21 22 port_file = self.getBuildArtifact("port") 23 commandline_args = [ 24 "platform", 25 "--listen", 26 listen_url, 27 "--socket-file", 28 port_file, 29 "--", 30 self.getBuildArtifact("a.out"), 31 "foo"] 32 self.spawnSubprocess( 33 lldbgdbserverutils.get_lldb_server_exe(), 34 commandline_args) 35 36 socket_id = lldbutil.wait_for_file_on_target(self, port_file) 37 38 new_platform = lldb.SBPlatform("remote-" + self.getPlatform()) 39 self.dbg.SetSelectedPlatform(new_platform) 40 41 connect_url = "connect://[%s]:%s" % (hostname, socket_id) 42 self.runCmd("platform connect %s" % connect_url) 43 44 lldbutil.run_break_set_by_symbol(self, "main") 45 process = self.process() 46 47 process.Continue() 48 49 frame = self.frame() 50 self.assertEqual(frame.GetFunction().GetName(), "main") 51 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2) 52 process.Continue() 53