/* Write data to a given memory address and length. */
static int gdb_mem_write(const uint8_t *buf, uintptr_t addr, size_t len)
/* Write data to a given memory address and length. */
static int gdb_mem_write(const uint8_t *buf, uintptr_t addr, size_t len)
{
	uint8_t align;
	int ret;
	if (!gdb_mem_can_write(addr, len, &align)) {
		ret = -1;
		goto out;
	}
	if (align > 1) {
		ret = gdb_mem_write_aligned(buf, addr, len, align);
	} else {
		ret = gdb_mem_write_unaligned(buf, addr, len);
	}
out:
	return ret;
}