* to debug a child process: add a call to "setenv()" before the call
to "exec()". It's a bit intrusive in this case but it's a reliable
It works because QEMU 1.0+ handles options passed through environment
variable before command-line options, thus QEMU_GDB is unset after
being used by QEMU itself. Finally, only the first QEMU instance that
sees this variable is affected.
Unlike the previous patch, this solution doesn't discard all QEMU
options. Also, it works with any QEMU options (see "qemu-sh4 -h").
Thanks for the update. I'll try the approach for "debugging the parent process" this evening - as you say if will allow me to keep other QEMU options in the child.
Re the "debugging a child process" option - the approach you suggest won't work if you don't have the source of the program, i.e. the ability to edit it and add in setenv(). I think it would be useful in such scenarios to have gdbserver automatically started on an incrementing port number, then the child process would be stopped at its start point and make debugging simpler. Just my view obviously.