diff mbox

[v2,1/2] Add GDB qAttached support

Message ID 51F2BF4F.8030107@siemens.com
State New
Headers show

Commit Message

Jan Kiszka July 26, 2013, 6:26 p.m. UTC
With this patch QEMU handles qAttached request from gdb. When QEMU
replies 1, GDB sends a "detach" command at the end of a debugging
session otherwise GDB sends "kill".

The default value for qAttached is 1 on system emulation and 0 on user
emulation.

Based on original version by Fabien Chouteau.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

v2: Rebase over master

 gdbstub.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

Comments

Andreas Färber March 12, 2014, 4:58 p.m. UTC | #1
Am 26.07.2013 20:26, schrieb Jan Kiszka:
> With this patch QEMU handles qAttached request from gdb. When QEMU

"With this patch" is always weird to read in Git history, also a
"gdbstub: " prefix would've been nice for consistency.

> replies 1, GDB sends a "detach" command at the end of a debugging
> session otherwise GDB sends "kill".
> 
> The default value for qAttached is 1 on system emulation and 0 on user
> emulation.
> 
> Based on original version by Fabien Chouteau.

If this is based on code by Fabien, shouldn't it carry his Signed-off-by
before yours?

Since "GDB stub" is in "Odd Fixes" state, maybe just step up as
maintainer and send a pull like for SLIRP? :)

Cheers,
Andreas

> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> v2: Rebase over master
> 
>  gdbstub.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/gdbstub.c b/gdbstub.c
> index 35ca7c2..4a6cc51 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -42,6 +42,12 @@
>  #include "sysemu/kvm.h"
>  #include "qemu/bitops.h"
>  
> +#ifdef CONFIG_USER_ONLY
> +#define GDB_ATTACHED "0"
> +#else
> +#define GDB_ATTACHED "1"
> +#endif
> +
>  static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
>                                           uint8_t *buf, int len, bool is_write)
>  {
> @@ -2489,6 +2495,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
>              break;
>          }
>  #endif
> +        if (strncmp(p, "Attached", 8) == 0) {
> +            put_packet(s, GDB_ATTACHED);
> +            break;
> +        }
>          /* Unrecognised 'q' command.  */
>          goto unknown_command;
>  
>
Jan Kiszka March 12, 2014, 5:31 p.m. UTC | #2
On 2014-03-12 17:58, Andreas Färber wrote:
> Am 26.07.2013 20:26, schrieb Jan Kiszka:
>> With this patch QEMU handles qAttached request from gdb. When QEMU
> 
> "With this patch" is always weird to read in Git history, also a
> "gdbstub: " prefix would've been nice for consistency.

Yes, will rephrase this.

> 
>> replies 1, GDB sends a "detach" command at the end of a debugging
>> session otherwise GDB sends "kill".
>>
>> The default value for qAttached is 1 on system emulation and 0 on user
>> emulation.
>>
>> Based on original version by Fabien Chouteau.
> 
> If this is based on code by Fabien, shouldn't it carry his Signed-off-by
> before yours?

Need to check how similar our versions actually are, if I can reuse his
signed-off or if I changed it (in that case it's not appropriate to keep
the original signed-off - according to my understanding).

> 
> Since "GDB stub" is in "Odd Fixes" state, maybe just step up as
> maintainer and send a pull like for SLIRP? :)

Oh, I can surely send a pull, but I can't handle another maintainership
properly. Slirp already became a stepchild...

Thanks for looking into this.

Jan
Peter Maydell March 12, 2014, 5:50 p.m. UTC | #3
On 12 March 2014 17:31, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On 2014-03-12 17:58, Andreas Färber wrote:
>> Am 26.07.2013 20:26, schrieb Jan Kiszka:
>>> Based on original version by Fabien Chouteau.
>>
>> If this is based on code by Fabien, shouldn't it carry his Signed-off-by
>> before yours?
>
> Need to check how similar our versions actually are, if I can reuse his
> signed-off or if I changed it (in that case it's not appropriate to keep
> the original signed-off - according to my understanding).

If there's still some of Fabien's code in there then as I understand it
the usual approach is to retain his authorship and Signed-off-by:,
and then follow that with "[you: summary of your changes]" and then
your signed-off-by. See for instance commit f19e00d77 where I
did a fair amount of rework on a patch originally submitted by Alex.

If you have significantly or totally rewritten the code then you can give
the patch your own author and signed-off-by, and acknowledge that
somebody else found the problem or suggested the general
approach for a fix with a Reported-by: or Suggested-by: tag.

Where exactly the line between the two lies is a judgement call.

This is really about making sure we give credit where due (and
conversely that we don't silently attribute later changes to an
original author who might not agree with them). (The legal audit
trail aspect is satisfied even without the original author's signoff
provided that original work was under a suitable license; this is
for instance how signoffs work for big chunks of other-project
code we import like the binutils disassemblers, libvixl, etc.)

thanks
-- PMM
diff mbox

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 35ca7c2..4a6cc51 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -42,6 +42,12 @@ 
 #include "sysemu/kvm.h"
 #include "qemu/bitops.h"
 
+#ifdef CONFIG_USER_ONLY
+#define GDB_ATTACHED "0"
+#else
+#define GDB_ATTACHED "1"
+#endif
+
 static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
                                          uint8_t *buf, int len, bool is_write)
 {
@@ -2489,6 +2495,10 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
             break;
         }
 #endif
+        if (strncmp(p, "Attached", 8) == 0) {
+            put_packet(s, GDB_ATTACHED);
+            break;
+        }
         /* Unrecognised 'q' command.  */
         goto unknown_command;