1 /* Debugging dump procedures for the VM server. */
7 #include "kernel/proc.h"
11 PRIVATE
void print_region(struct vm_region_info
*vri
)
15 switch (vri
->vri_seg
) {
16 case T
: c
= 'T'; break;
17 case D
: c
= 'D'; break;
21 printf(" %c %08lx-%08lx %c%c%c %c (%lu kB)\n", c
, vri
->vri_addr
,
22 vri
->vri_addr
+ vri
->vri_length
,
23 (vri
->vri_prot
& PROT_READ
) ? 'r' : '-',
24 (vri
->vri_prot
& PROT_WRITE
) ? 'w' : '-',
25 (vri
->vri_prot
& PROT_EXEC
) ? 'x' : '-',
26 (vri
->vri_flags
& MAP_SHARED
) ? 's' : 'p',
27 vri
->vri_length
/ 1024L);
32 static struct proc proc
[NR_TASKS
+ NR_PROCS
];
33 static struct vm_region_info vri
[LINES
];
34 struct vm_stats_info vsi
;
35 struct vm_usage_info vui
;
36 static int prev_i
= -1;
37 static vir_bytes prev_base
= 0;
38 int r
, r2
, i
, j
, first
, n
= 0;
41 if ((r
= vm_info_stats(&vsi
)) != OK
) {
42 printf("IS: warning: couldn't talk to VM: %d\n", r
);
46 printf("Total %u kB, free %u kB, largest free area %u kB\n",
47 vsi
.vsi_total
* (vsi
.vsi_pagesize
/ 1024),
48 vsi
.vsi_free
* (vsi
.vsi_pagesize
/ 1024),
49 vsi
.vsi_largest
* (vsi
.vsi_pagesize
/ 1024));
57 if ((r
= sys_getproctab(proc
)) != OK
) {
58 printf("IS: warning: couldn't get copy of process table: %d\n", r
);
62 for (i
= prev_i
; i
< NR_TASKS
+ NR_PROCS
&& n
< LINES
; i
++, prev_base
= 0) {
63 if (i
< NR_TASKS
|| isemptyp(&proc
[i
])) continue;
65 /* The first batch dump for each process contains a header line. */
66 first
= prev_base
== 0;
68 r
= vm_info_region(proc
[i
].p_endpoint
, vri
, LINES
- first
, &prev_base
);
71 printf("Process %d (%s): error %d\n",
72 proc
[i
].p_endpoint
, proc
[i
].p_name
, r
);
78 /* The entire batch should fit on the screen. */
79 if (n
+ 1 + r
> LINES
) {
80 prev_base
= 0; /* restart on next page */
84 if ((r2
= vm_info_usage(proc
[i
].p_endpoint
, &vui
)) != OK
) {
85 printf("Process %d (%s): error %d\n",
86 proc
[i
].p_endpoint
, proc
[i
].p_name
, r2
);
91 printf("Process %d (%s): total %lu kB, common %lu kB, "
93 proc
[i
].p_endpoint
, proc
[i
].p_name
,
94 vui
.vui_total
/ 1024L, vui
.vui_common
/ 1024L,
95 vui
.vui_shared
/ 1024L);
99 for (j
= 0; j
< r
; j
++) {
100 print_region(&vri
[j
]);
104 if (n
> LINES
) printf("IS: internal error\n");
105 if (n
== LINES
) break;
107 /* This may have to wipe out the "--more--" from below. */
112 if (i
>= NR_TASKS
+ NR_PROCS
) {
116 else printf("--more--\r");