xref: /llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py (revision 4cc8f2a017c76af25234afc7c380550e9c93135c)
1import lldb
2import binascii
3import os
4from lldbsuite.test.lldbtest import *
5from lldbsuite.test.decorators import *
6from lldbsuite.test.gdbclientutils import *
7from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
8
9
10@skipIfRemote
11class TestProcessConnect(GDBRemoteTestBase):
12
13    NO_DEBUG_INFO_TESTCASE = True
14
15    def test_gdb_remote_sync(self):
16        """Test the gdb-remote command in synchronous mode"""
17        try:
18            self.dbg.SetAsync(False)
19            self.expect("gdb-remote " + self.server.get_connect_address(),
20                        substrs=['Process', 'stopped'])
21        finally:
22            self.dbg.GetSelectedTarget().GetProcess().Kill()
23
24    def test_gdb_remote_async(self):
25        """Test the gdb-remote command in asynchronous mode"""
26        try:
27            self.dbg.SetAsync(True)
28            self.expect("gdb-remote " + self.server.get_connect_address(),
29                        matching=False,
30                        substrs=['Process', 'stopped'])
31            lldbutil.expect_state_changes(self, self.dbg.GetListener(),
32                                          self.process(), [lldb.eStateStopped])
33        finally:
34            self.dbg.GetSelectedTarget().GetProcess().Kill()
35        lldbutil.expect_state_changes(self, self.dbg.GetListener(),
36                                      self.process(), [lldb.eStateExited])
37
38    @skipIfWindows
39    def test_process_connect_sync(self):
40        """Test the gdb-remote command in synchronous mode"""
41        try:
42            self.dbg.SetAsync(False)
43            self.expect("platform select remote-gdb-server",
44                        substrs=['Platform: remote-gdb-server', 'Connected: no'])
45            self.expect("process connect " + self.server.get_connect_url(),
46                        substrs=['Process', 'stopped'])
47        finally:
48            self.dbg.GetSelectedTarget().GetProcess().Kill()
49
50    @skipIfWindows
51    def test_process_connect_async(self):
52        """Test the gdb-remote command in asynchronous mode"""
53        try:
54            self.dbg.SetAsync(True)
55            self.expect("platform select remote-gdb-server",
56                        substrs=['Platform: remote-gdb-server', 'Connected: no'])
57            self.expect("process connect " + self.server.get_connect_url(),
58                        matching=False,
59                        substrs=['Process', 'stopped'])
60            lldbutil.expect_state_changes(self, self.dbg.GetListener(),
61                                          self.process(), [lldb.eStateStopped])
62        finally:
63            self.dbg.GetSelectedTarget().GetProcess().Kill()
64        lldbutil.expect_state_changes(self, self.dbg.GetListener(),
65                                      self.process(), [lldb.eStateExited])
66