4 import gdbremote_testcase
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
11 mydir = TestBase.compute_mydir(__file__)
14 super(TestPlatformProcessConnect, self).setUp()
15 self._initial_platform = lldb.DBG.GetSelectedPlatform()
18 lldb.DBG.SetSelectedPlatform(self._initial_platform)
19 super(TestPlatformProcessConnect, self).tearDown()
24 @expectedFailureAll(hostoslist=["windows"], triple='.*-android')
25 def test_platform_process_connect(self):
27 self.init_llgs_test(False)
29 working_dir = lldb.remote_platform.GetWorkingDirectory()
30 src = lldb.SBFileSpec(self.getBuildArtifact("a.out"))
31 dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
32 err = lldb.remote_platform.Put(src, dest)
35 "Unable copy '%s' to '%s'.\n>>> %s" %
36 (f, wd, err.GetCString()))
38 m = re.search("^(.*)://([^:/]*)", configuration.lldb_platform_url)
41 unix_protocol = protocol.startswith("unix-")
43 p = re.search("^(.*)-connect", protocol)
44 path = lldbutil.join_remote_paths(configuration.lldb_platform_working_dir,
45 self.getBuildDirBasename(), "platform-%d.sock" % int(time.time()))
46 listen_url = "%s://%s" % (p.group(1), path)
50 port_file = "%s/port" % working_dir
62 self.debug_monitor_exe,
65 self.addTearDownHook(self.cleanupSubprocesses)
67 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
69 new_debugger = lldb.SBDebugger.Create()
70 new_debugger.SetAsync(False)
72 def del_debugger(new_debugger=new_debugger):
74 self.addTearDownHook(del_debugger)
76 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
77 new_debugger.SetSelectedPlatform(new_platform)
78 new_interpreter = new_debugger.GetCommandInterpreter()
81 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
83 connect_url = "%s://%s:%s" % (protocol, hostname, socket_id)
85 command = "platform connect %s" % (connect_url)
86 result = lldb.SBCommandReturnObject()
87 new_interpreter.HandleCommand(command, result)
90 "platform process connect failed: %s" %
93 target = new_debugger.GetSelectedTarget()
94 process = target.GetProcess()
95 thread = process.GetThreadAtIndex(0)
97 breakpoint = target.BreakpointCreateByName("main")
100 frame = thread.GetFrameAtIndex(0)
101 self.assertEqual(frame.GetFunction().GetName(), "main")
102 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)