From e4375fd3d9f2075e8e8d6bce8e66c2776ecb6fc7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 1 Feb 2014 05:23:56 -0800 Subject: [PATCH] Stub out [qQvV].* commands --- src/debugger/gdb-stub.c | 54 +++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/debugger/gdb-stub.c b/src/debugger/gdb-stub.c index ead6115c6..72ae14663 100644 --- a/src/debugger/gdb-stub.c +++ b/src/debugger/gdb-stub.c @@ -77,18 +77,20 @@ static void _sendMessage(struct GDBStub* stub) { stub->lineAck = GDB_ACK_PENDING; } uint8_t checksum = 0; - int i; + int i = 1; char buffer = stub->outgoing[0]; char swap; stub->outgoing[0] = '$'; - for (i = 1; i < GDB_STUB_MAX_LINE - 5; ++i) { - checksum += buffer; - swap = stub->outgoing[i]; - stub->outgoing[i] = buffer; - buffer = swap; - if (!buffer) { - ++i; - break; + if (buffer) { + for (; i < GDB_STUB_MAX_LINE - 5; ++i) { + checksum += buffer; + swap = stub->outgoing[i]; + stub->outgoing[i] = buffer; + buffer = swap; + if (!buffer) { + ++i; + break; + } } } stub->outgoing[i] = '#'; @@ -166,7 +168,27 @@ static void _readRegister(struct GDBStub* stub, const char* message) { return; } _int2hex32(value, stub->outgoing); - stub->outgoing[8] = 0; + stub->outgoing[8] = '\0'; + _sendMessage(stub); +} + +static void _processQMinCommand(struct GDBStub* stub, const char* message) { + stub->outgoing[0] = '\0'; + _sendMessage(stub); +} + +static void _processQMajCommand(struct GDBStub* stub, const char* message) { + stub->outgoing[0] = '\0'; + _sendMessage(stub); +} + +static void _processVMajCommand(struct GDBStub* stub, const char* message) { + stub->outgoing[0] = '\0'; + _sendMessage(stub); +} + +static void _processVMinCommand(struct GDBStub* stub, const char* message) { + stub->outgoing[0] = '\0'; _sendMessage(stub); } @@ -228,6 +250,18 @@ size_t _parseGDBMessage(struct GDBStub* stub, const char* message) { case 'p': _readRegister(stub, message); break; + case 'Q': + _processQMajCommand(stub, message); + break; + case 'q': + _processQMinCommand(stub, message); + break; + case 'V': + _processVMajCommand(stub, message); + break; + case 'v': + _processVMinCommand(stub, message); + break; default: _error(stub, GDB_UNSUPPORTED_COMMAND); break;