Annotation of 43BSD/ucb/pascal/pdx/process/runcont.c, revision 1.1.1.1

1.1       root        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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.