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