File: TestThreadSelectionBug.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (53 lines) | stat: -rw-r--r-- 2,075 bytes parent folder | download | duplicates (10)
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
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from lldbsuite.test.gdbclientutils import *
from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase


class TestThreadSelectionBug(GDBRemoteTestBase):
    def test(self):
        class MyResponder(MockGDBServerResponder):
            def cont(self):
                # Simulate process stopping due to a raise(SIGINT)
                return "T01reason:signal"

        self.server.responder = MyResponder()
        target = self.createTarget("a.yaml")
        process = self.connect(target)
        python_os_plugin_path = os.path.join(self.getSourceDir(), "operating_system.py")
        command = "settings set target.process.python-os-plugin-path '{}'".format(
            python_os_plugin_path
        )
        self.dbg.HandleCommand(command)

        self.assertTrue(process, PROCESS_IS_VALID)
        self.assertEqual(process.GetNumThreads(), 3)

        # Verify our OS plug-in threads showed up
        thread = process.GetThreadByID(0x1)
        self.assertTrue(
            thread.IsValid(),
            "Make sure there is a thread 0x1 after we load the python OS plug-in",
        )
        thread = process.GetThreadByID(0x2)
        self.assertTrue(
            thread.IsValid(),
            "Make sure there is a thread 0x2 after we load the python OS plug-in",
        )
        thread = process.GetThreadByID(0x3)
        self.assertTrue(
            thread.IsValid(),
            "Make sure there is a thread 0x3 after we load the python OS plug-in",
        )

        # Verify that a thread other than 3 is selected.
        thread = process.GetSelectedThread()
        self.assertNotEqual(thread.GetThreadID(), 0x3)

        # Verify that we select the thread backed by physical thread 1, rather
        # than virtual thread 1. The mapping comes from the OS plugin, where we
        # specified that thread 3 is backed by real thread 1.
        process.Continue()
        thread = process.GetSelectedThread()
        self.assertEqual(thread.GetThreadID(), 0x3)