centralized the printing of a source line number and file
authorMark Linton <linton@ucbvax.Berkeley.EDU>
Fri, 12 Feb 1982 15:53:25 +0000 (07:53 -0800)
committerMark Linton <linton@ucbvax.Berkeley.EDU>
Fri, 12 Feb 1982 15:53:25 +0000 (07:53 -0800)
to a routine called "printwhere" in pstatus.c ... other routines
were modified to use this routine

SCCS-vsn: usr.bin/pascal/pdx/process/pstatus.c 1.3
SCCS-vsn: usr.bin/pascal/pdx/process/start.c 1.5
SCCS-vsn: usr.bin/pascal/pdx/process/step.c 1.2

usr/src/usr.bin/pascal/pdx/process/pstatus.c
usr/src/usr.bin/pascal/pdx/process/start.c
usr/src/usr.bin/pascal/pdx/process/step.c

index 32a1572..d94d8c3 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)pstatus.c 1.2 %G%";
+static char sccsid[] = "@(#)pstatus.c 1.3 %G%";
 
 /*
  * process status routines
 
 /*
  * process status routines
@@ -22,38 +22,55 @@ static char sccsid[] = "@(#)pstatus.c 1.2 %G%";
 
 printstatus()
 {
 
 printstatus()
 {
-       if (process->signo == SIGINT) {
-               isstopped = TRUE;
-               printerror();
+    if (process->signo == SIGINT) {
+       isstopped = TRUE;
+       printerror();
+    }
+    if (isbperr() && isstopped) {
+       skimsource(srcfilename(pc));
+       printf("stopped at ");
+       printwhere(curline, cursource);
+       putchar('\n');
+       if (curline > 0) {
+           printlines(curline, curline);
+       } else {
+           printinst(pc, pc);
        }
        }
-       if (isbperr() && isstopped) {
-               printf("stopped at ");
-               if (curline > 0) {
-                       printf("line %d", curline);
-                       if (nlhdr.nfiles > 1) {
-                               printf(" in file %s", cursource);
-                       }
-                       putchar('\n');
-                       printlines(curline, curline);
-               } else {
-#                      if (isvaxpx)
-                               printf("location %d\n", pc);
-#                      else
-                               printf("location 0x%x\n", pc);
-#                      endif
-                       printinst(pc, pc);
-               }
-               erecover();
+       erecover();
+    } else {
+       isstopped = FALSE;
+       fixbps();
+       fixintr();
+       if (process->status == FINISHED) {
+           quit(0);
        } else {
        } else {
-               isstopped = FALSE;
-               fixbps();
-               fixintr();
-               if (process->status == FINISHED) {
-                       quit(0);
-               } else {
-                       printerror();
-               }
+           printerror();
+       }
+    }
+}
+
+
+/*
+ * Print out the "line N [in file F]" information that accompanies
+ * messages in various places.
+ */
+
+printwhere(lineno, filename)
+LINENO lineno;
+char *filename;
+{
+    if (lineno > 0) {
+       printf("line %d", lineno);
+       if (nlhdr.nfiles > 1) {
+           printf(" in file %s", filename);
        }
        }
+    } else {
+#      if (isvaxpx)
+           printf("location %d\n", pc);
+#      else
+           printf("location 0x%x\n", pc);
+#      endif
+    }
 }
 
 /*
 }
 
 /*
@@ -63,5 +80,5 @@ printstatus()
 BOOLEAN isfinished(p)
 PROCESS *p;
 {
 BOOLEAN isfinished(p)
 PROCESS *p;
 {
-       return(p->status == FINISHED);
+    return(p->status == FINISHED);
 }
 }
index d354462..ed2d625 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)start.c 1.4 %G%";
+static char sccsid[] = "@(#)start.c 1.5 %G%";
 
 /*
  * Begin execution.
 
 /*
  * Begin execution.
@@ -96,16 +96,12 @@ char *infile, *outfile;
 
 endprogram()
 {
 
 endprogram()
 {
-    char *filename;
-
     if (ss_variables) {
        prvarnews();
     }
     printf("\nexecution completed\n");
     curfunc = program;
     if (ss_variables) {
        prvarnews();
     }
     printf("\nexecution completed\n");
     curfunc = program;
-    if ((filename = srcfilename(pc)) != cursource) {
-       skimsource(filename);
-    }
+    skimsource(srcfilename(pc));
     curline = lastlinenum;
     erecover();
 }
     curline = lastlinenum;
     erecover();
 }
@@ -124,4 +120,5 @@ LOCAL setsigtrace()
     psigtrace(p, SIGTRAP, TRUE);
     psigtrace(p, SIGIOT, TRUE);
     psigtrace(p, SIGILL, TRUE);
     psigtrace(p, SIGTRAP, TRUE);
     psigtrace(p, SIGIOT, TRUE);
     psigtrace(p, SIGILL, TRUE);
+    psigtrace(p, SIGBUS, TRUE);
 }
 }
index 5921280..a6c7e23 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)step.c 1.1 %G%";
+static char sccsid[] = "@(#)step.c 1.2 %G%";
 
 /*
  * Continue execution up to the next source line.
 
 /*
  * Continue execution up to the next source line.
@@ -22,11 +22,11 @@ static char sccsid[] = "@(#)step.c 1.1 %G%";
 #include "mappings.h"
 #include "process.rep"
 
 #include "mappings.h"
 #include "process.rep"
 
-#      if (isvax)
-#              include "machine/vaxops.h"
+#   if (isvax)
+#       include "machine/vaxops.h"
 
 
-               LOCAL ADDRESS getcall();
-#      endif
+       LOCAL ADDRESS getcall();
+#   endif
 
 /*
  * Stepc is what is called when the step command is given.
 
 /*
  * Stepc is what is called when the step command is given.
@@ -35,27 +35,27 @@ static char sccsid[] = "@(#)step.c 1.1 %G%";
 
 stepc()
 {
 
 stepc()
 {
-       if (!isstopped) {
-               error("can't continue execution");
-       }
-       isstopped = FALSE;
-       dostep(FALSE);
-       isstopped = TRUE;
+    if (!isstopped) {
+       error("can't continue execution");
+    }
+    isstopped = FALSE;
+    dostep(FALSE);
+    isstopped = TRUE;
 }
 
 next()
 {
 }
 
 next()
 {
-       if (!isstopped) {
-               error("can't continue execution");
-       }
-       isstopped = FALSE;
-       dostep(TRUE);
-       isstopped = TRUE;
+    if (!isstopped) {
+       error("can't continue execution");
+    }
+    isstopped = FALSE;
+    dostep(TRUE);
+    isstopped = TRUE;
 }
 
 step()
 {
 }
 
 step()
 {
-       dostep(FALSE);
+    dostep(FALSE);
 }
 
 /*
 }
 
 /*
@@ -67,46 +67,42 @@ step()
 stepto(addr)
 ADDRESS addr;
 {
 stepto(addr)
 ADDRESS addr;
 {
-       setbp(addr);
-       resume();
-       unsetbp(addr);
-       if (!isbperr()) {
-               printstatus();
-       }
+    setbp(addr);
+    resume();
+    unsetbp(addr);
+    if (!isbperr()) {
+       printstatus();
+    }
 }
 
 LOCAL dostep(isnext)
 BOOLEAN isnext;
 {
 }
 
 LOCAL dostep(isnext)
 BOOLEAN isnext;
 {
-       register ADDRESS addr;
-       register LINENO line;
-       char *filename;
-
-       addr = pc;
-       do {
-#              if (isvaxpx)
-                       addr = nextaddr(addr, isnext);
-#              else
-                       if (isnext && (addr = getcall(addr)) != 0) {
-                               stepto(addr);
-                       } else {
-                               pstep(process);
-                               addr = process->pc;
-                               pc = process->pc;
-                               errnum = process->signo;
-                               if (!isbperr()) {
-                                       printstatus();
-                               }
-                       }
-#              endif
-               line = linelookup(addr);
-       } while (line == 0 && !ss_instructions);
-       stepto(addr);
-       curline = line;
-       filename = srcfilename(addr);
-       if (filename != cursource) {
-               skimsource(filename);
-       }
+    register ADDRESS addr;
+    register LINENO line;
+    char *filename;
+
+    addr = pc;
+    do {
+#       if (isvaxpx)
+           addr = nextaddr(addr, isnext);
+#       else
+           if (isnext && (addr = getcall(addr)) != 0) {
+               stepto(addr);
+           } else {
+               pstep(process);
+               addr = process->pc;
+               pc = process->pc;
+               errnum = process->signo;
+               if (!isbperr()) {
+                   printstatus();
+               }
+           }
+#       endif
+       line = linelookup(addr);
+    } while (line == 0 && !ss_instructions);
+    stepto(addr);
+    curline = line;
 }
 
 # if (isvax)
 }
 
 # if (isvax)
@@ -122,14 +118,14 @@ BOOLEAN isnext;
 LOCAL ADDRESS getcall(addr)
 ADDRESS addr;
 {
 LOCAL ADDRESS getcall(addr)
 ADDRESS addr;
 {
-       VAXOP op;
-
-       iread(&op, addr, sizeof(addr));
-       if (op == O_CALLS) {
-               return(addr + 7);
-       } else {
-               return(0);
-       }
+    VAXOP op;
+
+    iread(&op, addr, sizeof(addr));
+    if (op == O_CALLS) {
+       return(addr + 7);
+    } else {
+       return(0);
+    }
 }
 
 # endif
 }
 
 # endif