4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / pascal / pdx / process / resume.c
CommitLineData
505bf312 1/*-
2839532b
KB
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
505bf312
KB
4 *
5 * %sccs.include.redist.c%
f644bb55 6 */
4a4056d7 7
f644bb55 8#ifndef lint
2839532b 9static char sccsid[] = "@(#)resume.c 8.1 (Berkeley) %G%";
505bf312 10#endif /* not lint */
82d3cd01 11
4a4056d7 12/*
c9208449 13 * Resume execution, first setting appropriate registers.
4a4056d7
ML
14 */
15
16#include "defs.h"
17#include <signal.h>
18#include "process.h"
19#include "machine.h"
20#include "main.h"
21#include "process.rep"
22#include "runtime/frame.rep"
23
c9208449
ML
24#include "machine/pxerrors.h"
25#include "pxinfo.h"
4a4056d7 26
4a4056d7 27/*
ca0bf12f 28 * Resume execution, set (get) pcode location counter before (after) resuming.
4a4056d7
ML
29 */
30
31resume()
32{
eb010214 33 register PROCESS *p;
eb010214
ML
34
35 p = process;
36 do {
37 if (option('e')) {
38 printf("execution resumes at pc 0x%x, lc %d\n", process->pc, pc);
39 fflush(stdout);
40 }
41 pcont(p);
24ba2374 42 dread(&pc, PCADDR, sizeof(pc)); /* Get pcode pc */
eb010214
ML
43 if (option('e')) {
44 printf("execution stops at pc 0x%x, lc %d on sig %d\n",
45 process->pc, pc, p->signo);
46 fflush(stdout);
47 }
eb010214 48 } while (p->signo == SIGCONT);
c9208449
ML
49 if (option('r') && p->signo != 0) {
50 choose();
51 }
ca0bf12f
ML
52
53 /*
54 * If px implements a breakpoint by executing a halt instruction
c9208449
ML
55 * the real pc must be incremented to skip over it.
56 *
57 * Currently, px sends itself a signal so no incrementing is needed.
58 *
59 if (isbperr()) {
60 p->pc++;
61 }
ca0bf12f 62 */
4a4056d7
ML
63}
64
4a4056d7
ML
65/*
66 * Under the -r option, we offer the opportunity to just get
67 * the px traceback and not actually enter the debugger.
b22f61d1
ML
68 *
69 * If the standard input is not a tty but standard error is,
70 * change standard input to be /dev/tty.
4a4056d7
ML
71 */
72
73LOCAL choose()
74{
eb010214
ML
75 register int c;
76
2f7c752b
ML
77 if (!isterm(stdin)) {
78 if (!isterm(stderr) || freopen("/dev/tty", "r", stdin) == NIL) {
b22f61d1
ML
79 unsetsigtraces(process);
80 pcont(process);
81 quit(process->exitval);
82 /* NOTREACHED */
83 }
84 }
eb010214 85 fprintf(stderr, "\nProgram error");
eb010214
ML
86 fprintf(stderr, "\nDo you wish to enter the debugger? ");
87 c = getchar();
88 if (c == 'n') {
89 unsetsigtraces(process);
90 pcont(process);
91 quit(process->exitval);
92 }
b22f61d1 93 while (c != '\n' && c != EOF) {
4a4056d7 94 c = getchar();
eb010214
ML
95 }
96 fprintf(stderr, "\nEntering debugger ...");
97 init();
98 option('r') = FALSE;
99 fprintf(stderr, " type 'help' for help.\n");
4a4056d7 100}