Commit | Line | Data |
---|---|---|
505bf312 | 1 | /*- |
ad787160 C |
2 | * Copyright (c) 1980, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
505bf312 | 4 | * |
ad787160 C |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
f644bb55 | 32 | */ |
4a4056d7 | 33 | |
f644bb55 | 34 | #ifndef lint |
ad787160 | 35 | static char sccsid[] = "@(#)resume.c 8.1 (Berkeley) 6/6/93"; |
505bf312 | 36 | #endif /* not lint */ |
82d3cd01 | 37 | |
4a4056d7 | 38 | /* |
c9208449 | 39 | * Resume execution, first setting appropriate registers. |
4a4056d7 ML |
40 | */ |
41 | ||
42 | #include "defs.h" | |
43 | #include <signal.h> | |
44 | #include "process.h" | |
45 | #include "machine.h" | |
46 | #include "main.h" | |
47 | #include "process.rep" | |
48 | #include "runtime/frame.rep" | |
49 | ||
c9208449 ML |
50 | #include "machine/pxerrors.h" |
51 | #include "pxinfo.h" | |
4a4056d7 | 52 | |
4a4056d7 | 53 | /* |
ca0bf12f | 54 | * Resume execution, set (get) pcode location counter before (after) resuming. |
4a4056d7 ML |
55 | */ |
56 | ||
57 | resume() | |
58 | { | |
eb010214 | 59 | register PROCESS *p; |
eb010214 ML |
60 | |
61 | p = process; | |
62 | do { | |
63 | if (option('e')) { | |
64 | printf("execution resumes at pc 0x%x, lc %d\n", process->pc, pc); | |
65 | fflush(stdout); | |
66 | } | |
67 | pcont(p); | |
24ba2374 | 68 | dread(&pc, PCADDR, sizeof(pc)); /* Get pcode pc */ |
eb010214 ML |
69 | if (option('e')) { |
70 | printf("execution stops at pc 0x%x, lc %d on sig %d\n", | |
71 | process->pc, pc, p->signo); | |
72 | fflush(stdout); | |
73 | } | |
eb010214 | 74 | } while (p->signo == SIGCONT); |
c9208449 ML |
75 | if (option('r') && p->signo != 0) { |
76 | choose(); | |
77 | } | |
ca0bf12f ML |
78 | |
79 | /* | |
80 | * If px implements a breakpoint by executing a halt instruction | |
c9208449 ML |
81 | * the real pc must be incremented to skip over it. |
82 | * | |
83 | * Currently, px sends itself a signal so no incrementing is needed. | |
84 | * | |
85 | if (isbperr()) { | |
86 | p->pc++; | |
87 | } | |
ca0bf12f | 88 | */ |
4a4056d7 ML |
89 | } |
90 | ||
4a4056d7 ML |
91 | /* |
92 | * Under the -r option, we offer the opportunity to just get | |
93 | * the px traceback and not actually enter the debugger. | |
b22f61d1 ML |
94 | * |
95 | * If the standard input is not a tty but standard error is, | |
96 | * change standard input to be /dev/tty. | |
4a4056d7 ML |
97 | */ |
98 | ||
99 | LOCAL choose() | |
100 | { | |
eb010214 ML |
101 | register int c; |
102 | ||
2f7c752b ML |
103 | if (!isterm(stdin)) { |
104 | if (!isterm(stderr) || freopen("/dev/tty", "r", stdin) == NIL) { | |
b22f61d1 ML |
105 | unsetsigtraces(process); |
106 | pcont(process); | |
107 | quit(process->exitval); | |
108 | /* NOTREACHED */ | |
109 | } | |
110 | } | |
eb010214 | 111 | fprintf(stderr, "\nProgram error"); |
eb010214 ML |
112 | fprintf(stderr, "\nDo you wish to enter the debugger? "); |
113 | c = getchar(); | |
114 | if (c == 'n') { | |
115 | unsetsigtraces(process); | |
116 | pcont(process); | |
117 | quit(process->exitval); | |
118 | } | |
b22f61d1 | 119 | while (c != '\n' && c != EOF) { |
4a4056d7 | 120 | c = getchar(); |
eb010214 ML |
121 | } |
122 | fprintf(stderr, "\nEntering debugger ..."); | |
123 | init(); | |
124 | option('r') = FALSE; | |
125 | fprintf(stderr, " type 'help' for help.\n"); | |
4a4056d7 | 126 | } |