home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / sco-crash / texts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-03  |  1.5 KB  |  72 lines

  1. #include <sys/param.h>
  2. #include <sys/sysmacros.h>
  3. #include <sys/types.h>
  4. #include <sys/var.h>
  5. #include <sys/inode.h>
  6. #include <sys/text.h>
  7. #include <sys/page.h>
  8. #include <sys/seg.h>
  9. #include <sys/proc.h>
  10. #include <a.out.h>
  11. #include "crash.h"
  12.  
  13. prtexts (items, cnt)
  14. int    *items;
  15. int    cnt;
  16. {
  17.     int    i;
  18.  
  19.     texts = (struct text *) malloc (v.v_text * sizeof (struct text));
  20.     lseek (kmemfd, namelist[NM_TEXT].xl_value, 0);
  21.     read (kmemfd, texts, sizeof (struct text) * v.v_text);
  22.  
  23.     printf ("SLOT  INODE  REF  LDREF  PROC  SWAPLO+   SIZE  FLAGS\n");
  24.  
  25.     if (cnt == 0) {
  26.         for (i = 0;i < v.v_text;i++) {
  27.             if (texts[i].x_count == 0)
  28.                 continue;
  29.  
  30.             dotext (i);
  31.         }
  32.     } else {
  33.         for (i = 0;i < cnt;i++) {
  34.             if (items[i] >= v.v_text)
  35.                 printf ("value (%d) out of range\n", items[i]);
  36.             else
  37.                 dotext (items[i]);
  38.         }
  39.     }
  40.     free ((char *) texts);
  41. }
  42.  
  43. dotext (i)
  44. int    i;
  45. {
  46.     struct    text    *tp;
  47.     int    procnum;
  48.  
  49.     tp = &texts[i];
  50.  
  51.     if (tp->x_ccount > 0)
  52.         procnum = tp->x_caddr -
  53.             (struct proc *) namelist[NM_PROC].xl_value;
  54.     else
  55.         procnum = 0;
  56.  
  57.     printf ("%4d  %5d  %3d  %5d  %4d  %7d  %5d ", i,
  58.         tp->x_iptr - (struct inode *) namelist[NM_INODE].xl_value,
  59.         tp->x_count, tp->x_ccount, procnum,
  60.         tp->x_daddr, tp->x_size);
  61.  
  62.     if (tp->x_flag & XTRC)        printf (" trace");
  63.     if (tp->x_flag & XWRIT)        printf (" write");
  64.     if (tp->x_flag & XLOAD)        printf (" loaded");
  65.     if (tp->x_flag & XLOCK)        printf (" locked");
  66.     if (tp->x_flag & XWANT)        printf (" wanted");
  67.     if (tp->x_flag & XLARGE)    printf (" large");
  68.     if (tp->x_flag & XFPU)        printf (" fpu");
  69.  
  70.     printf ("\n");
  71. }
  72.