cleanup, add manual pages
[unix-history] / usr / src / old / dbx / printsym.c
index 9823b09..3bf9531 100644 (file)
@@ -5,10 +5,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)printsym.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)printsym.c 5.5 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-static char rcsid[] = "$Header: printsym.c,v 1.5 84/12/26 10:41:28 linton Exp $";
+static char rcsid[] = "$Header: printsym.c,v 1.4 87/04/15 00:23:35 donn Exp $";
 
 /*
  * Printing of symbolic information.
 
 /*
  * Printing of symbolic information.
@@ -27,6 +27,7 @@ static char rcsid[] = "$Header: printsym.c,v 1.5 84/12/26 10:41:28 linton Exp $"
 #include "names.h"
 #include "keywords.h"
 #include "main.h"
 #include "names.h"
 #include "keywords.h"
 #include "main.h"
+#include <ctype.h>
 
 #ifndef public
 #endif
 
 #ifndef public
 #endif
@@ -46,8 +47,8 @@ static char rcsid[] = "$Header: printsym.c,v 1.5 84/12/26 10:41:28 linton Exp $"
  */
 
 private String clname[] = {
  */
 
 private String clname[] = {
-    "bad use", "constant", "type", "variable", "array", "@dynarray",
-    "@subarray", "fileptr", "record", "field",
+    "bad use", "constant", "type", "variable", "array", "array",
+    "dynarray", "subarray", "fileptr", "record", "field",
     "procedure", "function", "funcvar",
     "ref", "pointer", "file", "set", "range", "label", "withptr",
     "scalar", "string", "program", "improper", "variant",
     "procedure", "function", "funcvar",
     "ref", "pointer", "file", "set", "range", "label", "withptr",
     "scalar", "string", "program", "improper", "variant",
@@ -252,6 +253,7 @@ Frame frame;
     t = rtype(p->type);
     switch (t->class) {
        case ARRAY:
     t = rtype(p->type);
     switch (t->class) {
        case ARRAY:
+       case OPENARRAY:
        case DYNARRAY:
        case SUBARRAY:
            t = rtype(t->type);
        case DYNARRAY:
        case SUBARRAY:
            t = rtype(t->type);
@@ -414,7 +416,7 @@ Symbol s;
        printf(" (%s)", symname(s->chain));
     }
     printf("\nblock\t0x%x", s->block);
        printf(" (%s)", symname(s->chain));
     }
     printf("\nblock\t0x%x", s->block);
-    if (s->block->name != nil) {
+    if (s->block != nil and s->block->name != nil) {
        printf(" (");
        printname(stdout, s->block);
        putchar(')');
        printf(" (");
        printname(stdout, s->block);
        putchar(')');
@@ -427,10 +429,18 @@ Symbol s;
 
        case VAR:
        case REF:
 
        case VAR:
        case REF:
-           if (s->level >= 3) {
-               printf("address\t0x%x\n", s->symvalue.offset);
-           } else {
-               printf("offset\t%d\n", s->symvalue.offset);
+           switch (s->storage) {
+               case INREG:
+                   printf("reg\t%d\n", s->symvalue.offset);
+                   break;
+
+               case STK:
+                   printf("offset\t%d\n", s->symvalue.offset);
+                   break;
+
+               case EXT:
+                   printf("address\t0x%x\n", s->symvalue.offset);
+                   break;
            }
            printf("size\t%d\n", size(s));
            break;
            }
            printf("size\t%d\n", size(s));
            break;
@@ -624,7 +634,11 @@ double r;
     extern char *index();
     char buf[256];
 
     extern char *index();
     char buf[256];
 
-    sprintf(buf, "%g", r);
+#   ifdef IRIS
+       sprintf(buf, "%lg", r);
+#   else
+       sprintf(buf, "%g", r);
+#   endif
     if (buf[0] == '.') {
        printf("0%s", buf);
     } else if (buf[0] == '-' and buf[1] == '.') {
     if (buf[0] == '.') {
        printf("0%s", buf);
     } else if (buf[0] == '-' and buf[1] == '.') {
@@ -656,7 +670,7 @@ char c;
     } else if (c >= ' ' && c <= '~') {
        putchar(c);
     } else {
     } else if (c >= ' ' && c <= '~') {
        putchar(c);
     } else {
-       printf("\\0%o",c);
+       printf("\\0%o",c&0xff);
     }
 }
 
     }
 }
 
@@ -725,6 +739,8 @@ boolean quotes;
     register Address a;
     register integer i, len;
     register boolean endofstring;
     register Address a;
     register integer i, len;
     register boolean endofstring;
+    register int unprintables;
+#define        MAXGARBAGE      4
     union {
        char ch[sizeof(Word)];
        int word;
     union {
        char ch[sizeof(Word)];
        int word;
@@ -737,6 +753,7 @@ boolean quotes;
            putchar('"');
        }
        a = addr;
            putchar('"');
        }
        a = addr;
+       unprintables = 0;
        endofstring = false;
        while (not endofstring) {
            dread(&u, a, sizeof(u));
        endofstring = false;
        while (not endofstring) {
            dread(&u, a, sizeof(u));
@@ -746,6 +763,10 @@ boolean quotes;
                    endofstring = true;
                } else {
                    printchar(u.ch[i]);
                    endofstring = true;
                } else {
                    printchar(u.ch[i]);
+                   if (!isascii(u.ch[i]) and ++unprintables > MAXGARBAGE) {
+                       endofstring = true;
+                       printf("...");
+                   }
                }
                ++i;
            } while (i < sizeof(Word) and not endofstring);
                }
                ++i;
            } while (i < sizeof(Word) and not endofstring);