Hi,
On Sun, Apr 29, 2012 at 11:55 AM, <
mark.h...@tesco.net> wrote:
> Excellent, thanks. I can confirm that the patch gets me around the issue
> (the child is started without gdbserver).
Indeed there's a more flexible solution that doesn't require any
patch, however it works with QEMU 1.0 and later only.
First, ask to each instance of QEMU to unset the QEMU_GDB environment
variable:
proot -Q 'qemu-sh4 -U QEMU_GDB' ...
Then, set this variable to the expected port number right before
executing the program you want to debug. For examples:
* to debug the first process (parent):
env QEMU_GDB=1234 proot -Q 'qemu-sh4 -U QEMU_GDB' ...
# waiting for GDB client
* to debug a process launched interactively (or in a script):
host$ proot -Q 'qemu-sh4 -U QEMU_GDB' ...
guest$ /usr/bin/echo "Hello world"
Hello world
guest$ env QEMU_GDB=1234 /usr/bin/echo "Hello world"
# waiting for GDB client
* 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
solution.
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").
Cédric.