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