xref: /minix3/minix/servers/is/dmp_kernel.c (revision 594df55e53732746ac76b15ad87a3eac02ec1619)
1433d6423SLionel Sambuc /* Debugging dump procedures for the kernel. */
2433d6423SLionel Sambuc 
3433d6423SLionel Sambuc #include "inc.h"
4*594df55eSDavid van Moolenbroek #include <lib.h>
5433d6423SLionel Sambuc #include <minix/timers.h>
6433d6423SLionel Sambuc #include <assert.h>
7433d6423SLionel Sambuc #include <machine/interrupt.h>
8433d6423SLionel Sambuc #include <minix/endpoint.h>
9433d6423SLionel Sambuc #include <minix/sysutil.h>
10433d6423SLionel Sambuc #include <minix/sys_config.h>
11433d6423SLionel Sambuc #include "kernel/const.h"
12433d6423SLionel Sambuc #include "kernel/config.h"
13433d6423SLionel Sambuc #include "kernel/debug.h"
14433d6423SLionel Sambuc #include "kernel/type.h"
15433d6423SLionel Sambuc #include "kernel/proc.h"
16433d6423SLionel Sambuc #include "kernel/ipc.h"
17433d6423SLionel Sambuc 
18433d6423SLionel Sambuc #define LINES 22
19433d6423SLionel Sambuc 
20433d6423SLionel Sambuc #define PRINTRTS(rp) { \
21433d6423SLionel Sambuc 	char *procname = "";	\
22433d6423SLionel Sambuc 	printf(" %s", p_rts_flags_str(rp->p_rts_flags));	\
23433d6423SLionel Sambuc 	if (rp->p_rts_flags & RTS_SENDING)				\
24433d6423SLionel Sambuc 		procname = proc_name(_ENDPOINT_P(rp->p_sendto_e)); \
25433d6423SLionel Sambuc 	else if (rp->p_rts_flags & RTS_RECEIVING)			\
26433d6423SLionel Sambuc 		procname = proc_name(_ENDPOINT_P(rp->p_getfrom_e)); \
27433d6423SLionel Sambuc 	printf(" %-7.7s", procname);	\
28433d6423SLionel Sambuc }
29433d6423SLionel Sambuc 
30433d6423SLionel Sambuc static int pagelines;
31433d6423SLionel Sambuc 
32433d6423SLionel Sambuc #define PROCLOOP(rp, oldrp) \
33433d6423SLionel Sambuc 	pagelines = 0; \
34433d6423SLionel Sambuc 	for (rp = oldrp; rp < END_PROC_ADDR; rp++) { \
35433d6423SLionel Sambuc 	  oldrp = BEG_PROC_ADDR; \
36433d6423SLionel Sambuc 	  if (isemptyp(rp)) continue; \
37433d6423SLionel Sambuc 	  if (++pagelines >= LINES) { oldrp = rp; printf("--more--\n"); break; }\
38433d6423SLionel Sambuc 	  if (proc_nr(rp) == IDLE) 	printf("(%2d) ", proc_nr(rp));  \
39433d6423SLionel Sambuc 	  else if (proc_nr(rp) < 0) 	printf("[%2d] ", proc_nr(rp)); 	\
40433d6423SLionel Sambuc 	  else 				printf(" %2d  ", proc_nr(rp));
41433d6423SLionel Sambuc 
42433d6423SLionel Sambuc #define click_to_round_k(n) \
43433d6423SLionel Sambuc 	((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
44433d6423SLionel Sambuc 
45433d6423SLionel Sambuc /* Declare some local dump procedures. */
46433d6423SLionel Sambuc static char *proc_name(int proc_nr);
47433d6423SLionel Sambuc static char *s_traps_str(int flags);
48433d6423SLionel Sambuc static char *s_flags_str(int flags);
49433d6423SLionel Sambuc static char *p_rts_flags_str(int flags);
50433d6423SLionel Sambuc 
51433d6423SLionel Sambuc /* Some global data that is shared among several dumping procedures.
52433d6423SLionel Sambuc  * Note that the process table copy has the same name as in the kernel
53433d6423SLionel Sambuc  * so that most macros and definitions from proc.h also apply here.
54433d6423SLionel Sambuc  */
55433d6423SLionel Sambuc struct proc proc[NR_TASKS + NR_PROCS];
56433d6423SLionel Sambuc struct priv priv[NR_SYS_PROCS];
57433d6423SLionel Sambuc struct boot_image image[NR_BOOT_PROCS];
58433d6423SLionel Sambuc 
59433d6423SLionel Sambuc /*===========================================================================*
60433d6423SLionel Sambuc  *				kmessages_dmp				     *
61433d6423SLionel Sambuc  *===========================================================================*/
62433d6423SLionel Sambuc void kmessages_dmp()
63433d6423SLionel Sambuc {
64433d6423SLionel Sambuc   struct kmessages *kmess;		/* get copy of kernel messages */
65433d6423SLionel Sambuc   static char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */
66433d6423SLionel Sambuc   int start;				/* calculate start of messages */
67433d6423SLionel Sambuc   int r;
68433d6423SLionel Sambuc   int size;
69433d6423SLionel Sambuc 
70*594df55eSDavid van Moolenbroek   kmess = get_minix_kerninfo()->kmessages;
71433d6423SLionel Sambuc 
72433d6423SLionel Sambuc   /* Try to print the kernel messages. First determine start and copy the
73433d6423SLionel Sambuc    * buffer into a print-buffer. This is done because the messages in the
74433d6423SLionel Sambuc    * copy may wrap (the kernel buffer is circular).
75433d6423SLionel Sambuc    */
76433d6423SLionel Sambuc   start = ((kmess->km_next + _KMESS_BUF_SIZE) - kmess->km_size) % _KMESS_BUF_SIZE;
77433d6423SLionel Sambuc   r = 0;
78433d6423SLionel Sambuc   size = kmess->km_size;
79433d6423SLionel Sambuc   while (size > 0) {
80433d6423SLionel Sambuc   	print_buf[r] = kmess->km_buf[(start+r) % _KMESS_BUF_SIZE];
81433d6423SLionel Sambuc   	r ++;
82433d6423SLionel Sambuc   	size--;
83433d6423SLionel Sambuc   }
84433d6423SLionel Sambuc   print_buf[r] = 0;		/* make sure it terminates */
85433d6423SLionel Sambuc   printf("Dump of all messages generated by the kernel.\n\n");
86433d6423SLionel Sambuc   printf("%s", print_buf);		/* print the messages */
87433d6423SLionel Sambuc }
88433d6423SLionel Sambuc 
89433d6423SLionel Sambuc /*===========================================================================*
90433d6423SLionel Sambuc  *				monparams_dmp				     *
91433d6423SLionel Sambuc  *===========================================================================*/
92433d6423SLionel Sambuc void monparams_dmp()
93433d6423SLionel Sambuc {
94433d6423SLionel Sambuc   char val[MULTIBOOT_PARAM_BUF_SIZE];
95433d6423SLionel Sambuc   char *e;
96433d6423SLionel Sambuc   int r;
97433d6423SLionel Sambuc 
98433d6423SLionel Sambuc   /* Try to get a copy of the boot monitor parameters. */
99433d6423SLionel Sambuc   if ((r = sys_getmonparams(val, sizeof(val))) != OK) {
100433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of monitor params: %d\n", r);
101433d6423SLionel Sambuc       return;
102433d6423SLionel Sambuc   }
103433d6423SLionel Sambuc 
104433d6423SLionel Sambuc   /* Append new lines to the result. */
105433d6423SLionel Sambuc   e = val;
106433d6423SLionel Sambuc   do {
107433d6423SLionel Sambuc 	e += strlen(e);
108433d6423SLionel Sambuc 	*e++ = '\n';
109433d6423SLionel Sambuc   } while (*e != 0);
110433d6423SLionel Sambuc 
111433d6423SLionel Sambuc   /* Finally, print the result. */
112433d6423SLionel Sambuc   printf("Dump of kernel environment strings set by boot monitor.\n");
113433d6423SLionel Sambuc   printf("\n%s\n", val);
114433d6423SLionel Sambuc }
115433d6423SLionel Sambuc 
116433d6423SLionel Sambuc /*===========================================================================*
117433d6423SLionel Sambuc  *				irqtab_dmp				     *
118433d6423SLionel Sambuc  *===========================================================================*/
119433d6423SLionel Sambuc void irqtab_dmp()
120433d6423SLionel Sambuc {
121433d6423SLionel Sambuc   int i,r;
122433d6423SLionel Sambuc   struct irq_hook irq_hooks[NR_IRQ_HOOKS];
123433d6423SLionel Sambuc   int irq_actids[NR_IRQ_VECTORS];
124433d6423SLionel Sambuc   struct irq_hook *e;	/* irq tab entry */
125433d6423SLionel Sambuc 
126433d6423SLionel Sambuc   if ((r = sys_getirqhooks(irq_hooks)) != OK) {
127433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of irq hooks: %d\n", r);
128433d6423SLionel Sambuc       return;
129433d6423SLionel Sambuc   }
130433d6423SLionel Sambuc   if ((r = sys_getirqactids(irq_actids)) != OK) {
131433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of irq mask: %d\n", r);
132433d6423SLionel Sambuc       return;
133433d6423SLionel Sambuc   }
134433d6423SLionel Sambuc 
135433d6423SLionel Sambuc #if 0
136433d6423SLionel Sambuc   printf("irq_actids:");
137433d6423SLionel Sambuc   for (i= 0; i<NR_IRQ_VECTORS; i++)
138433d6423SLionel Sambuc 	printf(" [%d] = 0x%08x", i, irq_actids[i]);
139433d6423SLionel Sambuc   printf("\n");
140433d6423SLionel Sambuc #endif
141433d6423SLionel Sambuc 
142433d6423SLionel Sambuc   printf("IRQ policies dump shows use of kernel's IRQ hooks.\n");
143433d6423SLionel Sambuc   printf("-h.id- -proc.nr- -irq nr- -policy- -notify id- -masked-\n");
144433d6423SLionel Sambuc   for (i=0; i<NR_IRQ_HOOKS; i++) {
145433d6423SLionel Sambuc   	e = &irq_hooks[i];
146433d6423SLionel Sambuc   	printf("%3d", i);
147433d6423SLionel Sambuc   	if (e->proc_nr_e==NONE) {
148433d6423SLionel Sambuc   	    printf("    <unused>\n");
149433d6423SLionel Sambuc   	    continue;
150433d6423SLionel Sambuc   	}
151433d6423SLionel Sambuc   	printf("%10d  ", e->proc_nr_e);
152433d6423SLionel Sambuc   	printf("    (%02d) ", e->irq);
153433d6423SLionel Sambuc   	printf("  %s", (e->policy & IRQ_REENABLE) ? "reenable" : "    -   ");
154433d6423SLionel Sambuc   	printf("   %4lu", e->notify_id);
155433d6423SLionel Sambuc 	if (irq_actids[e->irq] & e->id)
156433d6423SLionel Sambuc 		printf("       masked");
157433d6423SLionel Sambuc 	printf("\n");
158433d6423SLionel Sambuc   }
159433d6423SLionel Sambuc   printf("\n");
160433d6423SLionel Sambuc }
161433d6423SLionel Sambuc 
162433d6423SLionel Sambuc /*===========================================================================*
163433d6423SLionel Sambuc  *				image_dmp				     *
164433d6423SLionel Sambuc  *===========================================================================*/
165433d6423SLionel Sambuc void image_dmp()
166433d6423SLionel Sambuc {
167433d6423SLionel Sambuc   int m, r;
168433d6423SLionel Sambuc   struct boot_image *ip;
169433d6423SLionel Sambuc 
170433d6423SLionel Sambuc   if ((r = sys_getimage(image)) != OK) {
171433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of image table: %d\n", r);
172433d6423SLionel Sambuc       return;
173433d6423SLionel Sambuc   }
174433d6423SLionel Sambuc   printf("Image table dump showing all processes included in system image.\n");
175433d6423SLionel Sambuc   printf("---name- -nr- flags -stack-\n");
176433d6423SLionel Sambuc   for (m=0; m<NR_BOOT_PROCS; m++) {
177433d6423SLionel Sambuc       ip = &image[m];
178433d6423SLionel Sambuc       printf("%8s %4d\n", ip->proc_name, ip->proc_nr);
179433d6423SLionel Sambuc   }
180433d6423SLionel Sambuc   printf("\n");
181433d6423SLionel Sambuc }
182433d6423SLionel Sambuc 
183433d6423SLionel Sambuc 
184433d6423SLionel Sambuc /*===========================================================================*
185433d6423SLionel Sambuc  *				kenv_dmp				     *
186433d6423SLionel Sambuc  *===========================================================================*/
187433d6423SLionel Sambuc void kenv_dmp()
188433d6423SLionel Sambuc {
189433d6423SLionel Sambuc     struct kinfo kinfo;
190433d6423SLionel Sambuc     struct machine machine;
191433d6423SLionel Sambuc     int r;
192433d6423SLionel Sambuc     if ((r = sys_getkinfo(&kinfo)) != OK) {
193433d6423SLionel Sambuc     	printf("IS: warning: couldn't get copy of kernel info struct: %d\n", r);
194433d6423SLionel Sambuc     	return;
195433d6423SLionel Sambuc     }
196433d6423SLionel Sambuc     if ((r = sys_getmachine(&machine)) != OK) {
197433d6423SLionel Sambuc     	printf("IS: warning: couldn't get copy of kernel machine struct: %d\n", r);
198433d6423SLionel Sambuc     	return;
199433d6423SLionel Sambuc     }
200433d6423SLionel Sambuc 
201433d6423SLionel Sambuc     printf("Dump of kinfo structure.\n\n");
202433d6423SLionel Sambuc     printf("Kernel info structure:\n");
203433d6423SLionel Sambuc     printf("- nr_procs:     %3u\n", kinfo.nr_procs);
204433d6423SLionel Sambuc     printf("- nr_tasks:     %3u\n", kinfo.nr_tasks);
205433d6423SLionel Sambuc     printf("- release:      %.6s\n", kinfo.release);
206433d6423SLionel Sambuc     printf("- version:      %.6s\n", kinfo.version);
207433d6423SLionel Sambuc     printf("\n");
208433d6423SLionel Sambuc }
209433d6423SLionel Sambuc 
210433d6423SLionel Sambuc /*===========================================================================*
211433d6423SLionel Sambuc  *			      s_flags_str				     *
212433d6423SLionel Sambuc  *===========================================================================*/
213433d6423SLionel Sambuc static char *s_flags_str(int flags)
214433d6423SLionel Sambuc {
215433d6423SLionel Sambuc 	static char str[10];
216433d6423SLionel Sambuc 	str[0] = (flags & PREEMPTIBLE)        ? 'P' : '-';
217433d6423SLionel Sambuc 	str[1] = (flags & BILLABLE)           ? 'B' : '-';
218433d6423SLionel Sambuc 	str[2] = (flags & DYN_PRIV_ID)        ? 'D' : '-';
219433d6423SLionel Sambuc 	str[3] = (flags & SYS_PROC)           ? 'S' : '-';
220433d6423SLionel Sambuc 	str[4] = (flags & CHECK_IO_PORT)      ? 'I' : '-';
221433d6423SLionel Sambuc 	str[5] = (flags & CHECK_IRQ)          ? 'Q' : '-';
222433d6423SLionel Sambuc 	str[6] = (flags & CHECK_MEM)          ? 'M' : '-';
223433d6423SLionel Sambuc 	str[7] = '\0';
224433d6423SLionel Sambuc 
225433d6423SLionel Sambuc 	return str;
226433d6423SLionel Sambuc }
227433d6423SLionel Sambuc 
228433d6423SLionel Sambuc /*===========================================================================*
229433d6423SLionel Sambuc  *			      s_traps_str				     *
230433d6423SLionel Sambuc  *===========================================================================*/
231433d6423SLionel Sambuc static char *s_traps_str(int flags)
232433d6423SLionel Sambuc {
233433d6423SLionel Sambuc 	static char str[10];
234433d6423SLionel Sambuc 	str[0] = (flags & (1 << SEND))  ? 'S' : '-';
235433d6423SLionel Sambuc 	str[1] = (flags & (1 << SENDA)) ? 'A' : '-';
236433d6423SLionel Sambuc 	str[2] = (flags & (1 << RECEIVE))  ? 'R' : '-';
237433d6423SLionel Sambuc 	str[3] = (flags & (1 << SENDREC))  ? 'B' : '-';
238433d6423SLionel Sambuc 	str[4] = (flags & (1 << NOTIFY)) ? 'N' : '-';
239433d6423SLionel Sambuc 	str[5] = '\0';
240433d6423SLionel Sambuc 
241433d6423SLionel Sambuc 	return str;
242433d6423SLionel Sambuc }
243433d6423SLionel Sambuc 
244433d6423SLionel Sambuc /*===========================================================================*
245433d6423SLionel Sambuc  *				privileges_dmp 				     *
246433d6423SLionel Sambuc  *===========================================================================*/
247433d6423SLionel Sambuc void privileges_dmp()
248433d6423SLionel Sambuc {
249433d6423SLionel Sambuc   register struct proc *rp;
250433d6423SLionel Sambuc   static struct proc *oldrp = BEG_PROC_ADDR;
251433d6423SLionel Sambuc   register struct priv *sp;
252433d6423SLionel Sambuc   int r, i;
253433d6423SLionel Sambuc 
254433d6423SLionel Sambuc   /* First obtain a fresh copy of the current process and system table. */
255433d6423SLionel Sambuc   if ((r = sys_getprivtab(priv)) != OK) {
256433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of system privileges table: %d\n", r);
257433d6423SLionel Sambuc       return;
258433d6423SLionel Sambuc   }
259433d6423SLionel Sambuc   if ((r = sys_getproctab(proc)) != OK) {
260433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of process table: %d\n", r);
261433d6423SLionel Sambuc       return;
262433d6423SLionel Sambuc   }
263433d6423SLionel Sambuc 
264433d6423SLionel Sambuc   printf("-nr- -id- -name-- -flags- traps grants -ipc_to--"
265433d6423SLionel Sambuc     "          -kernel calls-\n");
266433d6423SLionel Sambuc 
267433d6423SLionel Sambuc   PROCLOOP(rp, oldrp)
268433d6423SLionel Sambuc         r = -1;
269433d6423SLionel Sambuc         for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++)
270433d6423SLionel Sambuc             if (sp->s_proc_nr == rp->p_nr) { r ++; break; }
271433d6423SLionel Sambuc         if (r == -1 && !isemptyp(rp)) {
272433d6423SLionel Sambuc 	    sp = &priv[USER_PRIV_ID];
273433d6423SLionel Sambuc         }
274433d6423SLionel Sambuc 	printf("(%02u) %-7.7s %s %s %6d",
275433d6423SLionel Sambuc 	       sp->s_id, rp->p_name,
276433d6423SLionel Sambuc 	       s_flags_str(sp->s_flags), s_traps_str(sp->s_trap_mask),
277433d6423SLionel Sambuc 		sp->s_grant_entries);
278433d6423SLionel Sambuc         for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) {
279433d6423SLionel Sambuc 	    printf(" %08x", get_sys_bits(sp->s_ipc_to, i));
280433d6423SLionel Sambuc        	}
281433d6423SLionel Sambuc 
282433d6423SLionel Sambuc 	printf(" ");
283433d6423SLionel Sambuc         for (i=0; i < NR_SYS_CALLS; i += BITCHUNK_BITS) {
284433d6423SLionel Sambuc 	    printf(" %08x", sp->s_k_call_mask[i/BITCHUNK_BITS]);
285433d6423SLionel Sambuc        	}
286433d6423SLionel Sambuc 	printf("\n");
287433d6423SLionel Sambuc 
288433d6423SLionel Sambuc   }
289433d6423SLionel Sambuc }
290433d6423SLionel Sambuc 
291433d6423SLionel Sambuc /*===========================================================================*
292433d6423SLionel Sambuc  *			       p_rts_flags_str 				     *
293433d6423SLionel Sambuc  *===========================================================================*/
294433d6423SLionel Sambuc static char *p_rts_flags_str(int flags)
295433d6423SLionel Sambuc {
296433d6423SLionel Sambuc 	static char str[10];
297433d6423SLionel Sambuc 	str[0] = (flags & RTS_PROC_STOP) ? 's' : '-';
298433d6423SLionel Sambuc 	str[1] = (flags & RTS_SENDING)  ? 'S' : '-';
299433d6423SLionel Sambuc 	str[2] = (flags & RTS_RECEIVING)    ? 'R' : '-';
300433d6423SLionel Sambuc 	str[3] = (flags & RTS_SIGNALED)    ? 'I' : '-';
301433d6423SLionel Sambuc 	str[4] = (flags & RTS_SIG_PENDING)    ? 'P' : '-';
302433d6423SLionel Sambuc 	str[5] = (flags & RTS_P_STOP)    ? 'T' : '-';
303433d6423SLionel Sambuc 	str[6] = (flags & RTS_NO_PRIV) ? 'p' : '-';
304433d6423SLionel Sambuc 	str[7] = '\0';
305433d6423SLionel Sambuc 
306433d6423SLionel Sambuc 	return str;
307433d6423SLionel Sambuc }
308433d6423SLionel Sambuc 
309433d6423SLionel Sambuc /*===========================================================================*
310433d6423SLionel Sambuc  *				proctab_dmp    				     *
311433d6423SLionel Sambuc  *===========================================================================*/
312433d6423SLionel Sambuc #if defined(__i386__)
313433d6423SLionel Sambuc void proctab_dmp(void)
314433d6423SLionel Sambuc {
315433d6423SLionel Sambuc /* Proc table dump */
316433d6423SLionel Sambuc 
317433d6423SLionel Sambuc   register struct proc *rp;
318433d6423SLionel Sambuc   static struct proc *oldrp = BEG_PROC_ADDR;
319433d6423SLionel Sambuc   int r;
320433d6423SLionel Sambuc 
321433d6423SLionel Sambuc   /* First obtain a fresh copy of the current process table. */
322433d6423SLionel Sambuc   if ((r = sys_getproctab(proc)) != OK) {
323433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of process table: %d\n", r);
324433d6423SLionel Sambuc       return;
325433d6423SLionel Sambuc   }
326433d6423SLionel Sambuc 
327433d6423SLionel Sambuc   printf("\n-nr-----gen---endpoint-name--- -prior-quant- -user----sys-rtsflags-from/to-\n");
328433d6423SLionel Sambuc 
329433d6423SLionel Sambuc   PROCLOOP(rp, oldrp)
330433d6423SLionel Sambuc 	printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint);
331433d6423SLionel Sambuc 	printf("%-8.8s %5u %5u %6lu %6lu ",
332433d6423SLionel Sambuc 	       rp->p_name,
333433d6423SLionel Sambuc 	       rp->p_priority,
334433d6423SLionel Sambuc 	       rp->p_quantum_size_ms,
335433d6423SLionel Sambuc 	       rp->p_user_time, rp->p_sys_time);
336433d6423SLionel Sambuc 	PRINTRTS(rp);
337433d6423SLionel Sambuc 	printf("\n");
338433d6423SLionel Sambuc   }
339433d6423SLionel Sambuc }
340433d6423SLionel Sambuc #endif				/* defined(__i386__) */
341433d6423SLionel Sambuc 
342433d6423SLionel Sambuc #if defined(__arm__)
343433d6423SLionel Sambuc void proctab_dmp(void)
344433d6423SLionel Sambuc {
345433d6423SLionel Sambuc     /* LSC FIXME: Not implemented for arm */
346433d6423SLionel Sambuc }
347433d6423SLionel Sambuc #endif				/* defined(__arm__) */
348433d6423SLionel Sambuc 
349433d6423SLionel Sambuc /*===========================================================================*
350433d6423SLionel Sambuc  *				procstack_dmp  				     *
351433d6423SLionel Sambuc  *===========================================================================*/
352433d6423SLionel Sambuc void procstack_dmp()
353433d6423SLionel Sambuc {
354433d6423SLionel Sambuc /* Proc table dump, with stack */
355433d6423SLionel Sambuc 
356433d6423SLionel Sambuc   register struct proc *rp;
357433d6423SLionel Sambuc   static struct proc *oldrp = BEG_PROC_ADDR;
358433d6423SLionel Sambuc   int r;
359433d6423SLionel Sambuc 
360433d6423SLionel Sambuc   /* First obtain a fresh copy of the current process table. */
361433d6423SLionel Sambuc   if ((r = sys_getproctab(proc)) != OK) {
362433d6423SLionel Sambuc       printf("IS: warning: couldn't get copy of process table: %d\n", r);
363433d6423SLionel Sambuc       return;
364433d6423SLionel Sambuc   }
365433d6423SLionel Sambuc 
366433d6423SLionel Sambuc   printf("\n-nr-rts flags--      --stack--\n");
367433d6423SLionel Sambuc 
368433d6423SLionel Sambuc   PROCLOOP(rp, oldrp)
369433d6423SLionel Sambuc 	PRINTRTS(rp);
370433d6423SLionel Sambuc 	printf("\n"); pagelines++;
371433d6423SLionel Sambuc 	sys_diagctl_stacktrace(rp->p_endpoint);
372433d6423SLionel Sambuc   }
373433d6423SLionel Sambuc }
374433d6423SLionel Sambuc 
375433d6423SLionel Sambuc /*===========================================================================*
376433d6423SLionel Sambuc  *				proc_name    				     *
377433d6423SLionel Sambuc  *===========================================================================*/
378433d6423SLionel Sambuc static char *proc_name(proc_nr)
379433d6423SLionel Sambuc int proc_nr;
380433d6423SLionel Sambuc {
381433d6423SLionel Sambuc   struct proc *p;
382433d6423SLionel Sambuc   if (proc_nr == ANY) return "ANY";
383433d6423SLionel Sambuc   if (proc_nr == NONE) return "NONE";	/* bogus */
384433d6423SLionel Sambuc   if (proc_nr < -NR_TASKS || proc_nr >= NR_PROCS) return "BOGUS";
385433d6423SLionel Sambuc   p = proc_addr(proc_nr);
386433d6423SLionel Sambuc   if (isemptyp(p)) return "EMPTY";	/* bogus */
387433d6423SLionel Sambuc   return p->p_name;
388433d6423SLionel Sambuc }
389433d6423SLionel Sambuc 
390