diff --git a/src/gdb_main.c b/src/gdb_main.c index 1e2cb86..af1edf9 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -207,6 +207,36 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall) } break; } + + /* Optional GDB packet support */ + case 'p': { /* Read single register */ + ERROR_IF_NO_TARGET(); + uint32_t reg; + sscanf(pbuf, "p%" SCNx32, ®); + uint8_t val[8]; + size_t s = target_reg_read(cur_target, reg, val, sizeof(val)); + if (s > 0) { + gdb_putpacket(hexify(pbuf, val, s), s * 2); + } else { + gdb_putpacketz("EFF"); + } + break; + } + case 'P': { /* Write single register */ + ERROR_IF_NO_TARGET(); + uint32_t reg; + int n; + sscanf(pbuf, "P%" SCNx32 "=%n", ®, &n); + uint8_t val[strlen(&pbuf[n])/2]; + unhexify(val, pbuf + n, sizeof(val)); + if (target_reg_write(cur_target, reg, val, sizeof(val)) > 0) { + gdb_putpacketz("OK"); + } else { + gdb_putpacketz("EFF"); + } + break; + } + case 'F': /* Semihosting call finished */ if (in_syscall) { return hostio_reply(tc, pbuf, size); @@ -216,7 +246,6 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall) } break; - /* Optional GDB packet support */ case '!': /* Enable Extended GDB Protocol. */ /* This doesn't do anything, we support the extended * protocol anyway, but GDB will never send us a 'R'