xref: /haiku/headers/private/kernel/debug.h (revision b028e77473189065f2baefc6f5e10d451cf591e2)
1 /*
2  * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de
3  * Distributed under the terms of the Haiku License.
4  *
5  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6  * Distributed under the terms of the NewOS License.
7  */
8 #ifndef _KERNEL_DEBUG_H
9 #define _KERNEL_DEBUG_H
10 
11 
12 #include <OS.h>
13 
14 #define KDEBUG 1
15 
16 #if DEBUG
17 /*
18  * The kernel debug level.
19  * Level 1 is usual asserts, > 1 should be used for very expensive runtime checks
20  */
21 #define KDEBUG 1
22 #endif
23 
24 #define ASSERT_ALWAYS(x) \
25 	do { if (!(x)) { panic("ASSERT FAILED (%s:%d): %s\n", __FILE__, __LINE__, #x); } } while (0)
26 
27 #define ASSERT_ALWAYS_PRINT(x, format...) \
28 	do {																	\
29 		if (!(x)) {															\
30 			dprintf(format);												\
31 			panic("ASSERT FAILED (%s:%d): %s\n", __FILE__, __LINE__, #x);	\
32 		}																	\
33 	} while (0)
34 
35 #if KDEBUG
36 #	define ASSERT(x)					ASSERT_ALWAYS(x)
37 #	define ASSERT_PRINT(x, format...)	ASSERT_ALWAYS_PRINT(x, format)
38 #else
39 #	define ASSERT(x)					do { } while(0)
40 #	define ASSERT_PRINT(x, format...)	do { } while(0)
41 #endif
42 
43 extern int dbg_register_file[B_MAX_CPU_COUNT][14];
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 struct kernel_args;
50 
51 extern status_t debug_init(struct kernel_args *args);
52 extern status_t	debug_init_post_vm(struct kernel_args *args);
53 extern status_t	debug_init_post_modules(struct kernel_args *args);
54 extern void debug_early_boot_message(const char *string);
55 extern void debug_puts(const char *s, int32 length);
56 extern bool debug_debugger_running(void);
57 extern void debug_stop_screen_debug_output(void);
58 
59 extern void _user_debug_output(const char *userString);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif	/* _KERNEL_DEBUG_H */
66