|
|
1.1 ! root 1: /* ! 2: * ! 3: * UNIX debugger ! 4: * ! 5: */ ! 6: ! 7: #include "defs.h" ! 8: #include "bkpt.h" ! 9: ! 10: static char NOPCS[] = "no process"; ! 11: ! 12: extern char lastc; ! 13: ! 14: /* sub process control */ ! 15: ! 16: subpcs(modif) ! 17: { ! 18: register int check; ! 19: int keepsig,runmode; ! 20: register BKPT *bk; ! 21: char *comptr; ! 22: char *malloc(); ! 23: WORD defval(); ! 24: ! 25: keepsig=0; ! 26: loopcnt=cntval; ! 27: switch (modif) { ! 28: ! 29: /* delete breakpoint */ ! 30: case 'd': ! 31: case 'D': ! 32: if ((bk=scanbkpt(dot)) == NULL) ! 33: error("no breakpoint set"); ! 34: bk->flag=BKPTCLR; ! 35: return; ! 36: ! 37: /* set breakpoint */ ! 38: case 'b': ! 39: case 'B': ! 40: if (bk=scanbkpt(dot)) ! 41: bk->flag=BKPTCLR; ! 42: for (bk=bkpthead; bk; bk=bk->nxtbkpt) ! 43: if (bk->flag == BKPTCLR) ! 44: break; ! 45: if (bk==0) { ! 46: bk = (BKPT *)malloc(sizeof(*bk)); ! 47: if (bk == NULL) ! 48: error("too many breakpoints"); ! 49: bk->nxtbkpt=bkpthead; ! 50: bkpthead=bk; ! 51: } ! 52: bk->loc = dot; ! 53: bk->initcnt = bk->count = cntval; ! 54: bk->flag = modif == 'b' ? BKPTSET : BKPTTMP; ! 55: check=MAXCOM-1; ! 56: comptr=bk->comm; ! 57: rdc(); ! 58: reread(); ! 59: do { ! 60: *comptr++ = readchar(); ! 61: } while (check-- && lastc!=EOR); ! 62: *comptr=0; ! 63: reread(); ! 64: if (check) ! 65: return; ! 66: error("bkpt command too long"); ! 67: ! 68: /* exit */ ! 69: case 'k' : ! 70: case 'K': ! 71: if (pid == 0) ! 72: error(NOPCS); ! 73: printf("%d: killed", pid); ! 74: endpcs(); ! 75: return; ! 76: ! 77: /* run program */ ! 78: case 'r': ! 79: case 'R': ! 80: endpcs(); ! 81: setup(); ! 82: runmode=CONTIN; ! 83: break; ! 84: ! 85: /* single step */ ! 86: case 's': ! 87: case 'S': ! 88: if (pid == 0) { ! 89: setup(); ! 90: loopcnt--; ! 91: } ! 92: else { ! 93: runmode=SINGLE; ! 94: keepsig=defval((WORD)signo); ! 95: } ! 96: break; ! 97: ! 98: /* continue with optional signal */ ! 99: case 'c': ! 100: case 'C': ! 101: case 0: ! 102: if (pid==0) ! 103: error(NOPCS); ! 104: runmode=CONTIN; ! 105: keepsig=defval((WORD)signo); ! 106: break; ! 107: ! 108: case 'g': /* grab the current process */ ! 109: if (adrflg && adrval == 0) { ! 110: if (pid == 0) ! 111: error(NOPCS); ! 112: ungrab(); ! 113: } ! 114: else { ! 115: grab(); ! 116: printf("stopped at%16t"); ! 117: delbp(); ! 118: printpc(); ! 119: } ! 120: return; ! 121: ! 122: default: ! 123: error("bad `:' command"); ! 124: } ! 125: ! 126: if (loopcnt>0 && runpcs(runmode,keepsig)) ! 127: printf("breakpoint%16t"); ! 128: else ! 129: printf("stopped at%16t"); ! 130: delbp(); ! 131: printpc(); ! 132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.