BSD 4 release
[unix-history] / usr / src / cmd / sdb / runpcs.c
index 70c1a13..970ff04 100644 (file)
@@ -1,3 +1,4 @@
+static char sccsid[] = "@(#)runpcs.c 4.1 10/9/80";
 #
 /*
  *
 #
 /*
  *
@@ -7,9 +8,13 @@
 
 #include "head.h"
 #include <a.out.h>
 
 #include "head.h"
 #include <a.out.h>
+#include <stab.h>
 struct user u;
 #include <stdio.h>
 
 struct user u;
 #include <stdio.h>
 
+#ifndef SIGTRAP
+#define        SIGTRAP SIGTRC
+#endif
 
 MSG            NOFORK;
 MSG            ENDPCS;
 
 MSG            NOFORK;
 MSG            ENDPCS;
@@ -17,39 +22,11 @@ MSG         BADWAIT;
 
 ADDR           sigint;
 ADDR           sigqit;
 
 ADDR           sigint;
 ADDR           sigqit;
+ADDR           userpc;
 
 /* breakpoints */
 BKPTR          bkpthead;
 
 
 /* breakpoints */
 BKPTR          bkpthead;
 
-
-REGLIST reglist [] = {
-               "p1lr", P1LR,
-               "p1br",P1BR,
-               "p0lr", P0LR,
-               "p0br",P0BR,
-               "ksp",KSP,
-               "esp",ESP,
-               "ssp",SSP,
-               "psl", PSL,
-               "pc", PC,
-               "usp",USP,
-               "fp", FP,
-               "ap", AP,
-               "r11", R11,
-               "r10", R10,
-               "r9", R9,
-               "r8", R8,
-               "r7", R7,
-               "r6", R6,
-               "r5", R5,
-               "r4", R4,
-               "r3", R3,
-               "r2", R2,
-               "r1", R1,
-               "r0", R0,
-};
-
-
 CHAR           lastc;
 
 INT            fcor;
 CHAR           lastc;
 
 INT            fcor;
@@ -74,8 +51,6 @@ getsig(sig)
 {      return(sig);
 }
 
 {      return(sig);
 }
 
-ADDR userpc = 1;
-
 runpcs(runmode,execsig)
 {
        REG BKPTR       bkpt;
 runpcs(runmode,execsig)
 {
        REG BKPTR       bkpt;
@@ -107,7 +82,7 @@ runpcs(runmode,execsig)
                                ANDF bkpt->comm[0]!=EOR)
                        THEN execbkpt(bkpt,execsig); execsig=0; loopcnt++;
                             goto loop1;
                                ANDF bkpt->comm[0]!=EOR)
                        THEN execbkpt(bkpt,execsig); execsig=0; loopcnt++;
                             goto loop1;
-                       ELSE bkpt->count=bkpt->initcnt;
+                       ELSE bkpt->flag=BKPTSET; bkpt->count=bkpt->initcnt;
                        FI
                ELSE execsig=signo;
                     if (execsig) break;
                        FI
                ELSE execsig=signo;
                     if (execsig) break;
@@ -118,7 +93,7 @@ runpcs(runmode,execsig)
 
 #define BPOUT 0
 #define BPIN 1
 
 #define BPOUT 0
 #define BPIN 1
-INT bpstate = BPOUT;
+INT bpstate;
 
 endpcs()
 {
 
 endpcs()
 {
@@ -153,14 +128,10 @@ setup()
        THEN ptrace(SETTRC,0,0,0);
             signal(SIGINT,sigint); signal(SIGQUIT,sigqit);
 #ifdef VFORK
        THEN ptrace(SETTRC,0,0,0);
             signal(SIGINT,sigint); signal(SIGQUIT,sigqit);
 #ifdef VFORK
-            signal(SIGTRC,nullsig);
+            signal(SIGTRAP,nullsig);
 #endif
                if (debug) printf("About to doexec  pid=%d\n",pid);
 #endif
                if (debug) printf("About to doexec  pid=%d\n",pid);
-#ifdef UCBVAX
             doexec(); _exit(0);
             doexec(); _exit(0);
-#else
-            doexec(); exit(0);
-#endif
        ELIF pid == -1
        THEN error(NOFORK);
        ELSE bpwait(); readregs();
        ELIF pid == -1
        THEN error(NOFORK);
        ELSE bpwait(); readregs();
@@ -216,21 +187,15 @@ doexec()
                                close(0);
                                if (open(filnam,0) < 0) {
                                        printf("%s: cannot open\n",filnam);
                                close(0);
                                if (open(filnam,0) < 0) {
                                        printf("%s: cannot open\n",filnam);
-#ifdef UCBVAX
-                                        _exit(0);
-#else
-                                        exit(0);
-#endif
+                                       fflush(stdout);
+                                       _exit(0);
                                }
                        } else {
                                close(1);
                                if (creat(filnam,0666) < 0) {
                                        printf("%s: cannot create\n",filnam);
                                }
                        } else {
                                close(1);
                                if (creat(filnam,0666) < 0) {
                                        printf("%s: cannot create\n",filnam);
-#ifdef UCBVAX
+                                       fflush(stdout);
                                         _exit(0);
                                         _exit(0);
-#else
-                                        exit(0);
-#endif
                                }
                        }
                } else if (c != '\n') {
                                }
                        }
                } else if (c != '\n') {
@@ -334,7 +299,7 @@ bpwait()
        ELSE signo = stat>>8;
             if (debug) printf("PC = %d, dbsubn = %d\n",
                ptrace(RUREGS, pid, PC, 0), extaddr("_dbsubn")); 
        ELSE signo = stat>>8;
             if (debug) printf("PC = %d, dbsubn = %d\n",
                ptrace(RUREGS, pid, PC, 0), extaddr("_dbsubn")); 
-            IF signo!=SIGTRC ANDF
+            IF signo!=SIGTRAP ANDF
                ptrace(RUREGS, pid, PC, 0) != extaddr("_dbsubn")
             THEN sigprint();
             ELSE signo=0;
                ptrace(RUREGS, pid, PC, 0) != extaddr("_dbsubn")
             THEN sigprint();
             ELSE signo=0;
@@ -342,6 +307,7 @@ bpwait()
        FI
 }
 
        FI
 }
 
+REGLIST reglist[];
 readregs()
 {
        /*get REG values from pcs*/
 readregs()
 {
        /*get REG values from pcs*/