Commit | Line | Data |
---|---|---|
2eea383b ML |
1 | /* Copyright (c) 1982 Regents of the University of California */ |
2 | ||
3 | static char sccsid[] = "@(#)runcont.c 1.1 %G%"; | |
4 | ||
5 | /* | |
6 | * execution management | |
7 | */ | |
8 | ||
9 | #include "defs.h" | |
10 | #include <signal.h> | |
11 | #include "process.h" | |
12 | #include "machine.h" | |
13 | #include "object.h" | |
14 | #include "breakpoint.h" | |
15 | #include "command.h" | |
16 | #include "process.rep" | |
17 | ||
18 | #define MAXNARGS 10 /* maximum number of arguments to RUN */ | |
19 | ||
20 | typedef char *string; | |
21 | ||
22 | LOCAL BOOLEAN just_started; | |
23 | LOCAL int argc; | |
24 | LOCAL string argv[MAXNARGS]; | |
25 | LOCAL string infile; | |
26 | LOCAL string outfile; | |
27 | ||
28 | /* | |
29 | * initialize the argument list | |
30 | */ | |
31 | ||
32 | arginit() | |
33 | { | |
34 | infile = NIL; | |
35 | outfile = NIL; | |
36 | # if (isvaxpx) | |
37 | argv[0] = "px"; | |
38 | argv[1] = "-d"; | |
39 | argv[2] = objname; | |
40 | argc = 3; | |
41 | # else | |
42 | argv[0] = objname; | |
43 | argc = 1; | |
44 | # endif | |
45 | } | |
46 | ||
47 | /* | |
48 | * add an argument to the list for the debuggee | |
49 | */ | |
50 | ||
51 | newarg(arg) | |
52 | string arg; | |
53 | { | |
54 | if (argc >= MAXNARGS) { | |
55 | error("too many arguments"); | |
56 | } | |
57 | argv[argc++] = arg; | |
58 | } | |
59 | ||
60 | /* | |
61 | * set the standard input for the debuggee | |
62 | */ | |
63 | ||
64 | inarg(filename) | |
65 | string filename; | |
66 | { | |
67 | if (infile != NIL) { | |
68 | error("multiple input redirects"); | |
69 | } | |
70 | infile = filename; | |
71 | } | |
72 | ||
73 | /* | |
74 | * set the standard output for the debuggee | |
75 | * should probably check to avoid overwriting an existing file | |
76 | */ | |
77 | ||
78 | outarg(filename) | |
79 | string filename; | |
80 | { | |
81 | if (outfile != NIL) { | |
82 | error("multiple output redirect"); | |
83 | } | |
84 | outfile = filename; | |
85 | } | |
86 | ||
87 | /* | |
88 | * run starts debuggee executing | |
89 | */ | |
90 | ||
91 | run() | |
92 | { | |
93 | fixbps(); | |
94 | curline = 0; | |
95 | start(argv, infile, outfile); | |
96 | just_started = TRUE; | |
97 | isstopped = FALSE; | |
98 | cont(); | |
99 | } | |
100 | ||
101 | /* | |
102 | * continue execution wherever we left off | |
103 | * | |
104 | * Note that this routine never returns. Eventually bpact() will fail | |
105 | * and we'll call printstatus or step will call it. | |
106 | */ | |
107 | ||
108 | typedef int INTFUNC(); | |
109 | ||
110 | LOCAL INTFUNC *dbintr; | |
111 | LOCAL intr(); | |
112 | ||
113 | #define succeeds == TRUE | |
114 | #define fails == FALSE | |
115 | ||
116 | cont() | |
117 | { | |
118 | dbintr = signal(SIGINT, &intr); | |
119 | if (just_started) { | |
120 | just_started = FALSE; | |
121 | } else { | |
122 | if (!isstopped) { | |
123 | error("can't continue execution"); | |
124 | } | |
125 | isstopped = FALSE; | |
126 | step(); | |
127 | } | |
128 | for (;;) { | |
129 | if (single_stepping) { | |
130 | printnews(); | |
131 | } else { | |
132 | setallbps(); | |
133 | resume(); | |
134 | unsetallbps(); | |
135 | if (bpact() fails) { | |
136 | printstatus(); | |
137 | } | |
138 | } | |
139 | step(); | |
140 | } | |
141 | /*NOTREACHED*/ | |
142 | } | |
143 | ||
144 | /* | |
145 | * This routine is called if we get an interrupt while "running" px | |
146 | * but actually in the debugger. Could happen, for example, while | |
147 | * processing breakpoints. | |
148 | * | |
149 | * We basically just want to keep going; the assumption is | |
150 | * that when the process resumes it will get the interrupt | |
151 | * which will then be handled. | |
152 | */ | |
153 | ||
154 | LOCAL intr() | |
155 | { | |
156 | signal(SIGINT, &intr); | |
157 | } | |
158 | ||
159 | fixintr() | |
160 | { | |
161 | signal(SIGINT, &dbintr); | |
162 | } |