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