This is an automated email from Gerrit. Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4436
-- gerrit commit 5496fa4b0e7d1edd1ac23f0dd5e6f6a5693e9e72 Author: Tomas Vanek <[email protected]> Date: Tue Feb 27 09:44:07 2018 +0100 gdb_server: gdb_memory_map() rework Drop generating xml blocks for non flash memory (we don't know if it is really RAM - gdb does not need it anyway, as it treats all not defined memory as a RAM) Use sector sizes instead of bank size. Detect a gap between sectors and emit xml blocks accordingly. Change-Id: If0e0e44b0c3b93067b4d717c9c7b07c08582e57b Signed-off-by: Tomas Vanek <[email protected]> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index cbf1ca9..6f6ffd6 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1778,7 +1778,6 @@ static int gdb_memory_map(struct connection *connection, int offset; int length; char *separator; - uint32_t ram_start = 0; int i; int target_flash_banks = 0; @@ -1793,9 +1792,6 @@ static int gdb_memory_map(struct connection *connection, /* Sort banks in ascending order. We need to report non-flash * memory as ram (or rather read/write) by default for GDB, since * it has no concept of non-cacheable read/write memory (i/o etc). - * - * FIXME Most non-flash addresses are *NOT* RAM! Don't lie. - * Current versions of GDB assume unlisted addresses are RAM... */ banks = malloc(sizeof(struct flash_bank *)*flash_get_bank_count()); @@ -1818,16 +1814,9 @@ static int gdb_memory_map(struct connection *connection, for (i = 0; i < target_flash_banks; i++) { int j; unsigned sector_size = 0; - uint32_t start; + unsigned group_len = 0; p = banks[i]; - start = p->base; - - if (ram_start < p->base) - xml_printf(&retval, &xml, &pos, &size, - "<memory type=\"ram\" start=\"0x%x\" " - "length=\"0x%x\"/>\n", - ram_start, p->base - ram_start); /* Report adjacent groups of same-size sectors. So for * example top boot CFI flash will list an initial region @@ -1836,27 +1825,27 @@ static int gdb_memory_map(struct connection *connection, * regions with 8KB, 32KB, and 64KB sectors; etc. */ for (j = 0; j < p->num_sectors; j++) { - unsigned group_len; /* Maybe start a new group of sectors. */ if (sector_size == 0) { + target_addr_t start; start = p->base + p->sectors[j].offset; xml_printf(&retval, &xml, &pos, &size, "<memory type=\"flash\" " - "start=\"0x%x\" ", + "start=\"" TARGET_ADDR_FMT "\" ", start); sector_size = p->sectors[j].size; + group_len = sector_size; + } else { + group_len += sector_size; /* equal to p->sectors[j].size */ } /* Does this finish a group of sectors? * If not, continue an already-started group. */ - if (j == p->num_sectors - 1) - group_len = (p->base + p->size) - start; - else if (p->sectors[j + 1].size != sector_size) - group_len = p->base + p->sectors[j + 1].offset - - start; - else + if (j < p->num_sectors - 1 + && p->sectors[j + 1].size == sector_size + && p->sectors[j + 1].offset == p->sectors[j].offset + sector_size) continue; xml_printf(&retval, &xml, &pos, &size, @@ -1866,24 +1855,11 @@ static int gdb_memory_map(struct connection *connection, "</memory>\n", group_len, sector_size); + sector_size = 0; } - - ram_start = p->base + p->size; } - if (ram_start != 0) - xml_printf(&retval, &xml, &pos, &size, - "<memory type=\"ram\" start=\"0x%x\" " - "length=\"0x%x\"/>\n", - ram_start, 0-ram_start); - /* ELSE a flash chip could be at the very end of the 32 bit address - * space, in which case ram_start will be precisely 0 - */ - - free(banks); - banks = NULL; - xml_printf(&retval, &xml, &pos, &size, "</memory-map>\n"); if (retval != ERROR_OK) { -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
