From f8bdc2443da0549194191804a80479ee7fd4531a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 1 Oct 2008 11:56:44 +0000 Subject: [PATCH] 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 --- build/config_headers/kernel_debug_config.h | 22 ++++++++++++++++++++++ headers/private/kernel/debug.h | 3 +-- src/system/kernel/cache/block_cache.cpp | 15 +++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 build/config_headers/kernel_debug_config.h diff --git a/build/config_headers/kernel_debug_config.h b/build/config_headers/kernel_debug_config.h new file mode 100644 index 0000000000..4f44d89f1d --- /dev/null +++ b/build/config_headers/kernel_debug_config.h @@ -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 diff --git a/headers/private/kernel/debug.h b/headers/private/kernel/debug.h index 7baf17c061..1755ca6c2e 100644 --- a/headers/private/kernel/debug.h +++ b/headers/private/kernel/debug.h @@ -8,13 +8,12 @@ #ifndef _KERNEL_DEBUG_H #define _KERNEL_DEBUG_H +#include "kernel_debug_config.h" #include #include -#define KDEBUG 1 - #if DEBUG /* * The kernel debug level. diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index 0d46a09ff7..f7633b8aab 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -25,6 +25,8 @@ #include #include +#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)