1*48096Sbostic /*- 2*48096Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*48096Sbostic * All rights reserved. 4*48096Sbostic * 5*48096Sbostic * %sccs.include.redist.c% 622512Sdist */ 75508Slinton 822512Sdist #ifndef lint 9*48096Sbostic static char sccsid[] = "@(#)resume.c 5.4 (Berkeley) 04/16/91"; 10*48096Sbostic #endif /* not lint */ 1130848Smckusick 125508Slinton /* 1311061Slinton * Resume execution, first setting appropriate registers. 145508Slinton */ 155508Slinton 165508Slinton #include "defs.h" 175508Slinton #include <signal.h> 185508Slinton #include "process.h" 195508Slinton #include "machine.h" 205508Slinton #include "main.h" 215508Slinton #include "process.rep" 225508Slinton #include "runtime/frame.rep" 235508Slinton 2411061Slinton #include "machine/pxerrors.h" 2511061Slinton #include "pxinfo.h" 265508Slinton 275508Slinton /* 2810766Slinton * Resume execution, set (get) pcode location counter before (after) resuming. 295508Slinton */ 305508Slinton 315508Slinton resume() 325508Slinton { 335714Slinton register PROCESS *p; 345508Slinton 355714Slinton p = process; 365714Slinton do { 375714Slinton if (option('e')) { 385714Slinton printf("execution resumes at pc 0x%x, lc %d\n", process->pc, pc); 395714Slinton fflush(stdout); 405714Slinton } 415714Slinton pcont(p); 4236538Smckusick dread(&pc, PCADDR, sizeof(pc)); /* Get pcode pc */ 435714Slinton if (option('e')) { 445714Slinton printf("execution stops at pc 0x%x, lc %d on sig %d\n", 455714Slinton process->pc, pc, p->signo); 465714Slinton fflush(stdout); 475714Slinton } 485714Slinton } while (p->signo == SIGCONT); 4911061Slinton if (option('r') && p->signo != 0) { 5011061Slinton choose(); 5111061Slinton } 5210766Slinton 5310766Slinton /* 5410766Slinton * If px implements a breakpoint by executing a halt instruction 5511061Slinton * the real pc must be incremented to skip over it. 5611061Slinton * 5711061Slinton * Currently, px sends itself a signal so no incrementing is needed. 5811061Slinton * 5911061Slinton if (isbperr()) { 6011061Slinton p->pc++; 6111061Slinton } 6210766Slinton */ 635508Slinton } 645508Slinton 655508Slinton /* 665508Slinton * Under the -r option, we offer the opportunity to just get 675508Slinton * the px traceback and not actually enter the debugger. 686074Slinton * 696074Slinton * If the standard input is not a tty but standard error is, 706074Slinton * change standard input to be /dev/tty. 715508Slinton */ 725508Slinton 735508Slinton LOCAL choose() 745508Slinton { 755714Slinton register int c; 765508Slinton 776873Slinton if (!isterm(stdin)) { 786873Slinton if (!isterm(stderr) || freopen("/dev/tty", "r", stdin) == NIL) { 796074Slinton unsetsigtraces(process); 806074Slinton pcont(process); 816074Slinton quit(process->exitval); 826074Slinton /* NOTREACHED */ 836074Slinton } 846074Slinton } 855714Slinton fprintf(stderr, "\nProgram error"); 865714Slinton fprintf(stderr, "\nDo you wish to enter the debugger? "); 875714Slinton c = getchar(); 885714Slinton if (c == 'n') { 895714Slinton unsetsigtraces(process); 905714Slinton pcont(process); 915714Slinton quit(process->exitval); 925714Slinton } 936074Slinton while (c != '\n' && c != EOF) { 945508Slinton c = getchar(); 955714Slinton } 965714Slinton fprintf(stderr, "\nEntering debugger ..."); 975714Slinton init(); 985714Slinton option('r') = FALSE; 995714Slinton fprintf(stderr, " type 'help' for help.\n"); 1005508Slinton } 101