15510Slinton /* Copyright (c) 1982 Regents of the University of California */ 25510Slinton 3*5739Slinton static char sccsid[] = "@(#)start.c 1.4 02/10/82"; 45510Slinton 55510Slinton /* 65510Slinton * Begin execution. 75510Slinton * 85510Slinton * For px, pstart does a traced exec to read in px and then stop. But we 95510Slinton * want control after px has read in the obj file and before it starts 105653Slinton * executing. The zeroth argument to px tells it to give us control 115510Slinton * by sending itself a signal just prior to interpreting. 125510Slinton * 135510Slinton * We set a "END_BP" breakpoint at the end of the code so that the 145510Slinton * process data doesn't disappear after the program terminates. 155510Slinton */ 165510Slinton 175510Slinton #include "defs.h" 185510Slinton #include <signal.h> 195510Slinton #include "process.h" 205510Slinton #include "machine.h" 215653Slinton #include "main.h" 225510Slinton #include "breakpoint.h" 235510Slinton #include "source.h" 245510Slinton #include "object.h" 255510Slinton #include "mappings.h" 265510Slinton #include "sym.h" 275510Slinton #include "process.rep" 285510Slinton 295714Slinton # if (isvaxpx) 305714Slinton # include "pxinfo.h" 315714Slinton # endif 325510Slinton 335510Slinton LOCAL PROCESS pbuf; 345510Slinton 355510Slinton start(argv, infile, outfile) 365510Slinton char **argv; 375510Slinton char *infile, *outfile; 385510Slinton { 395714Slinton char *cmd; 405510Slinton 415714Slinton process = &pbuf; 425714Slinton setsigtrace(); 435714Slinton # if (isvaxpx) 445714Slinton cmd = "px"; 455714Slinton # else 465714Slinton cmd = argv[0]; 475714Slinton # endif 485714Slinton pstart(process, cmd, argv, infile, outfile); 495714Slinton if (process->status == STOPPED) { 505714Slinton # if (isvaxpx) 515714Slinton TRAPARGS *ap, t; 525653Slinton 535714Slinton pcont(process); 545714Slinton if (process->status != STOPPED) { 555714Slinton if (option('t')) { 565714Slinton quit(process->exitval); 575714Slinton } else { 585714Slinton panic("px exited with %d", process->exitval); 595510Slinton } 605714Slinton } 615714Slinton dread(&ap, process->fp + 2*sizeof(int), sizeof(ap)); 625714Slinton dread(&t, ap, sizeof(TRAPARGS)); 635714Slinton if (t.nargs != 5) { 645714Slinton if (option('t')) { 655714Slinton unsetsigtraces(process); 665714Slinton pcont(process); 675714Slinton quit(process->exitval); 685714Slinton } else { 695714Slinton panic("start: args out of sync"); 705714Slinton } 715714Slinton } 725714Slinton DISPLAY = t.disp; 735714Slinton DP = t.dp; 745714Slinton ENDOFF = t.objstart; 755714Slinton PCADDRP = t.pcaddrp; 765714Slinton LOOPADDR = t.loopaddr; 775714Slinton # endif 785714Slinton pc = 0; 795714Slinton curfunc = program; 805714Slinton if (objsize != 0) { 815714Slinton addbp(lastaddr(), END_BP, NIL, NIL, NIL, 0); 825510Slinton } 835714Slinton } else { 845714Slinton panic("could not start program"); 855714Slinton } 865510Slinton } 875510Slinton 885510Slinton /* 895510Slinton * Note the termination of the program. We do this so as to avoid 905510Slinton * having the process exit, which would make the values of variables 915510Slinton * inaccessible. 925510Slinton * 935510Slinton * Although the END_BP should really be deleted, it is taken 945510Slinton * care of by fixbps the next time the program runs. 955510Slinton */ 965510Slinton 975510Slinton endprogram() 985510Slinton { 995714Slinton char *filename; 1005510Slinton 1015714Slinton if (ss_variables) { 1025714Slinton prvarnews(); 1035714Slinton } 1045714Slinton printf("\nexecution completed\n"); 1055714Slinton curfunc = program; 1065714Slinton if ((filename = srcfilename(pc)) != cursource) { 1075714Slinton skimsource(filename); 1085714Slinton } 1095714Slinton curline = lastlinenum; 1105714Slinton erecover(); 1115510Slinton } 1125510Slinton 1135510Slinton /* 1145510Slinton * set up what signals we want to trace 1155510Slinton */ 1165510Slinton 1175510Slinton LOCAL setsigtrace() 1185510Slinton { 1195714Slinton register int i; 1205714Slinton register PROCESS *p; 1215510Slinton 1225714Slinton p = process; 1235714Slinton psigtrace(p, SIGINT, TRUE); 1245714Slinton psigtrace(p, SIGTRAP, TRUE); 1255714Slinton psigtrace(p, SIGIOT, TRUE); 126*5739Slinton psigtrace(p, SIGILL, TRUE); 1275510Slinton } 128