1 #ifndef KERNEL_DEBUG_CONFIG_H 2 #define KERNEL_DEBUG_CONFIG_H 3 4 // Master switch: 5 // 0: Disables all debug code that hasn't been enabled otherwise. 6 // 1: Enables some lightweight debug code. 7 // 2: Enables more debug code. Will impact performance. 8 #define KDEBUG_LEVEL 2 9 10 #define KDEBUG_LEVEL_2 (KDEBUG_LEVEL >= 2) 11 #define KDEBUG_LEVEL_1 (KDEBUG_LEVEL >= 1) 12 #define KDEBUG_LEVEL_0 (KDEBUG_LEVEL >= 0) 13 14 15 // general kernel debugging 16 17 // Enables kernel ASSERT()s and various checks, locking primitives aren't 18 // benaphore-style. 19 #define KDEBUG KDEBUG_LEVEL_2 20 21 // Size of the heap used by the kernel debugger. 22 #define KDEBUG_HEAP (64 * 1024) 23 24 // Set to 0 to disable support for kernel breakpoints. 25 #define KERNEL_BREAKPOINTS 1 26 27 // Enables the debug syslog feature (accessing the previous syslog in the boot 28 // loader) by default. Can be overridden in the boot loader menu. 29 #define KDEBUG_ENABLE_DEBUG_SYSLOG KDEBUG_LEVEL_1 30 31 32 // block/file cache 33 34 // Enables debugger commands. 35 #define DEBUG_BLOCK_CACHE KDEBUG_LEVEL_1 36 37 // Enables checks that non-dirty blocks really aren't changed. Seriously 38 // degrades performance when the block cache is used heavily. 39 #define BLOCK_CACHE_DEBUG_CHANGED KDEBUG_LEVEL_2 40 41 // Enables a global list of file maps and related debugger commands. 42 #define DEBUG_FILE_MAP KDEBUG_LEVEL_1 43 44 45 // heap / slab 46 47 // Initialize newly allocated memory with something non zero. 48 #define PARANOID_KERNEL_MALLOC KDEBUG_LEVEL_2 49 50 // Check for double free, and fill freed memory with 0xdeadbeef. 51 #define PARANOID_KERNEL_FREE KDEBUG_LEVEL_2 52 53 // Validate sanity of the heap after each operation (slow!). 54 #define PARANOID_HEAP_VALIDATION 0 55 56 // Store size, thread and team info at the end of each allocation block. 57 // Enables the "allocations*" debugger commands. 58 #define KERNEL_HEAP_LEAK_CHECK 0 59 60 // Enables the "allocations*" debugger commands for the slab. 61 #define SLAB_ALLOCATION_TRACKING 0 62 63 64 // interrupts 65 66 // Adds statistics and unhandled counter per interrupts. Enables the "ints" 67 // debugger command. 68 #define DEBUG_INTERRUPTS KDEBUG_LEVEL_1 69 70 71 // semaphores 72 73 // Enables tracking of the last threads that acquired/released a semaphore. 74 #define DEBUG_SEM_LAST_ACQUIRER KDEBUG_LEVEL_1 75 76 77 // SMP 78 79 // Enables spinlock caller debugging. When acquiring a spinlock twice on a 80 // non-SMP machine, this will give a clue who locked it the first time. 81 // Furthermore (also on SMP machines) the "spinlock" debugger command will be 82 // available. 83 #define DEBUG_SPINLOCKS KDEBUG_LEVEL_2 84 85 #define DEBUG_SPINLOCK_LATENCIES 0 86 87 88 // VM 89 90 // Enables the vm_page::queue field, i.e. it is tracked which queue the page 91 // should be in. 92 #define DEBUG_PAGE_QUEUE 0 93 94 // Enables the vm_page::access_count field, which is used to detect invalid 95 // concurrent access to the page. 96 #ifndef __riscv 97 #define DEBUG_PAGE_ACCESS KDEBUG_LEVEL_2 98 #endif 99 100 // Enables a global list of all vm_cache structures. 101 #define DEBUG_CACHE_LIST KDEBUG_LEVEL_2 102 103 // Enables swap support. 104 #define ENABLE_SWAP_SUPPORT 1 105 106 // Use the selected allocator as generic memory allocator (malloc()/free()). 107 #define USE_DEBUG_HEAP_FOR_MALLOC 0 108 // Heap implementation with additional debugging facilities. 109 #define USE_GUARDED_HEAP_FOR_MALLOC 0 110 // Heap implementation that allocates memory so that the end of the 111 // allocation always coincides with a page end and is followed by a guard 112 // page which is marked non-present. Out of bounds access (both read and 113 // write) therefore cause a crash (unhandled page fault). Note that this 114 // allocator is neither speed nor space efficient, indeed it wastes huge 115 // amounts of pages and address space so it is quite easy to hit limits. 116 #define USE_SLAB_ALLOCATOR_FOR_MALLOC 1 117 // Heap implementation based on the slab allocator (for production use). 118 119 // Replace the object cache with the guarded heap to force debug features. Also 120 // requires the use of the guarded heap for malloc. 121 #define USE_GUARDED_HEAP_FOR_OBJECT_CACHE 0 122 123 // Enables additional sanity checks in the slab allocator's memory manager. 124 #define DEBUG_SLAB_MEMORY_MANAGER_PARANOID_CHECKS 0 125 126 // Disables memory re-use in the guarded heap (freed memory is never reused and 127 // stays invalid causing every access to crash). Note that this is a magnitude 128 // more space inefficient than the guarded heap itself. Fully booting may not 129 // work at all due to address space waste. 130 #define DEBUG_GUARDED_HEAP_DISABLE_MEMORY_REUSE 0 131 132 // When set limits the amount of available RAM (in MB). 133 //#define LIMIT_AVAILABLE_MEMORY 256 134 135 // Enables tracking of page allocations. 136 #define VM_PAGE_ALLOCATION_TRACKING 0 137 138 // Enables the (boot) system profiler for use with "profile -r" 139 #define SYSTEM_PROFILER 0 140 #define SYSTEM_PROFILE_SIZE 40 * 1024 * 1024 141 #define SYSTEM_PROFILE_STACK_DEPTH 10 142 #define SYSTEM_PROFILE_INTERVAL 10000 143 144 145 // Network 146 147 // Enables additional assertions in the tcp add-on. 148 #define DEBUG_TCP_BUFFER_QUEUE KDEBUG_LEVEL_2 149 150 151 #endif // KERNEL_DEBUG_CONFIG_H 152