|
|
1.1 root 1: /* Copyright (c) 1982 Regents of the University of California */
2:
3: static char sccsid[] = "@(#)start.c 1.7 3/8/82";
4:
5: /*
6: * Begin execution.
7: *
8: * For px, pstart does a traced exec to read in px and then stop. But we
9: * want control after px has read in the obj file and before it starts
10: * executing. The zeroth argument to px tells it to give us control
11: * by sending itself a signal just prior to interpreting.
12: *
13: * We set a "END_BP" breakpoint at the end of the code so that the
14: * process data doesn't disappear after the program terminates.
15: */
16:
17: #include "defs.h"
18: #include <signal.h>
19: #include "process.h"
20: #include "machine.h"
21: #include "main.h"
22: #include "breakpoint.h"
23: #include "source.h"
24: #include "object.h"
25: #include "mappings.h"
26: #include "sym.h"
27: #include "process.rep"
28:
29: # if (isvaxpx)
30: # include "pxinfo.h"
31: # endif
32:
33: start(argv, infile, outfile)
34: char **argv;
35: char *infile, *outfile;
36: {
37: char *cmd;
38:
39: setsigtrace();
40: # if (isvaxpx)
41: cmd = "px";
42: # else
43: cmd = argv[0];
44: # endif
45: pstart(process, cmd, argv, infile, outfile);
46: if (process->status == STOPPED) {
47: # if (isvaxpx)
48: TRAPARGS *ap, t;
49:
50: pcont(process);
51: if (process->status != STOPPED) {
52: if (option('t')) {
53: quit(process->exitval);
54: } else {
55: panic("px exited with %d", process->exitval);
56: }
57: }
58: dread(&ap, process->fp + 2*sizeof(int), sizeof(ap));
59: dread(&t, ap, sizeof(TRAPARGS));
60: if (t.nargs != 5) {
61: if (option('t')) {
62: unsetsigtraces(process);
63: pcont(process);
64: quit(process->exitval);
65: } else {
66: panic("start: args out of sync");
67: }
68: }
69: DISPLAY = t.disp;
70: DP = t.dp;
71: ENDOFF = t.objstart;
72: PCADDRP = t.pcaddrp;
73: LOOPADDR = t.loopaddr;
74: # endif
75: pc = 0;
76: curfunc = program;
77: if (objsize != 0) {
78: addbp(lastaddr(), END_BP, NIL, NIL, NIL, 0);
79: }
80: }
81: }
82:
83: /*
84: * Note the termination of the program. We do this so as to avoid
85: * having the process exit, which would make the values of variables
86: * inaccessible.
87: *
88: * Although the END_BP should really be deleted, it is taken
89: * care of by fixbps the next time the program runs.
90: */
91:
92: endprogram()
93: {
94: if (ss_variables) {
95: prvarnews();
96: }
97: printf("\nexecution completed\n");
98: curfunc = program;
99: skimsource(srcfilename(pc));
100: curline = lastlinenum;
101: erecover();
102: }
103:
104: /*
105: * set up what signals we want to trace
106: */
107:
108: LOCAL setsigtrace()
109: {
110: register int i;
111: register PROCESS *p;
112:
113: p = process;
114: psigtrace(p, SIGINT, TRUE);
115: psigtrace(p, SIGTRAP, TRUE);
116: psigtrace(p, SIGIOT, TRUE);
117: psigtrace(p, SIGILL, TRUE);
118: psigtrace(p, SIGBUS, TRUE);
119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.