1*14471Ssam #ifndef lint 2*14471Ssam static char sccsid[] = "@(#)pcs.c 4.2 08/11/83"; 3*14471Ssam #endif 43763Sroot /* 53763Sroot * 63763Sroot * UNIX debugger 73763Sroot * 83763Sroot */ 93763Sroot 103763Sroot #include "defs.h" 113763Sroot 123763Sroot 133763Sroot MSG NOBKPT; 143763Sroot MSG SZBKPT; 153763Sroot MSG EXBKPT; 163763Sroot MSG NOPCS; 173763Sroot MSG BADMOD; 183763Sroot 193763Sroot /* breakpoints */ 203763Sroot BKPTR bkpthead; 213763Sroot 223763Sroot CHAR *lp; 233763Sroot CHAR lastc; 243763Sroot 253763Sroot INT signo; 263763Sroot L_INT dot; 273763Sroot INT pid; 283763Sroot L_INT cntval; 293763Sroot L_INT loopcnt; 303763Sroot 313763Sroot L_INT entrypt; 323763Sroot INT adrflg; 333763Sroot 343763Sroot 353763Sroot 363763Sroot /* sub process control */ 373763Sroot subpcs(modif)383763Srootsubpcs(modif) 393763Sroot { 403763Sroot REG INT check; 413763Sroot INT execsig,runmode; 423763Sroot REG BKPTR bkptr; 433763Sroot STRING comptr; 443763Sroot execsig=0; loopcnt=cntval; 453763Sroot 463763Sroot switch (modif) { 473763Sroot 483763Sroot /* delete breakpoint */ 493763Sroot case 'd': case 'D': 503763Sroot IF (bkptr=scanbkpt(dot)) 513763Sroot THEN bkptr->flag=0; return; 523763Sroot ELSE error(NOBKPT); 533763Sroot FI 543763Sroot 553763Sroot /* set breakpoint */ 563763Sroot case 'b': case 'B': 573763Sroot IF (bkptr=scanbkpt(dot)) 583763Sroot THEN bkptr->flag=0; 593763Sroot FI 603763Sroot FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt 613763Sroot DO IF bkptr->flag == 0 623763Sroot THEN break; 633763Sroot FI 643763Sroot OD 653763Sroot IF bkptr==0 663763Sroot THEN IF (bkptr=sbrk(sizeof *bkptr)) == -1 673763Sroot THEN error(SZBKPT); 683763Sroot ELSE bkptr->nxtbkpt=bkpthead; 693763Sroot bkpthead=bkptr; 703763Sroot FI 713763Sroot FI 723763Sroot bkptr->loc = dot; 733763Sroot bkptr->initcnt = bkptr->count = cntval; 743763Sroot bkptr->flag = BKPTSET; 753763Sroot check=MAXCOM-1; comptr=bkptr->comm; rdc(); lp--; 763763Sroot REP *comptr++ = readchar(); 773763Sroot PER check-- ANDF lastc!=EOR DONE 783763Sroot *comptr=0; lp--; 793763Sroot IF check 803763Sroot THEN return; 813763Sroot ELSE error(EXBKPT); 823763Sroot FI 833763Sroot 843763Sroot /* exit */ 853763Sroot case 'k' :case 'K': 863763Sroot IF pid 873763Sroot THEN printf("%d: killed", pid); endpcs(); return; 883763Sroot FI 893763Sroot error(NOPCS); 903763Sroot 913763Sroot /* run program */ 923763Sroot case 'r': case 'R': 933763Sroot endpcs(); 943763Sroot setup(); runmode=CONTIN; 953763Sroot IF adrflg 963763Sroot THEN IF !scanbkpt(dot) THEN loopcnt++; FI 973763Sroot ELSE IF !scanbkpt(entrypt+2) THEN loopcnt++; FI 983763Sroot FI 993763Sroot break; 1003763Sroot 1013763Sroot /* single step */ 1023763Sroot case 's': case 'S': 1033763Sroot IF pid 1043763Sroot THEN 1053763Sroot runmode=SINGLE; execsig=getsig(signo); 1063763Sroot ELSE setup(); loopcnt--; 1073763Sroot FI 1083763Sroot break; 1093763Sroot 1103763Sroot /* continue with optional signal */ 1113763Sroot case 'c': case 'C': case 0: 1123763Sroot IF pid==0 THEN error(NOPCS); FI 1133763Sroot runmode=CONTIN; execsig=getsig(signo); 1143763Sroot break; 1153763Sroot 1163763Sroot default: error(BADMOD); 1173763Sroot } 1183763Sroot 1193763Sroot IF loopcnt>0 ANDF runpcs(runmode,execsig) 1203763Sroot THEN printf("breakpoint%16t"); 1213763Sroot ELSE printf("stopped at%16t"); 1223763Sroot FI 1233763Sroot delbp(); 1243763Sroot printpc(); 1253763Sroot } 1263763Sroot 127