xref: /original-bsd/usr.bin/pascal/pdx/process/step.c (revision a1c2194a)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)step.c	5.3 (Berkeley) 04/16/91";
10 #endif /* not lint */
11 
12 /*
13  * Continue execution up to the next source line.
14  *
15  * We call "nextaddr" from the machine module to figure out
16  * what the object address is that corresponds to the next source line.
17  * If nextaddr returns -1, then the end of the program has been reached.
18  *
19  * There are two ways to define the next source line depending on what
20  * is desired when a procedure or function call is encountered.  Step
21  * stops at the beginning of the procedure or call; next skips over it.
22  */
23 
24 #include "defs.h"
25 #include "process.h"
26 #include "machine.h"
27 #include "breakpoint.h"
28 #include "source.h"
29 #include "mappings.h"
30 #include "process.rep"
31 
32 /*
33  * Stepc is what is called when the step command is given.
34  * It has to play with the "isstopped" information.
35  */
36 
37 stepc()
38 {
39     if (!isstopped) {
40 	error("can't continue execution");
41     }
42     isstopped = FALSE;
43     dostep(FALSE);
44     isstopped = TRUE;
45 }
46 
47 next()
48 {
49     if (!isstopped) {
50 	error("can't continue execution");
51     }
52     isstopped = FALSE;
53     dostep(TRUE);
54     isstopped = TRUE;
55 }
56 
57 step()
58 {
59     dostep(FALSE);
60 }
61 
62 /*
63  * Resume execution up to the given address.  It is assumed that
64  * no breakpoints exist between the current address and the one
65  * we're stepping to.  This saves us from setting all the breakpoints.
66  */
67 
68 stepto(addr)
69 ADDRESS addr;
70 {
71     setbp(addr);
72     resume();
73     unsetbp(addr);
74     if (!isbperr()) {
75 	printstatus();
76     }
77 }
78 
79 LOCAL dostep(isnext)
80 BOOLEAN isnext;
81 {
82     register ADDRESS addr;
83     register LINENO line;
84 
85     addr = pc;
86     do {
87 	addr = nextaddr(addr, isnext);
88 	line = linelookup(addr);
89     } while (line == 0 && !ss_instructions);
90     stepto(addr);
91     curline = line;
92 }
93