122512Sdist /* 222512Sdist * Copyright (c) 1980 Regents of the University of California. 322512Sdist * All rights reserved. The Berkeley software License Agreement 422512Sdist * specifies the terms and conditions for redistribution. 522512Sdist */ 65508Slinton 722512Sdist #ifndef lint 8*36538Smckusick static char sccsid[] = "@(#)resume.c 5.3 (Berkeley) 01/09/89"; 922512Sdist #endif not lint 1030848Smckusick 115508Slinton /* 1211061Slinton * Resume execution, first setting appropriate registers. 135508Slinton */ 145508Slinton 155508Slinton #include "defs.h" 165508Slinton #include <signal.h> 175508Slinton #include "process.h" 185508Slinton #include "machine.h" 195508Slinton #include "main.h" 205508Slinton #include "process.rep" 215508Slinton #include "runtime/frame.rep" 225508Slinton 2311061Slinton #include "machine/pxerrors.h" 2411061Slinton #include "pxinfo.h" 255508Slinton 265508Slinton /* 2710766Slinton * Resume execution, set (get) pcode location counter before (after) resuming. 285508Slinton */ 295508Slinton 305508Slinton resume() 315508Slinton { 325714Slinton register PROCESS *p; 335508Slinton 345714Slinton p = process; 355714Slinton do { 365714Slinton if (option('e')) { 375714Slinton printf("execution resumes at pc 0x%x, lc %d\n", process->pc, pc); 385714Slinton fflush(stdout); 395714Slinton } 405714Slinton pcont(p); 41*36538Smckusick dread(&pc, PCADDR, sizeof(pc)); /* Get pcode pc */ 425714Slinton if (option('e')) { 435714Slinton printf("execution stops at pc 0x%x, lc %d on sig %d\n", 445714Slinton process->pc, pc, p->signo); 455714Slinton fflush(stdout); 465714Slinton } 475714Slinton } while (p->signo == SIGCONT); 4811061Slinton if (option('r') && p->signo != 0) { 4911061Slinton choose(); 5011061Slinton } 5110766Slinton 5210766Slinton /* 5310766Slinton * If px implements a breakpoint by executing a halt instruction 5411061Slinton * the real pc must be incremented to skip over it. 5511061Slinton * 5611061Slinton * Currently, px sends itself a signal so no incrementing is needed. 5711061Slinton * 5811061Slinton if (isbperr()) { 5911061Slinton p->pc++; 6011061Slinton } 6110766Slinton */ 625508Slinton } 635508Slinton 645508Slinton /* 655508Slinton * Under the -r option, we offer the opportunity to just get 665508Slinton * the px traceback and not actually enter the debugger. 676074Slinton * 686074Slinton * If the standard input is not a tty but standard error is, 696074Slinton * change standard input to be /dev/tty. 705508Slinton */ 715508Slinton 725508Slinton LOCAL choose() 735508Slinton { 745714Slinton register int c; 755508Slinton 766873Slinton if (!isterm(stdin)) { 776873Slinton if (!isterm(stderr) || freopen("/dev/tty", "r", stdin) == NIL) { 786074Slinton unsetsigtraces(process); 796074Slinton pcont(process); 806074Slinton quit(process->exitval); 816074Slinton /* NOTREACHED */ 826074Slinton } 836074Slinton } 845714Slinton fprintf(stderr, "\nProgram error"); 855714Slinton fprintf(stderr, "\nDo you wish to enter the debugger? "); 865714Slinton c = getchar(); 875714Slinton if (c == 'n') { 885714Slinton unsetsigtraces(process); 895714Slinton pcont(process); 905714Slinton quit(process->exitval); 915714Slinton } 926074Slinton while (c != '\n' && c != EOF) { 935508Slinton c = getchar(); 945714Slinton } 955714Slinton fprintf(stderr, "\nEntering debugger ..."); 965714Slinton init(); 975714Slinton option('r') = FALSE; 985714Slinton fprintf(stderr, " type 'help' for help.\n"); 995508Slinton } 100