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