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[] = "@(#)runcont.c	5.1 (Berkeley) 6/6/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * Execution management.
  13:  */
  14: 
  15: #include "defs.h"
  16: #include <signal.h>
  17: #include "process.h"
  18: #include "machine.h"
  19: #include "object.h"
  20: #include "main.h"
  21: #include "breakpoint.h"
  22: #include "command.h"
  23: #include "process.rep"
  24: 
  25: #define MAXNARGS 100        /* maximum number of arguments to RUN */
  26: 
  27: typedef char *String;
  28: 
  29: LOCAL BOOLEAN just_started;
  30: LOCAL int argc;
  31: LOCAL String argv[MAXNARGS];
  32: LOCAL String infile;
  33: LOCAL String outfile;
  34: LOCAL PROCESS pbuf;
  35: PROCESS *process = &pbuf;
  36: 
  37: /*
  38:  * This is a px-related kludge to deal with the possibility
  39:  * of object code magically coming from a tmp file.
  40:  */
  41: 
  42: LOCAL String mode;
  43: LOCAL String realname;
  44: 
  45: setargs(m, r)
  46: char *m, *r;
  47: {
  48:     mode = m;
  49:     realname = r;
  50: }
  51: 
  52: /*
  53:  * Initialize the argument list.
  54:  */
  55: 
  56: arginit()
  57: {
  58:     infile = NIL;
  59:     outfile = NIL;
  60: #   if (isvaxpx)
  61:     argv[0] = mode;
  62:     argv[1] = objname;
  63:     if (option('t') && realname == NIL) {
  64:         argc = 2;
  65:     } else {
  66:         argv[2] = realname;
  67:         argc = 3;
  68:     }
  69: #   else
  70:     argv[0] = objname;
  71:     argc = 1;
  72: #   endif
  73: }
  74: 
  75: /*
  76:  * Add an argument to the list for the debuggee.
  77:  */
  78: 
  79: newarg(arg)
  80: String arg;
  81: {
  82:     if (argc >= MAXNARGS) {
  83:     error("too many arguments to run");
  84:     }
  85:     argv[argc++] = arg;
  86: }
  87: 
  88: /*
  89:  * Set the standard input for the debuggee.
  90:  */
  91: 
  92: inarg(filename)
  93: String filename;
  94: {
  95:     if (infile != NIL) {
  96:     error("multiple input redirects");
  97:     }
  98:     infile = filename;
  99: }
 100: 
 101: /*
 102:  * Set the standard output for the debuggee.
 103:  * Probably should check to avoid overwriting an existing file.
 104:  */
 105: 
 106: outarg(filename)
 107: String filename;
 108: {
 109:     if (outfile != NIL) {
 110:     error("multiple output redirect");
 111:     }
 112:     outfile = filename;
 113: }
 114: 
 115: /*
 116:  * Initial start of the process.  The idea is to get it to the point
 117:  * where the object code has been loaded but execution has not begun.
 118:  */
 119: 
 120: initstart()
 121: {
 122:     arginit();
 123:     argv[argc] = NIL;
 124:     initcache(process);
 125:     start(argv, infile, outfile);
 126:     if (process->status != STOPPED) {
 127:     panic("could not start program");
 128:     }
 129: }
 130: 
 131: /*
 132:  * Run starts debuggee executing.
 133:  */
 134: 
 135: run()
 136: {
 137:     fixbps();
 138:     curline = 0;
 139:     argv[argc] = NIL;
 140:     start(argv, infile, outfile);
 141:     if (process->status == STOPPED) {
 142:     just_started = TRUE;
 143:     isstopped = FALSE;
 144:     cont();
 145:     } else if (option('r')) {
 146:     panic("could not start program");
 147:     }
 148: }
 149: 
 150: /*
 151:  * Continue execution wherever we left off.
 152:  *
 153:  * Note that this routine never returns.  Eventually bpact() will fail
 154:  * and we'll call printstatus or step will call it.
 155:  */
 156: 
 157: typedef int INTFUNC();
 158: 
 159: LOCAL INTFUNC *dbintr;
 160: LOCAL intr();
 161: 
 162: #define succeeds    == TRUE
 163: #define fails       == FALSE
 164: 
 165: cont()
 166: {
 167:     dbintr = signal(SIGINT, intr);
 168:     if (just_started) {
 169:     just_started = FALSE;
 170:     } else {
 171:     if (!isstopped) {
 172:         error("can't continue execution");
 173:     }
 174:     isstopped = FALSE;
 175:     step();
 176:     }
 177:     for (;;) {
 178:     if (single_stepping) {
 179:         printnews();
 180:     } else {
 181:         setallbps();
 182:         resume();
 183:         unsetallbps();
 184:         if (bpact() fails) {
 185:         printstatus();
 186:         }
 187:     }
 188:     step();
 189:     }
 190:     /* NOTREACHED */
 191: }
 192: 
 193: /*
 194:  * This routine is called if we get an interrupt while "running" px
 195:  * but actually in the debugger.  Could happen, for example, while
 196:  * processing breakpoints.
 197:  *
 198:  * We basically just want to keep going; the assumption is
 199:  * that when the process resumes it will get the interrupt
 200:  * which will then be handled.
 201:  */
 202: 
 203: LOCAL intr()
 204: {
 205:     signal(SIGINT, intr);
 206: }
 207: 
 208: fixintr()
 209: {
 210:     signal(SIGINT, dbintr);
 211: }

Defined functions

arginit defined in line 56; used 1 times
cont defined in line 165; used 1 times
fixintr defined in line 208; used 1 times
inarg defined in line 92; never used
initstart defined in line 120; never used
intr defined in line 203; used 3 times
newarg defined in line 79; never used
outarg defined in line 106; never used
run defined in line 135; never used
setargs defined in line 45; never used

Defined variables

argc defined in line 30; used 7 times
argv defined in line 31; used 9 times
infile defined in line 32; used 5 times
mode defined in line 42; used 2 times
outfile defined in line 33; used 5 times
realname defined in line 43; used 3 times
sccsid defined in line 8; never used

Defined typedef's

String defined in line 27; used 8 times

Defined macros

MAXNARGS defined in line 25; used 2 times
fails defined in line 163; used 1 times
succeeds defined in line 162; never used
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1553
Valid CSS Valid XHTML 1.0 Strict