LLDB Bridge class, exposing the common expected interface for the OpenImageDebugger to access the required buffer data and interact with the debugger.
| 17 | |
| 18 | |
| 19 | class LldbBridge(BridgeInterface): |
| 20 | """ |
| 21 | LLDB Bridge class, exposing the common expected interface for the OpenImageDebugger |
| 22 | to access the required buffer data and interact with the debugger. |
| 23 | """ |
| 24 | |
| 25 | def __init__(self, type_bridge): |
| 26 | # type: (TypeInspectorInterface) -> None |
| 27 | global instance |
| 28 | instance = self |
| 29 | self._type_bridge = type_bridge |
| 30 | self._pending_requests = [] |
| 31 | self._lock = threading.Lock() |
| 32 | self._event_queue = [] |
| 33 | self._event_handler = None |
| 34 | self._last_thread_id = 0 |
| 35 | self._last_frame_idx = 0 |
| 36 | |
| 37 | # Store debugger from the main thread since it isn't available from an event loop. |
| 38 | self._debugger = lldb.debugger |
| 39 | |
| 40 | event_loop_thread = threading.Thread(target=self.event_loop) |
| 41 | event_loop_thread.daemon = True |
| 42 | event_loop_thread.start() |
| 43 | |
| 44 | def get_lldb_backend(self): |
| 45 | # type: () -> lldb.SBDebugger |
| 46 | return self._debugger |
| 47 | |
| 48 | def get_backend_name(self): |
| 49 | return 'lldb' |
| 50 | |
| 51 | def _check_frame_modification(self): |
| 52 | process = self._get_process(self.get_lldb_backend()) |
| 53 | if process.is_stopped: |
| 54 | thread = self._get_thread(process) |
| 55 | frame = self._get_frame(thread) |
| 56 | |
| 57 | thread_id = thread.id if thread is not None else 0 |
| 58 | frame_idx = frame.idx if thread is not None else 0 |
| 59 | |
| 60 | frame_was_updated = thread_id != self._last_thread_id or \ |
| 61 | frame_idx != self._last_frame_idx |
| 62 | |
| 63 | self._last_thread_id = thread_id |
| 64 | self._last_frame_idx = frame_idx |
| 65 | |
| 66 | if frame_was_updated: |
| 67 | with self._lock: |
| 68 | self._event_queue.append('stop') |
| 69 | |
| 70 | def event_loop(self): |
| 71 | while True: |
| 72 | self._check_frame_modification() |
| 73 | |
| 74 | requests_to_process = [] |
| 75 | with self._lock: |
| 76 | requests_to_process = self._pending_requests |
nothing calls this directly
no outgoing calls
no test coverage detected