Skip to contentSkip to conversation

gdbstub: Send a reply to the vKill packet.

PATCH Applied Sandra Loosemore 3 participants 4 messages Feb 12, 2019 – Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdbstub: Send a reply to the vKill packet.

Per the GDB remote protocol documentation

https://sourceware.org/gdb/current/onlinedocs/gdb/Packets.html#index-vKill-packet

the debug stub is expected to send a reply to the 'vKill' packet. At least some versions of GDB crash if the gdb stub simply exits without sending a reply. This patch fixes QEMU's gdb stub to conform to the expected behavior.

Note that QEMU's existing handling of the legacy 'k' packet is
correct: in that case GDB does not expect a reply, and QEMU does not send one.

---
 gdbstub.c | 1 +
 1 file changed, 1 insertion(+)
gdbstub.c +1 -0
index 70cf330..eb129f6 100644
@@ -1363,6 +1363,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
             break;
         } else if (strncmp(p, "Kill;", 5) == 0) {
             /* Kill the target */
+            put_packet(s, "OK");
             error_report("QEMU: Terminated via GDBstub");
             exit(0);
         } else {
Signature · 1 line
2.8.1
#1 lore raw
Quoted 10 lines · Sandra Loosemore

Per the GDB remote protocol documentation

https://sourceware.org/gdb/current/onlinedocs/gdb/Packets.html#index-vKill-packet

the debug stub is expected to send a reply to the 'vKill' packet. At least some versions of GDB crash if the gdb stub simply exits without sending a reply. This patch fixes QEMU's gdb stub to conform to the expected behavior.

Quoted 5 lines

Note that QEMU's existing handling of the legacy 'k' packet is
correct: in that case GDB does not expect a reply, and QEMU does not send one.

Thanks, applied to target-arm.next.

As an aside, do you know if there is any kind of test suite for the remote protocol that implementors of a debug stub can use to check that they're conforming to it?

-- PMM

#2 lore raw
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Sandra Loosemore

Per the GDB remote protocol documentation

https://sourceware.org/gdb/current/onlinedocs/gdb/Packets.html#index-vKill-packet

the debug stub is expected to send a reply to the 'vKill' packet. At least some versions of GDB crash if the gdb stub simply exits without sending a reply. This patch fixes QEMU's gdb stub to conform to the expected behavior.

Note that QEMU's existing handling of the legacy 'k' packet is
correct: in that case GDB does not expect a reply, and QEMU does not send one.

Quoted 7 lines
Quoted 1 line

Thanks, applied to target-arm.next.

As an aside, do you know if there is any kind of test suite for the remote protocol that implementors of a debug stub can use to check that they're conforming to it?

Well, I discovered this problem by running the GDB testsuite (using QEMU for nios2-elf target with the other target-specific patches I recently posted). I'm not sure if it's designed to exhaustively test the entire remote protocol, but it does a pretty good job of covering user-visible GDB features that depend on the remote target doing something reasonable, even if it's just saying "Huh? I don't know how to do that." :-)

-Sandra

#3 lore raw

14.02.2019. 19.27, "Sandra Loosemore" <[email protected]> је написао/ла:

Quoted 4 lines · Peter Maydell
Quoted 2 lines

On Tue, 12 Feb 2019 at 21:52, Sandra Loosemore <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines

Per the GDB remote protocol documentation

https://sourceware.org/gdb/current/onlinedocs/gdb/Packets.html#index-vKill-packet

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines

the debug stub is expected to send a reply to the 'vKill' packet. At least some versions of GDB crash if the gdb stub simply exits without sending a reply. This patch fixes QEMU's gdb stub to conform to the expected behavior.

Note that QEMU's existing handling of the legacy 'k' packet is
correct: in that case GDB does not expect a reply, and QEMU does not send one.

Quoted 8 lines
Quoted 5 lines

Thanks, applied to target-arm.next.

As an aside, do you know if there is any kind of test suite for the remote protocol that implementors of a debug stub can use to check that they're conforming to it?

Well, I discovered this problem by running the GDB testsuite (using QEMU

for nios2-elf target with the other target-specific patches I recently posted). I'm not sure if it's designed to exhaustively test the entire remote protocol, but it does a pretty good job of covering user-visible GDB features that depend on the remote target doing something reasonable, even if it's just saying "Huh? I don't know how to do that." :-)

Quoted 1 line

Debugging using gdb/qemu setups is fairly frequent use case and perhaps we should have a test module for interoperability of gdb and qemu, and also "make check-gdb".

Thanks for pinpointing and fixing bugs in this area, Sandra!

Aleksandar

Quoted 2 lines

-Sandra