/*-----------------------------------------------------------------*/ void clearUSERbp ( unsigned int addr ) { breakp *bp; /* for break points delete if they are STEP */ for ( bp = hTabFirstItemWK(bptable,addr); bp ; bp = hTabNextItemWK(bptable)) { /* if this is a step then delete */ if (bp->bpType == USER || bp->bpType == TMPUSER) { hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); /* if this leaves no other break points then send command to simulator to delete bp from this addr */ if (hTabSearch(bptable,bp->addr) == NULL) { simClearBP(bp->addr); } fprintf(stdout,"Deleted breakpoint %d\n", bp->bpnum); userBpPresent-- ; freeUSERbp(bp); break; } } if (!bp) fprintf(stderr,"No breakpoint at address 0x%x.\n",addr); }
/*-----------------------------------------------------------------*/ 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 * hTabItemWithKey (hTab * htab, int key) { hashtItem *htip; if (!(htip = hTabSearch (htab, key))) return NULL; return htip->item; }
/*-----------------------------------------------------------------*/ void deleteUSERbp (int bpnum) { breakp *bp; int k; Dprintf(D_break, ("break: deleteUSERbp %d\n", bpnum)); /* for break points delete if they are STEP */ for ( bp = hTabFirstItem(bptable,&k); bp ; bp = hTabNextItem(bptable,&k)) { /* if this is a user then delete if break point matches or bpnumber == -1 (meaning delete all user break points */ if ((bp->bpType == USER || bp->bpType == TMPUSER ) && ( bp->bpnum == bpnum || bpnum == -1)) { hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); /* if this leaves no other break points then send command to simulator to delete bp from this addr */ if (hTabSearch(bptable,bp->addr) == NULL) { simClearBP (bp->addr); Dprintf(D_break, ("break: deleteUSERbp:simClearBP 0x%x\n", bp->addr)); } fprintf(stdout,"Deleted breakpoint %d\n",bp->bpnum); userBpPresent-- ; freeUSERbp(bp); if (bpnum == -1) continue ; else break; } } if (!bp && bpnum != -1) fprintf(stderr,"No breakpoint number %d.\n",bpnum); }