Fix duplicate lockbits memory output of -p*/s

In order to output memories of a part always in the same order the
developer options use an odered list of all known memories. Owing
to the partial match feature of dev_locate_mem_noalias() they
would therefore print an existing lockbits memory twice, once for
the memory lock and once for the memory lockbits.
This commit is contained in:
Stefan Rueger 2023-01-02 22:22:34 +00:00
parent 82cf688357
commit c44d0e9c73
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
1 changed files with 10 additions and 3 deletions

View File

@ -486,6 +486,13 @@ typedef struct {
AVRMEMdeep mems[40]; AVRMEMdeep mems[40];
} AVRPARTdeep; } AVRPARTdeep;
// Return memory iff its desc matches str exactly
static AVRMEM *dev_locate_mem(const AVRPART *p, const char *str) {
AVRMEM *m = p->mem? avr_locate_mem_noalias(p, str): NULL;
return m && strcmp(m->desc, str) == 0? m: NULL;
}
static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) { static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) {
AVRMEM *m; AVRMEM *m;
size_t di; size_t di;
@ -525,7 +532,7 @@ static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) {
// Fill in all memories we got in defined order // Fill in all memories we got in defined order
di = 0; di = 0;
for(size_t mi=0; mi < sizeof avr_mem_order/sizeof *avr_mem_order && avr_mem_order[mi]; mi++) { for(size_t mi=0; mi < sizeof avr_mem_order/sizeof *avr_mem_order && avr_mem_order[mi]; mi++) {
m = p->mem? avr_locate_mem_noalias(p, avr_mem_order[mi]): NULL; m = dev_locate_mem(p, avr_mem_order[mi]);
if(m) { if(m) {
if(di >= sizeof d->mems/sizeof *d->mems) { if(di >= sizeof d->mems/sizeof *d->mems) {
pmsg_error("ran out of mems[] space, increase size in AVRMEMdeep of developer_opts.c and recompile\n"); pmsg_error("ran out of mems[] space, increase size in AVRMEMdeep of developer_opts.c and recompile\n");
@ -726,8 +733,8 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool
for(size_t mi=0; mi < sizeof avr_mem_order/sizeof *avr_mem_order && avr_mem_order[mi]; mi++) { for(size_t mi=0; mi < sizeof avr_mem_order/sizeof *avr_mem_order && avr_mem_order[mi]; mi++) {
AVRMEM *m, *bm; AVRMEM *m, *bm;
m = p->mem? avr_locate_mem_noalias(p, avr_mem_order[mi]): NULL; m = dev_locate_mem(p, avr_mem_order[mi]);
bm = base && base->mem? avr_locate_mem_noalias(base, avr_mem_order[mi]): NULL; bm = base? dev_locate_mem(base, avr_mem_order[mi]): NULL;
if(!m && bm && !tsv) if(!m && bm && !tsv)
dev_info("\n memory \"%s\" = NULL;\n", bm->desc); dev_info("\n memory \"%s\" = NULL;\n", bm->desc);