minix/servers/vm/sanitycheck.h
Ben Gras 35a108b911 panic() cleanup.
this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
2010-03-05 15:05:11 +00:00

71 lines
1.6 KiB
C

#ifndef _SANITYCHECK_H
#define _SANITYCHECK_H 1
#include "vm.h"
#include "glo.h"
#if SANITYCHECKS
/* This macro is used in the sanity check functions, where file and
* line are function arguments.
*/
#define MYASSERT(c) do { if(!(c)) { \
printf("VM:%s:%d: %s failed\n", file, line, #c); \
panic("sanity check failed"); } } while(0)
#define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
slab_sanitycheck(__FILE__, __LINE__); }
#define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
struct vmproc *vmp; \
vm_assert(incheck == 0); \
incheck = 1; \
usedpages_reset(); \
slab_sanitycheck(__FILE__, __LINE__); \
for(vmp = vmproc; vmp < &vmproc[VMP_NR]; vmp++) { \
if((vmp->vm_flags & (VMF_INUSE | VMF_HASPT)) == \
(VMF_INUSE | VMF_HASPT)) { \
PT_SANE(&vmp->vm_pt); \
} \
} \
map_sanitycheck(__FILE__, __LINE__); \
vm_assert(incheck == 1); \
incheck = 0; \
}
#include "../../kernel/proc.h"
#define USE(obj, code) do { \
slabunlock(obj, sizeof(*obj)); \
do { \
code \
} while(0); \
slablock(obj, sizeof(*obj)); \
} while(0)
#define SLABSANE(ptr) { \
if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
panic("SLABSANE failed"); \
} \
}
#define NOTRUNNABLE(ep) { \
struct proc pr; \
if(sys_getproc(&pr, ep) != OK) { \
panic("VM: sys_getproc failed: %d", ep); \
} \
if(!pr.p_rts_flags) { \
panic("VM: runnable: %d", ep); \
} \
}
#else
#define SANITYCHECK
#define SLABSANITYCHECK(l)
#define USE(obj, code) do { code } while(0)
#define SLABSANE(ptr)
#define NOTRUNNABLE(ep)
#endif
#endif