148096Sbostic /*-
2*62144Sbostic  * Copyright (c) 1980, 1993
3*62144Sbostic  *	The Regents of the University of California.  All rights reserved.
448096Sbostic  *
548096Sbostic  * %sccs.include.redist.c%
622515Sdist  */
75511Slinton 
822515Sdist #ifndef lint
9*62144Sbostic static char sccsid[] = "@(#)step.c	8.1 (Berkeley) 06/06/93";
1048096Sbostic #endif /* not lint */
1148096Sbostic 
125511Slinton /*
135511Slinton  * Continue execution up to the next source line.
145511Slinton  *
155511Slinton  * We call "nextaddr" from the machine module to figure out
165511Slinton  * what the object address is that corresponds to the next source line.
175511Slinton  * If nextaddr returns -1, then the end of the program has been reached.
185511Slinton  *
195511Slinton  * There are two ways to define the next source line depending on what
205511Slinton  * is desired when a procedure or function call is encountered.  Step
215511Slinton  * stops at the beginning of the procedure or call; next skips over it.
225511Slinton  */
235511Slinton 
245511Slinton #include "defs.h"
255511Slinton #include "process.h"
265511Slinton #include "machine.h"
275511Slinton #include "breakpoint.h"
285511Slinton #include "source.h"
295511Slinton #include "mappings.h"
305511Slinton #include "process.rep"
315511Slinton 
325511Slinton /*
335511Slinton  * Stepc is what is called when the step command is given.
345511Slinton  * It has to play with the "isstopped" information.
355511Slinton  */
365511Slinton 
stepc()375511Slinton stepc()
385511Slinton {
395761Slinton     if (!isstopped) {
405761Slinton 	error("can't continue execution");
415761Slinton     }
425761Slinton     isstopped = FALSE;
435761Slinton     dostep(FALSE);
445761Slinton     isstopped = TRUE;
455511Slinton }
465511Slinton 
next()475511Slinton next()
485511Slinton {
495761Slinton     if (!isstopped) {
505761Slinton 	error("can't continue execution");
515761Slinton     }
525761Slinton     isstopped = FALSE;
535761Slinton     dostep(TRUE);
545761Slinton     isstopped = TRUE;
555511Slinton }
565511Slinton 
step()575511Slinton step()
585511Slinton {
595761Slinton     dostep(FALSE);
605511Slinton }
615511Slinton 
625511Slinton /*
635511Slinton  * Resume execution up to the given address.  It is assumed that
645511Slinton  * no breakpoints exist between the current address and the one
655511Slinton  * we're stepping to.  This saves us from setting all the breakpoints.
665511Slinton  */
675511Slinton 
stepto(addr)685511Slinton stepto(addr)
695511Slinton ADDRESS addr;
705511Slinton {
715761Slinton     setbp(addr);
725761Slinton     resume();
735761Slinton     unsetbp(addr);
745761Slinton     if (!isbperr()) {
755761Slinton 	printstatus();
765761Slinton     }
775511Slinton }
785511Slinton 
dostep(isnext)795511Slinton LOCAL dostep(isnext)
805511Slinton BOOLEAN isnext;
815511Slinton {
825761Slinton     register ADDRESS addr;
835761Slinton     register LINENO line;
845511Slinton 
855761Slinton     addr = pc;
865761Slinton     do {
8730848Smckusick 	addr = nextaddr(addr, isnext);
885761Slinton 	line = linelookup(addr);
895761Slinton     } while (line == 0 && !ss_instructions);
905761Slinton     stepto(addr);
915761Slinton     curline = line;
925511Slinton }
93