gdb: Implement 'p' and 'P' register access
This commit is contained in:
parent
9f4cf4124e
commit
19a8078f99
|
@ -207,6 +207,36 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
||||||
}
|
}
|
||||||
break;
|
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 */
|
case 'F': /* Semihosting call finished */
|
||||||
if (in_syscall) {
|
if (in_syscall) {
|
||||||
return hostio_reply(tc, pbuf, size);
|
return hostio_reply(tc, pbuf, size);
|
||||||
|
@ -216,7 +246,6 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Optional GDB packet support */
|
|
||||||
case '!': /* Enable Extended GDB Protocol. */
|
case '!': /* Enable Extended GDB Protocol. */
|
||||||
/* This doesn't do anything, we support the extended
|
/* This doesn't do anything, we support the extended
|
||||||
* protocol anyway, but GDB will never send us a 'R'
|
* protocol anyway, but GDB will never send us a 'R'
|
||||||
|
|
Loading…
Reference in New Issue