1: #include "../h/rt.h"
   2: /*
   3:  * display(i,f) - display local variables of i most recent
   4:  * procedure activations, plus global variables.
   5:  * Output to file f (default &errout).
   6:  */
   7: 
   8: Xdisplay(nargs, arg2, arg1, arg0)
   9: int nargs;
  10: struct descrip arg2, arg1, arg0;
  11:    {
  12:    register int *ap, *fp;
  13:    register struct descrip *dp;
  14:    register struct descrip *np;
  15:    register int n;
  16:    long l;
  17:    int count;
  18:    FILE *f;
  19:    struct b_proc *bp;
  20:    extern int *boundary;
  21:    extern struct descrip *globals, *eglobals;
  22:    extern struct descrip *gnames;
  23:    extern struct descrip *statics;
  24: 
  25:    /*
  26:     * i defaults to &level; f defaults to &errout.
  27:     */
  28:    defint(&arg1, &l, k_level);
  29:    deffile(&arg2, &errout);
  30:    /*
  31:     * Produce error if file can't be written on.
  32:     */
  33:    f = BLKLOC(arg2)->file.fd;
  34:    if ((BLKLOC(arg2)->file.status & FS_WRITE) == 0)
  35:       runerr(213, &arg2);
  36: 
  37:    /*
  38:     * Produce error if i is negative; constrain i to be >= &level.
  39:     */
  40:    if (l < 0)
  41:       runerr(205, &arg1);
  42:    else if (l > k_level)
  43:       count = k_level;
  44:    else
  45:       count = l;
  46: 
  47:    fp = boundary;       /* start fp at most recent procedure frame */
  48:    while (count--) {        /* go back through 'count' frames */
  49: #ifdef VAX
  50:       ap = (int *) fp[2];   /* get old ap */
  51:       fp = (int *) fp[3];   /* get old fp */
  52:       if (fp == 0)      /* only trace back to start of current stack*/
  53:          break;
  54:       n = ap[1];        /* get number of arguments */
  55:                 /* calculate address of procedure descriptor*/
  56:       dp = (struct descrip *) (ap + 2 + 2*n);
  57: #endif VAX
  58: #ifdef PORT
  59: /*
  60:  * Insert code here to calculate (in dp) the address of arg0 in
  61:  *  procedure frame prior to one referenced by fp.
  62:  */
  63: #endif PORT
  64: #ifdef PDP11
  65:       fp = fp[0];       /* get old fp */
  66:       if (fp == 0)      /* only trace back to start of current stack*/
  67:          break;
  68:       n = fp[2];        /* get number of arguments */
  69:       dp = fp + 3 + 2*n;    /* calculate address of procedure descriptor*/
  70: #endif PDP11
  71:       bp = (struct b_proc *) BLKLOC(*dp);   /* get address of procedure block */
  72: 
  73:       /*
  74:        * Print procedure name.
  75:        */
  76:       putstr(f, STRLOC(bp->pname), STRLEN(bp->pname));
  77:       fprintf(f, " local identifiers:\n");
  78: 
  79:       /*
  80:        * Print arguments.
  81:        */
  82:       np = bp->lnames;
  83:       for (n = bp->nparam; n > 0; n--) {
  84:          fprintf(f, "   ");
  85:          putstr(f, STRLOC(*np), STRLEN(*np));
  86:          fprintf(f, " = ");
  87:          outimage(f, --dp, 0);
  88:          putc('\n', f);
  89:          np++;
  90:          }
  91: 
  92:       /*
  93:        * Print local dynamics.
  94:        */
  95:       dp = (struct descrip *) (fp - FRAMELIMIT);
  96:       for (n = bp->ndynam; n > 0; n--) {
  97:          fprintf(f, "   ");
  98:          putstr(f, STRLOC(*np), STRLEN(*np));
  99:          fprintf(f, " = ");
 100:          outimage(f, --dp, 0);
 101:          putc('\n', f);
 102:          np++;
 103:          }
 104: 
 105:       /*
 106:        * Print local statics.
 107:        */
 108:       dp = &statics[bp->fstatic];
 109:       for (n = bp->nstatic; n > 0; n--) {
 110:          fprintf(f, "   ");
 111:          putstr(f, STRLOC(*np), STRLEN(*np));
 112:          fprintf(f, " = ");
 113:          outimage(f, dp++, 0);
 114:          putc('\n', f);
 115:          np++;
 116:          }
 117: 
 118:       }
 119: 
 120:    /*
 121:     * Print globals.
 122:     */
 123:    fprintf(f, "global identifiers:\n");
 124:    dp = globals;
 125:    np = gnames;
 126:    while (dp < eglobals) {
 127:       fprintf(f, "   ");
 128:       putstr(f, STRLOC(*np), STRLEN(*np));
 129:       fprintf(f, " = ");
 130:       outimage(f, dp++, 0);
 131:       putc('\n', f);
 132:       np++;
 133:       }
 134:    fflush(f);
 135:    arg0 = nulldesc;         /* Return null value. */
 136:    }
 137: 
 138: Procblock(display,2)

Defined functions

Xdisplay defined in line 8; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 924
Valid CSS Valid XHTML 1.0 Strict