Removed debug dumps from the PM and FS servers. The dumps are now done by the

IS servers, which obtains a copy of the data through the getsysinfo() system
call. CTRL-F1 now is a special TTY key to shows function key mappings.
This commit is contained in:
Jorrit Herder 2005-06-07 14:43:35 +00:00
parent 4de736535c
commit c2cd510adf
20 changed files with 616 additions and 655 deletions

View file

@ -490,7 +490,7 @@ int scode; /* scan code for a function key */
if (F1 <= fkey && fkey <= F12) { /* F1-F12 */
observers = &fkey_obs[0];
index = fkey - F1;
} else if (SF2 <= fkey && fkey <= SF12) { /* Shift F2-F12 */
} else if (SF1 <= fkey && fkey <= SF12) { /* Shift F2-F12 */
observers = &sfkey_obs[0];
index = fkey - SF1;
}

View file

@ -39,6 +39,7 @@
#define SI_KINFO 0 /* get kernel info via PM */
#define SI_PROC_ADDR 1 /* address of process table */
#define SI_PROC_TAB 2 /* copy of entire process table */
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
#define NULL ((void *)0)

View file

@ -199,7 +199,6 @@ vir_bytes size;
int privilege;
{
/* Build descriptor for a code segment. */
sdesc(segdp, base, size);
segdp->access = (privilege << DPL_SHIFT)
| (PRESENT | SEGMENT | EXECUTABLE | READABLE);
@ -231,7 +230,6 @@ phys_bytes base;
vir_bytes size;
{
/* Fill in the size fields (base, limit and granularity) of a descriptor. */
segdp->base_low = base;
segdp->base_middle = base >> BASE_MIDDLE_SHIFT;
segdp->base_high = base >> BASE_HIGH_SHIFT;
@ -313,7 +311,6 @@ vir_bytes offset;
unsigned dpl_type;
{
/* Build descriptor for an interrupt gate. */
register struct gatedesc_s *idp;
idp = &idt[vec_nr];

View file

@ -13,7 +13,7 @@ CFLAGS = -I$i
LDFLAGS = -i
LIBS = -lsys -lutils
OBJ = main.o open.o read.o write.o pipe.o dmap.o dmp.o \
OBJ = main.o open.o read.o write.o pipe.o dmap.o \
device.o path.o mount.o link.o super.o inode.o \
cache.o cache2.o filedes.o stadir.o protect.o time.o \
cmostime.o lock.o misc.o utility.o select.o table.o
@ -65,12 +65,6 @@ dmap.o: $h/com.h
dmap.o: $h/utils.h
dmap.o: dmap.h
dmp.o: $a
dmp.o: dmap.h
dmp.o: $h/callnr.h
dmp.o: $h/com.h
dmp.o: $h/keymap.h
filedes.o: $a
filedes.o: file.h
filedes.o: fproc.h

View file

@ -9,6 +9,8 @@
#define NR_SUPERS 8 /* # slots in super block table */
#define NR_LOCKS 8 /* # slots in the file locking table */
#define NR_DEVICES 16 /* # slots in the device <-> driver table */
/* The type of sizeof may be (unsigned) long. Use the following macro for
* taking the sizes of small objects so that there are no surprises like
* (small) long constants being passed to routines expecting an int.

View file

@ -42,7 +42,7 @@ int flags; /* mode bits and flags */
* device number for being in range. All others can trust this check.)
*/
major = (dev >> MAJOR) & BYTE;
if (major >= max_major) major = 0;
if (major >= NR_DEVICES) major = 0;
dp = &dmap[major];
r = (*dp->dmap_opcl)(DEV_OPEN, dev, proc, flags);
if (r == SUSPEND) panic(__FILE__,"suspend on open from", dp->dmap_driver);

View file

@ -28,7 +28,7 @@
Driver enabled Open/Cls I/O Driver # Flags Device File
-------------- -------- ------ ----------- ----- ------ ----
*/
struct dmap dmap[] = {
struct dmap dmap[NR_DEVICES] = {
DT(1, no_dev, 0, 0, 0) /* 0 = not used */
DT(1, gen_opcl, gen_io, MEMORY, 0) /* 1 = /dev/mem */
DT(ENABLE_FLOPPY, gen_opcl, gen_io, FLOPPY, 0) /* 2 = /dev/fd0 */
@ -54,11 +54,6 @@ struct dmap dmap[] = {
#endif /* IBM_PC */
};
/* This is the maximum major number at compile time. This may change when
* devices are dynamically added or removed.
*/
int max_major = sizeof(dmap)/sizeof(struct dmap);
/*===========================================================================*
* map_driver *
@ -77,19 +72,15 @@ int dev_style; /* style of the device */
struct dmap *dp;
/* Get pointer to device entry in the dmap table. */
if (major >= max_major) /* verify bounds */
return(ENODEV);
if (major >= NR_DEVICES) return(ENODEV);
dp = &dmap[major];
/* See if updating the entry is allowed. */
if (! (dp->dmap_flags & DMAP_MUTABLE))
return(EPERM);
if (dp->dmap_flags & DMAP_BUSY)
return(EBUSY);
if (! (dp->dmap_flags & DMAP_MUTABLE)) return(EPERM);
if (dp->dmap_flags & DMAP_BUSY) return(EBUSY);
/* Check process number of new driver. */
if (! isokprocnr(proc_nr))
return(EINVAL);
if (! isokprocnr(proc_nr)) return(EINVAL);
/* Try to update the entry. */
switch (dev_style) {
@ -143,12 +134,8 @@ PUBLIC void map_controllers()
for (dp = drivertab;
dp < drivertab + sizeof(drivertab)/sizeof(drivertab[0]); dp++) {
if (strcmp(ctrlr_type, dp->wini_type) == 0) { /* found driver name */
#if DEAD_CODE
if ((s=sys_getprocnr(&proc_nr, /* lookup proc nr */
dp->proc_name, strlen(dp->proc_name)+1)) == OK) {
#endif
if ((s=findproc(dp->proc_name, &proc_nr)) == OK) {
for (i=0; i< max_major; i++) { /* find mapping */
for (i=0; i< NR_DEVICES; i++) { /* find mapping */
if (dmap[i].dmap_driver == CTRLR(c)) {
if (map_driver(i, proc_nr, STYLE_DEV) == OK) {
printf("FS: controller %s (%s) mapped to %s driver (proc. nr %d)\n",

View file

@ -28,6 +28,5 @@ EXTERN int rdwt_err; /* status of last disk i/o request */
/* Data initialized elsewhere. */
extern _PROTOTYPE (int (*call_vec[]), (void) ); /* sys call table */
extern int max_major; /* maximum major device (+ 1) */
extern char dot1[2]; /* dot1 (&dot1[0]) and dot2 (&dot2[0]) have a special */
extern char dot2[3]; /* meaning to search_dir: no access permission check. */

View file

@ -46,6 +46,14 @@ PUBLIC int do_getsysinfo()
src_addr = (vir_bytes) &proc_addr;
len = sizeof(struct fproc *);
break;
case SI_PROC_TAB:
src_addr = (vir_bytes) fproc;
len = sizeof(struct fproc) * NR_PROCS;
break;
case SI_DMAP_TAB:
src_addr = (vir_bytes) dmap;
len = sizeof(struct dmap) * NR_DEVICES;
break;
default:
return(EINVAL);
}
@ -421,10 +429,6 @@ PUBLIC int do_svrctl()
major = (device.dev >> MAJOR) & BYTE;
r=map_driver(major, who, device.style);
return(r);
#if DEAD_CODE
if ((r=map_driver(major, who, device.style)) == OK)
fp->fp_pid = PID_SERVER;
#endif
}
default:
return(EINVAL);

View file

@ -8,6 +8,8 @@ s = $i/sys
m = $i/minix
b = $i/ibm
k = $u/src/kernel
p = $u/src/servers/pm
f = $u/src/servers/fs
# programs, flags, etc.
CC = exec cc
@ -15,7 +17,7 @@ CFLAGS = -I$i
LDFLAGS = -i
LIBS = -lsys -lutils
OBJ = main.o dmp.o diag.o kputc.o
OBJ = main.o dmp.o dmp_kernel.o dmp_pm.o dmp_fs.o diag.o kputc.o
# build local binary
all build: $(SERVER)
@ -41,12 +43,21 @@ a = is.h proto.h glo.h \
main.o: $a
dmp.o: $a
diag.o: $a
diag.o: $k/type.h
dmp.o: $a
dmp.o: $i/timers.h $i/string.h $b/interrupt.h
dmp.o: $k/proc.h $k/sendmask.h $k/type.h $k/const.h
dmp_kernel.o: $a
dmp_kernel.o: $i/timers.h $i/string.h $b/interrupt.h
dmp_kernel.o: $k/proc.h $k/sendmask.h $k/type.h $k/const.h
dmp_pm.o: $a
dmp_pm.o: $p/mproc.h
dmp_fs.o: $a
dmp_fs.o: $f/fproc.h
dmp_fs.o: $f/dmap.h
kputc.o: $a

View file

@ -105,3 +105,30 @@ int c; /* char to be added to diag buffer */
diag_size += 1;
}
/*===========================================================================*
* diagnostics_dmp *
*===========================================================================*/
PUBLIC void diagnostics_dmp()
{
char print_buf[DIAG_BUF_SIZE+1]; /* buffer used to print */
int start; /* calculate start of messages */
int size, r;
/* Reprint all diagnostic messages. First determine start and copy the
* buffer into a print-buffer. This is done because the messages in the
* copy may wrap (the buffer is circular).
*/
start = ((diag_next + DIAG_BUF_SIZE) - diag_size) % DIAG_BUF_SIZE;
r = 0;
size = diag_size;
while (size > 0) {
print_buf[r] = diag_buf[(start+r) % DIAG_BUF_SIZE];
r ++;
size --;
}
print_buf[r] = 0; /* make sure it terminates */
printf("Dump of diagnostics from device drivers and servers.\n\n");
printf(print_buf); /* print the messages */
}

View file

@ -7,47 +7,7 @@
* handle_fkey: handle a function key pressed notification
*/
/* Several header files from the kernel are included here so that we can use
* the constants, macros, and types needed to make the debugging dumps.
*/
#include "is.h"
#include <timers.h>
#include <string.h>
#include <ibm/interrupt.h>
#include <minix/config.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#include "../../kernel/proc.h"
#include "../../kernel/sendmask.h"
#define click_to_round_k(n) \
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
/* Declare some local dump procedures. */
FORWARD _PROTOTYPE( char *proc_name, (int proc_nr) );
FORWARD _PROTOTYPE( void proctab_dmp, (void) );
FORWARD _PROTOTYPE( void memmap_dmp, (void) );
FORWARD _PROTOTYPE( void sendmask_dmp, (void) );
FORWARD _PROTOTYPE( void image_dmp, (void) );
FORWARD _PROTOTYPE( void irqtab_dmp, (void) );
FORWARD _PROTOTYPE( void kmessages_dmp, (void) );
FORWARD _PROTOTYPE( void diagnostics_dmp, (void) );
FORWARD _PROTOTYPE( void sched_dmp, (void) );
FORWARD _PROTOTYPE( void monparams_dmp, (void) );
FORWARD _PROTOTYPE( void kenv_dmp, (void) );
FORWARD _PROTOTYPE( void memchunks_dmp, (void) );
#if ENABLE_LOCK_TIMING
FORWARD _PROTOTYPE( void timing_dmp, (void) );
#endif
/* Some global data that is shared among several dumping procedures.
* Note that the process table copy has the same name as in the kernel
* so that most macros and definitions from proc.h also apply here.
*/
struct proc proc[NR_TASKS + NR_PROCS];
struct system_image image[IMAGE_SIZE];
/*===========================================================================*
@ -64,10 +24,8 @@ PUBLIC int do_fkey_pressed(message *m)
case F5: monparams_dmp(); break;
case F6: irqtab_dmp(); break;
case F7: kmessages_dmp(); break;
#if ENABLE_LOCK_TIMING
case F8: timing_dmp(); break;
#endif
case F9: diagnostics_dmp(); break;
case F10: kenv_dmp(); break;
case F11: memchunks_dmp(); break;
case F12: sched_dmp(); break;
@ -76,8 +34,16 @@ PUBLIC int do_fkey_pressed(message *m)
m->NOTIFY_FLAGS, m->NOTIFY_ARG);
}
}
if (SF1 <= m->NOTIFY_ARG && m->NOTIFY_ARG <= SF12) {
switch(m->NOTIFY_ARG) {
case SF1: mproc_dmp(); break;
case SF3: fproc_dmp(); break;
case SF4: dtab_dmp(); break;
case SF6: diagnostics_dmp(); break;
default:
printf("IS: unhandled notify for Shift-F%d (code %d)\n",
m->NOTIFY_FLAGS, m->NOTIFY_ARG);
@ -86,486 +52,3 @@ PUBLIC int do_fkey_pressed(message *m)
return(EDONTREPLY);
}
/*===========================================================================*
* diagnostics_dmp *
*===========================================================================*/
PRIVATE void diagnostics_dmp()
{
char print_buf[DIAG_BUF_SIZE+1]; /* buffer used to print */
int start; /* calculate start of messages */
int size, r;
/* Try to print the kernel messages. First determine start and copy the
* buffer into a print-buffer. This is done because the messages in the
* copy may wrap (the kernel buffer is circular).
*/
start = ((diag_next + DIAG_BUF_SIZE) - diag_size) % DIAG_BUF_SIZE;
r = 0;
size = diag_size;
while (size > 0) {
print_buf[r] = diag_buf[(start+r) % DIAG_BUF_SIZE];
r ++;
size --;
}
print_buf[r] = 0; /* make sure it terminates */
printf("Dump of diagnostics from device drivers and servers.\n\n");
printf(print_buf); /* print the messages */
}
#if ENABLE_LOCK_TIMING
/*===========================================================================*
* timing_dmp *
*===========================================================================*/
PRIVATE void timing_dmp()
{
static struct lock_timedata timingdata[TIMING_CATEGORIES];
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
static int offsetlines = 0;
if ((r = sys_getlocktimings(timingdata)) != OK) {
report("warning: couldn't get copy of lock timings", r);
return;
}
for(c = 0; c < TIMING_CATEGORIES; c++) {
int b;
if(!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
continue;
x = printf("%-*s: misses %lu, resets %lu, measurements %lu: ",
TIMING_NAME, timingdata[c].names,
timingdata[c].misses,
timingdata[c].resets,
timingdata[c].measurements);
for(b = 0; b < TIMING_POINTS; b++) {
int w;
if(!timingdata[c].lock_timings[b])
continue;
x += (w = printf(" %5d: %5d", timingdata[c].lock_timings_range[0] +
b*timingdata[c].binsize,
timingdata[c].lock_timings[b]));
if(x + w >= 80) { printf("\n"); x = 0; }
}
if(x > 0) printf("\n");
}
}
#endif
/*===========================================================================*
* kmessages_dmp *
*===========================================================================*/
PRIVATE void kmessages_dmp()
{
struct kmessages kmess; /* get copy of kernel messages */
char print_buf[KMESS_BUF_SIZE+1]; /* this one is used to print */
int next, size; /* vars returned by sys_kmess() */
int start; /* calculate start of messages */
int r;
/* Try to get a copy of the kernel messages. */
if ((r = sys_getkmessages(&kmess)) != OK) {
report("IS","warning: couldn't get copy of kmessages", r);
return;
}
/* Try to print the kernel messages. First determine start and copy the
* buffer into a print-buffer. This is done because the messages in the
* copy may wrap (the kernel buffer is circular).
*/
start = ((kmess.km_next + KMESS_BUF_SIZE) - kmess.km_size) % KMESS_BUF_SIZE;
r = 0;
while (kmess.km_size > 0) {
print_buf[r] = kmess.km_buf[(start+r) % KMESS_BUF_SIZE];
r ++;
kmess.km_size --;
}
print_buf[r] = 0; /* make sure it terminates */
printf("Dump of all messages generated by the kernel.\n\n");
printf("%s", print_buf); /* print the messages */
}
/*===========================================================================*
* monparams_dmp *
*===========================================================================*/
PRIVATE void monparams_dmp()
{
char val[1024];
char *e;
int r;
/* Try to get a copy of the boot monitor parameters. */
if ((r = sys_getmonparams(val, sizeof(val))) != OK) {
report("IS","warning: couldn't get copy of monitor params", r);
return;
}
/* Append new lines to the result. */
e = val;
do {
e += strlen(e);
*e++ = '\n';
} while (*e != 0);
/* Finally, print the result. */
printf("Dump of kernel environment strings set by boot monitor.\n");
printf("\n%s\n", val);
}
/*===========================================================================*
* irqtab_dmp *
*===========================================================================*/
PRIVATE void irqtab_dmp()
{
int i,j,r;
struct irq_hook irq_hooks[NR_IRQ_HOOKS];
struct irq_hook *e; /* irq tab entry */
char *irq[] = {
"clock", /* 00 */
"keyboard", /* 01 */
"cascade", /* 02 */
"eth/rs232", /* 03 */
"rs232", /* 04 */
"xt_wini", /* 05 */
"floppy", /* 06 */
"printer", /* 07 */
"", /* 08 */
"", /* 09 */
"", /* 10 */
"", /* 11 */
"", /* 12 */
"", /* 13 */
"at_wini_0", /* 14 */
"at_wini_1", /* 15 */
};
if ((r = sys_getirqhooks(irq_hooks)) != OK) {
report("IS","warning: couldn't get copy of irq hooks", r);
return;
}
printf("IRQ policies dump shows use of kernel's IRQ hooks.\n");
printf("-h.id- -proc.nr- -IRQ vector (nr.)- -policy- \n");
for (i=0; i<NR_IRQ_HOOKS; i++) {
e = &irq_hooks[i];
printf("%3d", i);
if (e->proc_nr==NONE) {
printf(" <unused>\n");
continue;
}
printf("%10d ", e->proc_nr);
printf(" %9.9s (%02d) ", irq[e->irq], e->irq);
printf(" %s\n", (e->policy & IRQ_REENABLE) ? "reenable" : "-");
}
printf("\n");
}
/*===========================================================================*
* image_dmp *
*===========================================================================*/
PRIVATE void image_dmp()
{
int i,j,r;
struct system_image *ip;
char maskstr[NR_TASKS + NR_PROCS] = "mask";
char* types[] = {"task", "system","driver", "server", "user", "idle"};
char* priorities[] = {"task", "higher","high", "normal", "low", "lower", "user","idle"};
if ((r = sys_getimage(image)) != OK) {
report("IS","warning: couldn't get copy of image table", r);
return;
}
printf("Image table dump showing all processes included in system image.\n");
printf("---name-- -nr- --type- -priority- ----pc- -stack- ------sendmask-------\n");
for (i=0; i<IMAGE_SIZE; i++) {
ip = &image[i];
for (j=-NR_TASKS; j<INIT_PROC_NR+2; j++)
maskstr[j+NR_TASKS] = (isallowed(ip->sendmask, j)) ? '1' : '0';
maskstr[j+NR_TASKS] = '\0';
printf("%8s %4d %7s %10s %7lu %7lu %s\n",
ip->proc_name, ip->proc_nr, types[ip->type], priorities[ip->priority],
(long)ip->initial_pc, ip->stksize, maskstr);
}
printf("\n");
}
/*===========================================================================*
* sched_dmp *
*===========================================================================*/
PRIVATE void sched_dmp()
{
struct proc *rdy_head[NR_SCHED_QUEUES];
char *types[] = {"task","higher","high","normal","low","lower","user","idle"};
struct kinfo kinfo;
register struct proc *rp;
vir_bytes ptr_diff;
int r;
/* First obtain a scheduling information. */
if ((r = sys_getschedinfo(proc, rdy_head)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
/* Then obtain kernel addresses to correct pointer information. */
if ((r = sys_getkinfo(&kinfo)) != OK) {
report("IS","warning: couldn't get kernel addresses", r);
return;
}
/* Update all pointers. Nasty pointer algorithmic ... */
ptr_diff = (vir_bytes) proc - (vir_bytes) kinfo.proc_addr;
for (r=0;r<NR_SCHED_QUEUES; r++)
if (rdy_head[r] != NIL_PROC)
rdy_head[r] =
(struct proc *)((vir_bytes) rdy_head[r] + ptr_diff);
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++)
if (rp->p_nextready != NIL_PROC)
rp->p_nextready =
(struct proc *)((vir_bytes) rp->p_nextready + ptr_diff);
/* Now show scheduling queues. */
printf("Dumping scheduling queues.\n");
for (r=0;r<NR_SCHED_QUEUES; r++) {
printf("* %6s: ", types[r]);
rp = rdy_head[r];
while (rp != NIL_PROC) {
printf("%3d, ", rp->p_nr);
rp = rp->p_nextready;
}
printf("NIL\n");
}
printf("\n");
}
/*===========================================================================*
* kenv_dmp *
*===========================================================================*/
PRIVATE void kenv_dmp()
{
struct kinfo kinfo;
struct machine machine;
int r;
if ((r = sys_getkinfo(&kinfo)) != OK) {
report("IS","warning: couldn't get copy of kernel info struct", r);
return;
}
if ((r = sys_getmachine(&machine)) != OK) {
report("IS","warning: couldn't get copy of kernel machine struct", r);
return;
}
printf("Dump of kinfo and machine structures.\n\n");
printf("Machine structure:\n");
printf("- pc_at: %3d\n", machine.pc_at);
printf("- ps_mca: %3d\n", machine.ps_mca);
printf("- processor: %3d\n", machine.processor);
printf("- protected: %3d\n", machine.protected);
printf("- vdu_ega: %3d\n", machine.vdu_ega);
printf("- vdu_vga: %3d\n\n", machine.vdu_vga);
printf("Kernel info structure:\n");
printf("- code_base: %5u\n", kinfo.code_base);
printf("- code_size: %5u\n", kinfo.code_size);
printf("- data_base: %5u\n", kinfo.data_base);
printf("- data_size: %5u\n", kinfo.data_size);
printf("- proc_addr: %5u\n", kinfo.proc_addr);
printf("- kmem_base: %5u\n", kinfo.kmem_base);
printf("- kmem_size: %5u\n", kinfo.kmem_size);
printf("- bootdev_base: %5u\n", kinfo.bootdev_base);
printf("- bootdev_size: %5u\n", kinfo.bootdev_size);
printf("- params_base: %5u\n", kinfo.params_base);
printf("- params_size: %5u\n", kinfo.params_size);
printf("- nr_procs: %3u\n", kinfo.nr_procs);
printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
printf("- version: %.6s\n", kinfo.version);
printf("\n");
}
/*===========================================================================*
* memchunks_dmp *
*===========================================================================*/
PRIVATE void memchunks_dmp()
{
int i,r;
struct memory mem[NR_MEMS];
if ((r = sys_getmemchunks(mem)) != OK) {
report("IS","warning: couldn't get copy of mem chunks", r);
return;
}
printf("Memory chunks:\n");
for (i=0; i<NR_MEMS; i++) {
printf("chunk %d: base %u, size %u\n", i, mem[i].base, mem[i].size);
}
printf("\n");
}
/*===========================================================================*
* sendmask_dmp *
*===========================================================================*/
PRIVATE void sendmask_dmp()
{
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, i,j, n = 0;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n\n");
printf("Sendmask dump for process table. User processes (*) don't have [].");
printf("\n");
printf("The rows of bits indicate to which processes each process may send.");
printf("\n\n");
printf(" ");
for (j=proc_nr(BEG_PROC_ADDR); j< INIT_PROC_NR+1; j++) {
printf("%3d", j);
}
printf(" *\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 20) break;
printf("%8s ", rp->p_name);
j = proc_nr(rp);
switch(rp->p_type) {
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
default: printf(" %2d ", proc_nr(rp));
}
for (j=proc_nr(BEG_PROC_ADDR); j<INIT_PROC_NR+2; j++) {
if (isallowed(rp->p_sendmask, j)) printf(" 1 ");
else printf(" 0 ");
}
printf("\n");
}
if (rp == END_PROC_ADDR) { printf("\n"); rp = BEG_PROC_ADDR; }
else printf("--more--\r");
oldrp = rp;
}
/*===========================================================================*
* proctab_dmp *
*===========================================================================*/
#if (CHIP == INTEL)
PRIVATE void proctab_dmp()
{
/* Proc table dump */
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, n = 0;
phys_clicks text, data, size;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n--nr/name--- -q- -sc- -user- -sys- -text- -data- -size- -flags- -command-\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 23) break;
text = rp->p_memmap[T].mem_phys;
data = rp->p_memmap[D].mem_phys;
size = rp->p_memmap[T].mem_len
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data);
switch(rp->p_type) {
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
default: printf(" %2d ", proc_nr(rp));
}
printf("%-7.7s %2u %02.2x %6lu%6lu%6uK%6uK%6uK %3x",
rp->p_name,
rp->p_priority,
(char) rp->p_call_mask,
rp->p_user_time, rp->p_sys_time,
click_to_round_k(text), click_to_round_k(data),
click_to_round_k(size),
rp->p_flags);
if (rp->p_flags & RECEIVING) {
printf(" %-7.7s", proc_name(rp->p_getfrom));
} else
if (rp->p_flags & SENDING) {
printf(" S:%-5.5s", proc_name(rp->p_sendto));
} else
if (rp->p_flags == 0) {
printf(" ");
}
printf("\n");
}
if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r");
oldrp = rp;
}
#endif /* (CHIP == INTEL) */
/*===========================================================================*
* memmap_dmp *
*===========================================================================*/
PRIVATE void memmap_dmp()
{
register struct proc *rp;
static struct proc *oldrp = proc;
int r, n = 0;
phys_clicks size;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n-nr/name--- --pc-- --sp-- -----text----- -----data----- ----stack----- --size-\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 23) break;
size = rp->p_memmap[T].mem_len
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len)
- rp->p_memmap[D].mem_phys);
printf("%3d %-7.7s%7lx%7lx %4x %4x %4x %4x %4x %4x %4x %4x %4x %5uK\n",
proc_nr(rp),
rp->p_name,
(unsigned long) rp->p_reg.pc,
(unsigned long) rp->p_reg.sp,
rp->p_memmap[T].mem_vir, rp->p_memmap[T].mem_phys, rp->p_memmap[T].mem_len,
rp->p_memmap[D].mem_vir, rp->p_memmap[D].mem_phys, rp->p_memmap[D].mem_len,
rp->p_memmap[S].mem_vir, rp->p_memmap[S].mem_phys, rp->p_memmap[S].mem_len,
click_to_round_k(size));
}
if (rp == END_PROC_ADDR) rp = proc;
else printf("--more--\r");
oldrp = rp;
}
/*===========================================================================*
* proc_name *
*===========================================================================*/
PRIVATE char *proc_name(proc_nr)
int proc_nr;
{
if (proc_nr == ANY) return "ANY";
return cproc_addr(proc_nr)->p_name;
}

View file

@ -1,61 +1,34 @@
/* This file contains procedures to dump to FS' data structures.
*
* The entry points into this file are
* do_fkey_pressed: a function key was pressed
* dtab_dump: display device<->driver table
* dtab_dump: display device <-> driver mappings
* fproc_dump: display FS process table
*
* Created:
* Oct 01, 2004: by Jorrit N. Herder
*/
#include "fs.h"
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/keymap.h>
#include "dmap.h"
#include "fproc.h"
FORWARD _PROTOTYPE( void dtab_dmp, (void));
FORWARD _PROTOTYPE( void fproc_dmp, (void));
#include "is.h"
#include "../fs/dmap.h"
#include "../fs/const.h"
#include "../fs/fproc.h"
/*===========================================================================*
* do_fkey_pressed *
*===========================================================================*/
PUBLIC int do_fkey_pressed(void)
{
printf("Debug dump of FS data structure: ");
#if DEAD_CODE
switch (m_in.FKEY_CODE) {
#else
switch (m_in.NOTIFY_FLAGS) {
#endif
case SF5: fproc_dmp(); break;
case SF6: dtab_dmp(); break;
default:
#if DEAD_CODE
printf("FS: unhandled notification for Shift+F%d key.\n",
m_in.FKEY_NUM);
#else
printf("FS: unhandled notification for Shift+F%d key.\n",
m_in.NOTIFY_FLAGS);
#endif
}
}
PUBLIC struct fproc fproc[NR_PROCS];
PUBLIC struct dmap dmap[NR_DEVICES];
/*===========================================================================*
* fproc_dmp *
*===========================================================================*/
PRIVATE void fproc_dmp()
PUBLIC void fproc_dmp()
{
struct fproc *fp;
int i, n=0;
static int prev_i;
printf("PROCESS TABLE (beta)\n");
getsysinfo(FS_PROC_NR, SI_PROC_TAB, fproc);
printf("File System (FS) process table dump\n");
printf("-nr- -pid- -tty- -umask- --uid-- --gid-- -ldr- -sus-rev-proc- -cloexec-\n");
for (i=prev_i; i<NR_PROCS; i++) {
fp = &fproc[i];
@ -80,7 +53,7 @@ PRIVATE void fproc_dmp()
/*===========================================================================*
* dtab_dmp *
*===========================================================================*/
PRIVATE void dtab_dmp()
PUBLIC void dtab_dmp()
{
int i;
char *file[] = {
@ -88,12 +61,16 @@ PRIVATE void dtab_dmp()
"/dev/tty ", "/dev/lp ", "/dev/ip ", "/dev/c1 ", "not used ",
"/dev/c2 ", "not used ", "/dev/c3 ", "/dev/audio", "/dev/mixer",
};
printf("DEVICE MAP\n");
getsysinfo(FS_PROC_NR, SI_DMAP_TAB, dmap);
printf("File System (FS) device <-> driver mappings\n");
printf("Dev File Open/Cls I/O Proc\n");
printf("--- ---------- -------- ------ ----\n");
for (i=0; i<max_major; i++) {
for (i=0; i<NR_DEVICES; i++) {
printf("%3d %s ", i, file[i] );
#if DEAD_CODE
if (dmap[i].dmap_opcl == no_dev) printf(" no_dev");
else if (dmap[i].dmap_opcl == gen_opcl) printf("gen_opcl");
else printf("%8x", dmap[i].dmap_opcl);
@ -101,6 +78,7 @@ PRIVATE void dtab_dmp()
if ((void *)dmap[i].dmap_io == (void *)no_dev) printf(" no_dev");
else if (dmap[i].dmap_io == gen_io) printf(" gen_io");
else printf("%8x", dmap[i].dmap_io);
#endif
printf("%6d\n", dmap[i].dmap_driver);
}

484
servers/is/dmp_kernel.c Normal file
View file

@ -0,0 +1,484 @@
/* Debugging dump procedures for the kernel. */
#include "is.h"
#include <timers.h>
#include <ibm/interrupt.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#include "../../kernel/proc.h"
#include "../../kernel/sendmask.h"
#define click_to_round_k(n) \
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
/* Declare some local dump procedures. */
FORWARD _PROTOTYPE( char *proc_name, (int proc_nr) );
/* Some global data that is shared among several dumping procedures.
* Note that the process table copy has the same name as in the kernel
* so that most macros and definitions from proc.h also apply here.
*/
PUBLIC struct proc proc[NR_TASKS + NR_PROCS];
PUBLIC struct system_image image[IMAGE_SIZE];
/*===========================================================================*
* timing_dmp *
*===========================================================================*/
PUBLIC void timing_dmp()
{
#if ! ENABLE_LOCK_TIMING
printf("Enable the ENABLE_LOCK_TIMING definition in <minix/config.h>\n");
#else
static struct lock_timedata timingdata[TIMING_CATEGORIES];
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
static int offsetlines = 0;
if ((r = sys_getlocktimings(timingdata)) != OK) {
report("warning: couldn't get copy of lock timings", r);
return;
}
for(c = 0; c < TIMING_CATEGORIES; c++) {
int b;
if(!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
continue;
x = printf("%-*s: misses %lu, resets %lu, measurements %lu: ",
TIMING_NAME, timingdata[c].names,
timingdata[c].misses,
timingdata[c].resets,
timingdata[c].measurements);
for(b = 0; b < TIMING_POINTS; b++) {
int w;
if(!timingdata[c].lock_timings[b])
continue;
x += (w = printf(" %5d: %5d", timingdata[c].lock_timings_range[0] +
b*timingdata[c].binsize,
timingdata[c].lock_timings[b]));
if(x + w >= 80) { printf("\n"); x = 0; }
}
if(x > 0) printf("\n");
}
#endif
}
/*===========================================================================*
* kmessages_dmp *
*===========================================================================*/
PUBLIC void kmessages_dmp()
{
struct kmessages kmess; /* get copy of kernel messages */
char print_buf[KMESS_BUF_SIZE+1]; /* this one is used to print */
int next, size; /* vars returned by sys_kmess() */
int start; /* calculate start of messages */
int r;
/* Try to get a copy of the kernel messages. */
if ((r = sys_getkmessages(&kmess)) != OK) {
report("IS","warning: couldn't get copy of kmessages", r);
return;
}
/* Try to print the kernel messages. First determine start and copy the
* buffer into a print-buffer. This is done because the messages in the
* copy may wrap (the kernel buffer is circular).
*/
start = ((kmess.km_next + KMESS_BUF_SIZE) - kmess.km_size) % KMESS_BUF_SIZE;
r = 0;
while (kmess.km_size > 0) {
print_buf[r] = kmess.km_buf[(start+r) % KMESS_BUF_SIZE];
r ++;
kmess.km_size --;
}
print_buf[r] = 0; /* make sure it terminates */
printf("Dump of all messages generated by the kernel.\n\n");
printf("%s", print_buf); /* print the messages */
}
/*===========================================================================*
* monparams_dmp *
*===========================================================================*/
PUBLIC void monparams_dmp()
{
char val[1024];
char *e;
int r;
/* Try to get a copy of the boot monitor parameters. */
if ((r = sys_getmonparams(val, sizeof(val))) != OK) {
report("IS","warning: couldn't get copy of monitor params", r);
return;
}
/* Append new lines to the result. */
e = val;
do {
e += strlen(e);
*e++ = '\n';
} while (*e != 0);
/* Finally, print the result. */
printf("Dump of kernel environment strings set by boot monitor.\n");
printf("\n%s\n", val);
}
/*===========================================================================*
* irqtab_dmp *
*===========================================================================*/
PUBLIC void irqtab_dmp()
{
int i,j,r;
struct irq_hook irq_hooks[NR_IRQ_HOOKS];
struct irq_hook *e; /* irq tab entry */
char *irq[] = {
"clock", /* 00 */
"keyboard", /* 01 */
"cascade", /* 02 */
"eth/rs232", /* 03 */
"rs232", /* 04 */
"xt_wini", /* 05 */
"floppy", /* 06 */
"printer", /* 07 */
"", /* 08 */
"", /* 09 */
"", /* 10 */
"", /* 11 */
"", /* 12 */
"", /* 13 */
"at_wini_0", /* 14 */
"at_wini_1", /* 15 */
};
if ((r = sys_getirqhooks(irq_hooks)) != OK) {
report("IS","warning: couldn't get copy of irq hooks", r);
return;
}
printf("IRQ policies dump shows use of kernel's IRQ hooks.\n");
printf("-h.id- -proc.nr- -IRQ vector (nr.)- -policy- \n");
for (i=0; i<NR_IRQ_HOOKS; i++) {
e = &irq_hooks[i];
printf("%3d", i);
if (e->proc_nr==NONE) {
printf(" <unused>\n");
continue;
}
printf("%10d ", e->proc_nr);
printf(" %9.9s (%02d) ", irq[e->irq], e->irq);
printf(" %s\n", (e->policy & IRQ_REENABLE) ? "reenable" : "-");
}
printf("\n");
}
/*===========================================================================*
* image_dmp *
*===========================================================================*/
PUBLIC void image_dmp()
{
int i,j,r;
struct system_image *ip;
char maskstr[NR_TASKS + NR_PROCS] = "mask";
char* types[] = {"task", "system","driver", "server", "user", "idle"};
char* priorities[] = {"task", "higher","high", "normal", "low", "lower", "user","idle"};
if ((r = sys_getimage(image)) != OK) {
report("IS","warning: couldn't get copy of image table", r);
return;
}
printf("Image table dump showing all processes included in system image.\n");
printf("---name-- -nr- --type- -priority- ----pc- -stack- ------sendmask-------\n");
for (i=0; i<IMAGE_SIZE; i++) {
ip = &image[i];
for (j=-NR_TASKS; j<INIT_PROC_NR+2; j++)
maskstr[j+NR_TASKS] = (isallowed(ip->sendmask, j)) ? '1' : '0';
maskstr[j+NR_TASKS] = '\0';
printf("%8s %4d %7s %10s %7lu %7lu %s\n",
ip->proc_name, ip->proc_nr, types[ip->type], priorities[ip->priority],
(long)ip->initial_pc, ip->stksize, maskstr);
}
printf("\n");
}
/*===========================================================================*
* sched_dmp *
*===========================================================================*/
PUBLIC void sched_dmp()
{
struct proc *rdy_head[NR_SCHED_QUEUES];
char *types[] = {"task","higher","high","normal","low","lower","user","idle"};
struct kinfo kinfo;
register struct proc *rp;
vir_bytes ptr_diff;
int r;
/* First obtain a scheduling information. */
if ((r = sys_getschedinfo(proc, rdy_head)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
/* Then obtain kernel addresses to correct pointer information. */
if ((r = sys_getkinfo(&kinfo)) != OK) {
report("IS","warning: couldn't get kernel addresses", r);
return;
}
/* Update all pointers. Nasty pointer algorithmic ... */
ptr_diff = (vir_bytes) proc - (vir_bytes) kinfo.proc_addr;
for (r=0;r<NR_SCHED_QUEUES; r++)
if (rdy_head[r] != NIL_PROC)
rdy_head[r] =
(struct proc *)((vir_bytes) rdy_head[r] + ptr_diff);
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++)
if (rp->p_nextready != NIL_PROC)
rp->p_nextready =
(struct proc *)((vir_bytes) rp->p_nextready + ptr_diff);
/* Now show scheduling queues. */
printf("Dumping scheduling queues.\n");
for (r=0;r<NR_SCHED_QUEUES; r++) {
printf("* %6s: ", types[r]);
rp = rdy_head[r];
while (rp != NIL_PROC) {
printf("%3d, ", rp->p_nr);
rp = rp->p_nextready;
}
printf("NIL\n");
}
printf("\n");
}
/*===========================================================================*
* kenv_dmp *
*===========================================================================*/
PUBLIC void kenv_dmp()
{
struct kinfo kinfo;
struct machine machine;
int r;
if ((r = sys_getkinfo(&kinfo)) != OK) {
report("IS","warning: couldn't get copy of kernel info struct", r);
return;
}
if ((r = sys_getmachine(&machine)) != OK) {
report("IS","warning: couldn't get copy of kernel machine struct", r);
return;
}
printf("Dump of kinfo and machine structures.\n\n");
printf("Machine structure:\n");
printf("- pc_at: %3d\n", machine.pc_at);
printf("- ps_mca: %3d\n", machine.ps_mca);
printf("- processor: %3d\n", machine.processor);
printf("- protected: %3d\n", machine.protected);
printf("- vdu_ega: %3d\n", machine.vdu_ega);
printf("- vdu_vga: %3d\n\n", machine.vdu_vga);
printf("Kernel info structure:\n");
printf("- code_base: %5u\n", kinfo.code_base);
printf("- code_size: %5u\n", kinfo.code_size);
printf("- data_base: %5u\n", kinfo.data_base);
printf("- data_size: %5u\n", kinfo.data_size);
printf("- proc_addr: %5u\n", kinfo.proc_addr);
printf("- kmem_base: %5u\n", kinfo.kmem_base);
printf("- kmem_size: %5u\n", kinfo.kmem_size);
printf("- bootdev_base: %5u\n", kinfo.bootdev_base);
printf("- bootdev_size: %5u\n", kinfo.bootdev_size);
printf("- params_base: %5u\n", kinfo.params_base);
printf("- params_size: %5u\n", kinfo.params_size);
printf("- nr_procs: %3u\n", kinfo.nr_procs);
printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
printf("- version: %.6s\n", kinfo.version);
printf("\n");
}
/*===========================================================================*
* memchunks_dmp *
*===========================================================================*/
PUBLIC void memchunks_dmp()
{
int i,r;
struct memory mem[NR_MEMS];
if ((r = sys_getmemchunks(mem)) != OK) {
report("IS","warning: couldn't get copy of mem chunks", r);
return;
}
printf("Memory chunks:\n");
for (i=0; i<NR_MEMS; i++) {
printf("chunk %d: base %u, size %u\n", i, mem[i].base, mem[i].size);
}
printf("\n");
}
/*===========================================================================*
* sendmask_dmp *
*===========================================================================*/
PUBLIC void sendmask_dmp()
{
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, i,j, n = 0;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n\n");
printf("Sendmask dump for process table. User processes (*) don't have [].");
printf("\n");
printf("The rows of bits indicate to which processes each process may send.");
printf("\n\n");
printf(" ");
for (j=proc_nr(BEG_PROC_ADDR); j< INIT_PROC_NR+1; j++) {
printf("%3d", j);
}
printf(" *\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 20) break;
printf("%8s ", rp->p_name);
j = proc_nr(rp);
switch(rp->p_type) {
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
default: printf(" %2d ", proc_nr(rp));
}
for (j=proc_nr(BEG_PROC_ADDR); j<INIT_PROC_NR+2; j++) {
if (isallowed(rp->p_sendmask, j)) printf(" 1 ");
else printf(" 0 ");
}
printf("\n");
}
if (rp == END_PROC_ADDR) { printf("\n"); rp = BEG_PROC_ADDR; }
else printf("--more--\r");
oldrp = rp;
}
/*===========================================================================*
* proctab_dmp *
*===========================================================================*/
#if (CHIP == INTEL)
PUBLIC void proctab_dmp()
{
/* Proc table dump */
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, n = 0;
phys_clicks text, data, size;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n--nr/name--- -q- -sc- -user- -sys- -text- -data- -size- -flags- -command-\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 23) break;
text = rp->p_memmap[T].mem_phys;
data = rp->p_memmap[D].mem_phys;
size = rp->p_memmap[T].mem_len
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data);
switch(rp->p_type) {
case P_IDLE: printf("/%2d/ ", proc_nr(rp)); break;
case P_TASK: printf("[%2d] ", proc_nr(rp)); break;
case P_SYSTEM: printf("<%2d> ", proc_nr(rp)); break;
case P_DRIVER: printf("{%2d} ", proc_nr(rp)); break;
case P_SERVER: printf("(%2d) ", proc_nr(rp)); break;
default: printf(" %2d ", proc_nr(rp));
}
printf("%-7.7s %2u %02.2x %6lu%6lu%6uK%6uK%6uK %3x",
rp->p_name,
rp->p_priority,
(char) rp->p_call_mask,
rp->p_user_time, rp->p_sys_time,
click_to_round_k(text), click_to_round_k(data),
click_to_round_k(size),
rp->p_flags);
if (rp->p_flags & RECEIVING) {
printf(" %-7.7s", proc_name(rp->p_getfrom));
} else
if (rp->p_flags & SENDING) {
printf(" S:%-5.5s", proc_name(rp->p_sendto));
} else
if (rp->p_flags == 0) {
printf(" ");
}
printf("\n");
}
if (rp == END_PROC_ADDR) rp = BEG_PROC_ADDR; else printf("--more--\r");
oldrp = rp;
}
#endif /* (CHIP == INTEL) */
/*===========================================================================*
* memmap_dmp *
*===========================================================================*/
PUBLIC void memmap_dmp()
{
register struct proc *rp;
static struct proc *oldrp = proc;
int r, n = 0;
phys_clicks size;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
report("IS","warning: couldn't get copy of process table", r);
return;
}
printf("\n-nr/name--- --pc-- --sp-- -----text----- -----data----- ----stack----- --size-\n");
for (rp = oldrp; rp < END_PROC_ADDR; rp++) {
if (isemptyp(rp)) continue;
if (++n > 23) break;
size = rp->p_memmap[T].mem_len
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len)
- rp->p_memmap[D].mem_phys);
printf("%3d %-7.7s%7lx%7lx %4x %4x %4x %4x %4x %4x %4x %4x %4x %5uK\n",
proc_nr(rp),
rp->p_name,
(unsigned long) rp->p_reg.pc,
(unsigned long) rp->p_reg.sp,
rp->p_memmap[T].mem_vir, rp->p_memmap[T].mem_phys, rp->p_memmap[T].mem_len,
rp->p_memmap[D].mem_vir, rp->p_memmap[D].mem_phys, rp->p_memmap[D].mem_len,
rp->p_memmap[S].mem_vir, rp->p_memmap[S].mem_phys, rp->p_memmap[S].mem_len,
click_to_round_k(size));
}
if (rp == END_PROC_ADDR) rp = proc;
else printf("--more--\r");
oldrp = rp;
}
/*===========================================================================*
* proc_name *
*===========================================================================*/
PRIVATE char *proc_name(proc_nr)
int proc_nr;
{
if (proc_nr == ANY) return "ANY";
return cproc_addr(proc_nr)->p_name;
}

View file

@ -1,57 +1,30 @@
/* This file contains procedures to dump to PM' data structures.
*
* The entry points into this file are
* do_fkey_pressed: a function key was pressed
* mproc_dump: display PM process table
* mproc_dmp: display PM process table
*
* Created:
* May 11, 2005: by Jorrit N. Herder
*/
#include "pm.h"
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/keymap.h>
#include <signal.h>
#include "mproc.h"
FORWARD _PROTOTYPE( void mproc_dmp, (void));
#include "is.h"
#include "../pm/mproc.h"
/*===========================================================================*
* do_fkey_pressed *
*===========================================================================*/
PUBLIC int do_fkey_pressed(void)
{
printf("Process Manager debug dump: ");
#if DEAD_CODE
switch (m_in.FKEY_NUM) {
#else
switch (m_in.NOTIFY_FLAGS) {
#endif
case SF7: mproc_dmp(); break;
default:
#if DEAD_CODE
printf("PM: unhandled notification for Shift+F%d key.\n",
m_in.FKEY_NUM);
#else
printf("PM: unhandled notification for Shift+F%d key.\n",
m_in.NOTIFY_FLAGS);
#endif
}
}
PUBLIC struct mproc mproc[NR_PROCS];
/*===========================================================================*
* mproc_dmp *
*===========================================================================*/
PRIVATE void mproc_dmp()
PUBLIC void mproc_dmp()
{
struct mproc *mp;
int i, n=0;
static int prev_i;
printf("Process Table\n");
static int prev_i = 0;
printf("Process manager (PM) process table dump\n");
getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
printf("-process- -nr-prnt- -pid/grp- --uid---gid-- -flags- --ignore--catch--block--\n");
for (i=prev_i; i<NR_PROCS; i++) {
@ -64,7 +37,7 @@ PRIVATE void mproc_dmp()
mp->mp_realuid, mp->mp_effuid, mp->mp_realgid, mp->mp_effgid);
printf("0x%04x ",
mp->mp_flags);
printf("0x%04x 0x%04x 0x%04x",
printf("0x%05x 0x%05x 0x%05x",
mp->mp_ignore, mp->mp_catch, mp->mp_sigmask);
printf("\n");
}

View file

@ -21,9 +21,11 @@
#include <minix/utils.h>
#include <minix/keymap.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "proto.h"
#include "glo.h"

View file

@ -41,7 +41,6 @@ PUBLIC void main(void)
* sending the reply. The loop never terminates, unless a panic occurs.
*/
int result;
static long count;
/* Initialize the server, then go to work. */
init_server();
@ -67,8 +66,8 @@ PUBLIC void main(void)
/* never reached */
continue;
default:
printf("Warning %u, IS got unexpected request %d from %d\n",
++count, m_in.m_type, m_in.m_source);
printf("Warning, IS got unexpected request %d from %d\n",
m_in.m_type, m_in.m_source);
result = EINVAL;
}

View file

@ -1,7 +1,5 @@
/* Function prototypes. */
/* Structs used in prototypes must be declared as such first. */
/* main.c */
_PROTOTYPE( void main, (void) );
@ -12,8 +10,28 @@ _PROTOTYPE( void kputc, (int c) );
_PROTOTYPE( int do_new_kmess, (message *m) );
_PROTOTYPE( int do_diagnostics, (message *m) );
_PROTOTYPE( void diag_putc, (int c) );
_PROTOTYPE( void diagnostics_dmp, (void) );
/* dmp.c */
_PROTOTYPE( int do_fkey_pressed, (message *m) );
_PROTOTYPE( int do_fkey_pressed, (message *m) );
/* dmp_kernel.c */
_PROTOTYPE( void proctab_dmp, (void) );
_PROTOTYPE( void memmap_dmp, (void) );
_PROTOTYPE( void sendmask_dmp, (void) );
_PROTOTYPE( void image_dmp, (void) );
_PROTOTYPE( void irqtab_dmp, (void) );
_PROTOTYPE( void kmessages_dmp, (void) );
_PROTOTYPE( void sched_dmp, (void) );
_PROTOTYPE( void monparams_dmp, (void) );
_PROTOTYPE( void kenv_dmp, (void) );
_PROTOTYPE( void memchunks_dmp, (void) );
_PROTOTYPE( void timing_dmp, (void) );
/* dmp_pm.c */
_PROTOTYPE( void mproc_dmp, (void) );
/* dmp_fs.c */
_PROTOTYPE( void dtab_dmp, (void) );
_PROTOTYPE( void fproc_dmp, (void) );

View file

@ -13,7 +13,7 @@ CC = exec cc
CFLAGS = -I$i
LDFLAGS = -i
OBJ = main.o forkexit.o break.o exec.o dmp.o time.o \
OBJ = main.o forkexit.o break.o exec.o time.o \
signal.o alloc.o utility.o table.o trace.o getset.o misc.o
# build local binary
@ -94,8 +94,6 @@ misc.o: $s/svrctl.h
misc.o: mproc.h
misc.o: param.h
dmp.o: $a
signal.o: $a
signal.o: $s/stat.h
signal.o: $h/callnr.h

View file

@ -75,6 +75,10 @@ PUBLIC int do_getsysinfo()
src_addr = (vir_bytes) &proc_addr;
len = sizeof(struct mproc *);
break;
case SI_PROC_TAB: /* copy entire process table */
src_addr = (vir_bytes) mproc;
len = sizeof(struct mproc) * NR_PROCS;
break;
default:
return(EINVAL);
}