File: TestConcurrentVFork.py

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (128 lines) | stat: -rw-r--r-- 5,841 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""
Make sure that the concurrent vfork() from multiple threads works correctly.
"""

import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *


class TestConcurrentVFork(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    def build_run_to_breakpoint(self, use_fork, call_exec):
        self.build()

        args = []
        if use_fork:
            args.append("--fork")
        if call_exec:
            args.append("--exec")
        launch_info = lldb.SBLaunchInfo(args)
        launch_info.SetWorkingDirectory(self.getBuildDir())

        return lldbutil.run_to_source_breakpoint(
            self, "// break here", lldb.SBFileSpec("main.cpp")
        )

    def follow_parent_helper(self, use_fork, call_exec):
        (target, process, thread, bkpt) = self.build_run_to_breakpoint(
            use_fork, call_exec
        )

        parent_pid = target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned()
        self.runCmd("settings set target.process.follow-fork-mode parent")
        self.runCmd("settings set target.process.stop-on-exec False", check=False)
        self.expect(
            "continue", substrs=[f"Process {parent_pid} exited with status = 0"]
        )

    def follow_child_helper(self, use_fork, call_exec):
        self.build_run_to_breakpoint(use_fork, call_exec)

        self.runCmd("settings set target.process.follow-fork-mode child")
        self.runCmd("settings set target.process.stop-on-exec False", check=False)
        # Child process exits with code "index + 10" since index is [0-4]
        # so the exit code should be 1[0-4]
        self.expect("continue", patterns=[r"exited with status = 1[0-4]"])

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_parent_vfork_no_exec(self):
        """
        Make sure that debugging concurrent vfork() from multiple threads won't crash lldb during follow-parent.
        And follow-parent successfully detach all child processes and exit debugger without calling exec.
        """
        self.follow_parent_helper(use_fork=False, call_exec=False)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_parent_fork_no_exec(self):
        """
        Make sure that debugging concurrent fork() from multiple threads won't crash lldb during follow-parent.
        And follow-parent successfully detach all child processes and exit debugger without calling exec
        """
        self.follow_parent_helper(use_fork=True, call_exec=False)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_parent_vfork_call_exec(self):
        """
        Make sure that debugging concurrent vfork() from multiple threads won't crash lldb during follow-parent.
        And follow-parent successfully detach all child processes and exit debugger after calling exec.
        """
        self.follow_parent_helper(use_fork=False, call_exec=True)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_parent_fork_call_exec(self):
        """
        Make sure that debugging concurrent vfork() from multiple threads won't crash lldb during follow-parent.
        And follow-parent successfully detach all child processes and exit debugger after calling exec.
        """
        self.follow_parent_helper(use_fork=True, call_exec=True)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_child_vfork_no_exec(self):
        """
        Make sure that debugging concurrent vfork() from multiple threads won't crash lldb during follow-child.
        And follow-child successfully detach parent process and exit child process with correct exit code without calling exec.
        """
        self.follow_child_helper(use_fork=False, call_exec=False)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_child_fork_no_exec(self):
        """
        Make sure that debugging concurrent fork() from multiple threads won't crash lldb during follow-child.
        And follow-child successfully detach parent process and exit child process with correct exit code without calling exec.
        """
        self.follow_child_helper(use_fork=True, call_exec=False)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_child_vfork_call_exec(self):
        """
        Make sure that debugging concurrent vfork() from multiple threads won't crash lldb during follow-child.
        And follow-child successfully detach parent process and exit child process with correct exit code after calling exec.
        """
        self.follow_child_helper(use_fork=False, call_exec=True)

    @skipUnlessPlatform(["linux"])
    # https://github.com/llvm/llvm-project/issues/85084.
    @skipIf(oslist=["linux"], archs=["aarch64", "arm"])
    def test_follow_child_fork_call_exec(self):
        """
        Make sure that debugging concurrent fork() from multiple threads won't crash lldb during follow-child.
        And follow-child successfully detach parent process and exit child process with correct exit code after calling exec.
        """
        self.follow_child_helper(use_fork=True, call_exec=True)