|
|
1.1 root 1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
2:
3: * ***********************************
4: * ***********************************
5: * ***** SINGLE STEP CONTROLLER ******
6: * *** R. B. Drake WH 8C-005 X4163 ***
7: * **** Sun Aug 26 11:35:49 1979 *****
8: * ***********************************
9: * ***********************************
10:
11: */
12: /* "@(#) sing.c: V 1.1 12/21/80" */
13:
14: /* single step monitor */
15: #include "bas.h"
16: extern char _string[];
17: extern int stpflg;
18: int singst = 32767;
19: int singflg;
20: extern char *ptr;
21: int stopl(),quit();
22: sing()
23: {
24: char *ch;
25: ch = expr;
26: singflg = -1; /* control from sing but not single stepping */
27: expunge();
28: restore();
29: signal(2,stopl);
30: if(fetch(0,&ptr) < 0)
31: {
32: error(0,5);
33: singflg = 0;
34: signal(2,quit);
35: return(-1);
36: }
37: if(ch[0] != '\0')
38: singst = atoi(ch);
39: else
40: singst = inst.thing.linno;
41: while(singex() == 0 && stpflg == 0)
42: if(fetch(-1,&ptr) < 0)
43: {
44: singflg = 0; /* done single stepping */
45: signal(SIGINT, quit);
46: return(0);
47: }
48: singflg=stpflg=0;
49: signal(SIGINT, quit);
50: return(0);
51: }
52: extern int subog;
53: singex()
54: {
55: char *save;
56: int hold;
57: if(inst.thing.linno == singst)
58: singflg = 1;
59: if(singflg == 1)
60: {
61: save = expr;
62: prin();
63: expr = save;
64: hold = inst.thing.opcode.lobyte;
65: }
66: if(bascall(inst.thing.opcode.lobyte) != 0)
67: error(inst.thing.opcode.lobyte,15); /* execution error */
68: if(singflg == -1)
69: return(0);
70: if(hold == subog)
71: return(0);
72: return(singwt());
73: }
74: singwt()
75: {
76: char *save;
77: if(singflg == 0) return(-1);
78: while(1)
79: {
80: printf("%c",'^');
81: if(fgets(_string,LINMAX,stdin) == 0) return(-1); /* ctl d */
82: if(_string[0] == '\n') return(0);
83: save = ptr;
84: bed((FILE *)0);
85: ptr = save;
86: if(singflg == -1) break;
87: }
88: return(0);
89: }
90: con()
91: {
92: if(expr[0] != 0)
93: singst = atoi(expr);
94: else
95: singst = 32767;
96: singflg = -1;
97: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.