67 lines · python
1import lldb2 3 4class OperatingSystemPlugIn(object):5 """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class6 This version stops once with threads 0x111 and 0x222, then stops a second time with threads7 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 = None15 self.registers = None16 self.threads = None17 self.times_called = 018 if isinstance(process, lldb.SBProcess) and process.IsValid():19 self.process = process20 self.threads = None # Will be an dictionary containing info for each thread21 22 def get_target(self):23 return self.process.target24 25 def get_thread_info(self):26 self.times_called += 127 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.threads67