Завершать DAP при потере остановленного MAME

This commit is contained in:
Александр Петров
2026-09-16 15:12:42 +03:00
parent d25f28e1cd
commit 0a71f94240
8 changed files with 137 additions and 37 deletions
+21 -11
View File
@@ -72,28 +72,38 @@ class SessionController:
self.changed.notify_all()
def _poll(self) -> None:
next_idle_snapshot = 0.0
while not self.closed:
if not self.running:
time.sleep(.02)
continue
delay = next_idle_snapshot - time.monotonic()
if delay > 0:
time.sleep(min(delay, .05))
continue
try:
with self.lock:
snapshot = self.session.bridge.request('snapshot')
if snapshot['state'] == 'stopped':
location = self.session.where(snapshot)
if self.source_step is not None:
self._source_step_stopped(location)
elif self._handle_logpoints(location):
self.session.bridge.request('continue')
continue
else:
self.running = False
self._emit('stopped', {'reason': 'breakpoint', 'location': location})
if self.running:
location = self.session.where(snapshot)
if self.source_step is not None:
self._source_step_stopped(location)
elif self._handle_logpoints(location):
self.session.bridge.request('continue')
continue
else:
self.running = False
self._emit('stopped', {'reason': 'breakpoint', 'location': location})
elif snapshot['state'] == 'running' and not self.running:
# Команда из родного окна MAME тоже меняет состояние CPU.
self.running = True
self._emit('continued', {'reason': 'external'})
elif snapshot['state'] == 'invalidated':
self.running = False
self.source_step = None
self.closed = True
self._emit('invalidated', {'reason': 'reset_or_load'})
if not self.running:
next_idle_snapshot = time.monotonic() + .5
except (BridgeError, SessionError, ValueError, OSError) as error:
self.running = False
self.source_step = None