122514Sdist /* 222514Sdist * Copyright (c) 1980 Regents of the University of California. 322514Sdist * All rights reserved. The Berkeley software License Agreement 422514Sdist * specifies the terms and conditions for redistribution. 522514Sdist */ 65510Slinton 722514Sdist #ifndef lint 8*30848Smckusick static char sccsid[] = "@(#)start.c 5.2 (Berkeley) 04/07/87"; 922514Sdist #endif not lint 10*30848Smckusick 115510Slinton /* 125510Slinton * Begin execution. 135510Slinton * 145510Slinton * For px, pstart does a traced exec to read in px and then stop. But we 155510Slinton * want control after px has read in the obj file and before it starts 165653Slinton * executing. The zeroth argument to px tells it to give us control 175510Slinton * by sending itself a signal just prior to interpreting. 185510Slinton * 195510Slinton * We set a "END_BP" breakpoint at the end of the code so that the 205510Slinton * process data doesn't disappear after the program terminates. 215510Slinton */ 225510Slinton 235510Slinton #include "defs.h" 245510Slinton #include <signal.h> 255510Slinton #include "process.h" 265510Slinton #include "machine.h" 275653Slinton #include "main.h" 285510Slinton #include "breakpoint.h" 295510Slinton #include "source.h" 305510Slinton #include "object.h" 315510Slinton #include "mappings.h" 325510Slinton #include "sym.h" 335510Slinton #include "process.rep" 345510Slinton 35*30848Smckusick #include "pxinfo.h" 365510Slinton 375510Slinton start(argv, infile, outfile) 385510Slinton char **argv; 395510Slinton char *infile, *outfile; 405510Slinton { 415714Slinton char *cmd; 425510Slinton 435714Slinton setsigtrace(); 44*30848Smckusick cmd = "/usr/ucb/px"; 455714Slinton pstart(process, cmd, argv, infile, outfile); 465714Slinton if (process->status == STOPPED) { 47*30848Smckusick TRAPARGS *ap, t; 485653Slinton 49*30848Smckusick pcont(process); 50*30848Smckusick if (process->status != STOPPED) { 51*30848Smckusick if (option('t')) { 52*30848Smckusick quit(process->exitval); 53*30848Smckusick } else { 54*30848Smckusick panic("px exited with %d", process->exitval); 555714Slinton } 56*30848Smckusick } 57*30848Smckusick #ifdef tahoe 58*30848Smckusick dread(&ap, process->fp, sizeof(ap)); 59*30848Smckusick ap = (TRAPARGS *)((unsigned)ap - 4); 60*30848Smckusick dread(&RETLOC, process->fp - 8, sizeof(RETLOC)); 61*30848Smckusick #else 62*30848Smckusick dread(&ap, process->fp + 2*sizeof(int), sizeof(ap)); 63*30848Smckusick #endif 64*30848Smckusick dread(&t, ap, sizeof(TRAPARGS)); 65*30848Smckusick 66*30848Smckusick #define NARGS 5 67*30848Smckusick #ifdef tahoe 68*30848Smckusick # define STKNARGS (sizeof(int)*(NARGS+1)) 69*30848Smckusick # define NARGLOC t.trp_removed 70*30848Smckusick #else 71*30848Smckusick # define STKNARGS (NARGS) 72*30848Smckusick # define NARGLOC t.nargs 73*30848Smckusick #endif 74*30848Smckusick if (NARGLOC != STKNARGS) { 75*30848Smckusick if (option('t')) { 76*30848Smckusick unsetsigtraces(process); 77*30848Smckusick pcont(process); 78*30848Smckusick quit(process->exitval); 79*30848Smckusick } else { 80*30848Smckusick panic("start: args out of sync"); 815714Slinton } 82*30848Smckusick } 83*30848Smckusick DISPLAY = t.disp; 84*30848Smckusick DP = t.dp; 85*30848Smckusick ENDOFF = t.objstart; 86*30848Smckusick PCADDRP = t.pcaddrp; 87*30848Smckusick LOOPADDR = t.loopaddr; 885714Slinton pc = 0; 895714Slinton curfunc = program; 905714Slinton if (objsize != 0) { 915714Slinton addbp(lastaddr(), END_BP, NIL, NIL, NIL, 0); 925510Slinton } 935714Slinton } 945510Slinton } 955510Slinton 965510Slinton /* 975510Slinton * Note the termination of the program. We do this so as to avoid 985510Slinton * having the process exit, which would make the values of variables 995510Slinton * inaccessible. 1005510Slinton * 1015510Slinton * Although the END_BP should really be deleted, it is taken 1025510Slinton * care of by fixbps the next time the program runs. 1035510Slinton */ 1045510Slinton 1055510Slinton endprogram() 1065510Slinton { 1075714Slinton if (ss_variables) { 1085714Slinton prvarnews(); 1095714Slinton } 1105714Slinton printf("\nexecution completed\n"); 1115714Slinton curfunc = program; 1125761Slinton skimsource(srcfilename(pc)); 1135714Slinton curline = lastlinenum; 1145714Slinton erecover(); 1155510Slinton } 1165510Slinton 1175510Slinton /* 1185510Slinton * set up what signals we want to trace 1195510Slinton */ 1205510Slinton 1215510Slinton LOCAL setsigtrace() 1225510Slinton { 1235714Slinton register PROCESS *p; 1245510Slinton 1255714Slinton p = process; 1265714Slinton psigtrace(p, SIGINT, TRUE); 1275714Slinton psigtrace(p, SIGTRAP, TRUE); 1285714Slinton psigtrace(p, SIGIOT, TRUE); 1295739Slinton psigtrace(p, SIGILL, TRUE); 1305761Slinton psigtrace(p, SIGBUS, TRUE); 1315510Slinton } 132