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

Defined functions

endprogram defined in line 97; never used
setsigtrace defined in line 113; used 1 times
  • in line 44
start defined in line 38; used 2 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2886
Valid CSS Valid XHTML 1.0 Strict