Commit | Line | Data |
---|---|---|
b4b7c436 ML |
1 | /* Copyright (c) 1982 Regents of the University of California */ |
2 | ||
3 | static char sccsid[] = "@(#)start.c 1.1 %G%"; | |
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 "-d" option 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 "breakpoint.h" | |
22 | #include "source.h" | |
23 | #include "object.h" | |
24 | #include "mappings.h" | |
25 | #include "sym.h" | |
26 | #include "process.rep" | |
27 | ||
28 | # if (isvaxpx) | |
29 | # include "pxinfo.h" | |
30 | # endif | |
31 | ||
32 | LOCAL PROCESS pbuf; | |
33 | ||
34 | start(argv, infile, outfile) | |
35 | char **argv; | |
36 | char *infile, *outfile; | |
37 | { | |
38 | char *pargv[4]; | |
39 | # if (isvaxpx) | |
40 | TRAPARGS *ap, t; | |
41 | # endif | |
42 | ||
43 | process = &pbuf; | |
44 | setsigtrace(); | |
45 | if (argv == NIL) { | |
46 | argv = pargv; | |
47 | # if (isvaxpx) | |
48 | pargv[0] = "px"; | |
49 | pargv[1] = "-d"; | |
50 | pargv[2] = objname; | |
51 | pargv[3] = NIL; | |
52 | # else | |
53 | pargv[0] = objname; | |
54 | pargv[1] = NIL; | |
55 | # endif | |
56 | } | |
57 | pstart(process, argv, infile, outfile); | |
58 | if (process->status == STOPPED) { | |
59 | # if (isvaxpx) | |
60 | pcont(process); | |
61 | if (process->status != STOPPED) { | |
62 | panic("px exited with %d", process->exitval); | |
63 | } | |
64 | dread(&ap, process->fp + 2*sizeof(int), sizeof(ap)); | |
65 | dread(&t, ap, sizeof(TRAPARGS)); | |
66 | if (t.nargs != 5) { | |
67 | panic("start: args out of sync"); | |
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 | char *filename; | |
95 | ||
96 | if (ss_variables) { | |
97 | prvarnews(); | |
98 | } | |
99 | printf("\nexecution completed\n"); | |
100 | curfunc = program; | |
101 | if ((filename = srcfilename(pc)) != cursource) { | |
102 | skimsource(filename); | |
103 | } | |
104 | curline = lastlinenum; | |
105 | erecover(); | |
106 | } | |
107 | ||
108 | /* | |
109 | * set up what signals we want to trace | |
110 | */ | |
111 | ||
112 | LOCAL setsigtrace() | |
113 | { | |
114 | register int i; | |
115 | register PROCESS *p; | |
116 | ||
117 | p = process; | |
118 | for (i = 1; i < NSIG; i++) { | |
119 | psigtrace(p, i, TRUE); | |
120 | } | |
121 | psigtrace(p, SIGHUP, FALSE); | |
122 | psigtrace(p, SIGKILL, FALSE); | |
123 | } |