Завершать DAP при потере остановленного MAME
This commit is contained in:
@@ -10,6 +10,7 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import select
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -90,6 +91,8 @@ def main():
|
||||
parser.add_argument('--build', default=None)
|
||||
parser.add_argument('--app-hdd', default=None)
|
||||
parser.add_argument('--launch-path', default=None)
|
||||
parser.add_argument('--exit-while-stopped', action='store_true',
|
||||
help='аварийно завершить собственный MAME на main и ждать DAP terminated')
|
||||
options, _ = parser.parse_known_args()
|
||||
if not PYTHON.is_file():
|
||||
raise RuntimeError('Нет local pyenv shim: '+str(PYTHON))
|
||||
@@ -121,6 +124,18 @@ def main():
|
||||
frame = frame_response['body']['stackFrames'][0]
|
||||
if frame['name'] != 'main':
|
||||
raise RuntimeError('Не main: '+str(frame))
|
||||
if options.exit_while_stopped:
|
||||
os.kill(launched['body']['mamePid'], signal.SIGKILL)
|
||||
deadline = time.monotonic()+15
|
||||
while time.monotonic() < deadline:
|
||||
message, buffer = receive(process, buffer, deadline-time.monotonic())
|
||||
if message.get('event') == 'terminated':
|
||||
print(json.dumps({'event': 'idle_mame_exit_terminates_dap',
|
||||
'frame': frame}, ensure_ascii=False), flush=True)
|
||||
send(process, 5, 'disconnect')
|
||||
wait_response(process, buffer, 'disconnect', 10)
|
||||
return 0
|
||||
raise RuntimeError('После закрытия остановленного MAME нет DAP terminated')
|
||||
if '--waitkey' in sys.argv:
|
||||
send(process, 5, 'setBreakpoints', {
|
||||
'source': {'path': str(ROOT/'tests/hello/hello.c')},
|
||||
|
||||
Reference in New Issue
Block a user