home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / texts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  1.9 KB  |  87 lines

  1. /*
  2.  * Copyright 1988, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #ifndef    lint
  13. static    char    sccsid[] = "@(#)texts.c    1.2    22:55:40    2/21/91";
  14. #endif
  15.  
  16. #include <sys/param.h>
  17. #include <sys/sysmacros.h>
  18. #include <sys/types.h>
  19. #include <sys/var.h>
  20. #include <sys/inode.h>
  21. #include <sys/text.h>
  22. #include <sys/page.h>
  23. #include <sys/seg.h>
  24. #include <sys/proc.h>
  25. #include <a.out.h>
  26. #include "crash.h"
  27.  
  28. prtexts (items, cnt)
  29. int    *items;
  30. int    cnt;
  31. {
  32.     int    i;
  33.  
  34.     texts = (struct text *) malloc (v.v_text * sizeof (struct text));
  35.     lseek (kmemfd, namelist[NM_TEXT].xl_value, 0);
  36.     read (kmemfd, texts, sizeof (struct text) * v.v_text);
  37.  
  38.     printf ("SLOT  INODE  REF  LDREF  PROC  SWAPLO+   SIZE  FLAGS\n");
  39.  
  40.     if (cnt == 0) {
  41.         for (i = 0;i < v.v_text;i++) {
  42.             if (texts[i].x_count == 0)
  43.                 continue;
  44.  
  45.             dotext (i);
  46.         }
  47.     } else {
  48.         for (i = 0;i < cnt;i++) {
  49.             if (items[i] >= v.v_text)
  50.                 printf ("value (%d) out of range\n", items[i]);
  51.             else
  52.                 dotext (items[i]);
  53.         }
  54.     }
  55.     free ((char *) texts);
  56. }
  57.  
  58. dotext (i)
  59. int    i;
  60. {
  61.     struct    text    *tp;
  62.     int    procnum;
  63.  
  64.     tp = &texts[i];
  65.  
  66.     if (tp->x_ccount > 0)
  67.         procnum = tp->x_caddr -
  68.             (struct proc *) namelist[NM_PROC].xl_value;
  69.     else
  70.         procnum = 0;
  71.  
  72.     printf ("%4d  %5d  %3d  %5d  %4d  %7d  %5d ", i,
  73.         tp->x_iptr - (struct inode *) namelist[NM_INODE].xl_value,
  74.         tp->x_count, tp->x_ccount, procnum,
  75.         tp->x_daddr, tp->x_size);
  76.  
  77.     if (tp->x_flag & XTRC)        printf (" trace");
  78.     if (tp->x_flag & XWRIT)        printf (" write");
  79.     if (tp->x_flag & XLOAD)        printf (" loaded");
  80.     if (tp->x_flag & XLOCK)        printf (" locked");
  81.     if (tp->x_flag & XWANT)        printf (" wanted");
  82.     if (tp->x_flag & XLARGE)    printf (" large");
  83.     if (tp->x_flag & XFPU)        printf (" fpu");
  84.  
  85.     printf ("\n");
  86. }
  87.