add/re-enable at_wini debug output
[minix3.git] / servers / is / dmp_pm.c
blobc6441c788b05fd1f5bb682dcd36b8ad2bde71eba
1 /* This file contains procedures to dump to PM' data structures.
3 * The entry points into this file are
4 * mproc_dmp: display PM process table
6 * Created:
7 * May 11, 2005: by Jorrit N. Herder
8 */
10 #include "inc.h"
11 #include "../pm/mproc.h"
12 #include <timers.h>
13 #include <minix/config.h>
14 #include <minix/type.h>
16 PUBLIC struct mproc mproc[NR_PROCS];
18 /*===========================================================================*
19 * mproc_dmp *
20 *===========================================================================*/
21 PRIVATE char *flags_str(int flags)
23 static char str[10];
24 str[0] = (flags & WAITING) ? 'W' : '-';
25 str[1] = (flags & ZOMBIE) ? 'Z' : '-';
26 str[2] = (flags & PAUSED) ? 'P' : '-';
27 str[3] = (flags & ALARM_ON) ? 'A' : '-';
28 str[4] = (flags & TRACED) ? 'T' : '-';
29 str[5] = (flags & STOPPED) ? 'S' : '-';
30 str[6] = (flags & SIGSUSPENDED) ? 'U' : '-';
31 str[7] = (flags & REPLY) ? 'R' : '-';
32 str[8] = (flags & ONSWAP) ? 'O' : '-';
33 str[9] = (flags & SWAPIN) ? 'I' : '-';
34 str[10] = (flags & DONT_SWAP) ? 'D' : '-';
35 str[11] = (flags & PRIV_PROC) ? 'P' : '-';
36 str[12] = '\0';
38 return str;
41 PUBLIC void mproc_dmp()
43 struct mproc *mp;
44 int i, n=0;
45 static int prev_i = 0;
47 printf("Process manager (PM) process table dump\n");
49 getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
51 printf("-process- -nr-prnt- -pid/ppid/grp- -uid--gid- -nice- -flags------\n");
52 for (i=prev_i; i<NR_PROCS; i++) {
53 mp = &mproc[i];
54 if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
55 if (++n > 22) break;
56 printf("%8.8s %4d%4d %4d%4d%4d ",
57 mp->mp_name, i, mp->mp_parent, mp->mp_pid, mproc[mp->mp_parent].mp_pid, mp->mp_procgrp);
58 printf("%d(%d) %d(%d) ",
59 mp->mp_realuid, mp->mp_effuid, mp->mp_realgid, mp->mp_effgid);
60 printf(" %3d %s ",
61 mp->mp_nice, flags_str(mp->mp_flags));
62 printf("\n");
64 if (i >= NR_PROCS) i = 0;
65 else printf("--more--\r");
66 prev_i = i;
69 /*===========================================================================*
70 * sigaction_dmp *
71 *===========================================================================*/
72 PUBLIC void sigaction_dmp()
74 struct mproc *mp;
75 int i, n=0;
76 static int prev_i = 0;
77 clock_t uptime;
79 printf("Process manager (PM) signal action dump\n");
81 getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
82 getuptime(&uptime);
84 printf("-process- -nr- --ignore- --catch- --block- -tomess-- -pending-- -alarm---\n");
85 for (i=prev_i; i<NR_PROCS; i++) {
86 mp = &mproc[i];
87 if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
88 if (++n > 22) break;
89 printf("%8.8s %3d ", mp->mp_name, i);
90 printf(" 0x%06x 0x%06x 0x%06x 0x%06x ",
91 mp->mp_ignore, mp->mp_catch, mp->mp_sigmask, mp->mp_sig2mess);
92 printf("0x%06x ", mp->mp_sigpending);
93 if (mp->mp_flags & ALARM_ON) printf("%8u", mp->mp_timer.tmr_exp_time-uptime);
94 else printf(" -");
95 printf("\n");
97 if (i >= NR_PROCS) i = 0;
98 else printf("--more--\r");
99 prev_i = i;
102 /*===========================================================================*
103 * holes_dmp *
104 *===========================================================================*/
105 PUBLIC void holes_dmp(void)
107 static struct pm_mem_info pmi;
108 int h;
109 int largest_bytes = 0, total_bytes = 0;
111 if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, &pmi) != OK) {
112 printf("Obtaining memory hole list failed.\n");
113 return;
115 printf("Available memory stats\n");
117 for(h = 0; h < _NR_HOLES; h++) {
118 if(pmi.pmi_holes[h].h_base && pmi.pmi_holes[h].h_len) {
119 int bytes;
120 bytes = (pmi.pmi_holes[h].h_len << CLICK_SHIFT);
121 printf("%08lx: %6d kB\n",
122 pmi.pmi_holes[h].h_base << CLICK_SHIFT, bytes / 1024);
123 if(bytes > largest_bytes) largest_bytes = bytes;
124 total_bytes += bytes;
127 printf("\n"
128 "Total memory free: %7d kB\n"
129 "Largest chunk: %7d kB\n"
130 "Uncontiguous rest: %7d kB (%d%% of total free)\n"
131 "Memory high watermark: %7d kB\n",
132 total_bytes/1024,
133 largest_bytes/1024,
134 (total_bytes-largest_bytes)/1024,
135 100*(total_bytes/100-largest_bytes/100)/total_bytes,
136 (pmi.pmi_hi_watermark/1024 << CLICK_SHIFT));
138 return;