xref: /llvm-project/lldb/test/API/functionalities/gdb_remote_client/operating_system.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprechtimport lldb
299451b44SJordan Rupprecht
399451b44SJordan Rupprecht
499451b44SJordan Rupprechtclass OperatingSystemPlugIn(object):
599451b44SJordan Rupprecht    """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
699451b44SJordan Rupprecht
799451b44SJordan Rupprecht    def __init__(self, process):
8*2238dcc3SJonas Devlieghere        """Initialization needs a valid.SBProcess object.
999451b44SJordan Rupprecht
1099451b44SJordan Rupprecht        This plug-in will get created after a live process is valid and has stopped for the first time.
11*2238dcc3SJonas Devlieghere        """
1299451b44SJordan Rupprecht        self.process = None
1399451b44SJordan Rupprecht        self.registers = None
1499451b44SJordan Rupprecht        self.threads = None
1599451b44SJordan Rupprecht        if isinstance(process, lldb.SBProcess) and process.IsValid():
1699451b44SJordan Rupprecht            self.process = process
1799451b44SJordan Rupprecht            self.threads = None  # Will be an dictionary containing info for each thread
1899451b44SJordan Rupprecht
1999451b44SJordan Rupprecht    def get_target(self):
2099451b44SJordan Rupprecht        return self.process.target
2199451b44SJordan Rupprecht
2299451b44SJordan Rupprecht    def get_thread_info(self):
2399451b44SJordan Rupprecht        if not self.threads:
24*2238dcc3SJonas Devlieghere            self.threads = [
25*2238dcc3SJonas Devlieghere                {
26*2238dcc3SJonas Devlieghere                    "tid": 0x1,
27*2238dcc3SJonas Devlieghere                    "name": "one",
28*2238dcc3SJonas Devlieghere                    "queue": "queue1",
29*2238dcc3SJonas Devlieghere                    "state": "stopped",
30*2238dcc3SJonas Devlieghere                    "stop_reason": "none",
31*2238dcc3SJonas Devlieghere                },
32*2238dcc3SJonas Devlieghere                {
33*2238dcc3SJonas Devlieghere                    "tid": 0x2,
34*2238dcc3SJonas Devlieghere                    "name": "two",
35*2238dcc3SJonas Devlieghere                    "queue": "queue2",
36*2238dcc3SJonas Devlieghere                    "state": "stopped",
37*2238dcc3SJonas Devlieghere                    "stop_reason": "none",
38*2238dcc3SJonas Devlieghere                },
39*2238dcc3SJonas Devlieghere                {
40*2238dcc3SJonas Devlieghere                    "tid": 0x3,
41*2238dcc3SJonas Devlieghere                    "name": "three",
42*2238dcc3SJonas Devlieghere                    "queue": "queue3",
43*2238dcc3SJonas Devlieghere                    "state": "stopped",
44*2238dcc3SJonas Devlieghere                    "stop_reason": "sigstop",
45*2238dcc3SJonas Devlieghere                    "core": 0,
46*2238dcc3SJonas Devlieghere                },
47*2238dcc3SJonas Devlieghere            ]
4899451b44SJordan Rupprecht        return self.threads
49