1: #include "defs.h" 2: 3: MSG NOBKPT; 4: MSG SZBKPT; 5: MSG EXBKPT; 6: MSG NOPCS; 7: MSG BADMOD; 8: 9: /* breakpoints */ 10: BKPTR bkpthead; 11: 12: char *lp; 13: char lastc; 14: u_int corhdr[ctob(USIZE)/sizeof(u_int)]; 15: MAP txtmap; 16: int signo; 17: long dot; 18: int pid; 19: long cntval; 20: long loopcnt; 21: int overlay; 22: char curov, symov; 23: 24: /* sub process control */ 25: 26: subpcs(modif) 27: { 28: register int check; 29: int execsig, runmode; 30: register BKPTR bkptr; 31: char *comptr; 32: 33: execsig=0; loopcnt=cntval; 34: 35: switch(modif) { 36: 37: /* delete breakpoint */ 38: case 'd': case 'D': 39: if (symov && symov!=curov) 40: setovmap(symov); 41: IF (bkptr=scanbkpt(shorten(dot))) 42: THEN bkptr->flag=0; 43: if (pid) del1bp(bkptr); 44: return; 45: ELSE error(NOBKPT); 46: FI 47: 48: /* set breakpoint */ 49: case 'b': case 'B': 50: if (symov && symov!=curov) 51: setovmap(symov); 52: IF (bkptr=scanbkpt(shorten(dot))) 53: THEN bkptr->flag=0; 54: if (pid) del1bp(bkptr); 55: FI 56: FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt 57: DO IF bkptr->flag == 0 58: THEN break; 59: FI 60: OD 61: IF bkptr==0 62: THEN IF (bkptr=(BKPTR)malloc(sizeof *bkptr)) == (BKPTR)NULL 63: THEN error(SZBKPT); 64: ELSE bkptr->nxtbkpt=bkpthead; 65: bkpthead=bkptr; 66: FI 67: FI 68: bkptr->loc = dot; 69: bkptr->initcnt = bkptr->count = cntval; 70: bkptr->flag = BKPTSET; 71: if (overlay && dot>txtmap.bo) 72: bkptr->ovly = symov ? symov : curov; 73: else bkptr->ovly = 0; /* base seg */ 74: check=MAXCOM-1; comptr=bkptr->comm; rdc(); lp--; 75: REP *comptr++ = readchar(); 76: PER check-- ANDF lastc!=EOR DONE 77: *comptr=0; lp--; 78: IF check 79: THEN if (pid) set1bp(bkptr); 80: return; 81: ELSE error(EXBKPT); 82: FI 83: 84: /* exit */ 85: case 'k' :case 'K': 86: IF pid 87: THEN printf("%d: killed", pid); endpcs(); return; 88: FI 89: error(NOPCS); 90: 91: /* run program */ 92: case 'r': case 'R': 93: endpcs(); 94: setup(); 95: setbp(); 96: runmode=PT_CONTINUE; 97: break; 98: 99: /* single step */ 100: case 's': case 'S': 101: runmode=PT_STEP; 102: IF pid 103: THEN execsig=getsig(signo); 104: ELSE setup(); loopcnt--; 105: FI 106: break; 107: 108: /* continue with optional signal */ 109: case 'c': case 'C': case 0: 110: IF pid==0 THEN error(NOPCS); FI 111: runmode=PT_CONTINUE; 112: execsig=getsig(signo); 113: break; 114: 115: default: error(BADMOD); 116: } 117: 118: IF loopcnt>0 ANDF runpcs(runmode, execsig) 119: THEN printf("breakpoint%16t"); 120: ELSE printf("stopped at%16t"); 121: FI 122: printpc(); 123: }