Created a central place for putting kernel debug enabling macros.

Currently it only contains KDEBUG and the block cache debugging macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27816 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-10-01 11:56:44 +00:00
parent 165e3a7944
commit f8bdc2443d
3 changed files with 30 additions and 10 deletions

View File

@ -0,0 +1,22 @@
#ifndef KERNEL_DEBUG_CONFIG_H
#define KERNEL_DEBUG_CONFIG_H
// general kernel debugging
// Enables kernel ASSERT()s and various checks, locking primitives aren't
// benaphore-style.
#define KDEBUG 1
// block cache
// Enables debugger commands.
#define DEBUG_BLOCK_CACHE
// Enables checks that non-dirty blocks really aren't changed. Seriously
// degrades performance when the block cache is used heavily.
#define BLOCK_CACHE_DEBUG_CHANGED
#endif // KERNEL_DEBUG_CONFIG_H

View File

@ -8,13 +8,12 @@
#ifndef _KERNEL_DEBUG_H
#define _KERNEL_DEBUG_H
#include "kernel_debug_config.h"
#include <KernelExport.h>
#include <module.h>
#define KDEBUG 1
#if DEBUG
/*
* The kernel debug level.

View File

@ -25,6 +25,8 @@
#include <util/AutoLock.h>
#include <util/khash.h>
#include "kernel_debug_config.h"
// TODO: this is a naive but growing implementation to test the API:
// 1) block reading/writing is not at all optimized for speed, it will
@ -41,9 +43,6 @@
# define TRACE(x) ;
#endif
#define DEBUG_BLOCK_CACHE
#define DEBUG_CHANGED
// This macro is used for fatal situations that are acceptable in a running
// system, like out of memory situations - should only panic for debugging.
#define FATAL(x) panic x
@ -66,7 +65,7 @@ struct cached_block {
void *current_data;
void *original_data;
void *parent_data;
#ifdef DEBUG_CHANGED
#ifdef BLOCK_CACHE_DEBUG_CHANGED
void *compare;
#endif
int32 ref_count;
@ -838,7 +837,7 @@ block_cache::FreeBlock(cached_block *block)
block->block_number, block->original_data, block->parent_data);
}
#ifdef DEBUG_CHANGED
#ifdef BLOCK_CACHE_DEBUG_CHANGED
Free(block->compare);
#endif
@ -910,7 +909,7 @@ block_cache::NewBlock(off_t blockNumber)
block->parent_data = NULL;
block->is_dirty = false;
block->unused = false;
#ifdef DEBUG_CHANGED
#ifdef BLOCK_CACHE_DEBUG_CHANGED
block->compare = NULL;
#endif
@ -1001,7 +1000,7 @@ block_cache::LowMemoryHandler(void *data, uint32 resources, int32 level)
static void
put_cached_block(block_cache *cache, cached_block *block)
{
#ifdef DEBUG_CHANGED
#ifdef BLOCK_CACHE_DEBUG_CHANGED
if (!block->is_dirty && block->compare != NULL
&& memcmp(block->current_data, block->compare, cache->block_size)) {
dprintf("new block:\n");
@ -2527,7 +2526,7 @@ block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length)
if (block == NULL)
return NULL;
#ifdef DEBUG_CHANGED
#ifdef BLOCK_CACHE_DEBUG_CHANGED
if (block->compare == NULL)
block->compare = cache->Allocate();
if (block->compare != NULL)