1 /* Debugging dump procedures for the VM server. */
7 #include "kernel/proc.h"
11 static void print_region(struct vm_region_info
*vri
, int *n
)
13 static int vri_count
, vri_prev_set
;
14 static struct vm_region_info vri_prev
;
17 /* part of a contiguous identical run? */
21 vri
->vri_prot
== vri_prev
.vri_prot
&&
22 vri
->vri_flags
== vri_prev
.vri_flags
&&
23 vri
->vri_length
== vri_prev
.vri_length
&&
24 vri
->vri_addr
== vri_prev
.vri_addr
+ vri_prev
.vri_length
;
37 printf(" (contiguously repeated %d more times)\n", vri_count
);
42 /* NULL indicates the end of a list of mappings, nothing else to do */
45 printf(" %08lx-%08lx %c%c%c (%lu kB)\n", vri
->vri_addr
,
46 vri
->vri_addr
+ vri
->vri_length
,
47 (vri
->vri_prot
& PROT_READ
) ? 'r' : '-',
48 (vri
->vri_prot
& PROT_WRITE
) ? 'w' : '-',
49 (vri
->vri_prot
& PROT_EXEC
) ? 'x' : '-',
50 vri
->vri_length
/ 1024L);
56 static struct proc proc
[NR_TASKS
+ NR_PROCS
];
57 static struct vm_region_info vri
[LINES
];
58 struct vm_stats_info vsi
;
59 struct vm_usage_info vui
;
60 static int prev_i
= -1;
61 static vir_bytes prev_base
= 0;
62 int r
, r2
, i
, j
, first
, n
= 0;
65 if ((r
= vm_info_stats(&vsi
)) != OK
) {
66 printf("IS: warning: couldn't talk to VM: %d\n", r
);
70 printf("Total %lu kB, free %lu kB, largest free %lu kB, cached %lu kB\n",
71 vsi
.vsi_total
* (vsi
.vsi_pagesize
/ 1024),
72 vsi
.vsi_free
* (vsi
.vsi_pagesize
/ 1024),
73 vsi
.vsi_largest
* (vsi
.vsi_pagesize
/ 1024),
74 vsi
.vsi_cached
* (vsi
.vsi_pagesize
/ 1024));
82 if ((r
= sys_getproctab(proc
)) != OK
) {
83 printf("IS: warning: couldn't get copy of process table: %d\n", r
);
87 for (i
= prev_i
; i
< NR_TASKS
+ NR_PROCS
&& n
< LINES
; i
++, prev_base
= 0) {
88 if (i
< NR_TASKS
|| isemptyp(&proc
[i
])) continue;
90 /* The first batch dump for each process contains a header line. */
91 first
= prev_base
== 0;
93 r
= vm_info_region(proc
[i
].p_endpoint
, vri
, LINES
- first
, &prev_base
);
96 printf("Process %d (%s): error %d\n",
97 proc
[i
].p_endpoint
, proc
[i
].p_name
, r
);
103 /* The entire batch should fit on the screen. */
104 if (n
+ 1 + r
> LINES
) {
105 prev_base
= 0; /* restart on next page */
109 if ((r2
= vm_info_usage(proc
[i
].p_endpoint
, &vui
)) != OK
) {
110 printf("Process %d (%s): error %d\n",
111 proc
[i
].p_endpoint
, proc
[i
].p_name
, r2
);
116 printf("Process %d (%s): total %lu kB, common %lu kB, "
118 proc
[i
].p_endpoint
, proc
[i
].p_name
,
119 vui
.vui_total
/ 1024L, vui
.vui_common
/ 1024L,
120 vui
.vui_shared
/ 1024L);
125 for (j
= 0; j
< r
; j
++) {
126 print_region(&vri
[j
], &n
);
129 if (LINES
- n
- 1 <= 0) break;
130 r
= vm_info_region(proc
[i
].p_endpoint
, vri
, LINES
- n
- 1,
134 printf("Process %d (%s): error %d\n",
135 proc
[i
].p_endpoint
, proc
[i
].p_name
, r
);
139 print_region(NULL
, &n
);
141 if (n
> LINES
) printf("IS: internal error\n");
142 if (n
== LINES
) break;
144 /* This may have to wipe out the "--more--" from below. */
149 if (i
>= NR_TASKS
+ NR_PROCS
) {
153 else printf("--more--\r");