merge in latest Linton version
authorDonn Seeley <donn@ucbvax.Berkeley.EDU>
Tue, 12 Jan 1988 16:59:23 +0000 (08:59 -0800)
committerDonn Seeley <donn@ucbvax.Berkeley.EDU>
Tue, 12 Jan 1988 16:59:23 +0000 (08:59 -0800)
SCCS-vsn: old/dbx/library.c 5.2
SCCS-vsn: old/dbx/main.c 5.4
SCCS-vsn: old/dbx/makedefs.c 5.2
SCCS-vsn: old/dbx/mappings.c 5.3
SCCS-vsn: old/dbx/mkdate.c 5.3
SCCS-vsn: old/dbx/modula-2.c 5.2
SCCS-vsn: old/dbx/names.c 5.2
SCCS-vsn: old/dbx/object.c 5.2

usr/src/old/dbx/library.c
usr/src/old/dbx/main.c
usr/src/old/dbx/makedefs.c
usr/src/old/dbx/mappings.c
usr/src/old/dbx/mkdate.c
usr/src/old/dbx/modula-2.c
usr/src/old/dbx/names.c
usr/src/old/dbx/object.c

index 947aa23..1586a79 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)library.c  5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)library.c  5.2 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: library.c,v 1.5 84/12/26 10:39:52 linton Exp $";
+static char rcsid[] = "$Header: library.c,v 1.2 87/03/25 20:50:14 donn Exp $";
 
 /*
  * General purpose routines.
 
 /*
  * General purpose routines.
@@ -64,14 +64,16 @@ extern int strlen();
 #define strdup(s)              strcpy(malloc((unsigned) strlen(s) + 1), s)
 #define streq(s1, s2)  (strcmp(s1, s2) == 0)
 
 #define strdup(s)              strcpy(malloc((unsigned) strlen(s) + 1), s)
 #define streq(s1, s2)  (strcmp(s1, s2) == 0)
 
-typedef int INTFUNC();
+typedef int IntFunc();
+
+IntFunc *onsyserr();
 
 typedef struct {
 
 typedef struct {
-    INTFUNC *func;
-} ERRINFO;
+    IntFunc *func;
+} ErrInfo;
 
 
-#define ERR_IGNORE ((INTFUNC *) 0)
-#define ERR_CATCH  ((INTFUNC *) 1)
+#define ERR_IGNORE ((IntFunc *) 0)
+#define ERR_CATCH  ((IntFunc *) 1)
 
 /*
  * Call a program.
 
 /*
  * Call a program.
@@ -352,13 +354,13 @@ extern _mycerror();
  * Initialize error information, setting defaults for handling errors.
  */
 
  * Initialize error information, setting defaults for handling errors.
  */
 
-private ERRINFO *errinfo;
+private ErrInfo *errinfo;
 
 private initErrInfo ()
 {
     integer i;
 
 
 private initErrInfo ()
 {
     integer i;
 
-    errinfo = alloc(sys_nerr, ERRINFO);
+    errinfo = alloc(sys_nerr, ErrInfo);
     for (i = 0; i < sys_nerr; i++) {
        errinfo[i].func = ERR_CATCH;
     }
     for (i = 0; i < sys_nerr; i++) {
        errinfo[i].func = ERR_CATCH;
     }
@@ -373,12 +375,12 @@ private initErrInfo ()
 
 public syserr()
 {
 
 public syserr()
 {
-    ERRINFO *e;
+    register ErrInfo *e;
 
     if (errno < 0 or errno > sys_nerr) {
        fatal("errno %d", errno);
     } else {
 
     if (errno < 0 or errno > sys_nerr) {
        fatal("errno %d", errno);
     } else {
-       if (errinfo == nil(ERRINFO *)) {
+       if (errinfo == nil(ErrInfo *)) {
            initErrInfo();
        }
        e = &(errinfo[errno]);
            initErrInfo();
        }
        e = &(errinfo[errno]);
@@ -417,17 +419,21 @@ public nocatcherrs()
 }
 
 /*
 }
 
 /*
- * Change the action on receipt of an error.
+ * Change the action on receipt of an error, returning the previous action.
  */
 
  */
 
-public onsyserr(n, f)
+public IntFunc *onsyserr(n, f)
 int n;
 int n;
-INTFUNC *f;
+IntFunc *f;
 {
 {
-    if (errinfo == nil(ERRINFO *)) {
+    IntFunc *oldf;
+
+    if (errinfo == nil(ErrInfo *)) {
        initErrInfo();
     }
        initErrInfo();
     }
+    oldf = errinfo[n].func;
     errinfo[n].func = f;
     errinfo[n].func = f;
+    return oldf;
 }
 
 /*
 }
 
 /*
@@ -435,7 +441,44 @@ INTFUNC *f;
  * Like a "perror" for signals.
  */
 
  * Like a "perror" for signals.
  */
 
+#ifdef SIGWINCH
 public int sys_nsig = NSIG;
 public int sys_nsig = NSIG;
+#else not 4.3 BSD
+/*
+ * This table is correct for 4.2-like systems but will
+ * be inadequate for System V (which is the sort of
+ * Unix that needs it!).
+ */
+public String sys_siglist[] = {
+    "no signal",
+    "hangup",
+    "interrupt",
+    "quit",
+    "illegal instruction",
+    "trace trap",
+    "IOT instruction",
+    "EMT instruction",
+    "floating point exception",
+    "kill",
+    "bus error",
+    "segmentation violation",
+    "bad argument to system call",
+    "broken pipe",
+    "alarm clock",
+    "soft kill",
+    "urgent I/O condition",
+    "stop signal not from tty",
+    "stop signal from tty",
+    "continue",
+    "child termination",
+    "stop (tty input)",
+    "stop (tty output)",
+    "possible input/output",
+    "exceeded CPU time limit",
+    "exceeded file size limit"
+};
+public int sys_nsig = sizeof sys_siglist / sizeof sys_siglist[0];
+#endif
 
 public psignal(s, n)
 String s;
 
 public psignal(s, n)
 String s;
@@ -491,6 +534,7 @@ String s;
     }
     fprintf(stderr, s, a, b, c, d, e, f, g, h, i, j, k, l, m);
     putc('\n', stderr);
     }
     fprintf(stderr, s, a, b, c, d, e, f, g, h, i, j, k, l, m);
     putc('\n', stderr);
+    fflush(stderr);
     if (shouldquit) {
        quit(1);
     }
     if (shouldquit) {
        quit(1);
     }
@@ -514,6 +558,7 @@ public beginerrmsg()
 public enderrmsg()
 {
     putc('\n', stderr);
 public enderrmsg()
 {
     putc('\n', stderr);
+    fflush(stderr);
     erecover();
 }
 
     erecover();
 }
 
@@ -662,3 +707,41 @@ register unsigned int n;
        while ((*dest++ = *src++) != '\0');
     }
 }
        while ((*dest++ = *src++) != '\0');
     }
 }
+
+#ifdef IRIS /* or in general for 4.2 - System V C library interface */
+
+public bcopy (fromaddr, toaddr, n)
+char *fromaddr, *toaddr;
+int n;
+{
+    blt(toaddr, fromaddr, n);
+}
+
+public bzero (addr, n)
+char *addr;
+int n;
+{
+    register char *p, *q;
+
+    p = addr;
+    q = p + n;
+    while (p < q) {
+       *p++ = '\0';
+    }
+}
+
+#include <string.h>
+
+public char *index (s, c)
+char *s, c;
+{
+    return strchr(s, c);
+}
+
+public char *rindex (s, c)
+char *s, c;
+{
+    return strrchr(s, c);
+}
+
+#endif
index 9aa9abb..bf82e1e 100644 (file)
@@ -11,10 +11,10 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.4 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: main.c,v 1.5 84/12/26 10:40:16 linton Exp $";
+static char rcsid[] = "$Header: main.c,v 1.4 87/07/08 21:31:27 donn Exp $";
 
 /*
  * Debugger main routine.
 
 /*
  * Debugger main routine.
@@ -25,6 +25,7 @@ static char rcsid[] = "$Header: main.c,v 1.5 84/12/26 10:40:16 linton Exp $";
 #include <signal.h>
 #include <errno.h>
 #include "main.h"
 #include <signal.h>
 #include <errno.h>
 #include "main.h"
+#include "tree.h"
 #include "eval.h"
 #include "debug.h"
 #include "symbols.h"
 #include "eval.h"
 #include "debug.h"
 #include "symbols.h"
@@ -41,17 +42,23 @@ static char rcsid[] = "$Header: main.c,v 1.5 84/12/26 10:40:16 linton Exp $";
 
 #define isterm(file)   (interactive or isatty(fileno(file)))
 
 
 #define isterm(file)   (interactive or isatty(fileno(file)))
 
-#include <sgtty.h>
-#include <fcntl.h>
+#ifdef IRIS
+#   include <termio.h>
 
 
-typedef struct {
-    struct sgttyb sg;          /* standard sgttyb structure */
-    struct tchars tc;          /* terminal characters */
-    struct ltchars ltc;                /* local special characters */
-    integer ldisc;             /* line discipline */
-    integer local;             /* TIOCLGET */
-    integer fcflags;           /* fcntl(2) F_GETFL, F_SETFL */
-} Ttyinfo;
+    typedef struct termio Ttyinfo;
+#else
+#   include <sgtty.h>
+#   include <fcntl.h>
+
+    typedef struct {
+       struct sgttyb sg;               /* standard sgttyb structure */
+       struct tchars tc;               /* terminal characters */
+       struct ltchars ltc;             /* local special characters */
+       integer ldisc;                  /* line discipline */
+       integer local;                  /* TIOCLGET */
+       integer fcflags;                /* fcntl(2) F_GETFL, F_SETFL */
+    } Ttyinfo;
+#endif
 
 #endif
 
 
 #endif
 
@@ -64,9 +71,13 @@ public boolean traceexec;            /* trace execution */
 public boolean tracesyms;              /* print symbols are they are read */
 public boolean traceblocks;            /* trace blocks while reading symbols */
 public boolean vaddrs;                 /* map addresses through page tables */
 public boolean tracesyms;              /* print symbols are they are read */
 public boolean traceblocks;            /* trace blocks while reading symbols */
 public boolean vaddrs;                 /* map addresses through page tables */
+public boolean quiet;                  /* don't print heading */
+public boolean autostrip;              /* strip C++ prefixes */
 
 public File corefile;                  /* File id of core dump */
 
 
 public File corefile;                  /* File id of core dump */
 
+public integer versionNumber = 4;
+
 #define FIRST_TIME 0                   /* initial value setjmp returns */
 
 private Boolean initdone = false;      /* true if initialization done */
 #define FIRST_TIME 0                   /* initial value setjmp returns */
 
 private Boolean initdone = false;      /* true if initialization done */
@@ -78,6 +89,7 @@ private Ttyinfo ttyinfo;
 private String corename;               /* name of core file */
 
 private catchintr();
 private String corename;               /* name of core file */
 
 private catchintr();
+private char **scanargs();
 
 /*
  * Main program.
 
 /*
  * Main program.
@@ -87,8 +99,6 @@ main(argc, argv)
 int argc;
 String argv[];
 {
 int argc;
 String argv[];
 {
-    register integer i;
-    extern String date;
     extern integer versionNumber;
     char **scanargs();
 
     extern integer versionNumber;
     char **scanargs();
 
@@ -99,11 +109,14 @@ String argv[];
 
     catcherrs();
     onsyserr(EINTR, nil);
 
     catcherrs();
     onsyserr(EINTR, nil);
+    onsyserr(EADDRINUSE, nil);
+    onsyserr(ENXIO, nil);
     setbuf(stdout, outbuf);
     setbuf(stdout, outbuf);
-    printf("dbx version 3.%d of %s.\nType 'help' for help.\n",
-       versionNumber, date);
-    fflush(stdout);
     argv = scanargs(argc, argv);
     argv = scanargs(argc, argv);
+    if (not runfirst and not quiet) {
+       printheading();
+    }
+    openfiles();
     language_init();
     symbols_init();
     process_init();
     language_init();
     symbols_init();
     process_init();
@@ -130,6 +143,16 @@ String argv[];
     quit(0);
 }
 
     quit(0);
 }
 
+public printheading ()
+{
+    extern String date;
+
+    printf("dbx version 3.%d of %s.\nType 'help' for help.\n",
+       versionNumber, date
+    );
+    fflush(stdout);
+}
+
 /*
  * Initialize the world, including setting initial input file
  * if the file exists.
 /*
  * Initialize the world, including setting initial input file
  * if the file exists.
@@ -158,6 +181,7 @@ public init()
        if (vaddrs) {
            coredump_getkerinfo();
        }
        if (vaddrs) {
            coredump_getkerinfo();
        }
+       getsrcpos();
        setcurfunc(whatblock(pc));
     } else {
        setcurfunc(program);
        setcurfunc(whatblock(pc));
     } else {
        setcurfunc(program);
@@ -274,17 +298,13 @@ private catchintr()
  * Scan the argument list.
  */
 
  * Scan the argument list.
  */
 
-private char **scanargs(argc, argv)
+private char **scanargs (argc, argv)
 int argc;
 String argv[];
 {
     extern char *optarg;
 int argc;
 String argv[];
 {
     extern char *optarg;
-    extern int optind;
-    register int i, j;
-    register Boolean foundfile;
-    register File f;
-    int ch;
-    char *tmp;
+    extern integer optind;
+    integer ch;
 
     runfirst = false;
     interactive = false;
 
     runfirst = false;
     interactive = false;
@@ -294,17 +314,21 @@ String argv[];
     tracesyms = false;
     traceblocks = false;
     vaddrs = false;
     tracesyms = false;
     traceblocks = false;
     vaddrs = false;
-    foundfile = false;
+    quiet = false;
+    autostrip = true;
     corefile = nil;
     coredump = true;
     sourcepath = list_alloc();
     list_append(list_item("."), nil, sourcepath);
 
     corefile = nil;
     coredump = true;
     sourcepath = list_alloc();
     list_append(list_item("."), nil, sourcepath);
 
-    while ((ch = getopt(argc, argv, "I:bc:eiklnrs")) != EOF)
+    while ((ch = getopt(argc, argv, "I:abc:eiklnqrs")) != EOF)
     switch((char)ch) {
        case 'I':
                list_append(list_item(optarg), nil, sourcepath);
                break;
     switch((char)ch) {
        case 'I':
                list_append(list_item(optarg), nil, sourcepath);
                break;
+       case 'a':
+               autostrip = false;
+               break;
        case 'b':
                tracebpts = true;
                break;
        case 'b':
                tracebpts = true;
                break;
@@ -330,6 +354,9 @@ String argv[];
        case 'n':
                traceblocks = true;
                break;
        case 'n':
                traceblocks = true;
                break;
+       case 'q':
+               quiet = true;
+               break;
        case 'r':       /* run program before accepting commands */
                runfirst = true;
                coredump = false;
        case 'r':       /* run program before accepting commands */
                runfirst = true;
                coredump = false;
@@ -344,7 +371,6 @@ String argv[];
     argv += optind;
     if (*argv) {
        objname = *argv;
     argv += optind;
     if (*argv) {
        objname = *argv;
-       foundfile = true;
        if (*++argv && coredump) {
                corename = *argv;
                corefile = fopen(*argv, "r");
        if (*++argv && coredump) {
                corename = *argv;
                corefile = fopen(*argv, "r");
@@ -353,9 +379,18 @@ String argv[];
                ++argv;
        }
     }
                ++argv;
        }
     }
-    if (*argv and not runfirst)
+    if (*argv and not runfirst) {
        fatal("extraneous argument %s", *argv);
        fatal("extraneous argument %s", *argv);
-    if (not foundfile and isatty(0)) {
+    }
+    return argv;
+}
+
+private openfiles ()
+{
+    File f;
+    char *tmp;
+
+    if (objname == nil and isatty(0)) {
        printf("enter object file name (default is `%s'): ", objname);
        fflush(stdout);
        gets(namebuf);
        printf("enter object file name (default is `%s'): ", objname);
        fflush(stdout);
        gets(namebuf);
@@ -389,7 +424,6 @@ String argv[];
            }
        }
     }
            }
        }
     }
-    return(argv);
 }
 
 /*
 }
 
 /*
@@ -400,24 +434,40 @@ public savetty(f, t)
 File f;
 Ttyinfo *t;
 {
 File f;
 Ttyinfo *t;
 {
-    ioctl(fileno(f), TIOCGETP, &(t->sg));
-    ioctl(fileno(f), TIOCGETC, &(t->tc));
-    ioctl(fileno(f), TIOCGLTC, &(t->ltc));
-    ioctl(fileno(f), TIOCGETD, &(t->ldisc));
-    ioctl(fileno(f), TIOCLGET, &(t->local));
-    t->fcflags = fcntl(fileno(f), F_GETFL, 0);
+#   ifdef IRIS
+       ioctl(fileno(f), TCGETA, t);
+#   else
+       ioctl(fileno(f), TIOCGETP, &(t->sg));
+       ioctl(fileno(f), TIOCGETC, &(t->tc));
+       ioctl(fileno(f), TIOCGLTC, &(t->ltc));
+       ioctl(fileno(f), TIOCGETD, &(t->ldisc));
+       ioctl(fileno(f), TIOCLGET, &(t->local));
+       t->fcflags = fcntl(fileno(f), F_GETFL, 0);
+       if ((t->fcflags&FASYNC) != 0) {
+           /* fprintf(stderr, "[async i/o found set -- reset]\n"); */
+           t->fcflags &= ~FASYNC;
+       }
+#   endif
 }
 
 public restoretty(f, t)
 File f;
 Ttyinfo *t;
 {
 }
 
 public restoretty(f, t)
 File f;
 Ttyinfo *t;
 {
-    ioctl(fileno(f), TIOCSETN, &(t->sg));
-    ioctl(fileno(f), TIOCSETC, &(t->tc));
-    ioctl(fileno(f), TIOCSLTC, &(t->ltc));
-    ioctl(fileno(f), TIOCSETD, &(t->ldisc));
-    ioctl(fileno(f), TIOCLSET, &(t->local));
-    (void) fcntl(fileno(f), F_SETFL, t->fcflags);
+#   ifdef IRIS
+       ioctl(fileno(f), TCSETA, t);
+#   else
+       ioctl(fileno(f), TIOCSETN, &(t->sg));
+       ioctl(fileno(f), TIOCSETC, &(t->tc));
+       ioctl(fileno(f), TIOCSLTC, &(t->ltc));
+       ioctl(fileno(f), TIOCSETD, &(t->ldisc));
+       ioctl(fileno(f), TIOCLSET, &(t->local));
+       if ((t->fcflags&FASYNC) != 0) {
+           /* fprintf(stderr, "[async i/o not set]\n"); */
+           t->fcflags &= ~FASYNC;
+       }
+       (void) fcntl(fileno(f), F_SETFL, t->fcflags);
+#   endif
 }
 
 /*
 }
 
 /*
index 27afb70..5a59c94 100644 (file)
@@ -11,10 +11,10 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)makedefs.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)makedefs.c 5.2 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: makedefs.c,v 1.4 84/12/26 10:40:22 linton Exp $";
+static char rcsid[] = "$Header: makedefs.c,v 1.2 87/03/26 19:14:02 donn Exp $";
 
 /*
  * Create a definitions file (e.g. .h) from an implementation file (e.g. .c).
 
 /*
  * Create a definitions file (e.g. .h) from an implementation file (e.g. .c).
@@ -38,6 +38,8 @@ static char rcsid[] = "$Header: makedefs.c,v 1.4 84/12/26 10:40:22 linton Exp $"
 
 #define procedure void
 
 
 #define procedure void
 
+#define streqn(s1, s2, n) (strncmp(s1, s2, n) == 0)
+
 Boolean force;
 Boolean copytext;
 
 Boolean force;
 Boolean copytext;
 
@@ -123,16 +125,35 @@ String s;
 copy()
 {
     register char *p;
 copy()
 {
     register char *p;
+    integer nesting;
     char line[1024];
 
     while (gets(line) != NULL) {
     char line[1024];
 
     while (gets(line) != NULL) {
-       if (strncmp(line, "#ifndef public", 14) == 0) {
+       if (streqn(line, "#ifndef public", 14)) {
            copytext = true;
            copytext = true;
-       } else if (strncmp(line, "#endif", 6) == 0) {
-           copytext = false;
-       } else if (strncmp(line, "public", 6) == 0) {
+           nesting = 1;
+       } else if (streqn(line, "public", 6)) {
            copydef(line);
        } else if (copytext) {
            copydef(line);
        } else if (copytext) {
+           if (streqn(line, "#ifdef", 6) or streqn(line, "#ifndef", 7)) {
+               ++nesting;
+               printf("%s\n", line);
+           } else if (streqn(line, "#endif", 6)) {
+               --nesting;
+               if (nesting <= 0) {
+                   copytext = false;
+               } else {
+                   printf("%s\n", line);
+               }
+           } else {
+               printf("%s\n", line);
+           }
+       } else if (
+           streqn(line, "#ifdef", 6) or
+           streqn(line, "#ifndef", 7) or
+           streqn(line, "#else", 5) or
+           streqn(line, "#endif", 6)
+       ) {
            printf("%s\n", line);
        }
     }
            printf("%s\n", line);
        }
     }
index e6eca8b..308daf6 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mappings.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)mappings.c 5.3 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: mappings.c,v 1.4 84/12/26 10:40:25 linton Exp $";
+static char rcsid[] = "$Header: mappings.c,v 1.3 87/03/26 19:41:55 donn Exp $";
 
 /*
  * Source-to-object and vice versa mappings.
 
 /*
  * Source-to-object and vice versa mappings.
@@ -101,10 +101,8 @@ Boolean exact;
     register Lineno r;
     register Address a;
 
     register Lineno r;
     register Address a;
 
-    if (nlhdr.nlines == 0) {
+    if (nlhdr.nlines == 0 or addr < linetab[0].addr) {
        r = -1;
        r = -1;
-    } else if (addr < linetab[0].addr) {
-       r = exact ? -1 : 0;
     } else {
        i = 0;
        j = nlhdr.nlines - 1;
     } else {
        i = 0;
        j = nlhdr.nlines - 1;
@@ -148,16 +146,28 @@ Boolean exact;
  * If it isn't, then we walk forward until the first suitable line is found.
  */
 
  * If it isn't, then we walk forward until the first suitable line is found.
  */
 
-public Lineno srcline(addr)
+public Lineno srcline (addr)
 Address addr;
 {
 Address addr;
 {
-    integer i;
-    Lineno r;
+    Lineno i, r;
     Symbol f1, f2;
     Symbol f1, f2;
+    Address a;
 
     i = findline(addr, false);
     if (i == -1) {
 
     i = findline(addr, false);
     if (i == -1) {
-       r = 0;
+       f1 = whatblock(addr);
+       if (f1 == nil or nosource(f1)) {
+           r = 0;
+       } else {
+           a = codeloc(f1);
+           for (;;) {
+               r = linelookup(a);
+               if (r != 0 or a >= CODESTART + objsize) {
+                   break;
+               }
+               ++a;
+           }
+       }
     } else {
        r = linetab[i].line;
        if (linetab[i].addr != addr) {
     } else {
        r = linetab[i].line;
        if (linetab[i].addr != addr) {
index ac726de..8e80ff3 100644 (file)
@@ -5,13 +5,17 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mkdate.c   5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)mkdate.c   5.3 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: mkdate.c,v 1.5 84/12/26 10:40:30 linton Exp $";
+static char rcsid[] = "$Header: mkdate.c,v 1.2 87/03/26 19:56:22 donn Exp $";
 
 #include <stdio.h>
 
 #include <stdio.h>
-#include <sys/time.h>
+#ifdef IRIS
+#   include <time.h>
+#else
+#   include <sys/time.h>
+#endif
 
 main()
 {
 
 main()
 {
@@ -25,30 +29,10 @@ main()
     t = localtime(&clock);
     printf("%d/%d/%d ", t->tm_mon + 1, t->tm_mday, t->tm_year % 100);
     printf("%d:%02d", t->tm_hour, t->tm_min);
     t = localtime(&clock);
     printf("%d/%d/%d ", t->tm_mon + 1, t->tm_mday, t->tm_year % 100);
     printf("%d:%02d", t->tm_hour, t->tm_min);
-    gethostname(name, &namelen);
-    printf(" (%s)", name);
+#   ifndef IRIS
+       gethostname(name, &namelen);
+       printf(" (%s)", name);
+#   endif
     printf("\";\n");
     printf("\";\n");
-    DoVersionNumber();
     exit(0);
 }
     exit(0);
 }
-
-DoVersionNumber()
-{
-    FILE *f;
-    int n;
-
-    f = fopen("version", "r");
-    if (f == NULL) {
-       n = 1;
-    } else {
-       fscanf(f, "%d", &n);
-       n = n + 1;
-       fclose(f);
-    }
-    f = fopen("version", "w");
-    if (f != NULL) {
-       fprintf(f, "%d\n", n);
-       fclose(f);
-    }
-    printf("int versionNumber = %d;\n", n);
-}
index a82bb53..5c3943e 100644 (file)
@@ -5,14 +5,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)modula-2.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)modula-2.c 5.2 (Berkeley) %G%";
 #endif not lint
 
 /*
  * Modula-2 specific symbol routines.
  */
 
 #endif not lint
 
 /*
  * Modula-2 specific symbol routines.
  */
 
-static char rcsid[] = "$Header: modula-2.c,v 1.6 84/12/26 10:40:33 linton Exp $";
+static char rcsid[] = "$Header: modula-2.c,v 1.2 87/03/26 20:12:54 donn Exp $";
 
 #include "defs.h"
 #include "symbols.h"
 
 #include "defs.h"
 #include "symbols.h"
@@ -90,23 +90,6 @@ register Symbol t1, t2;
     return b;
 }
 
     return b;
 }
 
-private boolean rangematch (t1, t2)
-register Symbol t1, t2;
-{
-    boolean b;
-    register Symbol rt1, rt2;
-
-    if (t1->class == RANGE and t2->class == RANGE) {
-       b = (boolean) (
-           t1->symvalue.rangev.lower == t2->symvalue.rangev.lower and
-           t1->symvalue.rangev.upper == t2->symvalue.rangev.upper
-       );
-    } else {
-       b = false;
-    }
-    return b;
-}
-
 private boolean nilMatch (t1, t2)
 register Symbol t1, t2;
 {
 private boolean nilMatch (t1, t2)
 register Symbol t1, t2;
 {
@@ -138,12 +121,12 @@ register Symbol t1, t2;
 
     b = (boolean) (
        (
 
     b = (boolean) (
        (
-           t1->class == DYNARRAY and t1->symvalue.ndims == 1 and
+           t1->class == OPENARRAY and t1->symvalue.ndims == 1 and
            t2->class == ARRAY and
            compatible(rtype(t2->chain)->type, t_int) and
            compatible(t1->type, t2->type)
        ) or (
            t2->class == ARRAY and
            compatible(rtype(t2->chain)->type, t_int) and
            compatible(t1->type, t2->type)
        ) or (
-           t2->class == DYNARRAY and t2->symvalue.ndims == 1 and
+           t2->class == OPENARRAY and t2->symvalue.ndims == 1 and
            t1->class == ARRAY and
            compatible(rtype(t1->chain)->type, t_int) and
            compatible(t1->type, t2->type)
            t1->class == ARRAY and
            compatible(rtype(t1->chain)->type, t_int) and
            compatible(t1->type, t2->type)
@@ -199,7 +182,7 @@ Symbol type1, type2;
            t2 = tmp;
        }
        b = (Boolean) (
            t2 = tmp;
        }
        b = (Boolean) (
-           builtinmatch(t1, t2) or rangematch(t1, t2) or
+           builtinmatch(t1, t2) or
            nilMatch(t1, t2) or enumMatch(t1, t2) or
            openArrayMatch(t1, t2) or stringArrayMatch(t1, t2)
        );
            nilMatch(t1, t2) or enumMatch(t1, t2) or
            openArrayMatch(t1, t2) or stringArrayMatch(t1, t2)
        );
@@ -268,6 +251,7 @@ Symbol s;
 
        case RANGE:
        case ARRAY:
 
        case RANGE:
        case ARRAY:
+       case OPENARRAY:
        case DYNARRAY:
        case SUBARRAY:
        case RECORD:
        case DYNARRAY:
        case SUBARRAY:
        case RECORD:
@@ -362,6 +346,14 @@ int n;
            printtype(t, t->type, n);
            break;
 
            printtype(t, t->type, n);
            break;
 
+       case OPENARRAY:
+           printf("array of ");
+           for (i = 1; i < t->symvalue.ndims; i++) {
+               printf("array of ");
+           }
+           printtype(t, t->type, n);
+           break;
+
        case DYNARRAY:
            printf("dynarray of ");
            for (i = 1; i < t->symvalue.ndims; i++) {
        case DYNARRAY:
            printf("dynarray of ");
            for (i = 1; i < t->symvalue.ndims; i++) {
@@ -619,10 +611,7 @@ integer n;
 
        case FIELD:
            if (isbitfield(s)) {
 
        case FIELD:
            if (isbitfield(s)) {
-               i = 0;
-               popn(size(s), &i);
-               i >>= (s->symvalue.field.offset mod BITSPERBYTE);
-               i &= ((1 << s->symvalue.field.length) - 1);
+               i = extractField(s);
                t = rtype(s->type);
                if (t->class == SCAL) {
                    printEnum(i, t);
                t = rtype(s->type);
                if (t->class == SCAL) {
                    printEnum(i, t);
@@ -646,6 +635,7 @@ integer n;
            }
            break;
 
            }
            break;
 
+       case OPENARRAY:
        case DYNARRAY:
            printDynarray(s);
            break;
        case DYNARRAY:
            printDynarray(s);
            break;
@@ -986,30 +976,38 @@ Node a, slist;
     integer n;
 
     t = rtype(a->nodetype);
     integer n;
 
     t = rtype(a->nodetype);
-    if (t->class == DYNARRAY or t->class == SUBARRAY) {
-       r = dynref(a, t, slist);
-    } else if (t->class == ARRAY) {
-       r = a;
-       eltype = rtype(t->type);
-       p = slist;
-       t = t->chain;
-       while (p != nil and t != nil) {
-           esub = p->value.arg[0];
-           if (not compatible(rtype(t), rtype(esub->nodetype))) {
-               suberror("subscript \"", esub, "\" is the wrong type");
-           }
-           r = build(O_INDEX, r, esub);
-           r->nodetype = eltype;
-           p = p->value.arg[1];
+    switch (t->class) {
+       case OPENARRAY:
+       case DYNARRAY:
+       case SUBARRAY:
+           r = dynref(a, t, slist);
+           break;
+
+       case ARRAY:
+           r = a;
+           eltype = rtype(t->type);
+           p = slist;
            t = t->chain;
            t = t->chain;
-       }
-       if (p != nil) {
-           suberror("too many subscripts for ", a, nil);
-       } else if (t != nil) {
-           suberror("not enough subscripts for ", a, nil);
-       }
-    } else {
-       suberror("\"", a, "\" is not an array");
+           while (p != nil and t != nil) {
+               esub = p->value.arg[0];
+               if (not compatible(rtype(t), rtype(esub->nodetype))) {
+                   suberror("subscript \"", esub, "\" is the wrong type");
+               }
+               r = build(O_INDEX, r, esub);
+               r->nodetype = eltype;
+               p = p->value.arg[1];
+               t = t->chain;
+           }
+           if (p != nil) {
+               suberror("too many subscripts for ", a, nil);
+           } else if (t != nil) {
+               suberror("not enough subscripts for ", a, nil);
+           }
+           break;
+
+       default:
+           suberror("\"", a, "\" is not an array");
+           break;
     }
     return r;
 }
     }
     return r;
 }
@@ -1111,9 +1109,13 @@ long i;
            error("subscript %d out of range [%d..%d]", i, lb, ub);
        }
        push(long, base + (i - lb) * size(t->type));
            error("subscript %d out of range [%d..%d]", i, lb, ub);
        }
        push(long, base + (i - lb) * size(t->type));
-    } else if (t->class == DYNARRAY and t->symvalue.ndims == 0) {
+    } else if ((t->class == OPENARRAY or t->class == DYNARRAY) and
+       t->symvalue.ndims == 0
+    ) {
        push(long, base + i * size(t->type));
        push(long, base + i * size(t->type));
-    } else if (t->class == DYNARRAY or t->class == SUBARRAY) {
+    } else if (t->class == OPENARRAY or t->class == DYNARRAY or
+       t->class == SUBARRAY
+    ) {
        push(long, i);
        sub = (long *) (sp - (t->symvalue.ndims * sizeof(long)));
        rpush(base, size(t));
        push(long, i);
        sub = (long *) (sp - (t->symvalue.ndims * sizeof(long)));
        rpush(base, size(t));
index d3ef46c..9269d6c 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)names.c    5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)names.c    5.2 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: names.c,v 1.4 84/12/26 10:40:47 linton Exp $";
+static char rcsid[] = "$Header: names.c,v 1.2 87/03/26 20:16:59 donn Exp $";
 
 /*
  * Name are the internal representation for identifiers.
 
 /*
  * Name are the internal representation for identifiers.
@@ -37,7 +37,12 @@ struct Name {
 #define ident(n) ((n == nil) ? "(noname)" : n->identifier)
 #endif
 
 #define ident(n) ((n == nil) ? "(noname)" : n->identifier)
 #endif
 
-#define HASHTABLESIZE 2997
+/*
+ * The hash table is a power of two, in order to make hashing faster.
+ * Using a non-prime is ok since we use chaining instead of re-hashing.
+ */
+
+#define HASHTABLESIZE 8192
 
 private Name nametable[HASHTABLESIZE];
 
 
 private Name nametable[HASHTABLESIZE];
 
@@ -47,7 +52,7 @@ private Name nametable[HASHTABLESIZE];
  * doesn't cause many a page fault.
  */
 
  * doesn't cause many a page fault.
  */
 
-#define CHUNKSIZE 200
+#define CHUNKSIZE 1000
 
 typedef struct Namepool {
     struct Name name[CHUNKSIZE];
 
 typedef struct Namepool {
     struct Name name[CHUNKSIZE];
@@ -64,9 +69,8 @@ private Integer nleft = 0;
  * The second argument specifies whether the string should be copied
  * into newly allocated space if not found.
  *
  * The second argument specifies whether the string should be copied
  * into newly allocated space if not found.
  *
- * Pardon my use of goto's, but it seemed more efficient and less convoluted
- * than adding a collection of boolean variables.  This routine is time
- * critical when starting up the debugger on large programs.
+ * This routine is time critical when starting up the debugger
+ * on large programs.
  */
 
 public Name identname(s, isallocated)
  */
 
 public Name identname(s, isallocated)
@@ -74,42 +78,37 @@ String s;
 Boolean isallocated;
 {
     register unsigned h;
 Boolean isallocated;
 {
     register unsigned h;
-    register Char *p, *q;
-    register Name n;
-    register Integer len;
+    register char *p, *q;
+    register Name n, *np;
     Namepool newpool;
 
     h = 0;
     for (p = s; *p != '\0'; p++) {
        h = (h << 1) ^ (*p);
     }
     Namepool newpool;
 
     h = 0;
     for (p = s; *p != '\0'; p++) {
        h = (h << 1) ^ (*p);
     }
-    h = h mod HASHTABLESIZE;
-    len = p - s;
-    n = nametable[h];
+    h &= (HASHTABLESIZE-1);
+    np = &nametable[h];
+    n = *np;
     while (n != nil) {
        p = s;
        q = n->identifier;
     while (n != nil) {
        p = s;
        q = n->identifier;
-       for (;;) {
-           if (*p != *q) {
-               goto nomatch;
-           } else if (*p == '\0') {
-               goto match;
+       while (*p == *q) {
+           if (*p == '\0') {
+               return n;
            }
            ++p;
            ++q;
        }
            }
            ++p;
            ++q;
        }
-    nomatch:
        n = n->chain;
     }
 
     /*
        n = n->chain;
     }
 
     /*
-     * Now we know that name hasn't been found (otherwise we'd have jumped
-     * down to match), so we allocate a name, store the identifier, and
+     * Now we know that name hasn't been found,
+     * so we allocate a name, store the identifier, and
      * enter it in the hash table.
      */
     if (nleft <= 0) {
        newpool = new(Namepool);
      * enter it in the hash table.
      */
     if (nleft <= 0) {
        newpool = new(Namepool);
-       bzero(newpool, sizeof(newpool));
        newpool->prevpool = namepool;
        namepool = newpool;
        nleft = CHUNKSIZE;
        newpool->prevpool = namepool;
        namepool = newpool;
        nleft = CHUNKSIZE;
@@ -119,7 +118,8 @@ Boolean isallocated;
     if (isallocated) {
        n->identifier = s;
     } else {
     if (isallocated) {
        n->identifier = s;
     } else {
-       n->identifier = newarr(char, len + 1);
+       /* this case doesn't happen very often */
+       n->identifier = newarr(char, strlen(s) + 1);
        p = s;
        q = n->identifier;
        while (*p != '\0') {
        p = s;
        q = n->identifier;
        while (*p != '\0') {
@@ -127,13 +127,8 @@ Boolean isallocated;
        }
        *q = '\0';
     }
        }
        *q = '\0';
     }
-    n->chain = nametable[h];
-    nametable[h] = n;
-
-    /*
-     * The two possibilities (name known versus unknown) rejoin.
-     */
-match:
+    n->chain = *np;
+    *np = n;
     return n;
 }
 
     return n;
 }
 
index dc2479d..380ff7f 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)object.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)object.c   5.2 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: object.c,v 1.6 84/12/26 10:40:51 linton Exp $";
+static char rcsid[] = "$Header: object.c,v 1.5 87/03/26 20:24:58 donn Exp $";
 
 /*
  * Object code interface, mainly for extraction of symbolic information.
 
 /*
  * Object code interface, mainly for extraction of symbolic information.
@@ -234,7 +234,7 @@ Fileid f;
     struct nlist *namelist;
     register struct nlist *np, *ub;
     register String name;
     struct nlist *namelist;
     register struct nlist *np, *ub;
     register String name;
-    register Boolean afterlg;
+    boolean afterlg, foundstab;
     integer index;
     char *lastchar;
 
     integer index;
     char *lastchar;
 
@@ -242,6 +242,7 @@ Fileid f;
     namelist = newarr(struct nlist, nlhdr.nsyms);
     read(f, namelist, nlhdr.nsyms * sizeof(struct nlist));
     afterlg = false;
     namelist = newarr(struct nlist, nlhdr.nsyms);
     read(f, namelist, nlhdr.nsyms * sizeof(struct nlist));
     afterlg = false;
+    foundstab = false;
     ub = &namelist[nlhdr.nsyms];
     curnp = &namelist[0];
     np = curnp;
     ub = &namelist[nlhdr.nsyms];
     curnp = &namelist[0];
     np = curnp;
@@ -275,6 +276,7 @@ Fileid f;
          *
         */
        if ((np->n_type&N_STAB) != 0) {
          *
         */
        if ((np->n_type&N_STAB) != 0) {
+           foundstab = true;
            enter_nl(name, np);
        } else if (name[0] == '-') {
            afterlg = true;
            enter_nl(name, np);
        } else if (name[0] == '-') {
            afterlg = true;
@@ -293,6 +295,9 @@ Fileid f;
        ++curnp;
        np = curnp;
     }
        ++curnp;
        np = curnp;
     }
+    if (not foundstab) {
+       warning("no source compiled with -g");
+    }
     dispose(namelist);
 }
 
     dispose(namelist);
 }
 
@@ -309,9 +314,10 @@ public String getcont ()
     ++curnp;
     index = curnp->n_un.n_strx;
     if (index == 0) {
     ++curnp;
     index = curnp->n_un.n_strx;
     if (index == 0) {
-       panic("continuation followed by empty stab");
+       name = "";
+    } else {
+       name = &stringtab[index - 4];
     }
     }
-    name = &stringtab[index - 4];
     return name;
 }
 
     return name;
 }
 
@@ -326,7 +332,8 @@ private initsyms ()
     nesting = 0;
     program = insert(identname("", true));
     program->class = PROG;
     nesting = 0;
     program = insert(identname("", true));
     program->class = PROG;
-    program->symvalue.funcv.beginaddr = 0;
+    program->language = primlang;
+    program->symvalue.funcv.beginaddr = CODESTART;
     program->symvalue.funcv.inline = false;
     newfunc(program, codeloc(program));
     findbeginning(program);
     program->symvalue.funcv.inline = false;
     newfunc(program, codeloc(program));
     findbeginning(program);
@@ -436,8 +443,8 @@ register struct nlist *np;
            if (index(name, ':') == nil) {
                if (not warned) {
                    warned = true;
            if (index(name, ':') == nil) {
                if (not warned) {
                    warned = true;
-                   warning("old style symbol information found in \"%s\"",
-                       curfilename());
+                   printf("warning: old style symbol information ");
+                   printf("found in \"%s\"\n", curfilename());
                }
            } else {
                entersym(name, np);
                }
            } else {
                entersym(name, np);
@@ -526,6 +533,9 @@ Name n;
     f->level = program->level;
     f->symvalue.funcv.src = false;
     f->symvalue.funcv.inline = false;
     f->level = program->level;
     f->symvalue.funcv.src = false;
     f->symvalue.funcv.inline = false;
+    if (f->chain != nil) {
+       panic("chain not nil in deffunc");
+    }
     return f;
 }
 
     return f;
 }
 
@@ -541,6 +551,7 @@ Name n;
 
     v = insert(n);
     v->language = findlanguage(".s");
 
     v = insert(n);
     v->language = findlanguage(".s");
+    v->storage = EXT;
     v->class = VAR;
     v->type = t_int;
     v->level = program->level;
     v->class = VAR;
     v->type = t_int;
     v->level = program->level;
@@ -568,6 +579,30 @@ Address addr;
     }
 }
 
     }
 }
 
+/*
+ * Avoid seeing Pascal labels as text symbols.
+ */
+
+private boolean PascalLabel (n)
+Name n;
+{
+    boolean b;
+    register char *p;
+
+    b = false;
+    if (curlang == findlanguage(".p")) {
+       p = ident(n);
+       while (*p != '\0') {
+           if (*p == '_' and *(p+1) == '$') {
+               b = true;
+               break;
+           }
+           ++p;
+       }
+    }
+    return b;
+}
+
 /*
  * Check to see if a global _name is already in the symbol table,
  * if not then insert it.
 /*
  * Check to see if a global _name is already in the symbol table,
  * if not then insert it.
@@ -603,10 +638,12 @@ register struct nlist *np;
            }
            if (count == 0) {
                if (t == nil) {
            }
            if (count == 0) {
                if (t == nil) {
-                   t = deffunc(n);
-                   updateTextSym(t, name, np->n_value);
-                   if (tracesyms) {
-                       printdecl(t);
+                   if (not PascalLabel(n)) {
+                       t = deffunc(n);
+                       updateTextSym(t, name, np->n_value);
+                       if (tracesyms) {
+                           printdecl(t);
+                       }
                    }
                } else {
                    if (t->class == MODULE) {
                    }
                } else {
                    if (t->class == MODULE) {
@@ -620,7 +657,7 @@ register struct nlist *np;
                    updateTextSym(t, name, np->n_value);
                }
            }
                    updateTextSym(t, name, np->n_value);
                }
            }
-       } else if ((np->n_type&N_TYPE) == N_BSS) {
+       } else if ((np->n_type&N_TYPE) == N_BSS or (np->n_type&N_TYPE) == N_DATA) {
            find(t, n) where
                t->class == COMMON
            endfind(t);
            find(t, n) where
                t->class == COMMON
            endfind(t);
@@ -714,6 +751,7 @@ register struct nlist *np;
        t->language = findlanguage(".s");
        t->type = t_int;
        t->block = cur;
        t->language = findlanguage(".s");
        t->type = t_int;
        t->block = cur;
+       t->storage = EXT;
        t->level = cur->level;
        if ((np->n_type&N_TYPE) == N_TEXT) {
            t->class = FUNC;
        t->level = cur->level;
        if ((np->n_type&N_TYPE) == N_TEXT) {
            t->class = FUNC;
@@ -824,6 +862,10 @@ Address addr;
        mname = rindex(mname, '/') + 1;
     }
     suffix = rindex(mname, '.');
        mname = rindex(mname, '/') + 1;
     }
     suffix = rindex(mname, '.');
+    if (suffix > mname && *(suffix-1) == '.') {
+       /* special hack for C++ */
+       --suffix;
+    }
     curlang = findlanguage(suffix);
     if (curlang == findlanguage(".f")) {
        strip_ = true;
     curlang = findlanguage(suffix);
     if (curlang == findlanguage(".f")) {
        strip_ = true;