Closed nathanchance closed 1 year ago
Though I'm still perplexed; why does
sys.exit(1)
not end the process? That still seems like a bug to me.
According to Python's documentation around sys.exit()
and subprocess.Popen()
:
A call to
sys.exit()
is translated into an exception so that clean-up handlers (finally
clauses oftry
statements) can be executed, and so that a debugger can execute a script without running the risk of losing control.Popen objects are supported as context managers via the
with
statement: on exit, standard file descriptors are closed, and the process is waited for.
So what I suspect is happening here is that sys.exit()
is called within the with
statement, raising a SystemExit
exception, and the interpreter waits for QEMU to exit before the script is allowed to exit. However, we spawned QEMU with -S
, which freezes the CPU until it is started with GDB, so the interpreter hangs. I do not know if that is really a bug. We could potentially solve it by wrapping the whole with
statement in a try
statement. But this seems like a better fix in my opinion.
Otherwise, the call to
sys.exit()
indie()
does not work and we end up hanging.Additionally, move it out of the while loop, as it does not make send to check for
gdb_bin
every single time we want to invoke it.