gdb: Implement 'p' and 'P' register access

This commit is contained in:
Gareth McMullin 2017-09-28 16:01:23 +13:00 committed by UweBonnes
parent 9f4cf4124e
commit 19a8078f99
1 changed files with 30 additions and 1 deletions

View File

@ -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, &reg);
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", &reg, &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'