From 0e451f73cf1ba3f9070a838ee6d7200135177f9e Mon Sep 17 00:00:00 2001 From: MCUdude Date: Mon, 17 Jan 2022 20:53:00 +0100 Subject: [PATCH] Print alias names if present --- src/avrpart.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index ee354be9..61580ac5 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -375,31 +375,53 @@ AVRMEM * avr_locate_mem(AVRPART * p, char * desc) void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, AVRPART * p, int type, int verbose) { + static LNODEID ln; + static AVRMEM * n; static unsigned int prev_mem_offset, prev_mem_size; int i, j; char * optr; if (m == NULL) { fprintf(f, - "%s Block Poll Page Polled\n" - "%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" - "%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", + "%s Block Poll Page Polled\n" + "%sMemory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" + "%s----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", prefix, prefix, prefix); } else { if (verbose > 2) { fprintf(f, - "%s Block Poll Page Polled\n" - "%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" - "%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", + "%s Block Poll Page Polled\n" + "%sMemory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" + "%s----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", prefix, prefix, prefix); } - if ((prev_mem_offset != m->offset || prev_mem_size != m->size) || (strcmp(p->family_id, "") == 0)) { // Don't print memory aliases + + // Get the next memory section, and stop before going out of band + if (ln == NULL) + ln = lnext(lfirst(p->mem)); + else + ln = lnext(ln); + if (ln != NULL) + n = ldata(ln); + + // Only print memory section if the previous section printed isn't identical + if(prev_mem_offset != m->offset || prev_mem_size != m->size || (strcmp(p->family_id, "") == 0)) { prev_mem_offset = m->offset; prev_mem_size = m->size; + /* Show alias if the current and the next memory section has the same offset + and size, we're not out of band and a family_id is present */ + char * mem_desc_alias = m->offset == n->offset && \ + m->size == n->size && \ + ln != NULL && \ + strcmp(p->family_id, "") != 0 ? + n->desc : ""; fprintf(f, - "%s%-11s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n", - prefix, m->desc, m->mode, m->delay, m->blocksize, m->pollindex, + "%s%-11s %-8s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n", + prefix, + m->desc, + mem_desc_alias, + m->mode, m->delay, m->blocksize, m->pollindex, m->paged ? "yes" : "no", m->size, m->page_size,