/* Given a starting address and length of a memory block, find a memory region descriptor from the memory region array where the memory block fits inside the memory region. */
static const struct gdb_mem_region* find_memory_region(const uintptr_t addr, const size_t len)
/* Given a starting address and length of a memory block, find a memory region descriptor from the memory region array where the memory block fits inside the memory region. */
static const struct gdb_mem_region* find_memory_region(const uintptr_t addr, const size_t len)
{
	const struct gdb_mem_region *r, *ret = NULL;
	unsigned int idx;
	for (idx = 0; idx < gdb_mem_num_regions; idx++) {
		r = &gdb_mem_region_array[idx];
		if ((addr >= r->start) &&
		    (addr < r->end) &&
		    ((addr + len) >= r->start) &&
		    ((addr + len) < r->end)) {
			ret = r;
			break;
		}
	}
	return ret;
}