Debug Macros
Many parts of the SerenityOS codebase have debug functionality through component-specific macros that print additional messages to the debug console.Enabling Debug Macros
Debug macros follow the pattern<component_name>_DEBUG and can be enabled individually at build time:
Meta/CMake/all_the_debug_macros.cmake.
Sanitizers
Address Sanitizer
Address Sanitizer catches memory corruption bugs including buffer overflows and memory leaks.Enable Address Sanitizer for Lagom tests
Enable Address Sanitizer for Lagom tests
Enable Kernel Address Sanitizer
Enable Kernel Address Sanitizer
Undefined Behavior Sanitizer
Detects undefined behavior like null pointer dereferences and signed integer overflows.Enable for userspace
Enable for userspace
Enable for kernel
Enable for kernel
Running tests with sanitizers
Running tests with sanitizers
Ensure UBSan errors fail the test:
Memory Sanitizer
Enables runtime checks for uninitialized memory accesses in Lagom test cases:Kernel Debugging
Extra Kernel Debug Symbols
For easier debugging of kernel code, enable extra debug symbols:-Og and -ggdb3 compile options for the kernel. By default, the kernel is built with -O2.
GDB Integration
Debugging with GDB
Debugging with GDB
SerenityOS supports GDB debugging through QEMU:
