xref: /llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1b601c671SMichał Górnyimport lldb
2121cff78SPavel Labathimport unittest
3b601c671SMichał Górnyfrom lldbsuite.test.lldbtest import *
4b601c671SMichał Górnyfrom lldbsuite.test.decorators import *
533c0f93fSPavel Labathfrom lldbsuite.test.gdbclientutils import *
633c0f93fSPavel Labathfrom lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
7b601c671SMichał Górny
8b601c671SMichał Górny
9b601c671SMichał Górnyclass TestMultiprocess(GDBRemoteTestBase):
10b601c671SMichał Górny    def test_qfThreadInfo(self):
11b601c671SMichał Górny        class MyResponder(MockGDBServerResponder):
12b601c671SMichał Górny            def qfThreadInfo(self):
13b601c671SMichał Górny                return "mp400.10200,p400.10204,p401.10300,p400.10208"
14b601c671SMichał Górny
15b601c671SMichał Górny        self.server.responder = MyResponder()
16*2238dcc3SJonas Devlieghere        target = self.dbg.CreateTarget("")
17b601c671SMichał Górny        if self.TraceOn():
18b601c671SMichał Górny            self.runCmd("log enable gdb-remote packets")
19*2238dcc3SJonas Devlieghere            self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets"))
20b601c671SMichał Górny        process = self.connect(target)
21b601c671SMichał Górny        self.assertEqual(process.id, 0x400)
22b601c671SMichał Górny        self.assertEqual(
23b601c671SMichał Górny            [process.threads[i].id for i in range(process.num_threads)],
24*2238dcc3SJonas Devlieghere            [0x10200, 0x10204, 0x10208],
25*2238dcc3SJonas Devlieghere        )
26b601c671SMichał Górny
27b601c671SMichał Górny    def test_stop_reason(self):
28b601c671SMichał Górny        class MyResponder(MockGDBServerResponder):
29b601c671SMichał Górny            def qfThreadInfo(self):
30b601c671SMichał Górny                return "mp400.10200,p400.10204"
31b601c671SMichał Górny
32b601c671SMichał Górny            def cont(self):
33b601c671SMichał Górny                return "S02thread:p400.10200;"
34b601c671SMichał Górny
35b601c671SMichał Górny        self.server.responder = MyResponder()
36*2238dcc3SJonas Devlieghere        target = self.dbg.CreateTarget("")
37b601c671SMichał Górny        if self.TraceOn():
38b601c671SMichał Górny            self.runCmd("log enable gdb-remote packets")
39*2238dcc3SJonas Devlieghere            self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets"))
40b601c671SMichał Górny        process = self.connect(target)
41b601c671SMichał Górny        process.Continue()
42*2238dcc3SJonas Devlieghere        self.assertEqual(
43*2238dcc3SJonas Devlieghere            process.GetThreadByID(0x10200).stop_reason, lldb.eStopReasonSignal
44*2238dcc3SJonas Devlieghere        )
45*2238dcc3SJonas Devlieghere        self.assertEqual(
46*2238dcc3SJonas Devlieghere            process.GetThreadByID(0x10204).stop_reason, lldb.eStopReasonNone
47*2238dcc3SJonas Devlieghere        )
48