fix structure arguments. don't map OREG to REG for STASG (match fails)
[unix-history] / usr / src / old / dbx / vax.c
index cf86815..d0078d3 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[] = "@(#)vax.c 1.3 %G%";
+static char sccsid[] = "@(#)vax.c 1.9 %G%";
 
 /*
  * Target machine dependent stuff.
 
 /*
  * Target machine dependent stuff.
@@ -260,6 +260,7 @@ int mode;
     char byte;
     short hword;
     int argval;
     char byte;
     short hword;
     int argval;
+    Symbol f;
 
     switch (nbytes) {
        case 1:
 
     switch (nbytes) {
        case 1:
@@ -280,7 +281,12 @@ int mode;
        argval += addr + nbytes;
     }
     if (reg == regname[PROGCTR]) {
        argval += addr + nbytes;
     }
     if (reg == regname[PROGCTR]) {
-       printf("%x", argval);
+       f = whatblock((Address) argval + 2);
+       if (codeloc(f) == argval + 2) {
+           printf("%s", symname(f));
+       } else {
+           printf("%x", argval);
+       }
     } else {
        printf("%d(%s)", argval, reg);
     }
     } else {
        printf("%d(%s)", argval, reg);
     }
@@ -308,11 +314,26 @@ private Format fmt[] = {
     { "b", " \\%o", sizeof(char) },
     { "c", " '%c'", sizeof(char) },
     { "s", "%c", sizeof(char) },
     { "b", " \\%o", sizeof(char) },
     { "c", " '%c'", sizeof(char) },
     { "s", "%c", sizeof(char) },
-    { "f", " %f", sizeof(double) },
+    { "f", " %f", sizeof(float) },
     { "g", " %g", sizeof(double) },
     { nil, nil, 0 }
 };
 
     { "g", " %g", sizeof(double) },
     { nil, nil, 0 }
 };
 
+private Format *findformat(s)
+String s;
+{
+    register Format *f;
+
+    f = &fmt[0];
+    while (f->name != nil and not streq(f->name, s)) {
+       ++f;
+    }
+    if (f->name == nil) {
+       error("bad print format \"%s\"", s);
+    }
+    return f;
+}
+
 public Address printdata(lowaddr, highaddr, format)
 Address lowaddr;
 Address highaddr;
 public Address printdata(lowaddr, highaddr, format)
 Address lowaddr;
 Address highaddr;
@@ -326,13 +347,7 @@ String format;
     if (lowaddr > highaddr) {
        error("first address larger than second");
     }
     if (lowaddr > highaddr) {
        error("first address larger than second");
     }
-    f = &fmt[0];
-    while (f->name != nil and not streq(f->name, format)) {
-       ++f;
-    }
-    if (f->name == nil) {
-       error("bad print format \"%s\"", format);
-    }
+    f = findformat(format);
     n = 0;
     value = 0;
     for (addr = lowaddr; addr <= highaddr; addr += f->length) {
     n = 0;
     value = 0;
     for (addr = lowaddr; addr <= highaddr; addr += f->length) {
@@ -367,33 +382,34 @@ String format;
     register Address addr;
     register Format *f;
     register Boolean isstring;
     register Address addr;
     register Format *f;
     register Boolean isstring;
-    int value;
+    char c;
+    union {
+       char charv;
+       short shortv;
+       int intv;
+       float floatv;
+       double doublev;
+    } value;
 
     if (count <= 0) {
        error("non-positive repetition count");
     }
 
     if (count <= 0) {
        error("non-positive repetition count");
     }
-    f = &fmt[0];
-    while (f->name != nil and not streq(f->name, format)) {
-       ++f;
-    }
-    if (f->name == nil) {
-       error("bad print format \"%s\"", format);
-    }
+    f = findformat(format);
     isstring = (Boolean) streq(f->name, "s");
     n = 0;
     addr = startaddr;
     isstring = (Boolean) streq(f->name, "s");
     n = 0;
     addr = startaddr;
-    value = 0;
+    value.intv = 0;
     for (i = 0; i < count; i++) {
        if (n == 0) {
            printf("%08x: ", addr);
        }
        if (isstring) {
            putchar('"');
     for (i = 0; i < count; i++) {
        if (n == 0) {
            printf("%08x: ", addr);
        }
        if (isstring) {
            putchar('"');
-           dread(&value, addr, sizeof(char));
-           while (value != '\0') {
-               printchar((char) value);
+           dread(&c, addr, sizeof(char));
+           while (c != '\0') {
+               printchar(c);
                ++addr;
                ++addr;
-               dread(&value, addr, sizeof(char));
+               dread(&c, addr, sizeof(char));
            }
            putchar('"');
            putchar('\n');
            }
            putchar('"');
            putchar('\n');
@@ -416,8 +432,36 @@ String format;
     prtaddr = addr;
 }
 
     prtaddr = addr;
 }
 
+/*
+ * Print out a value according to the given format.
+ */
+
+public printvalue(v, format)
+long v;
+String format;
+{
+    Format *f;
+    char *p, *q;
+
+    f = findformat(format);
+    if (streq(f->name, "s")) {
+       putchar('"');
+       p = (char *) &v;
+       q = p + sizeof(v);
+       while (p < q) {
+           printchar(*p);
+           ++p;
+       }
+       putchar('"');
+    } else {
+       printf(f->printfstring, v);
+    }
+    putchar('\n');
+}
+
 /*
  * Print out an execution time error.
 /*
  * Print out an execution time error.
+ * Assumes the source position of the error has been calculated.
  *
  * Have to check if the -r option was specified; if so then
  * the object file information hasn't been read in yet.
  *
  * Have to check if the -r option was specified; if so then
  * the object file information hasn't been read in yet.
@@ -427,7 +471,6 @@ public printerror()
 {
     extern Integer sys_nsig;
     extern String sys_siglist[];
 {
     extern Integer sys_nsig;
     extern String sys_siglist[];
-    String filename;
     Integer err;
 
     if (isfinished(process)) {
     Integer err;
 
     if (isfinished(process)) {
@@ -439,10 +482,6 @@ public printerror()
        init();
        fprintf(stderr, " type 'help' for help\n");
     }
        init();
        fprintf(stderr, " type 'help' for help\n");
     }
-    curline = srcline(pc);
-    curfunc = whatblock(pc);
-    filename = srcfilename(pc);
-    setsource(filename);
     err = errnum(process);
     if (err == SIGINT) {
        printf("\n\ninterrupt ");
     err = errnum(process);
     if (err == SIGINT) {
        printf("\n\ninterrupt ");
@@ -467,21 +506,6 @@ public printerror()
     erecover();
 }
 
     erecover();
 }
 
-private printloc()
-{
-    if (curline > 0) {
-       if (nlhdr.nfiles > 1) {
-           printf("at line %d in file %s", curline, cursource);
-       } else {
-           printf("at line %d", curline);
-       }
-    } else {
-       printf("in ");
-       printname(stdout, curfunc);
-       printf(" at 0x%x", pc);
-    }
-}
-
 /*
  * Note the termination of the program.  We do this so as to avoid
  * having the process exit, which would make the values of variables
 /*
  * Note the termination of the program.  We do this so as to avoid
  * having the process exit, which would make the values of variables
@@ -503,7 +527,7 @@ public endprogram()
 
 /*
  * Single step the machine a source line (or instruction if "inst_tracing"
 
 /*
  * Single step the machine a source line (or instruction if "inst_tracing"
- * is true.  If "isnext" is true, skip over procedure calls.
+ * is true).  If "isnext" is true, skip over procedure calls.
  */
 
 private Address getcall();
  */
 
 private Address getcall();
@@ -516,15 +540,17 @@ Boolean isnext;
     String filename;
 
     addr = nextaddr(pc, isnext);
     String filename;
 
     addr = nextaddr(pc, isnext);
-    if (not inst_tracing) {
+    if (not inst_tracing and nlhdr.nlines != 0) {
        line = linelookup(addr);
        while (line == 0) {
            addr = nextaddr(addr, isnext);
            line = linelookup(addr);
        }
        line = linelookup(addr);
        while (line == 0) {
            addr = nextaddr(addr, isnext);
            line = linelookup(addr);
        }
+       curline = line;
+    } else {
+       curline = 0;
     }
     stepto(addr);
     }
     stepto(addr);
-    curline = line;
     filename = srcfilename(addr);
     setsource(filename);
 }
     filename = srcfilename(addr);
     setsource(filename);
 }
@@ -578,11 +604,20 @@ Boolean isnext;
                pstep(process);
                addr = reg(PROGCTR);
                pc = addr;
                pstep(process);
                addr = reg(PROGCTR);
                pc = addr;
-               callnews(/* iscall = */ true);
+               curfunc = whatblock(pc);
                if (not isbperr()) {
                    printstatus();
                if (not isbperr()) {
                    printstatus();
-               } else {
+                   /* NOTREACHED */
+               }
+               bpact();
+               if (nosource(curfunc) and canskip(curfunc) and
+                 nlhdr.nlines != 0) {
+                   addrstatus = KNOWN;
+                   addr = return_addr();
+                   stepto(addr);
                    bpact();
                    bpact();
+               } else {
+                   callnews(/* iscall = */ true);
                }
            }
            break;
                }
            }
            break;
@@ -593,6 +628,7 @@ Boolean isnext;
            callnews(/* iscall = */ false);
            addr = return_addr();
            stepto(addr);
            callnews(/* iscall = */ false);
            addr = return_addr();
            stepto(addr);
+           bpact();
            break;
 
        case O_BNEQ: case O_BEQL: case O_BGTR:
            break;
 
        case O_BNEQ: case O_BEQL: case O_BGTR:
@@ -795,7 +831,7 @@ Address addr;
            return;
        }
     }
            return;
        }
     }
-    iread(&save, addr, sizeof(addr));
+    iread(&save, addr, sizeof(save));
     newsave = new(Savelist);
     newsave->location = addr;
     newsave->save = save;
     newsave = new(Savelist);
     newsave->location = addr;
     newsave->save = save;