Завершать DAP при потере остановленного MAME
This commit is contained in:
@@ -140,6 +140,8 @@ class DapEngine:
|
||||
elif event['event'] == 'output':
|
||||
translated.append(('output', {'category': event['body'].get('category','console'),
|
||||
'output': event['body']['output']}))
|
||||
if result['closed'] and not any(name == 'terminated' for name, _ in translated):
|
||||
translated.append(('terminated', {'restart': False}))
|
||||
return translated, result['closed']
|
||||
|
||||
@staticmethod
|
||||
|
||||
+21
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user