xref: /llvm-project/lldb/test/API/functionalities/gdb_remote_client/operating_system_2.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1import lldb
2
3
4class OperatingSystemPlugIn(object):
5    """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class
6    This version stops once with threads 0x111 and 0x222, then stops a second time with threads
7    0x111 and 0x333."""
8
9    def __init__(self, process):
10        """Initialization needs a valid.SBProcess object.
11
12        This plug-in will get created after a live process is valid and has stopped for the first time.
13        """
14        self.process = None
15        self.registers = None
16        self.threads = None
17        self.times_called = 0
18        if isinstance(process, lldb.SBProcess) and process.IsValid():
19            self.process = process
20            self.threads = None  # Will be an dictionary containing info for each thread
21
22    def get_target(self):
23        return self.process.target
24
25    def get_thread_info(self):
26        self.times_called += 1
27
28        if self.times_called == 1:
29            self.threads = [
30                {
31                    "tid": 0x111,
32                    "name": "one",
33                    "queue": "queue1",
34                    "state": "stopped",
35                    "stop_reason": "none",
36                    "core": 1,
37                },
38                {
39                    "tid": 0x222,
40                    "name": "two",
41                    "queue": "queue2",
42                    "state": "stopped",
43                    "stop_reason": "none",
44                    "core": 0,
45                },
46            ]
47        else:
48            self.threads = [
49                {
50                    "tid": 0x111,
51                    "name": "one",
52                    "queue": "queue1",
53                    "state": "stopped",
54                    "stop_reason": "none",
55                    "core": 1,
56                },
57                {
58                    "tid": 0x333,
59                    "name": "three",
60                    "queue": "queue3",
61                    "state": "stopped",
62                    "stop_reason": "none",
63                    "core": 0,
64                },
65            ]
66        return self.threads
67