|
|
1.1 ! root 1: /* ! 2: * ! 3: * UNIX debugger ! 4: * ! 5: */ ! 6: ! 7: #include "defs.h" ! 8: ! 9: ! 10: MSG NOBKPT; ! 11: MSG SZBKPT; ! 12: MSG EXBKPT; ! 13: MSG NOPCS; ! 14: MSG BADMOD; ! 15: ! 16: /* breakpoints */ ! 17: BKPTR bkpthead; ! 18: ! 19: CHAR *lp; ! 20: CHAR lastc; ! 21: ! 22: INT signo; ! 23: L_INT dot; ! 24: L_INT pid; ! 25: L_INT cntval; ! 26: L_INT loopcnt; ! 27: ! 28: L_INT entrypt; ! 29: INT adrflg; ! 30: ! 31: ! 32: ! 33: /* sub process control */ ! 34: ! 35: subpcs(modif) ! 36: { ! 37: REG check; ! 38: REG execsig,runmode; ! 39: REG BKPTR bkptr; ! 40: REG STRING comptr; ! 41: execsig=0; loopcnt=cntval; ! 42: ! 43: switch (modif) { ! 44: ! 45: /* delete breakpoint */ ! 46: case 'd': case 'D': ! 47: IF (bkptr=scanbkpt(dot)) ! 48: THEN bkptr->flag=0; return; ! 49: ELSE error(NOBKPT); ! 50: FI ! 51: ! 52: /* set breakpoint */ ! 53: case 'b': case 'B': ! 54: IF (bkptr=scanbkpt(dot)) ! 55: THEN bkptr->flag=0; ! 56: FI ! 57: FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt ! 58: DO IF bkptr->flag == 0 ! 59: THEN break; ! 60: FI ! 61: OD ! 62: IF bkptr==0 ! 63: THEN IF (bkptr=(BKPTR)sbrk(sizeof *bkptr)) == (BKPTR)-1 ! 64: THEN error(SZBKPT); ! 65: ELSE bkptr->nxtbkpt=bkpthead; ! 66: bkpthead=bkptr; ! 67: FI ! 68: FI ! 69: bkptr->loc = dot; ! 70: bkptr->initcnt = bkptr->count = cntval; ! 71: bkptr->flag = BKPTSET; ! 72: check=MAXCOM-1; comptr=bkptr->comm; rdc(); lp--; ! 73: REP *comptr++ = readchar(); ! 74: PER check-- ANDF lastc!=EOR DONE ! 75: *comptr=0; lp--; ! 76: IF check ! 77: THEN return; ! 78: ELSE error(EXBKPT); ! 79: FI ! 80: ! 81: /* exit */ ! 82: case 'k' :case 'K': ! 83: IF pid ! 84: THEN printf("%d: killed", pid); endpcs(); return; ! 85: FI ! 86: error(NOPCS); ! 87: ! 88: /* run program */ ! 89: case 'r': case 'R': ! 90: endpcs(); ! 91: setup(); runmode=CONTIN; ! 92: /* ! 93: IF adrflg ! 94: THEN IF !scanbkpt(dot) THEN loopcnt++; FI ! 95: ELSE IF !scanbkpt(entrypt+2) THEN loopcnt++; FI ! 96: FI ! 97: */ ! 98: break; ! 99: ! 100: /* single step */ ! 101: case 's': case 'S': ! 102: IF pid ! 103: THEN ! 104: runmode=SINGLE; execsig=getsig(signo); ! 105: ELSE setup(); loopcnt--; ! 106: FI ! 107: break; ! 108: ! 109: /* continue with optional signal */ ! 110: case 'c': case 'C': case 0: ! 111: IF pid==0 THEN error(NOPCS); FI ! 112: runmode=CONTIN; 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: delbp(); ! 123: printpc(); ! 124: } ! 125:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.