On 01/22/2013 03:59 PM, Jan Kiszka wrote: > On 2013-01-22 15:04, Fabien Chouteau wrote: >> Hello Qemu folks, >> >> I'm sorry to be (very) late, but I do not agree with this patch. >> >> Your modification just makes the "kill" command behave like "detach", so >> why not use "detach" instead? > > gdb automatically issues kill when you quite. This is where most > casualties came from.
Hello Jan, I asked Joel Brobecker(CC'd), a Gdb maintainer, about this issue. Here is the answer: On 01/23/2013 12:49 PM, Joel Brobecker wrote: >> There's a patch in Qemu's Gdb remote server that makes the "kill" >> command act like "detach". > > It seems incorrect to me. The behavior should be as follow: > - If the debugger was attached to an existing process, the "quit" > command should result in a "detach". > - If the debugger created the process, then "quit" should result > in a "kill". > > With that in mind, if GDB sends a "kill", it means that Qemu told > GDB that it created the process. What it should be doing, if a "kill" > is not the desired behavior, is to tell GDB that the process was > attached to. For this, there is qAttached packet. See the GDB > Users Manual, and in particular: > > | `qAttached:pid' > | Return an indication of whether the remote server attached to an > | existing process or created a new process. When the multiprocess > | protocol extensions are supported (see multiprocess extensions), pid is > | an integer in hexadecimal format identifying the target process. > | Otherwise, gdb will omit the pid field and the query packet will be > | simplified as `qAttached'. This query is used, for example, to know > | whether the remote process should be detached or killed when a gdb > | session is ended with the quit command. > | > | Reply: > | > | `1' > | The remote server attached to an existing process. > | `0' > | The remote server created a new process. > | `E NN' > | A badly formed request or an error was encountered. qAttached is not supported in Qemu yet, this explains why Gdb sends "kill" at the end of debug session. I will implement it and revert your patch. Gdb will automatically detach instead of kill at the end of debugging session. Is that OK? Regards, -- Fabien Chouteau