/* Read data from a given memory address and length. */
static int gdb_mem_read(uint8_t *buf, size_t buf_len, uintptr_t addr, size_t len)
/* Read data from a given memory address and length. */
static int gdb_mem_read(uint8_t *buf, size_t buf_len, uintptr_t addr, size_t len)
{
	uint8_t align;
	int ret;
	if ((len * 2) > buf_len) {
		ret = -1;
		goto out;
	}
	if (!gdb_mem_can_read(addr, len, &align)) {
		ret = -1;
		goto out;
	}
	if (align > 1) {
		ret = gdb_mem_read_aligned(buf, buf_len,
					   addr, len,
					   align);
	} else {
		ret = gdb_mem_read_unaligned(buf, buf_len,
					     addr, len);
	}
out:
	return ret;
}