3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
.decorators
import *
5 from lldbsuite
.test
.gdbclientutils
import *
6 from lldbsuite
.test
.lldbgdbclient
import GDBRemoteTestBase
9 class TestMultiprocess(GDBRemoteTestBase
):
10 def base_test(self
, variant
, follow_child
=False):
11 class MyResponder(MockGDBServerResponder
):
16 self
.property = "{}-events+".format(variant
)
18 def qSupported(self
, client_supported
):
19 assert "multiprocess+" in client_supported
20 assert self
.property in client_supported
21 return "{};multiprocess+;{}".format(
22 super().qSupported(client_supported
), self
.property
25 def qfThreadInfo(self
):
31 return "T0fthread:p400.10200;reason:{0};{0}:p401.10400;".format(
37 self
.detached
= packet
40 self
.server
.responder
= MyResponder()
41 target
= self
.dbg
.CreateTarget("")
43 self
.runCmd("log enable gdb-remote packets")
44 self
.addTearDownHook(lambda: self
.runCmd("log disable gdb-remote packets"))
46 self
.runCmd("settings set target.process.follow-fork-mode child")
47 process
= self
.connect(target
)
48 self
.assertEqual(process
.GetProcessID(), 1024)
51 self
.server
.responder
.detached
, r
"D;0*400" if follow_child
else r
"D;0*401"
53 self
.assertEqual(process
.GetProcessID(), 1025 if follow_child
else 1024)
56 self
.base_test("fork")
59 self
.base_test("vfork")
61 def test_fork_follow_child(self
):
62 self
.base_test("fork", follow_child
=True)
64 def test_vfork_follow_child(self
):
65 self
.base_test("vfork", follow_child
=True)