/*-----------------------------------------------------------------*/ void hTabAddItemIfNotP (hTab ** htab, int key, void *item) { if (!*htab) { hTabAddItem (htab, key, item); return; } if (hTabItemWithKey (*htab, key)) return; hTabAddItem (htab, key, item); }
/*-----------------------------------------------------------------*/ int setBreakPoint (unsigned addr, char addrType, char bpType, int (*callBack)(unsigned,breakp *,context *) , char *fileName, int lineno) { breakp *bp, *bpl; Dprintf(D_break, ("setBreakPoint: addr:%x atype:%s bpType:%s [%s:%d]\n", addr, debug_bp_type_strings[(int)addrType], debug_bp_type_strings[(int)bpType], fileName, lineno+1)); /* allocate & init a new bp */ bp = Safe_calloc(1,sizeof(breakp)); bp->addr = addr; bp->addrType = addrType; bp->bpType = bpType; bp->callBack = callBack; bp->bpnum = ((bpType == USER || bpType == TMPUSER)? ++bpnum : 0); bp->filename = fileName; bp->lineno = lineno; /* if this is an user break point then check if there already exists one for this address */ if (bpType == USER || bpType == TMPUSER) { for ( bpl = hTabFirstItemWK(bptable,addr) ; bpl; bpl = hTabNextItemWK(bptable)) { /* if also a user break point then issue Note : */ if (bpl->bpType == USER || bpType == TMPUSER) fprintf(stderr,"Note: breakpoint %d also set at pc 0x%x\n", bpl->bpnum,bpl->addr); } fprintf(stderr,"Breakpoint %d at 0x%x: file %s, line %d.\n", bp->bpnum, addr, fileName, lineno+1); userBpPresent++; } if (bpType != STEP && bpType != NEXT) { /* if a break point does not already exist then send command to simulator to add one */ if (!hTabSearch(bptable,addr)) /* send the break command to the simulator */ simSetBP (addr); } /* now add the break point to list */ hTabAddItem(&bptable,addr,bp); return bp->bpnum ; }
/*-----------------------------------------------------------------*/ void hashiCodeKeys (eBBlock ** ebbs, int count) { int i; for (i = 0; i < count; i++) { iCode *ic; for (ic = ebbs[i]->sch; ic; ic = ic->next) hTabAddItem (&iCodehTab, ic->key, ic); } }
/*-----------------------------------------------------------------*/ static void sequenceiCode (eBBlock ** ebbs, int count) { int i; for (i = 0; i < count; i++) { iCode *ic; ebbs[i]->fSeq = iCodeSeq + 1; for (ic = ebbs[i]->sch; ic; ic = ic->next) { ic->seq = ++iCodeSeq; ic->depth = ebbs[i]->depth; //hTabAddItem (&iCodehTab, ic->key, ic); hTabAddItem (&iCodeSeqhTab, ic->seq, ic); } ebbs[i]->lSeq = iCodeSeq; } }
/*-----------------------------------------------------------------*/ hTab * hTabFromTable (hTab * htab) { hTab *nhtab; hashtItem *htip; int key; if (!htab) return NULL; nhtab = newHashTable (htab->size); for (key = htab->minKey; key <= htab->maxKey; key++) { for (htip = htab->table[key]; htip; htip = htip->next) hTabAddItem (&nhtab, htip->key, htip->item); } return nhtab; }
static void pic14_constructAbsMap (struct dbuf_s *oBuf, struct dbuf_s *gloBuf) { memmap *maps[] = { data, sfr, NULL }; int i; hTab *ht = NULL; symbol *sym; set *aliases; int addr, min=-1, max=-1; int size; for (i=0; maps[i] != NULL; i++) { for (sym = (symbol *)setFirstItem (maps[i]->syms); sym; sym = setNextItem (maps[i]->syms)) { if (IS_DEFINED_HERE(sym) && SPEC_ABSA(sym->etype)) { addr = SPEC_ADDR(sym->etype); /* handle CONFIG words here */ if (IS_CONFIG_ADDRESS( addr )) { //fprintf( stderr, "%s: assignment to CONFIG@0x%x found\n", __FUNCTION__, addr ); //fprintf( stderr, "ival: %p (0x%x)\n", sym->ival, (int)list2int( sym->ival ) ); if (sym->ival) { pic14_assignConfigWordValue( addr, (int)list2int( sym->ival ) ); } else { fprintf( stderr, "ERROR: Symbol %s, which is covering a __CONFIG word must be initialized!\n", sym->name ); } continue; } if (max == -1 || addr > max) max = addr; if (min == -1 || addr < min) min = addr; //fprintf (stderr, "%s: sym %s @ 0x%x\n", __FUNCTION__, sym->name, addr); aliases = hTabItemWithKey (ht, addr); if (aliases) { /* May not use addSetHead, as we cannot update the * list's head in the hastable `ht'. */ addSet (&aliases, sym); #if 0 fprintf( stderr, "%s: now %d aliases for %s @ 0x%x\n", __FUNCTION__, elementsInSet(aliases), sym->name, addr); #endif } else { addSet (&aliases, sym); hTabAddItem (&ht, addr, aliases); } // if } // if } // for sym } // for i /* now emit definitions for all absolute symbols */ dbuf_printf (oBuf, "%s", iComments2); dbuf_printf (oBuf, "; absolute symbol definitions\n"); dbuf_printf (oBuf, "%s", iComments2); for (addr=min; addr <= max; addr++) { size = 1; aliases = hTabItemWithKey (ht, addr); if (aliases && elementsInSet(aliases)) { /* Make sure there is no initialized value at this location! */ for (sym = setFirstItem(aliases); sym; sym = setNextItem(aliases)) { if (sym->ival) break; } // for if (sym) continue; dbuf_printf (oBuf, "UD_abs_%s_%x\tudata_ovr\t0x%04x\n", moduleName, addr, addr); for (sym = setFirstItem (aliases); sym; sym = setNextItem (aliases)) { if (getSize(sym->type) > size) { size = getSize(sym->type); } /* initialized values are handled somewhere else */ if (sym->ival) continue; /* emit STATUS as well as _STATUS, required for SFRs only */ //dbuf_printf (oBuf, "%s\tres\t0\n", sym->name); dbuf_printf (oBuf, "%s\n", sym->rname); if (IS_GLOBAL(sym) && !IS_STATIC(sym->etype)) { //emitIfNew(gloBuf, &emitted, "\tglobal\t%s\n", sym->name); emitIfNew(gloBuf, &emitted, "\tglobal\t%s\n", sym->rname); } // if } // for dbuf_printf (oBuf, "\tres\t%d\n", size); } // if } // for i }