1 /* Copyright (c) 1982 Regents of the University of California */ 2 3 static char sccsid[] = "@(#)start.c 1.6 03/08/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 } else { 81 panic("could not start program"); 82 } 83 } 84 85 /* 86 * Note the termination of the program. We do this so as to avoid 87 * having the process exit, which would make the values of variables 88 * inaccessible. 89 * 90 * Although the END_BP should really be deleted, it is taken 91 * care of by fixbps the next time the program runs. 92 */ 93 94 endprogram() 95 { 96 if (ss_variables) { 97 prvarnews(); 98 } 99 printf("\nexecution completed\n"); 100 curfunc = program; 101 skimsource(srcfilename(pc)); 102 curline = lastlinenum; 103 erecover(); 104 } 105 106 /* 107 * set up what signals we want to trace 108 */ 109 110 LOCAL setsigtrace() 111 { 112 register int i; 113 register PROCESS *p; 114 115 p = process; 116 psigtrace(p, SIGINT, TRUE); 117 psigtrace(p, SIGTRAP, TRUE); 118 psigtrace(p, SIGIOT, TRUE); 119 psigtrace(p, SIGILL, TRUE); 120 psigtrace(p, SIGBUS, TRUE); 121 } 122