Started implementing debugging facilities

This commit is contained in:
2022-12-14 21:45:24 +00:00
parent 51e065faaf
commit 72bf6faadd
11 changed files with 124 additions and 11 deletions

View File

@@ -0,0 +1,62 @@
#!/usr/bin/env python3
import sys
import os
import subprocess
import time
import signal
qemu_args = []
gdb_args = []
cur_program = ''
def run_process(args):
p = subprocess.Popen(args,
bufsize=1,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
while True:
retcode = p.poll()
line = p.stdout.read(1)
yield line
if retcode is not None:
break
for arg in sys.argv[1:]:
if arg == '--qemu':
cur_program = 'qemu'
continue
elif arg == '--gdb':
cur_program = 'gdb'
continue
if cur_program == 'qemu':
qemu_args += [arg]
elif cur_program == 'gdb':
gdb_args += [arg]
else:
print('No program specified')
exit(-1)
env = os.environ.copy()
signal.signal(signal.SIGINT, signal.SIG_IGN)
qemu = subprocess.Popen(qemu_args,
env=env,
start_new_session=True,
restore_signals=False)
time.sleep(1)
if qemu.poll() is not None:
print('Failed to start QEMU')
exit(-1)
subprocess.run(gdb_args,
env=env,
stdout=sys.stdout,
stdin=sys.stdin,
stderr=sys.stderr)
qemu.kill()