VM information interface

This commit is contained in:
David van Moolenbroek
2010-01-19 21:00:20 +00:00
parent 7d51b0cce1
commit 61bb82a44b
18 changed files with 412 additions and 64 deletions

View File

@@ -20,7 +20,7 @@ CFLAGS = $(CPROFILE) $(CPPFLAGS)
LDFLAGS = -i
LIBS = -lsys
OBJ = main.o dmp.o dmp_kernel.o dmp_pm.o dmp_fs.o dmp_rs.o dmp_ds.o
OBJ = main.o dmp.o dmp_kernel.o dmp_pm.o dmp_fs.o dmp_rs.o dmp_ds.o dmp_vm.o
# build local binary
all build: $(SERVER)

View File

@@ -23,7 +23,7 @@ struct hook_entry {
{ F5, monparams_dmp, "Boot monitor parameters" },
{ F6, irqtab_dmp, "IRQ hooks and policies" },
{ F7, kmessages_dmp, "Kernel messages" },
{ F8, vm_dmp, "VM status" },
{ F8, vm_dmp, "VM status and process maps" },
{ F10, kenv_dmp, "Kernel parameters" },
{ F11, timing_dmp, "Timing details (if enabled)" },
{ SF1, mproc_dmp, "Process manager process table" },
@@ -126,12 +126,3 @@ PUBLIC void mapping_dmp(void)
printf(" %10s. %s\n", key_name(hooks[h].key), hooks[h].name);
printf("\n");
}
/*===========================================================================*
* vm_dmp *
*===========================================================================*/
PUBLIC void vm_dmp(void)
{
vm_ctl(VCTLP_STATS_MEM, 0);
}

View File

@@ -1,6 +1,8 @@
#include "inc.h"
#include "../ds/store.h"
#define LINES 22
PRIVATE struct data_store ds_store[NR_DS_KEYS];
PUBLIC void data_store_dmp()
@@ -16,7 +18,7 @@ PUBLIC void data_store_dmp()
printf("Data store contents:\n");
printf("-slot- ------key------ -----owner----- ---type--- ----value---\n");
for(i = prev_i; i < NR_DS_KEYS; i++) {
for(i = prev_i; i < NR_DS_KEYS && n < LINES; i++) {
p = &ds_store[i];
if(!(p->flags & DSF_IN_USE))
continue;
@@ -43,8 +45,7 @@ PUBLIC void data_store_dmp()
return;
}
if(n++ == 21)
break;
n++;
}
if (i >= NR_DS_KEYS) i = 0;

119
servers/is/dmp_vm.c Normal file
View File

@@ -0,0 +1,119 @@
/* Debugging dump procedures for the VM server. */
#include "inc.h"
#include <sys/mman.h>
#include <minix/vm.h>
#include <timers.h>
#include "../../kernel/proc.h"
#define LINES 24
PRIVATE void print_region(struct vm_region_info *vri)
{
char c;
switch (vri->vri_seg) {
case T: c = 'T'; break;
case D: c = 'D'; break;
default: c = '?';
}
printf(" %c %08lx-%08lx %c%c%c %c (%lu kB)\n", c, vri->vri_addr,
vri->vri_addr + vri->vri_length,
(vri->vri_prot & PROT_READ) ? 'r' : '-',
(vri->vri_prot & PROT_WRITE) ? 'w' : '-',
(vri->vri_prot & PROT_EXEC) ? 'x' : '-',
(vri->vri_flags & MAP_SHARED) ? 's' : 'p',
vri->vri_length / 1024L);
}
PUBLIC void vm_dmp()
{
static struct proc proc[NR_TASKS + NR_PROCS];
static struct vm_region_info vri[LINES];
struct vm_stats_info vsi;
struct vm_usage_info vui;
static int prev_i = -1;
static vir_bytes prev_base = 0;
int r, r2, i, j, first, n = 0;
if (prev_i == -1) {
if ((r = vm_info_stats(&vsi)) != OK) {
report("IS", "warning: couldn't talk to VM", r);
return;
}
printf("Total %u kB, free %u kB, largest free area %u kB\n",
vsi.vsi_total * (vsi.vsi_pagesize / 1024),
vsi.vsi_free * (vsi.vsi_pagesize / 1024),
vsi.vsi_largest * (vsi.vsi_pagesize / 1024));
n++;
printf("\n");
n++;
prev_i++;
}
if ((r = sys_getproctab(proc)) != OK) {
report("IS", "warning: couldn't get copy of process table", r);
return;
}
for (i = prev_i; i < NR_TASKS + NR_PROCS && n < LINES; i++, prev_base = 0) {
if (i < NR_TASKS || isemptyp(&proc[i])) continue;
/* The first batch dump for each process contains a header line. */
first = prev_base == 0;
r = vm_info_region(proc[i].p_endpoint, vri, LINES - first, &prev_base);
if (r < 0) {
printf("Process %d (%s): error %d\n",
proc[i].p_endpoint, proc[i].p_name, r);
n++;
continue;
}
if (first) {
/* The entire batch should fit on the screen. */
if (n + 1 + r > LINES) {
prev_base = 0; /* restart on next page */
break;
}
if ((r2 = vm_info_usage(proc[i].p_endpoint, &vui)) != OK) {
printf("Process %d (%s): error %d\n",
proc[i].p_endpoint, proc[i].p_name, r2);
n++;
continue;
}
printf("Process %d (%s): total %lu kB, common %lu kB, "
"shared %lu kB\n",
proc[i].p_endpoint, proc[i].p_name,
vui.vui_total / 1024L, vui.vui_common / 1024L,
vui.vui_shared / 1024L);
n++;
}
for (j = 0; j < r; j++) {
print_region(&vri[j]);
n++;
}
if (n > LINES) printf("IS: internal error\n");
if (n == LINES) break;
/* This may have to wipe out the "--more--" from below. */
printf(" \n");
n++;
}
if (i >= NR_TASKS + NR_PROCS) {
i = -1;
prev_base = 0;
}
else printf("--more--\r");
prev_i = i;
}