BSD 4 release
[unix-history] / usr / src / cmd / sdb / sub.c
index 60a789d..7b986fe 100644 (file)
@@ -1,5 +1,7 @@
+static char sccsid[] = "@(#)sub.c 4.1 10/9/80";
 #include "head.h"
 #include <a.out.h>
 #include "head.h"
 #include <a.out.h>
+#include <stab.h>
 #include "cdefs.h"
 #include <stdio.h>
 struct user u;
 #include "cdefs.h"
 #include <stdio.h>
 struct user u;
@@ -85,11 +87,19 @@ chkerr()
 eqstr(s1, s2)
        REG STRING      s1, s2;
 {
 eqstr(s1, s2)
        REG STRING      s1, s2;
 {
+#ifndef FLEXNAMES
        REG STRING       es1;
        REG STRING       es1;
+#endif
        if (s2 == (STRING) -1) return(0);
        if (s2 == (STRING) -1) return(0);
+#ifndef FLEXNAMES
        es1 = s1+8;
        es1 = s1+8;
+#endif
        WHILE *s1++ == *s2
        WHILE *s1++ == *s2
+#ifndef FLEXNAMES
        DO IF *s2++ == 0 ORF s1>=es1
        DO IF *s2++ == 0 ORF s1>=es1
+#else
+       DO IF *s2++ == 0
+#endif
           THEN return(1);
           FI
        OD
           THEN return(1);
           FI
        OD
@@ -137,32 +147,59 @@ char d; {
  */
 eqpat(pat, str)
 char *pat, *str; {
  */
 eqpat(pat, str)
 char *pat, *str; {
+#ifndef FLEXNAMES
        return(eqpatr(pat, str, 0));
        return(eqpatr(pat, str, 0));
+#else
+       return(eqpatr(pat, str));
+#endif
 }
 
 }
 
+#ifndef FLEXNAMES
 eqpatr(pat, str, cnt)
 eqpatr(pat, str, cnt)
+#else
+eqpatr(pat, str)
+#endif
 char *pat, *str; {
        register int i;
        register char p, s;
        
        p = pat[0];
        s = str[0];
 char *pat, *str; {
        register int i;
        register char p, s;
        
        p = pat[0];
        s = str[0];
+#ifndef FLEXNAMES
        if (cnt == 8) return(1);
        if (cnt == 8) return(1);
+#endif
        if (p == '?') {
                if (s == '\0') return(0);
        if (p == '?') {
                if (s == '\0') return(0);
+#ifndef FLEXNAMES
                return(eqpatr(pat+1, str+1, cnt+1));
                return(eqpatr(pat+1, str+1, cnt+1));
+#else
+               return(eqpatr(pat+1, str+1));
+#endif
        }
        if (p == '*') {
                if (pat[1] == '\0') return(1);
        }
        if (p == '*') {
                if (pat[1] == '\0') return(1);
+#ifndef FLEXNAMES
                for(i=1; i<8-cnt; i++) {
                        if (eqpatr(pat+1, str+i, cnt+i)) return(1);
                for(i=1; i<8-cnt; i++) {
                        if (eqpatr(pat+1, str+i, cnt+i)) return(1);
+#else
+               for(i=1; ; i++) {
+                       if (eqpatr(pat+1, str+i)) return(1);
+#endif
                        if (str[i] == '\0') return(0);
                }
                        if (str[i] == '\0') return(0);
                }
+#ifndef FLEXNAMES
                return(0);
                return(0);
+#else
+               /*NOTREACHED*/
+#endif
        }
        if ((eqany(p, ".[->") || p == '\0') && s == '\0') return(1);
        if (p != s) return(0);
        }
        if ((eqany(p, ".[->") || p == '\0') && s == '\0') return(1);
        if (p != s) return(0);
+#ifndef FLEXNAMES
        return(eqpatr(pat+1, str+1, cnt+1));
        return(eqpatr(pat+1, str+1, cnt+1));
+#else
+       return(eqpatr(pat+1, str+1));
+#endif
 }
 
 /* gets indirect address for pointers and subscripts */
 }
 
 /* gets indirect address for pointers and subscripts */
@@ -171,7 +208,7 @@ ADDR addr; {
        if (ISARY(type)) return(addr);
        if (class == N_RSYM)
                return(*(ADDR *)(((ADDR) &u) + R0 + (WORDSIZE)*addr));
        if (ISARY(type)) return(addr);
        if (class == N_RSYM)
                return(*(ADDR *)(((ADDR) &u) + R0 + (WORDSIZE)*addr));
-       return(getval(addr, 'd'));
+       return(getval(addr, 'd', DSP));
 }
 
 long
 }
 
 long
@@ -264,10 +301,64 @@ char *p; {
                        printf("Unknown variable: %s\n", argsp);
                        return(-1);
                }
                        printf("Unknown variable: %s\n", argsp);
                        return(-1);
                }
-               value = getval(j, typetodesc(sl_type, 0)[0]);
+               value = getval(j, typetodesc(sl_type, 0)[0], DSP);
                do {
                        p++;
                } while (varchar(*p) || number(*p));
        }
        return(value);
 }
                do {
                        p++;
                } while (varchar(*p) || number(*p));
        }
        return(value);
 }
+
+prhex(v) 
+long v; {
+       if (v < 0)  {
+               v = -v;
+               printf("-");
+       }
+       if (v <= 9)
+               printf("%d", v);
+       else
+               printf("0x%x", v);
+}
+
+/* print hex number in field of length 12 */
+prhex12(v) 
+long v; {
+       if (v >= -9 && v <= 9)
+               printf("%-12d", v);
+       else
+               printf("0x%-12x", v);
+}
+
+/* print line number followed by offset */
+prlnoff(procp, v)
+struct proct *procp; ADDR v; {
+       int lineno, diff;
+       char *name;
+       name = procp->pname;
+       if (name[0] == '_') {
+#ifndef FLEXNAMES
+               printf("%.7s", name+1);
+#else
+               printf("%s", name+1);
+#endif
+               lineno = -1;
+       } else {
+#ifndef FLEXNAMES
+               printf("%8s", name);
+#else
+               printf("%s", name);
+#endif
+               lineno = adrtolineno((ADDR) v);
+       }
+       if (lineno == -1)
+               diff = v - procp->paddr;
+       else {
+               printf(":%d", lineno);
+               diff = v - lnfaddr;  /* set by adrtolineno() */
+       }
+       if (diff) {
+               printf("+");
+               prhex(diff);
+       }
+}