1433d6423SLionel Sambuc /* This file contains procedures to dump to PM' data structures.
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * The entry points into this file are
4433d6423SLionel Sambuc * mproc_dmp: display PM process table
5433d6423SLionel Sambuc *
6433d6423SLionel Sambuc * Created:
7433d6423SLionel Sambuc * May 11, 2005: by Jorrit N. Herder
8433d6423SLionel Sambuc */
9433d6423SLionel Sambuc
10433d6423SLionel Sambuc #include "inc.h"
11433d6423SLionel Sambuc #include "../pm/mproc.h"
12433d6423SLionel Sambuc #include <minix/timers.h>
13433d6423SLionel Sambuc #include <minix/config.h>
14433d6423SLionel Sambuc #include <minix/type.h>
15433d6423SLionel Sambuc
16433d6423SLionel Sambuc struct mproc mproc[NR_PROCS];
17433d6423SLionel Sambuc
18433d6423SLionel Sambuc /*===========================================================================*
19433d6423SLionel Sambuc * mproc_dmp *
20433d6423SLionel Sambuc *===========================================================================*/
flags_str(int flags)21433d6423SLionel Sambuc static char *flags_str(int flags)
22433d6423SLionel Sambuc {
23433d6423SLionel Sambuc static char str[12];
24433d6423SLionel Sambuc str[0] = (flags & WAITING) ? 'W' : '-';
25433d6423SLionel Sambuc str[1] = (flags & ZOMBIE) ? 'Z' : '-';
26433d6423SLionel Sambuc str[2] = (flags & ALARM_ON) ? 'A' : '-';
27433d6423SLionel Sambuc str[3] = (flags & EXITING) ? 'E' : '-';
28433d6423SLionel Sambuc str[4] = (flags & TRACE_STOPPED) ? 'T' : '-';
29433d6423SLionel Sambuc str[5] = (flags & SIGSUSPENDED) ? 'U' : '-';
30433d6423SLionel Sambuc str[6] = (flags & VFS_CALL) ? 'F' : '-';
31433d6423SLionel Sambuc str[7] = (flags & PROC_STOPPED) ? 's' : '-';
32433d6423SLionel Sambuc str[8] = (flags & PRIV_PROC) ? 'p' : '-';
33433d6423SLionel Sambuc str[9] = (flags & PARTIAL_EXEC) ? 'x' : '-';
34433d6423SLionel Sambuc str[10] = (flags & DELAY_CALL) ? 'd' : '-';
35433d6423SLionel Sambuc str[11] = '\0';
36433d6423SLionel Sambuc
37433d6423SLionel Sambuc return str;
38433d6423SLionel Sambuc }
39433d6423SLionel Sambuc
40*4aa48abaSRichard Sailer void
mproc_dmp(void)41*4aa48abaSRichard Sailer mproc_dmp(void)
42433d6423SLionel Sambuc {
43433d6423SLionel Sambuc struct mproc *mp;
44433d6423SLionel Sambuc int i, n=0;
45433d6423SLionel Sambuc static int prev_i = 0;
46433d6423SLionel Sambuc
47433d6423SLionel Sambuc if (getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc, sizeof(mproc)) != OK) {
48433d6423SLionel Sambuc printf("Error obtaining table from PM. Perhaps recompile IS?\n");
49433d6423SLionel Sambuc return;
50433d6423SLionel Sambuc }
51433d6423SLionel Sambuc
52433d6423SLionel Sambuc printf("Process manager (PM) process table dump\n");
53433d6423SLionel Sambuc printf("-process- -nr-pnr-tnr- --pid--ppid--pgrp- -uid-- -gid-- -nice- -flags-----\n");
54433d6423SLionel Sambuc for (i=prev_i; i<NR_PROCS; i++) {
55433d6423SLionel Sambuc mp = &mproc[i];
56433d6423SLionel Sambuc if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
57433d6423SLionel Sambuc if (++n > 22) break;
58433d6423SLionel Sambuc printf("%8.8s %4d%4d%4d %5d %5d %5d ",
59433d6423SLionel Sambuc mp->mp_name, i, mp->mp_parent, mp->mp_tracer, mp->mp_pid, mproc[mp->mp_parent].mp_pid, mp->mp_procgrp);
60433d6423SLionel Sambuc printf("%2d(%2d) %2d(%2d) ",
61433d6423SLionel Sambuc mp->mp_realuid, mp->mp_effuid, mp->mp_realgid, mp->mp_effgid);
62433d6423SLionel Sambuc printf(" %3d %s ",
63433d6423SLionel Sambuc mp->mp_nice, flags_str(mp->mp_flags));
64433d6423SLionel Sambuc printf("\n");
65433d6423SLionel Sambuc }
66433d6423SLionel Sambuc if (i >= NR_PROCS) i = 0;
67433d6423SLionel Sambuc else printf("--more--\r");
68433d6423SLionel Sambuc prev_i = i;
69433d6423SLionel Sambuc }
70433d6423SLionel Sambuc
71433d6423SLionel Sambuc /*===========================================================================*
72433d6423SLionel Sambuc * sigaction_dmp *
73433d6423SLionel Sambuc *===========================================================================*/
74*4aa48abaSRichard Sailer void
sigaction_dmp(void)75*4aa48abaSRichard Sailer sigaction_dmp(void)
76433d6423SLionel Sambuc {
77433d6423SLionel Sambuc struct mproc *mp;
78433d6423SLionel Sambuc int i, n=0;
79433d6423SLionel Sambuc static int prev_i = 0;
80433d6423SLionel Sambuc clock_t uptime;
81433d6423SLionel Sambuc
82433d6423SLionel Sambuc if (getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc, sizeof(mproc)) != OK) {
83433d6423SLionel Sambuc printf("Error obtaining table from PM. Perhaps recompile IS?\n");
84433d6423SLionel Sambuc return;
85433d6423SLionel Sambuc }
86d91f738bSDavid van Moolenbroek uptime = getticks();
87433d6423SLionel Sambuc
88433d6423SLionel Sambuc printf("Process manager (PM) signal action dump\n");
89433d6423SLionel Sambuc printf("-process- -nr- --ignore- --catch- --block- -pending- -alarm---\n");
90433d6423SLionel Sambuc for (i=prev_i; i<NR_PROCS; i++) {
91433d6423SLionel Sambuc mp = &mproc[i];
92433d6423SLionel Sambuc if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
93433d6423SLionel Sambuc if (++n > 22) break;
94433d6423SLionel Sambuc printf("%8.8s %3d ", mp->mp_name, i);
95433d6423SLionel Sambuc printf(" %08x %08x %08x ",
96433d6423SLionel Sambuc mp->mp_ignore.__bits[0], mp->mp_catch.__bits[0],
97433d6423SLionel Sambuc mp->mp_sigmask.__bits[0]);
98433d6423SLionel Sambuc printf("%08x ", mp->mp_sigpending.__bits[0]);
995ae1a533SBen Gras if (mp->mp_flags & ALARM_ON) printf("%8lu",
1005ae1a533SBen Gras (unsigned long) (mp->mp_timer.tmr_exp_time-uptime));
101433d6423SLionel Sambuc else printf(" -");
102433d6423SLionel Sambuc printf("\n");
103433d6423SLionel Sambuc }
104433d6423SLionel Sambuc if (i >= NR_PROCS) i = 0;
105433d6423SLionel Sambuc else printf("--more--\r");
106433d6423SLionel Sambuc prev_i = i;
107433d6423SLionel Sambuc }
108433d6423SLionel Sambuc
109433d6423SLionel Sambuc
110