Files
clang-p2996/lldb/test/API/functionalities/gdb_remote_client/TestFork.py
Michał Górny 0a1d80d56e [lldb] [gdb-remote client] Support minimal fork/vfork handling
Add a support for handling fork/vfork stops in LLGS client.  At this
point, it only sends a detach packet for the newly forked child
(and implicitly resumes the parent).

Differential Revision: https://reviews.llvm.org/D100206
2021-08-30 10:24:38 +02:00

53 lines
1.7 KiB
Python

from __future__ import print_function
import lldb
import unittest
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from gdbclientutils import *
class TestMultiprocess(GDBRemoteTestBase):
def base_test(self, variant):
class MyResponder(MockGDBServerResponder):
def __init__(self):
super().__init__()
self.first = True
self.detached = None
self.property = "{}-events+".format(variant)
def qSupported(self, client_supported):
assert "multiprocess+" in client_supported
assert self.property in client_supported
return "{};multiprocess+;{}".format(
super().qSupported(client_supported), self.property)
def qfThreadInfo(self):
return "mp400.10200"
def cont(self):
if self.first:
self.first = False
return ("T0fthread:p400.10200;reason:{0};{0}:p401.10400;"
.format(variant))
return "W00"
def D(self, packet):
self.detached = packet
return "OK"
self.server.responder = MyResponder()
target = self.dbg.CreateTarget('')
if self.TraceOn():
self.runCmd("log enable gdb-remote packets")
self.addTearDownHook(
lambda: self.runCmd("log disable gdb-remote packets"))
process = self.connect(target)
process.Continue()
self.assertRegex(self.server.responder.detached, r"D;0*401")
def test_fork(self):
self.base_test("fork")
def test_vfork(self):
self.base_test("vfork")