122515Sdist /* 222515Sdist * Copyright (c) 1980 Regents of the University of California. 322515Sdist * All rights reserved. The Berkeley software License Agreement 422515Sdist * specifies the terms and conditions for redistribution. 522515Sdist */ 65511Slinton 722515Sdist #ifndef lint 8*30848Smckusick static char sccsid[] = "@(#)step.c 5.2 (Berkeley) 04/07/87"; 922515Sdist #endif not lint 105511Slinton /* 115511Slinton * Continue execution up to the next source line. 125511Slinton * 135511Slinton * We call "nextaddr" from the machine module to figure out 145511Slinton * what the object address is that corresponds to the next source line. 155511Slinton * If nextaddr returns -1, then the end of the program has been reached. 165511Slinton * 175511Slinton * There are two ways to define the next source line depending on what 185511Slinton * is desired when a procedure or function call is encountered. Step 195511Slinton * stops at the beginning of the procedure or call; next skips over it. 205511Slinton */ 215511Slinton 225511Slinton #include "defs.h" 235511Slinton #include "process.h" 245511Slinton #include "machine.h" 255511Slinton #include "breakpoint.h" 265511Slinton #include "source.h" 275511Slinton #include "mappings.h" 285511Slinton #include "process.rep" 295511Slinton 305511Slinton /* 315511Slinton * Stepc is what is called when the step command is given. 325511Slinton * It has to play with the "isstopped" information. 335511Slinton */ 345511Slinton 355511Slinton stepc() 365511Slinton { 375761Slinton if (!isstopped) { 385761Slinton error("can't continue execution"); 395761Slinton } 405761Slinton isstopped = FALSE; 415761Slinton dostep(FALSE); 425761Slinton isstopped = TRUE; 435511Slinton } 445511Slinton 455511Slinton next() 465511Slinton { 475761Slinton if (!isstopped) { 485761Slinton error("can't continue execution"); 495761Slinton } 505761Slinton isstopped = FALSE; 515761Slinton dostep(TRUE); 525761Slinton isstopped = TRUE; 535511Slinton } 545511Slinton 555511Slinton step() 565511Slinton { 575761Slinton dostep(FALSE); 585511Slinton } 595511Slinton 605511Slinton /* 615511Slinton * Resume execution up to the given address. It is assumed that 625511Slinton * no breakpoints exist between the current address and the one 635511Slinton * we're stepping to. This saves us from setting all the breakpoints. 645511Slinton */ 655511Slinton 665511Slinton stepto(addr) 675511Slinton ADDRESS addr; 685511Slinton { 695761Slinton setbp(addr); 705761Slinton resume(); 715761Slinton unsetbp(addr); 725761Slinton if (!isbperr()) { 735761Slinton printstatus(); 745761Slinton } 755511Slinton } 765511Slinton 775511Slinton LOCAL dostep(isnext) 785511Slinton BOOLEAN isnext; 795511Slinton { 805761Slinton register ADDRESS addr; 815761Slinton register LINENO line; 825511Slinton 835761Slinton addr = pc; 845761Slinton do { 85*30848Smckusick addr = nextaddr(addr, isnext); 865761Slinton line = linelookup(addr); 875761Slinton } while (line == 0 && !ss_instructions); 885761Slinton stepto(addr); 895761Slinton curline = line; 905511Slinton } 91