From 1a3a0836c017ab5e5672472033f3ff369dc33c39 Mon Sep 17 00:00:00 2001 From: asynts Date: Sat, 23 Jan 2021 23:29:11 +0100 Subject: [PATCH] Everywhere: Use CMake to generate AK/Debug.h. This was done with the help of several scripts, I dump them here to easily find them later: awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in) do find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \; done # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list. awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in --- AK/{Debug.h => Debug.h.in} | 280 ++++++++++++------ CMakeLists.txt | 3 + Kernel/ACPI/Parser.cpp | 6 +- Kernel/Arch/i386/CPU.cpp | 2 +- Kernel/Devices/PS2MouseDevice.cpp | 2 +- Kernel/Devices/VMWareBackdoor.cpp | 2 +- Kernel/FileSystem/VirtualFileSystem.cpp | 2 +- Kernel/Interrupts/SharedIRQHandler.cpp | 8 +- Kernel/Lock.cpp | 20 +- Kernel/Lock.h | 6 +- Kernel/Net/E1000NetworkAdapter.cpp | 8 +- Kernel/Net/IPv4Socket.cpp | 4 +- Kernel/Net/TCPSocket.cpp | 8 +- Kernel/PCI/Access.cpp | 2 +- Kernel/PCI/IOAccess.cpp | 2 +- Kernel/PCI/MMIOAccess.cpp | 4 +- Kernel/Storage/IDEChannel.cpp | 18 +- Kernel/Syscalls/fork.cpp | 2 +- Kernel/Thread.cpp | 10 +- Kernel/Thread.h | 7 +- Kernel/Time/HPET.cpp | 8 +- Kernel/VM/AnonymousVMObject.cpp | 6 +- Kernel/VM/MemoryManager.cpp | 2 +- Kernel/VM/RangeAllocator.cpp | 4 +- Kernel/VM/Region.cpp | 2 +- Meta/CMake/all_the_debug_macros.cmake | 270 ++++++----------- Meta/Lagom/CMakeLists.txt | 12 +- Userland/DevTools/HackStudio/CursorTool.cpp | 8 +- .../LanguageServers/Cpp/ClientConnection.cpp | 4 +- .../Shell/ClientConnection.cpp | 2 +- .../DevTools/UserspaceEmulator/Emulator.cpp | 5 +- Userland/Libraries/LibCore/Gzip.cpp | 6 +- Userland/Libraries/LibCore/NetworkJob.cpp | 2 +- .../NumberTheory/ModularFunctions.cpp | 2 +- Userland/Libraries/LibDebug/DebugInfo.cpp | 9 +- .../Libraries/LibDebug/Dwarf/LineProgram.cpp | 26 +- Userland/Libraries/LibGemini/Job.cpp | 2 +- Userland/Libraries/LibGfx/GIFLoader.cpp | 4 +- Userland/Libraries/LibGfx/JPGLoader.cpp | 2 +- Userland/Libraries/LibGfx/PNGLoader.cpp | 18 +- Userland/Libraries/LibGfx/Painter.cpp | 4 +- Userland/Libraries/LibHTTP/Job.cpp | 2 +- Userland/Libraries/LibMarkdown/Text.cpp | 7 +- Userland/Libraries/LibRegex/RegexDebug.h | 5 +- Userland/Libraries/LibRegex/RegexLexer.cpp | 3 +- Userland/Libraries/LibRegex/RegexMatcher.cpp | 12 +- Userland/Libraries/LibRegex/RegexParser.cpp | 4 +- Userland/Libraries/LibRegex/Tests/Regex.cpp | 14 +- Userland/Libraries/LibTLS/ClientHandshake.cpp | 36 +-- Userland/Libraries/LibTLS/Exchange.cpp | 7 +- Userland/Libraries/LibTLS/Record.cpp | 8 +- Userland/Libraries/LibTLS/Socket.cpp | 8 +- Userland/Libraries/LibTLS/TLSv12.cpp | 14 +- .../LibWeb/HTML/Parser/HTMLTokenizer.cpp | 2 +- Userland/Libraries/LibWeb/Loader/Resource.cpp | 4 +- .../Libraries/LibWeb/WebContentClient.cpp | 4 +- .../ImageDecoder/ClientConnection.cpp | 4 +- Userland/Services/WindowServer/Compositor.cpp | 2 +- Userland/Services/WindowServer/Screen.cpp | 4 +- 59 files changed, 475 insertions(+), 459 deletions(-) rename AK/{Debug.h => Debug.h.in} (68%) diff --git a/AK/Debug.h b/AK/Debug.h.in similarity index 68% rename from AK/Debug.h rename to AK/Debug.h.in index 5358103df1..45daff1d23 100644 --- a/AK/Debug.h +++ b/AK/Debug.h.in @@ -26,561 +26,653 @@ #pragma once -// FIXME: We could generate this file with CMake and configure. +#cmakedefine01 PROCESS_DEBUG +#cmakedefine01 SCHEDULER_DEBUG +#cmakedefine01 SCHEDULER_RUNNABLE_DEBUG +#cmakedefine01 THREAD_DEBUG +#cmakedefine01 LOCK_DEBUG +#cmakedefine01 SIGNAL_DEBUG +#cmakedefine01 BMP_DEBUG +#cmakedefine01 WAITBLOCK_DEBUG +#cmakedefine01 WAITQUEUE_DEBUG +#cmakedefine01 MULTIPROCESSOR_DEBUG +#cmakedefine01 ACPI_DEBUG +#cmakedefine01 PAGE_FAULT_DEBUG +#cmakedefine01 CONTEXT_SWITCH_DEBUG +#cmakedefine01 SMP_DEBUG +#cmakedefine01 BXVGA_DEBUG +#cmakedefine01 PS2MOUSE_DEBUG +#cmakedefine01 VMWAREBACKDOOR_DEBUG +#cmakedefine01 FILEDESCRIPTION_DEBUG +#cmakedefine01 PROCFS_DEBUG +#cmakedefine01 VFS_DEBUG +#cmakedefine01 IOAPIC_DEBUG +#cmakedefine01 IRQ_DEBUG +#cmakedefine01 INTERRUPT_DEBUG +#cmakedefine01 E1000_DEBUG +#cmakedefine01 IPV4_SOCKET_DEBUG +#cmakedefine01 DEBUG_LOCAL_SOCKET +#cmakedefine01 DEBUG_SOCKET +#cmakedefine01 TCP_SOCKET_DEBUG +#cmakedefine01 PCI_DEBUG +#cmakedefine01 PATA_DEBUG +#cmakedefine01 DEBUG_IO +#cmakedefine01 FORK_DEBUG +#cmakedefine01 DEBUG_POLL_SELECT +#cmakedefine01 HPET_DEBUG +#cmakedefine01 HPET_COMPARATOR_DEBUG +#cmakedefine01 MASTERPTY_DEBUG +#cmakedefine01 SLAVEPTY_DEBUG +#cmakedefine01 PTMX_DEBUG +#cmakedefine01 TTY_DEBUG +#cmakedefine01 CONTIGUOUS_VMOBJECT_DEBUG +#cmakedefine01 VRA_DEBUG +#cmakedefine01 COPY_DEBUG +#cmakedefine01 DEBUG_CURSOR_TOOL +#cmakedefine01 DEBUG_FILE_CONTENT +#cmakedefine01 DEBUG_GZIP +#cmakedefine01 CNETWORKJOB_DEBUG +#cmakedefine01 CSOCKET_DEBUG +#cmakedefine01 SAFE_SYSCALL_DEBUG +#cmakedefine01 GHASH_PROCESS_DEBUG +#cmakedefine01 NT_DEBUG +#cmakedefine01 CRYPTO_DEBUG +#cmakedefine01 DWARF_DEBUG +#cmakedefine01 DEBUG_HUNKS +#cmakedefine01 JOB_DEBUG +#cmakedefine01 GIF_DEBUG +#cmakedefine01 JPG_DEBUG +#cmakedefine01 EMOJI_DEBUG +#cmakedefine01 FILL_PATH_DEBUG +#cmakedefine01 PNG_DEBUG +#cmakedefine01 PORTABLE_IMAGE_LOADER_DEBUG +#cmakedefine01 DEBUG_SYNTAX_HIGHLIGHTING +#cmakedefine01 KEYBOARD_SHORTCUTS_DEBUG +#cmakedefine01 DEBUG_MARKDOWN +#cmakedefine01 REGEX_DEBUG +#cmakedefine01 TLS_DEBUG +#cmakedefine01 DEBUG_SPAM +#cmakedefine01 WRAPPER_GERNERATOR_DEBUG +#cmakedefine01 PARSER_DEBUG +#cmakedefine01 TOKENIZER_TRACE +#cmakedefine01 IMAGE_LOADER_DEBUG +#cmakedefine01 RESOURCE_DEBUG +#cmakedefine01 CACHE_DEBUG +#cmakedefine01 DHCPV4_DEBUG +#cmakedefine01 DHCPV4CLIENT_DEBUG +#cmakedefine01 IMAGE_DECODER_DEBUG +#cmakedefine01 SYSTEM_MENU_DEBUG +#cmakedefine01 SYSTEMSERVER_DEBUG +#cmakedefine01 SERVICE_DEBUG +#cmakedefine01 COMPOSE_DEBUG +#cmakedefine01 MINIMIZE_ANIMATION_DEBUG +#cmakedefine01 OCCLUSIONS_DEBUG +#cmakedefine01 DEBUG_MENUS +#cmakedefine01 WSSCREEN_DEBUG +#cmakedefine01 WINDOWMANAGER_DEBUG +#cmakedefine01 RESIZE_DEBUG +#cmakedefine01 MOVE_DEBUG +#cmakedefine01 DOUBLECLICK_DEBUG +#cmakedefine01 DISASM_DUMP +#cmakedefine01 DEBUG_PATH +#cmakedefine01 LOCK_TRACE_DEBUG +#cmakedefine01 LOCK_RESTORE_DEBUG +#cmakedefine01 FUTEXQUEUE_DEBUG +#cmakedefine01 FUTEX_DEBUG -#ifdef PROCESS_DEBUG +#if PROCESS_DEBUG constexpr bool debug_process = true; #else constexpr bool debug_process = false; #endif -#ifdef SCHEDULER_DEBUG +#if SCHEDULER_DEBUG constexpr bool debug_scheduler = true; #else constexpr bool debug_scheduler = false; #endif -#ifdef SCHEDULER_RUNNABLE_DEBUG +#if SCHEDULER_RUNNABLE_DEBUG constexpr bool debug_scheduler_runnable = true; #else constexpr bool debug_scheduler_runnable = false; #endif -#ifdef THREAD_DEBUG +#if THREAD_DEBUG constexpr bool debug_thread = true; #else constexpr bool debug_thread = false; #endif -#ifdef LOCK_DEBUG +#if LOCK_DEBUG constexpr bool debug_lock = true; #else constexpr bool debug_lock = false; #endif -#ifdef SIGNAL_DEBUG +#if SIGNAL_DEBUG constexpr bool debug_signal = true; #else constexpr bool debug_signal = false; #endif -#ifdef BMP_DEBUG +#if BMP_DEBUG constexpr bool debug_bmp = true; #else constexpr bool debug_bmp = false; #endif -#ifdef WAITBLOCK_DEBUG +#if WAITBLOCK_DEBUG constexpr bool debug_waitblock = true; #else constexpr bool debug_waitblock = false; #endif -#ifdef WAITQUEUE_DEBUG +#if WAITQUEUE_DEBUG constexpr bool debug_waitqueue = true; #else constexpr bool debug_waitqueue = false; #endif -#ifdef MULTIPROCESSOR_DEBUG +#if MULTIPROCESSOR_DEBUG constexpr bool debug_multiprocessor = true; #else constexpr bool debug_multiprocessor = false; #endif -#ifdef ACPI_DEBUG +#if ACPI_DEBUG constexpr bool debug_acpi = true; #else constexpr bool debug_acpi = false; #endif -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG constexpr bool debug_page_fault = true; #else constexpr bool debug_page_fault = false; #endif -#ifdef CONTEXT_SWITCH_DEBUG +#if CONTEXT_SWITCH_DEBUG constexpr bool debug_context_switch = true; #else constexpr bool debug_context_switch = false; #endif -#ifdef SMP_DEBUG +#if SMP_DEBUG constexpr bool debug_smp = true; #else constexpr bool debug_smp = false; #endif -#ifdef BXVGA_DEBUG +#if BXVGA_DEBUG constexpr bool debug_bxvga = true; #else constexpr bool debug_bxvga = false; #endif -#ifdef PS2MOUSE_DEBUG +#if PS2MOUSE_DEBUG constexpr bool debug_ps2mouse = true; #else constexpr bool debug_ps2mouse = false; #endif -#ifdef VMWAREBACKDOOR_DEBUG +#if VMWAREBACKDOOR_DEBUG constexpr bool debug_vmware_backdoor = true; #else constexpr bool debug_vmware_backdoor = false; #endif -#ifdef FILEDESCRIPTION_DEBUG +#if FILEDESCRIPTION_DEBUG constexpr bool debug_file_description = true; #else constexpr bool debug_file_description = false; #endif -#ifdef PROCFS_DEBUG +#if PROCFS_DEBUG constexpr bool debug_procfs = true; #else constexpr bool debug_procfs = false; #endif -#ifdef VFS_DEBUG +#if VFS_DEBUG constexpr bool debug_vfs = true; #else constexpr bool debug_vfs = false; #endif -#ifdef IOAPIC_DEBUG +#if IOAPIC_DEBUG constexpr bool debug_ioapic = true; #else constexpr bool debug_ioapic = false; #endif -#ifdef IRQ_DEBUG +#if IRQ_DEBUG constexpr bool debug_irq = true; #else constexpr bool debug_irq = false; #endif -#ifdef INTERRUPT_DEBUG +#if INTERRUPT_DEBUG constexpr bool debug_interrupt = true; #else constexpr bool debug_interrupt = false; #endif -#ifdef E1000_DEBUG +#if E1000_DEBUG constexpr bool debug_e1000 = true; #else constexpr bool debug_e1000 = false; #endif -#ifdef IPV4_SOCKET_DEBUG +#if IPV4_SOCKET_DEBUG constexpr bool debug_ipv4_socket = true; #else constexpr bool debug_ipv4_socket = false; #endif -#ifdef DEBUG_LOCAL_SOCKET +#if DEBUG_LOCAL_SOCKET constexpr bool debug_local_socket = true; #else constexpr bool debug_local_socket = false; #endif -#ifdef DEBUG_SOCKET +#if DEBUG_SOCKET constexpr bool debug_socket = true; #else constexpr bool debug_socket = false; #endif -#ifdef TCP_SOCKET_DEBUG +#if TCP_SOCKET_DEBUG constexpr bool debug_tcp_socket = true; #else constexpr bool debug_tcp_socket = false; #endif -#ifdef PCI_DEBUG +#if PCI_DEBUG constexpr bool debug_pci = true; #else constexpr bool debug_pci = false; #endif -#ifdef PATA_DEBUG +#if PATA_DEBUG constexpr bool debug_pata = true; #else constexpr bool debug_pata = false; #endif -#ifdef DEBUG_IO +#if DEBUG_IO constexpr bool debug_io = true; #else constexpr bool debug_io = false; #endif -#ifdef FORK_DEBUG +#if FORK_DEBUG constexpr bool debug_fork = true; #else constexpr bool debug_fork = false; #endif -#ifdef DEBUG_POLL_SELECT +#if DEBUG_POLL_SELECT constexpr bool debug_poll_select = true; #else constexpr bool debug_poll_select = false; #endif -#ifdef HPET_DEBUG +#if HPET_DEBUG constexpr bool debug_hpet = true; #else constexpr bool debug_hpet = false; #endif -#ifdef HPET_COMPARATOR_DEBUG +#if HPET_COMPARATOR_DEBUG constexpr bool debug_hpet_comperator = true; #else constexpr bool debug_hpet_comperator = false; #endif -#ifdef MASTERPTY_DEBUG +#if MASTERPTY_DEBUG constexpr bool debug_masterpty = true; #else constexpr bool debug_masterpty = false; #endif -#ifdef SLAVEPTY_DEBUG +#if SLAVEPTY_DEBUG constexpr bool debug_slavepty = true; #else constexpr bool debug_slavepty = false; #endif -#ifdef PTMX_DEBUG +#if PTMX_DEBUG constexpr bool debug_ptmx = true; #else constexpr bool debug_ptmx = false; #endif -#ifdef TTY_DEBUG +#if TTY_DEBUG constexpr bool debug_tty = true; #else constexpr bool debug_tty = false; #endif -#ifdef CONTIGUOUS_VMOBJECT_DEBUG +#if CONTIGUOUS_VMOBJECT_DEBUG constexpr bool debug_contiguous_vmobject = true; #else constexpr bool debug_contiguous_vmobject = false; #endif -#ifdef VRA_DEBUG +#if VRA_DEBUG constexpr bool debug_vra = true; #else constexpr bool debug_vra = false; #endif -#ifdef COPY_DEBUG +#if COPY_DEBUG constexpr bool debug_copy = true; #else constexpr bool debug_copy = false; #endif -#ifdef DEBUG_CURSOR_TOOL +#if DEBUG_CURSOR_TOOL constexpr bool debug_cursor_tool = true; #else constexpr bool debug_cursor_tool = false; #endif -#ifdef DEBUG_FILE_CONTENT +#if DEBUG_FILE_CONTENT constexpr bool debug_file_content = true; #else constexpr bool debug_file_content = false; #endif -#ifdef DEBUG_GZIP +#if DEBUG_GZIP constexpr bool debug_gzip = true; #else constexpr bool debug_gzip = false; #endif -#ifdef CNETWORKJOB_DEBUG +#if CNETWORKJOB_DEBUG constexpr bool debug_cnetworkjob = true; #else constexpr bool debug_cnetworkjob = false; #endif -#ifdef CSOCKET_DEBUG +#if CSOCKET_DEBUG constexpr bool debug_csocket = true; #else constexpr bool debug_csocket = false; #endif -#ifdef SAFE_SYSCALL_DEBUG +#if SAFE_SYSCALL_DEBUG constexpr bool debug_safe_syscall = true; #else constexpr bool debug_safe_syscall = false; #endif -#ifdef GHASH_PROCESS_DEBUG +#if GHASH_PROCESS_DEBUG constexpr bool debug_ghash_process = true; #else constexpr bool debug_ghash_process = false; #endif -#ifdef NT_DEBUG +#if NT_DEBUG constexpr bool debug_nt = true; #else constexpr bool debug_nt = false; #endif -#ifdef CRYPTO_DEBUG +#if CRYPTO_DEBUG constexpr bool debug_crypto = true; #else constexpr bool debug_crypto = false; #endif -#ifdef DWARF_DEBUG +#if DWARF_DEBUG constexpr bool debug_dwarf = true; #else constexpr bool debug_dwarf = false; #endif -#ifdef DEBUG_HUNKS +#if DEBUG_HUNKS constexpr bool debug_hunks = true; #else constexpr bool debug_hunks = false; #endif -#ifdef JOB_DEBUG +#if JOB_DEBUG constexpr bool debug_job = true; #else constexpr bool debug_job = false; #endif -#ifdef GIF_DEBUG +#if GIF_DEBUG constexpr bool debug_gif = true; #else constexpr bool debug_gif = false; #endif -#ifdef JPG_DEBUG +#if JPG_DEBUG constexpr bool debug_jpg = true; #else constexpr bool debug_jpg = false; #endif -#ifdef EMOJI_DEBUG +#if EMOJI_DEBUG constexpr bool debug_emoji = true; #else constexpr bool debug_emoji = false; #endif -#ifdef FILL_PATH_DEBUG +#if FILL_PATH_DEBUG constexpr bool debug_fill_path = true; #else constexpr bool debug_fill_path = false; #endif -#ifdef PNG_DEBUG +#if PNG_DEBUG constexpr bool debug_png = true; #else constexpr bool debug_png = false; #endif -#ifdef PORTABLE_IMAGE_LOADER_DEBUG +#if PORTABLE_IMAGE_LOADER_DEBUG constexpr bool debug_portable_image_loader = true; #else constexpr bool debug_portable_image_loader = false; #endif -#ifdef DEBUG_SYNTAX_HIGHLIGHTING +#if DEBUG_SYNTAX_HIGHLIGHTING constexpr bool debug_syntax_highlighting = true; #else constexpr bool debug_syntax_highlighting = false; #endif -#ifdef KEYBOARD_SHORTCUTS_DEBUG +#if KEYBOARD_SHORTCUTS_DEBUG constexpr bool debug_keyboard_shortcuts = true; #else constexpr bool debug_keyboard_shortcuts = false; #endif -#ifdef DEBUG_MARKDOWN +#if DEBUG_MARKDOWN constexpr bool debug_markdown = true; #else constexpr bool debug_markdown = false; #endif -#ifdef REGEX_DEBUG +#if REGEX_DEBUG constexpr bool debug_regex = true; #else constexpr bool debug_regex = false; #endif -#ifdef TLS_DEBUG +#if TLS_DEBUG constexpr bool debug_tls = true; #else constexpr bool debug_tls = false; #endif -#ifdef DEBUG_SPAM +#if DEBUG_SPAM constexpr bool debug_spam = true; #else constexpr bool debug_spam = false; #endif -#ifdef WRAPPER_GERNERATOR_DEBUG +#if WRAPPER_GERNERATOR_DEBUG constexpr bool debug_wrapper_generator = true; #else constexpr bool debug_wrapper_generator = false; #endif -#ifdef PARSER_DEBUG +#if PARSER_DEBUG constexpr bool debug_parser = true; #else constexpr bool debug_parser = false; #endif -#ifdef TOKENIZER_TRACE +#if TOKENIZER_TRACE constexpr bool debug_trace_tokenizer = true; #else constexpr bool debug_trace_tokenizer = false; #endif -#ifdef IMAGE_LOADER_DEBUG +#if IMAGE_LOADER_DEBUG constexpr bool debug_image_loader = true; #else constexpr bool debug_image_loader = false; #endif -#ifdef RESOURCE_DEBUG +#if RESOURCE_DEBUG constexpr bool debug_resource = true; #else constexpr bool debug_resource = false; #endif -#ifdef CACHE_DEBUG +#if CACHE_DEBUG constexpr bool debug_cache = true; #else constexpr bool debug_cache = false; #endif -#ifdef DHCPV4_DEBUG +#if DHCPV4_DEBUG constexpr bool debug_dhcpv4 = true; #else constexpr bool debug_dhcpv4 = false; #endif -#ifdef DHCPV4CLIENT_DEBUG +#if DHCPV4CLIENT_DEBUG constexpr bool debug_dhcpv4_client = true; #else constexpr bool debug_dhcpv4_client = false; #endif -#ifdef IMAGE_DECODER_DEBUG +#if IMAGE_DECODER_DEBUG constexpr bool debug_image_decoder = true; #else constexpr bool debug_image_decoder = false; #endif -#ifdef SYSTEM_MENU_DEBUG +#if SYSTEM_MENU_DEBUG constexpr bool debug_system_menu = true; #else constexpr bool debug_system_menu = false; #endif -#ifdef SYSTEMSERVER_DEBUG +#if SYSTEMSERVER_DEBUG constexpr bool debug_system_server = true; #else constexpr bool debug_system_server = false; #endif -#ifdef SERVICE_DEBUG +#if SERVICE_DEBUG constexpr bool debug_service = true; #else constexpr bool debug_service = false; #endif -#ifdef COMPOSE_DEBUG +#if COMPOSE_DEBUG constexpr bool debug_compose = true; #else constexpr bool debug_compose = false; #endif -#ifdef MINIMIZE_ANIMATION_DEBUG +#if MINIMIZE_ANIMATION_DEBUG constexpr bool debug_minimize_animation = true; #else constexpr bool debug_minimize_animation = false; #endif -#ifdef OCCLUSIONS_DEBUG +#if OCCLUSIONS_DEBUG constexpr bool debug_occlusions = true; #else constexpr bool debug_occlusions = false; #endif -#ifdef DEBUG_MENUS +#if DEBUG_MENUS constexpr bool debug_menus = true; #else constexpr bool debug_menus = false; #endif -#ifdef WSSCREEN_DEBUG +#if WSSCREEN_DEBUG constexpr bool debug_wsscreen = true; #else constexpr bool debug_wsscreen = false; #endif -#ifdef WINDOWMANAGER_DEBUG +#if WINDOWMANAGER_DEBUG constexpr bool debug_window_manager = true; #else constexpr bool debug_window_manager = false; #endif -#ifdef RESIZE_DEBUG +#if RESIZE_DEBUG constexpr bool debug_resize = true; #else constexpr bool debug_resize = false; #endif -#ifdef MOVE_DEBUG +#if MOVE_DEBUG constexpr bool debug_move = true; #else constexpr bool debug_move = false; #endif -#ifdef DOUBLECLICK_DEBUG +#if DOUBLECLICK_DEBUG constexpr bool debug_double_click = true; #else constexpr bool debug_double_click = false; #endif -#ifdef DISASM_DUMP +#if DISASM_DUMP constexpr bool debug_disasm_dump = true; #else constexpr bool debug_disasm_dump = false; #endif -#ifdef DEBUG_PATH +#if DEBUG_PATH constexpr bool debug_path = true; #else constexpr bool debug_path = false; #endif -#ifdef LOCK_TRACE_DEBUG +#if LOCK_TRACE_DEBUG constexpr bool debug_lock_trace = true; #else constexpr bool debug_lock_trace = false; #endif -#ifdef LOCK_RESTORE_DEBUG +#if LOCK_RESTORE_DEBUG constexpr bool debug_lock_restore = true; #else constexpr bool debug_lock_restore = false; #endif -#ifdef FUTEXQUEUE_DEBUG +#if FUTEXQUEUE_DEBUG constexpr bool debug_futex_queue = true; #else constexpr bool debug_futex_queue = false; #endif -#ifdef FUTEX_DEBUG +#if FUTEX_DEBUG constexpr bool debug_futex = true; #else constexpr bool debug_futex = false; diff --git a/CMakeLists.txt b/CMakeLists.txt index c37c28d6c8..fd6e5683b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,8 +68,11 @@ if (ENABLE_ALL_THE_DEBUG_MACROS) include(${CMAKE_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake) endif(ENABLE_ALL_THE_DEBUG_MACROS) +configure_file(AK/Debug.h.in AK/Debug.h @ONLY) + include_directories(Userland/Libraries) include_directories(.) +include_directories(${CMAKE_BINARY_DIR}) add_subdirectory(Meta/Lagom) add_subdirectory(Userland/DevTools/IPCCompiler) diff --git a/Kernel/ACPI/Parser.cpp b/Kernel/ACPI/Parser.cpp index dcb66ba332..c7e54570f6 100644 --- a/Kernel/ACPI/Parser.cpp +++ b/Kernel/ACPI/Parser.cpp @@ -235,7 +235,7 @@ void Parser::try_acpi_shutdown() size_t Parser::get_table_size(PhysicalAddress table_header) { InterruptDisabler disabler; -#ifdef ACPI_DEBUG +#if ACPI_DEBUG dbgln("ACPI: Checking SDT Length"); #endif return map_typed(table_header)->length; @@ -244,7 +244,7 @@ size_t Parser::get_table_size(PhysicalAddress table_header) u8 Parser::get_table_revision(PhysicalAddress table_header) { InterruptDisabler disabler; -#ifdef ACPI_DEBUG +#if ACPI_DEBUG dbgln("ACPI: Checking SDT Revision"); #endif return map_typed(table_header)->revision; @@ -252,7 +252,7 @@ u8 Parser::get_table_revision(PhysicalAddress table_header) void Parser::initialize_main_system_description_table() { -#ifdef ACPI_DEBUG +#if ACPI_DEBUG dbgln("ACPI: Checking Main SDT Length to choose the correct mapping size"); #endif ASSERT(!m_main_system_description_table.is_null()); diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index 9a9e1a29af..540d068a5e 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -318,7 +318,7 @@ void page_fault_handler(TrapFrame* trap) handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory); } else if (response == PageFaultResponse::Continue) { -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln("Continuing after resolved page fault"); #endif } else { diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp index e55a765940..bd7023f536 100644 --- a/Kernel/Devices/PS2MouseDevice.cpp +++ b/Kernel/Devices/PS2MouseDevice.cpp @@ -184,7 +184,7 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) } packet.is_relative = true; -#ifdef PS2MOUSE_DEBUG +#if PS2MOUSE_DEBUG dbgln("PS2 Relative Mouse: Buttons {:x}", packet.buttons); dbgln("Mouse: X {}, Y {}, Z {}", packet.x, packet.y, packet.z); #endif diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp index a8c698b26e..2066ccef7b 100644 --- a/Kernel/Devices/VMWareBackdoor.cpp +++ b/Kernel/Devices/VMWareBackdoor.cpp @@ -215,7 +215,7 @@ Optional VMWareBackdoor::receive_mouse_packet() command.command = VMMOUSE_STATUS; send(command); if (command.ax == 0xFFFF0000) { -#ifdef PS2MOUSE_DEBUG +#if PS2MOUSE_DEBUG klog() << "PS2MouseDevice: Resetting VMWare mouse"; #endif disable_absolute_vmmouse(); diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 25029dc021..1a7b50a549 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -58,7 +58,7 @@ VFS& VFS::the() VFS::VFS() { -#ifdef VFS_DEBUG +#if VFS_DEBUG klog() << "VFS: Constructing VFS"; #endif } diff --git a/Kernel/Interrupts/SharedIRQHandler.cpp b/Kernel/Interrupts/SharedIRQHandler.cpp index 2c1e5e031d..7667a4a477 100644 --- a/Kernel/Interrupts/SharedIRQHandler.cpp +++ b/Kernel/Interrupts/SharedIRQHandler.cpp @@ -42,7 +42,7 @@ void SharedIRQHandler::initialize(u8 interrupt_number) void SharedIRQHandler::register_handler(GenericInterruptHandler& handler) { -#ifdef INTERRUPT_DEBUG +#if INTERRUPT_DEBUG klog() << "Interrupt Handler registered @ Shared Interrupt Handler " << interrupt_number(); #endif m_handlers.set(&handler); @@ -50,7 +50,7 @@ void SharedIRQHandler::register_handler(GenericInterruptHandler& handler) } void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler) { -#ifdef INTERRUPT_DEBUG +#if INTERRUPT_DEBUG klog() << "Interrupt Handler unregistered @ Shared Interrupt Handler " << interrupt_number(); #endif m_handlers.remove(&handler); @@ -69,7 +69,7 @@ SharedIRQHandler::SharedIRQHandler(u8 irq) : GenericInterruptHandler(irq) , m_responsible_irq_controller(InterruptManagement::the().get_responsible_irq_controller(irq)) { -#ifdef INTERRUPT_DEBUG +#if INTERRUPT_DEBUG klog() << "Shared Interrupt Handler registered @ " << interrupt_number(); #endif disable_interrupt_vector(); @@ -77,7 +77,7 @@ SharedIRQHandler::SharedIRQHandler(u8 irq) SharedIRQHandler::~SharedIRQHandler() { -#ifdef INTERRUPT_DEBUG +#if INTERRUPT_DEBUG klog() << "Shared Interrupt Handler unregistered @ " << interrupt_number(); #endif disable_interrupt_vector(); diff --git a/Kernel/Lock.cpp b/Kernel/Lock.cpp index 9b0ddb5090..602541d517 100644 --- a/Kernel/Lock.cpp +++ b/Kernel/Lock.cpp @@ -32,7 +32,7 @@ namespace Kernel { -#ifdef LOCK_DEBUG +#if LOCK_DEBUG void Lock::lock(Mode mode) { lock("unknown", 0, mode); @@ -68,7 +68,7 @@ void Lock::lock(Mode mode) } ASSERT(m_times_locked == 0); m_times_locked++; -#ifdef LOCK_DEBUG +#if LOCK_DEBUG current_thread->holding_lock(*this, 1, file, line); #endif m_lock.store(false, AK::memory_order_release); @@ -90,7 +90,7 @@ void Lock::lock(Mode mode) ASSERT(mode == Mode::Exclusive || mode == Mode::Shared); ASSERT(m_times_locked > 0); m_times_locked++; -#ifdef LOCK_DEBUG +#if LOCK_DEBUG current_thread->holding_lock(*this, 1, file, line); #endif m_lock.store(false, AK::memory_order_release); @@ -111,7 +111,7 @@ void Lock::lock(Mode mode) it->value++; else m_shared_holders.set(current_thread, 1); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG current_thread->holding_lock(*this, 1, file, line); #endif m_lock.store(false, AK::memory_order_release); @@ -179,7 +179,7 @@ void Lock::unlock() m_mode = Mode::Unlocked; } -#ifdef LOCK_DEBUG +#if LOCK_DEBUG current_thread->holding_lock(*this, -1); #endif @@ -219,7 +219,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode m_times_locked = 0; m_mode = Mode::Unlocked; m_lock.store(false, AK::memory_order_release); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG m_holder->holding_lock(*this, -(int)lock_count_to_restore); #endif previous_mode = Mode::Exclusive; @@ -240,7 +240,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode ASSERT(it->value > 0); lock_count_to_restore = it->value; ASSERT(lock_count_to_restore > 0); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG m_holder->holding_lock(*this, -(int)lock_count_to_restore); #endif m_shared_holders.remove(it); @@ -269,7 +269,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode } } -#ifdef LOCK_DEBUG +#if LOCK_DEBUG void Lock::restore_lock(Mode mode, u32 lock_count) { return restore_lock("unknown", 0, mode, lock_count); @@ -301,7 +301,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count) ASSERT(m_shared_holders.is_empty()); m_holder = current_thread; m_lock.store(false, AK::memory_order_release); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG m_holder->holding_lock(*this, (int)lock_count, file, line); #endif return; @@ -322,7 +322,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count) // There may be other shared lock holders already, but we should not have an entry yet ASSERT(set_result == AK::HashSetResult::InsertedNewEntry); m_lock.store(false, AK::memory_order_release); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG m_holder->holding_lock(*this, (int)lock_count, file, line); #endif return; diff --git a/Kernel/Lock.h b/Kernel/Lock.h index 9756587a3f..b3fe5a10df 100644 --- a/Kernel/Lock.h +++ b/Kernel/Lock.h @@ -51,7 +51,7 @@ public: ~Lock() { } void lock(Mode = Mode::Exclusive); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG void lock(const char* file, int line, Mode mode = Mode::Exclusive); void restore_lock(const char* file, int line, Mode, u32); #endif @@ -98,7 +98,7 @@ private: class Locker { public: -#ifdef LOCK_DEBUG +#if LOCK_DEBUG ALWAYS_INLINE explicit Locker(const char* file, int line, Lock& l, Lock::Mode mode = Lock::Mode::Exclusive) : m_lock(l) { @@ -133,7 +133,7 @@ private: bool m_locked { true }; }; -#ifdef LOCK_DEBUG +#if LOCK_DEBUG # define LOCKER(...) Locker locker(__FILE__, __LINE__, __VA_ARGS__) # define RESTORE_LOCK(lock, ...) (lock).restore_lock(__FILE__, __LINE__, __VA_ARGS__) #else diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp index 49b4067167..188f2fec09 100644 --- a/Kernel/Net/E1000NetworkAdapter.cpp +++ b/Kernel/Net/E1000NetworkAdapter.cpp @@ -423,7 +423,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload) { disable_irq(); size_t tx_current = in32(REG_TXDESCTAIL) % number_of_tx_descriptors; -#ifdef E1000_DEBUG +#if E1000_DEBUG klog() << "E1000: Sending packet (" << payload.size() << " bytes)"; #endif auto* tx_descriptors = (e1000_tx_desc*)m_tx_descriptors_region->vaddr().as_ptr(); @@ -434,7 +434,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload) descriptor.length = payload.size(); descriptor.status = 0; descriptor.cmd = CMD_EOP | CMD_IFCS | CMD_RS; -#ifdef E1000_DEBUG +#if E1000_DEBUG klog() << "E1000: Using tx descriptor " << tx_current << " (head is at " << in32(REG_TXDESCHEAD) << ")"; #endif tx_current = (tx_current + 1) % number_of_tx_descriptors; @@ -448,7 +448,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload) } m_wait_queue.wait_on({}, "E1000NetworkAdapter"); } -#ifdef E1000_DEBUG +#if E1000_DEBUG dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status); #endif } @@ -467,7 +467,7 @@ void E1000NetworkAdapter::receive() auto* buffer = m_rx_buffers_regions[rx_current].vaddr().as_ptr(); u16 length = rx_descriptors[rx_current].length; ASSERT(length <= 8192); -#ifdef E1000_DEBUG +#if E1000_DEBUG klog() << "E1000: Received 1 packet @ " << buffer << " (" << length << ") bytes!"; #endif did_receive({ buffer, length }); diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 8d3d426136..2b6ede30ff 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -222,7 +222,7 @@ KResultOr IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer& if (rc < 0) return rc; -#ifdef IPV4_SOCKET_DEBUG +#if IPV4_SOCKET_DEBUG klog() << "sendto: destination=" << m_peer_address.to_string().characters() << ":" << m_peer_port; #endif @@ -364,7 +364,7 @@ KResultOr IPv4Socket::recvfrom(FileDescription& description, UserOrKerne return EINVAL; } -#ifdef IPV4_SOCKET_DEBUG +#if IPV4_SOCKET_DEBUG klog() << "recvfrom: type=" << type() << ", local_port=" << local_port(); #endif diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index e10c9031f7..9e9b78186e 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -169,7 +169,7 @@ KResultOr TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, Use auto& ipv4_packet = *reinterpret_cast(raw_ipv4_packet.data()); auto& tcp_packet = *static_cast(ipv4_packet.payload()); size_t payload_size = raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size(); -#ifdef TCP_SOCKET_DEBUG +#if TCP_SOCKET_DEBUG klog() << "payload_size " << payload_size << ", will it fit in " << buffer_size << "?"; #endif ASSERT(buffer_size >= payload_size); @@ -252,7 +252,7 @@ void TCPSocket::send_outgoing_packets() packet.tx_time = now; packet.tx_counter++; -#ifdef TCP_SOCKET_DEBUG +#if TCP_SOCKET_DEBUG auto& tcp_packet = *(TCPPacket*)(packet.buffer.data()); klog() << "sending tcp packet from " << local_address().to_string().characters() << ":" << local_port() << " to " << peer_address().to_string().characters() << ":" << peer_port() << " with (" << (tcp_packet.has_syn() ? "SYN " : "") << (tcp_packet.has_ack() ? "ACK " : "") << (tcp_packet.has_fin() ? "FIN " : "") << (tcp_packet.has_rst() ? "RST " : "") << ") seq_no=" << tcp_packet.sequence_number() << ", ack_no=" << tcp_packet.ack_number() << ", tx_counter=" << packet.tx_counter; #endif @@ -450,7 +450,7 @@ bool TCPSocket::protocol_is_disconnected() const void TCPSocket::shut_down_for_writing() { if (state() == State::Established) { -#ifdef TCP_SOCKET_DEBUG +#if TCP_SOCKET_DEBUG dbgln(" Sending FIN/ACK from Established and moving into FinWait1"); #endif [[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK); @@ -465,7 +465,7 @@ KResult TCPSocket::close() Locker socket_locker(lock()); auto result = IPv4Socket::close(); if (state() == State::CloseWait) { -#ifdef TCP_SOCKET_DEBUG +#if TCP_SOCKET_DEBUG dbgln(" Sending FIN from CloseWait and moving into LastAck"); #endif [[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK); diff --git a/Kernel/PCI/Access.cpp b/Kernel/PCI/Access.cpp index 1740d7a2b6..d82142eb1a 100644 --- a/Kernel/PCI/Access.cpp +++ b/Kernel/PCI/Access.cpp @@ -109,7 +109,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Functio callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) }); if (early_read_type(address) == PCI_TYPE_BRIDGE) { u8 secondary_bus = early_read8_field(address, PCI_SECONDARY_BUS); -#ifdef PCI_DEBUG +#if PCI_DEBUG klog() << "PCI: Found secondary bus: " << secondary_bus; #endif ASSERT(secondary_bus != bus); diff --git a/Kernel/PCI/IOAccess.cpp b/Kernel/PCI/IOAccess.cpp index bcf81c8e00..73ac6a8413 100644 --- a/Kernel/PCI/IOAccess.cpp +++ b/Kernel/PCI/IOAccess.cpp @@ -86,7 +86,7 @@ void IOAccess::write32_field(Address address, u32 field, u32 value) void IOAccess::enumerate_hardware(Function callback) { -#ifdef PCI_DEBUG +#if PCI_DEBUG dbgln("PCI: IO enumerating hardware"); #endif // Single PCI host controller. diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp index 908c1f1ea0..d7fa97f6bb 100644 --- a/Kernel/PCI/MMIOAccess.cpp +++ b/Kernel/PCI/MMIOAccess.cpp @@ -85,7 +85,7 @@ void MMIOAccess::initialize(PhysicalAddress mcfg) { if (!Access::is_initialized()) { new MMIOAccess(mcfg); -#ifdef PCI_DEBUG +#if PCI_DEBUG dbgln("PCI: MMIO access initialised."); #endif } @@ -97,7 +97,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) klog() << "PCI: Using MMIO for PCI configuration space access"; auto checkup_region = MM.allocate_kernel_region(p_mcfg.page_base(), (PAGE_SIZE * 2), "PCI MCFG Checkup", Region::Access::Read | Region::Access::Write); -#ifdef PCI_DEBUG +#if PCI_DEBUG dbgln("PCI: Checking MCFG Table length to choose the correct mapping size"); #endif diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp index 2bc92f4817..4a2af72c0b 100644 --- a/Kernel/Storage/IDEChannel.cpp +++ b/Kernel/Storage/IDEChannel.cpp @@ -146,7 +146,7 @@ IDEChannel::~IDEChannel() void IDEChannel::start_request(AsyncBlockDeviceRequest& request, bool use_dma, bool is_slave) { ScopedSpinLock lock(m_request_lock); -#ifdef PATA_DEBUG +#if PATA_DEBUG dbgln("IDEChannel::start_request"); #endif m_current_request = &request; @@ -231,19 +231,19 @@ void IDEChannel::handle_irq(const RegisterState&) u8 bstatus = m_io_group.bus_master_base().offset(2).in(); if (!(bstatus & 0x4)) { // interrupt not from this device, ignore -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel: ignore interrupt"; #endif return; } ScopedSpinLock lock(m_request_lock); -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel: interrupt: DRQ=" << ((status & ATA_SR_DRQ) != 0) << " BSY=" << ((status & ATA_SR_BSY) != 0) << " DRDY=" << ((status & ATA_SR_DRDY) != 0); #endif if (!m_current_request) { -#ifdef PATA_DEBUG +#if PATA_DEBUG dbgln("IDEChannel: IRQ but no pending request!"); #endif return; @@ -324,7 +324,7 @@ void IDEChannel::detect_disks() ; if (m_io_group.io_base().offset(ATA_REG_STATUS).in() == 0x00) { -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel: No " << (i == 0 ? "master" : "slave") << " disk detected!"; #endif continue; @@ -439,7 +439,7 @@ void IDEChannel::ata_read_sectors(bool slave_request) { auto& request = *m_current_request; ASSERT(request.block_count() <= 256); -#ifdef PATA_DEBUG +#if PATA_DEBUG dbgln("IDEChannel::ata_read_sectors"); #endif @@ -447,7 +447,7 @@ void IDEChannel::ata_read_sectors(bool slave_request) ; auto lba = request.block_index(); -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel: Reading " << request.block_count() << " sector(s) @ LBA " << lba; #endif @@ -570,14 +570,14 @@ void IDEChannel::ata_write_sectors(bool slave_request) ASSERT(request.block_count() <= 256); u32 start_sector = request.block_index(); u32 count = request.block_count(); -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel::ata_write_sectors request (" << count << " sector(s) @ " << start_sector << ")"; #endif while (m_io_group.io_base().offset(ATA_REG_STATUS).in() & ATA_SR_BSY) ; -#ifdef PATA_DEBUG +#if PATA_DEBUG klog() << "IDEChannel: Writing " << count << " sector(s) @ LBA " << start_sector; #endif diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 2641b1ab95..a3cf64bc5f 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -72,7 +72,7 @@ pid_t Process::sys$fork(RegisterState& regs) child_tss.gs = regs.gs; child_tss.ss = regs.userspace_ss; -#ifdef FORK_DEBUG +#if FORK_DEBUG dbgln("fork: child will begin executing at {:04x}:{:08x} with stack {:04x}:{:08x}, kstack {:04x}:{:08x}", child_tss.cs, child_tss.eip, child_tss.ss, child_tss.esp, child_tss.ss0, child_tss.esp0); #endif diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 8a4bef44fb..be9909f6c2 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -357,7 +357,7 @@ void Thread::finalize() ASSERT(Thread::current() == g_finalizer); ASSERT(Thread::current() != this); -#ifdef LOCK_DEBUG +#if LOCK_DEBUG ASSERT(!m_lock.own_lock()); if (lock_count() > 0) { dbgln("Thread {} leaking {} Locks!", *this, lock_count()); @@ -687,7 +687,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) ASSERT(process().is_user_process()); ASSERT(this == Thread::current()); -#ifdef SIGNAL_DEBUG +#if SIGNAL_DEBUG klog() << "signal: dispatch signal " << signal << " to " << *this << " state: " << state_string(); #endif @@ -756,7 +756,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) } if (handler_vaddr.as_ptr() == SIG_IGN) { -#ifdef SIGNAL_DEBUG +#if SIGNAL_DEBUG klog() << "signal: " << *this << " ignored signal " << signal; #endif return DispatchSignalResult::Continue; @@ -780,7 +780,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) u32 ret_eip = state.eip; u32 ret_eflags = state.eflags; -#ifdef SIGNAL_DEBUG +#if SIGNAL_DEBUG klog() << "signal: setting up user stack to return to eip: " << String::format("%p", (void*)ret_eip) << " esp: " << String::format("%p", (void*)old_esp); #endif @@ -820,7 +820,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) setup_stack(regs); regs.eip = g_return_to_ring3_from_signal_trampoline.get(); -#ifdef SIGNAL_DEBUG +#if SIGNAL_DEBUG dbgln("signal: Thread in state '{}' has been primed with signal handler {:04x}:{:08x} to deliver {}", state_string(), m_tss.cs, m_tss.eip, signal); #endif return DispatchSignalResult::Continue; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index f1096420e2..234878114b 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -26,6 +26,7 @@ #pragma once +#include #include #include #include @@ -47,8 +48,6 @@ #include #include -//#define LOCK_DEBUG - namespace Kernel { enum class DispatchSignalResult { @@ -1109,7 +1108,7 @@ public: RecursiveSpinLock& get_lock() const { return m_lock; } -#ifdef LOCK_DEBUG +#if LOCK_DEBUG void holding_lock(Lock& lock, int refs_delta, const char* file = nullptr, int line = 0) { ASSERT(refs_delta != 0); @@ -1246,7 +1245,7 @@ private: SignalActionData m_signal_action_data[32]; Blocker* m_blocker { nullptr }; -#ifdef LOCK_DEBUG +#if LOCK_DEBUG struct HoldingLockInfo { Lock* lock; const char* file; diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index ea29c56736..ad6cb7537e 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -275,7 +275,7 @@ u64 HPET::update_time(u64& seconds_since_boot, u32& ticks_this_second, bool quer void HPET::enable_periodic_interrupt(const HPETComparator& comparator) { -#ifdef HPET_DEBUG +#if HPET_DEBUG klog() << "HPET: Set comparator " << comparator.comparator_number() << " to be periodic."; #endif disable(comparator); @@ -289,7 +289,7 @@ void HPET::enable_periodic_interrupt(const HPETComparator& comparator) } void HPET::disable_periodic_interrupt(const HPETComparator& comparator) { -#ifdef HPET_DEBUG +#if HPET_DEBUG klog() << "HPET: Disable periodic interrupt in comparator " << comparator.comparator_number() << "."; #endif disable(comparator); @@ -304,7 +304,7 @@ void HPET::disable_periodic_interrupt(const HPETComparator& comparator) void HPET::disable(const HPETComparator& comparator) { -#ifdef HPET_DEBUG +#if HPET_DEBUG klog() << "HPET: Disable comparator " << comparator.comparator_number() << "."; #endif ASSERT(comparator.comparator_number() <= m_comparators.size()); @@ -313,7 +313,7 @@ void HPET::disable(const HPETComparator& comparator) } void HPET::enable(const HPETComparator& comparator) { -#ifdef HPET_DEBUG +#if HPET_DEBUG klog() << "HPET: Enable comparator " << comparator.comparator_number() << "."; #endif ASSERT(comparator.comparator_number() <= m_comparators.size()); diff --git a/Kernel/VM/AnonymousVMObject.cpp b/Kernel/VM/AnonymousVMObject.cpp index 3bd055e69e..a7342fa93e 100644 --- a/Kernel/VM/AnonymousVMObject.cpp +++ b/Kernel/VM/AnonymousVMObject.cpp @@ -443,7 +443,7 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual auto& page_slot = physical_pages()[page_index]; bool have_committed = m_shared_committed_cow_pages && is_nonvolatile(page_index); if (page_slot->ref_count() == 1) { -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln(" >> It's a COW page but nobody is sharing it anymore. Remap r/w"); #endif set_should_cow(page_index, false); @@ -456,12 +456,12 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual RefPtr page; if (have_committed) { -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln(" >> It's a committed COW page and it's time to COW!"); #endif page = m_shared_committed_cow_pages->allocate_one(); } else { -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln(" >> It's a COW page and it's time to COW!"); #endif page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No); diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 6f69959a07..1180592f85 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -384,7 +384,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault) dump_kernel_regions(); return PageFaultResponse::ShouldCrash; } -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln("MM: CPU[{}] handle_page_fault({:#04x}) at {}", Processor::current().id(), fault.code(), fault.vaddr()); #endif auto* region = find_region_from_vaddr(fault.vaddr()); diff --git a/Kernel/VM/RangeAllocator.cpp b/Kernel/VM/RangeAllocator.cpp index 44ed6a7400..3e12588aca 100644 --- a/Kernel/VM/RangeAllocator.cpp +++ b/Kernel/VM/RangeAllocator.cpp @@ -43,7 +43,7 @@ void RangeAllocator::initialize_with_range(VirtualAddress base, size_t size) { m_total_range = { base, size }; m_available_ranges.append({ base, size }); -#ifdef VRA_DEBUG +#if VRA_DEBUG ScopedSpinLock lock(m_lock); dump(); #endif @@ -215,7 +215,7 @@ void RangeAllocator::deallocate(Range range) return; } } -#ifdef VRA_DEBUG +#if VRA_DEBUG dbgln("VRA: After deallocate"); dump(); #endif diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 54828e4e96..72067d0ec0 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -458,7 +458,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region) auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region); if (!page_slot.is_null() && !page_slot->is_shared_zero_page() && !page_slot->is_lazy_committed_page()) { -#ifdef PAGE_FAULT_DEBUG +#if PAGE_FAULT_DEBUG dbgln("MM: zero_page() but page already present. Fine with me!"); #endif if (!remap_vmobject_page(page_index_in_vmobject)) diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index bbc5930692..6e5711b820 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -1,178 +1,96 @@ -add_compile_definitions("ACPI_DEBUG") -add_compile_definitions("APIC_DEBUG") -add_compile_definitions("APIC_SMP_DEBUG") -add_compile_definitions("ARP_DEBUG") -add_compile_definitions("AWAVLOADER_DEBUG") -add_compile_definitions("BBFS_DEBUG") -add_compile_definitions("BMP_DEBUG") -add_compile_definitions("BXVGA_DEBUG") -add_compile_definitions("CACHE_DEBUG") -add_compile_definitions("CALLBACK_MACHINE_DEBUG") -add_compile_definitions("CHTTPJOB_DEBUG") -add_compile_definitions("CNETWORKJOB_DEBUG") -add_compile_definitions("COMMIT_DEBUG") -add_compile_definitions("COMPOSE_DEBUG") -add_compile_definitions("CONTEXT_SWITCH_DEBUG") -add_compile_definitions("CONTIGUOUS_VMOBJECT_DEBUG") -add_compile_definitions("COPY_DEBUG") -add_compile_definitions("CRYPTO_DEBUG") -add_compile_definitions("CSOCKET_DEBUG") -add_compile_definitions("DEBUG_AUTOCOMPLETE") -add_compile_definitions("DEBUG_CPP_LANGUAGE_SERVER") -add_compile_definitions("DEBUG_CURSOR_TOOL") -add_compile_definitions("DEBUG_DIFF") -add_compile_definitions("DEBUG_FILE_CONTENT") -add_compile_definitions("DEBUG_GZIP") -add_compile_definitions("DEBUG_HIGHLIGHT_FOCUSED_FRAME") -add_compile_definitions("DEBUG_HUNKS") -add_compile_definitions("DEBUG_IO") -add_compile_definitions("DEBUG_ITEM_RECTS") -add_compile_definitions("DEBUG_LOCAL_SOCKET") -add_compile_definitions("DEBUG_MAPPED_FILE") -add_compile_definitions("DEBUG_MARKDOWN") -add_compile_definitions("DEBUG_MENUS") -add_compile_definitions("DEBUG_POLL_SELECT") -add_compile_definitions("DEBUG_SH_LANGUAGE_SERVER") -add_compile_definitions("DEBUG_SPAM") -add_compile_definitions("DEBUG_STRINGIMPL") -add_compile_definitions("DEBUG_SYNTAX_HIGHLIGHTING") -add_compile_definitions("DEBUG_TEXTEDITOR") -add_compile_definitions("DEFERRED_INVOKE_DEBUG") -add_compile_definitions("DHCPV4CLIENT_DEBUG") -add_compile_definitions("DHCPV4_DEBUG") -add_compile_definitions("DOUBLECLICK_DEBUG") -add_compile_definitions("DRAGDROP_DEBUG") -add_compile_definitions("DWARF_DEBUG") -add_compile_definitions("DYNAMIC_LOAD_DEBUG") -add_compile_definitions("E1000_DEBUG") -add_compile_definitions("EBR_DEBUG") -add_compile_definitions("EDITOR_DEBUG") -add_compile_definitions("ELF_IMAGE_DEBUG") -add_compile_definitions("EMOJI_DEBUG") -add_compile_definitions("ETHERNET_DEBUG") -add_compile_definitions("ETHERNET_VERY_DEBUG") -add_compile_definitions("EVENTLOOP_DEBUG") -add_compile_definitions("EVENT_DEBUG") -add_compile_definitions("EXEC_DEBUG") -add_compile_definitions("EXT2_DEBUG") -add_compile_definitions("EXT2_VERY_DEBUG") -add_compile_definitions("FIFO_DEBUG") -add_compile_definitions("FILEDESCRIPTION_DEBUG") -add_compile_definitions("FILL_PATH_DEBUG") -add_compile_definitions("FORK_DEBUG") -add_compile_definitions("FUTEXQUEUE_DEBUG") -add_compile_definitions("FUTEX_DEBUG") -add_compile_definitions("GBOXLAYOUT_DEBUG") -add_compile_definitions("GEMINIJOB_DEBUG") -add_compile_definitions("GEMINI_DEBUG") -add_compile_definitions("GENERATE_DEBUG_CODE") -add_compile_definitions("GHASH_PROCESS_DEBUG") -add_compile_definitions("GIF_DEBUG") -add_compile_definitions("GLOBAL_DTORS_DEBUG") -add_compile_definitions("GMENU_DEBUG") -add_compile_definitions("GPT_DEBUG") -add_compile_definitions("HEAP_DEBUG") -add_compile_definitions("HEX_DEBUG") -add_compile_definitions("HPET_COMPARATOR_DEBUG") -add_compile_definitions("HPET_DEBUG") -add_compile_definitions("HTTPSJOB_DEBUG") -add_compile_definitions("ICMP_DEBUG") -add_compile_definitions("ICO_DEBUG") -add_compile_definitions("IMAGE_DECODER_CLIENT_DEBUG") -add_compile_definitions("IMAGE_DECODER_DEBUG") -add_compile_definitions("IMAGE_LOADER_DEBUG") -add_compile_definitions("INTERRUPT_DEBUG") -add_compile_definitions("IOAPIC_DEBUG") -add_compile_definitions("IPC_DEBUG") -add_compile_definitions("IPV4_DEBUG") -add_compile_definitions("IPV4_SOCKET_DEBUG") -add_compile_definitions("IRC_DEBUG") -add_compile_definitions("IRQ_DEBUG") -add_compile_definitions("JOB_DEBUG") -add_compile_definitions("JPG_DEBUG") -add_compile_definitions("KEYBOARD_DEBUG") -add_compile_definitions("KEYBOARD_SHORTCUTS_DEBUG") -add_compile_definitions("KMALLOC_DEBUG_LARGE_ALLOCATIONS") -add_compile_definitions("LEXER_DEBUG") -add_compile_definitions("LOCK_DEBUG") -add_compile_definitions("LOCK_RESTORE_DEBUG") -add_compile_definitions("LOCK_TRACE_DEBUG") -add_compile_definitions("LOOKUPSERVER_DEBUG") -add_compile_definitions("Loader_DEBUG") -add_compile_definitions("MALLOC_DEBUG") -add_compile_definitions("MASTERPTY_DEBUG") -add_compile_definitions("MBR_DEBUG") -add_compile_definitions("MEMORY_DEBUG") -add_compile_definitions("MENU_DEBUG") -add_compile_definitions("MINIMIZE_ANIMATION_DEBUG") -add_compile_definitions("MOVE_DEBUG") -add_compile_definitions("MULTIPROCESSOR_DEBUG") -add_compile_definitions("NETWORK_TASK_DEBUG") -add_compile_definitions("NT_DEBUG") -add_compile_definitions("OBJECT_DEBUG") -add_compile_definitions("OCCLUSIONS_DEBUG") -add_compile_definitions("OFFD_DEBUG") -add_compile_definitions("PAGE_FAULT_DEBUG") -add_compile_definitions("PARSER_DEBUG") -add_compile_definitions("PATA_DEBUG") -add_compile_definitions("PATA_DEVICE_DEBUG") -add_compile_definitions("PATH_DEBUG") -add_compile_definitions("PCI_DEBUG") -add_compile_definitions("PNG_DEBUG") -add_compile_definitions("PORTABLE_IMAGE_LOADER_DEBUG") -add_compile_definitions("PROCESS_DEBUG") -add_compile_definitions("PROCFS_DEBUG") -add_compile_definitions("PS2MOUSE_DEBUG") -add_compile_definitions("PTHREAD_DEBUG") -add_compile_definitions("PTMX_DEBUG") -add_compile_definitions("REACHABLE_DEBUG") -add_compile_definitions("REGEX_DEBUG") -add_compile_definitions("RESIZE_DEBUG") -add_compile_definitions("RESOURCE_DEBUG") -add_compile_definitions("ROUTING_DEBUG") -add_compile_definitions("RTL8139_DEBUG") -add_compile_definitions("SAFE_SYSCALL_DEBUG") -add_compile_definitions("SB16_DEBUG") -add_compile_definitions("SCHEDULER_DEBUG") -add_compile_definitions("SCHEDULER_RUNNABLE_DEBUG") -add_compile_definitions("SELECTION_DEBUG") -add_compile_definitions("SERVICE_DEBUG") -add_compile_definitions("SH_DEBUG") -add_compile_definitions("SIGNAL_DEBUG") -add_compile_definitions("SLAVEPTY_DEBUG") -add_compile_definitions("SMP_DEBUG") -add_compile_definitions("SOCKET_DEBUG") -add_compile_definitions("STORAGE_DEVICE_DEBUG") -add_compile_definitions("SYSTEMSERVER_DEBUG") -add_compile_definitions("SYSTEM_MENU_DEBUG") -add_compile_definitions("TCP_DEBUG") -add_compile_definitions("TCP_SOCKET_DEBUG") -add_compile_definitions("TERMCAP_DEBUG") -add_compile_definitions("TERMINAL_DEBUG") -add_compile_definitions("THREAD_DEBUG") -add_compile_definitions("TLS_DEBUG") -add_compile_definitions("TTY_DEBUG") -add_compile_definitions("UCI_DEBUG") -add_compile_definitions("UHCI_DEBUG") -add_compile_definitions("UHCI_VERBOSE_DEBUG") -add_compile_definitions("UDP_DEBUG") -add_compile_definitions("UPDATE_COALESCING_DEBUG") -add_compile_definitions("VERY_DEBUG") -add_compile_definitions("VFS_DEBUG") -add_compile_definitions("VMWAREBACKDOOR_DEBUG") -add_compile_definitions("VOLATILE_PAGE_RANGES_DEBUG") -add_compile_definitions("VRA_DEBUG") -add_compile_definitions("WAITBLOCK_DEBUG") -add_compile_definitions("WAITQUEUE_DEBUG") -add_compile_definitions("WEAKABLE_DEBUG") -add_compile_definitions("WINDOWMANAGER_DEBUG") -add_compile_definitions("WSMESSAGELOOP_DEBUG") -add_compile_definitions("DEBUG_SOCKET") -add_compile_definitions("WSSCREEN_DEBUG") -add_compile_definitions("DEBUG_PATH") -# False positive: IF_BMP_DEBUG is not actually a flag. -# add_compile_definitions("IF_BMP_DEBUG") +set(PROCESS_DEBUG ON) +set(SCHEDULER_DEBUG ON) +set(SCHEDULER_RUNNABLE_DEBUG ON) +set(THREAD_DEBUG ON) +set(LOCK_DEBUG ON) +set(SIGNAL_DEBUG ON) +set(BMP_DEBUG ON) +set(WAITBLOCK_DEBUG ON) +set(WAITQUEUE_DEBUG ON) +set(MULTIPROCESSOR_DEBUG ON) +set(ACPI_DEBUG ON) +set(PAGE_FAULT_DEBUG ON) +set(CONTEXT_SWITCH_DEBUG ON) +set(SMP_DEBUG ON) +set(BXVGA_DEBUG ON) +set(PS2MOUSE_DEBUG ON) +set(VMWARE_BACKDOOR_DEBUG ON) +set(FILEDESCRIPTION_DEBUG ON) +set(PROCFS_DEBUG ON) +set(VFS_DEBUG ON) +set(IOAPIC_DEBUG ON) +set(IRQ_DEBUG ON) +set(INTERRUPT_DEBUG ON) +set(E1000_DEBUG ON) +set(IPV4_SOCKET_DEBUG ON) +set(LOCAL_SOCKET_DEBUG ON) +set(SOCKET_DEBUG ON) +set(TCP_SOCKET_DEBUG ON) +set(PCI_DEBUG ON) +set(PATA_DEBUG ON) +set(IO_DEBUG ON) +set(FORK_DEBUG ON) +set(POLL_SELECT_DEBUG ON) +set(HPET_DEBUG ON) +set(HPET_COMPARATOR_DEBUG ON) +set(MASTERPTY_DEBUG ON) +set(SLAVEPTY_DEBUG ON) +set(PTMX_DEBUG ON) +set(TTY_DEBUG ON) +set(CONTIGUOUS_VMOBJECT_DEBUG ON) +set(VRA_DEBUG ON) +set(COPY_DEBUG ON) +set(CURSOR_TOOL_DEBUG ON) +set(FILE_CONTENT_DEBUG ON) +set(GZIP_DEBUG ON) +set(CNETWORKJOB_DEBUG ON) +set(CSOCKET_DEBUG ON) +set(SAFE_SYSCALL_DEBUG ON) +set(GHASH_PROCESS_DEBUG ON) +set(NT_DEBUG ON) +set(CRYPTO_DEBUG ON) +set(DWARF_DEBUG ON) +set(HUNKS_DEBUG ON) +set(JOB_DEBUG ON) +set(GIF_DEBUG ON) +set(JPG_DEBUG ON) +set(EMOJI_DEBUG ON) +set(FILL_PATH_DEBUG ON) +set(PNG_DEBUG ON) +set(PORTABLE_IMAGE_LOADER_DEBUG ON) +set(SYNTAX_HIGHLIGHTING_DEBUG ON) +set(KEYBOARD_SHORTCUTS_DEBUG ON) +set(MARKDOWN_DEBUG ON) +set(REGEX_DEBUG ON) +set(TLS_DEBUG ON) +set(SPAM_DEBUG ON) +set(PARSER_DEBUG ON) +set(TOKENIZER_TRACE_DEBUG ON) +set(IMAGE_LOADER_DEBUG ON) +set(RESOURCE_DEBUG ON) +set(CACHE_DEBUG ON) +set(DHCPV4_DEBUG ON) +set(DHCPV4CLIENT_DEBUG ON) +set(IMAGE_DECODER_DEBUG ON) +set(SYSTEM_MENU_DEBUG ON) +set(SYSTEMSERVER_DEBUG ON) +set(SERVICE_DEBUG ON) +set(COMPOSE_DEBUG ON) +set(MINIMIZE_ANIMATION_DEBUG ON) +set(OCCLUSIONS_DEBUG ON) +set(MENUS_DEBUG ON) +set(WSSCREEN_DEBUG ON) +set(WINDOWMANAGER_DEBUG ON) +set(RESIZE_DEBUG ON) +set(MOVE_DEBUG ON) +set(DOUBLECLICK_DEBUG ON) +set(DISASM_DUMP_DEBUG ON) +set(PATH_DEBUG ON) +set(LOCK_TRACE_DEBUG ON) +set(LOCK_RESTORE_DEBUG ON) +set(FUTEXQUEUE_DEBUG ON) +set(FUTEX_DEBUG ON) # False positive: LOG_DEBUG is a flag, but for a bitset, not a feature. -# add_compile_definitions("LOG_DEBUG") +# add_compile_definitions("LOG_DEBUG=ON") # Clogs up build: The WrapperGenerator stuff is run at compile time. -# add_compile_definitions("WRAPPER_GERNERATOR_DEBUG") +# add_compile_definitions("WRAPPER_GERNERATOR_DEBUG=ON") diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index c98f73456f..5a1d1059e7 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -77,9 +77,15 @@ set(LAGOM_REGEX_SOURCES ${LIBREGEX_LIBC_SOURCES} ${LIBREGEX_SOURCES}) set(LAGOM_CORE_SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES}) set(LAGOM_MORE_SOURCES ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBTTF_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBGUI_GML_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${SHELL_SOURCES}) -include_directories (../../) -include_directories (../../Userland/) -include_directories (../../Userland/Libraries/) +# FIXME: This is a hack, because the lagom stuff can be build individually or +# in combination with the system, we generate two Debug.h files. One in +# Build/AK/Debug.h and the other in Build/Meta/Lagom/AK/Debug.h. +configure_file(../../AK/Debug.h.in AK/Debug.h @ONLY) + +include_directories(../../) +include_directories(../../Userland/) +include_directories(../../Userland/Libraries/) +include_directories(${CMAKE_BINARY_DIR}) add_library(LagomCore ${LAGOM_CORE_SOURCES}) if (BUILD_LAGOM) diff --git a/Userland/DevTools/HackStudio/CursorTool.cpp b/Userland/DevTools/HackStudio/CursorTool.cpp index aed955e888..15fbce04d9 100644 --- a/Userland/DevTools/HackStudio/CursorTool.cpp +++ b/Userland/DevTools/HackStudio/CursorTool.cpp @@ -36,7 +36,7 @@ namespace HackStudio { void CursorTool::on_mousedown(GUI::MouseEvent& event) { -#ifdef DEBUG_CURSOR_TOOL +#if DEBUG_CURSOR_TOOL dbgln("CursorTool::on_mousedown"); #endif auto& form_widget = m_editor.form_widget(); @@ -73,7 +73,7 @@ void CursorTool::on_mousedown(GUI::MouseEvent& event) void CursorTool::on_mouseup(GUI::MouseEvent& event) { -#ifdef DEBUG_CURSOR_TOOL +#if DEBUG_CURSOR_TOOL dbgln("CursorTool::on_mouseup"); #endif if (event.button() == GUI::MouseButton::Left) { @@ -94,7 +94,7 @@ void CursorTool::on_mouseup(GUI::MouseEvent& event) void CursorTool::on_mousemove(GUI::MouseEvent& event) { -#ifdef DEBUG_CURSOR_TOOL +#if DEBUG_CURSOR_TOOL dbgln("CursorTool::on_mousemove"); #endif auto& form_widget = m_editor.form_widget(); @@ -133,7 +133,7 @@ void CursorTool::on_mousemove(GUI::MouseEvent& event) void CursorTool::on_keydown(GUI::KeyEvent& event) { -#ifdef DEBUG_CURSOR_TOOL +#if DEBUG_CURSOR_TOOL dbgln("CursorTool::on_keydown"); #endif diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp index ec61984e54..0f1eb1d228 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp @@ -104,7 +104,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText } GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() }; document->insert_at(start_position, message.text(), &s_default_document_client); -#ifdef DEBUG_FILE_CONTENT +#if DEBUG_FILE_CONTENT dbgln("{}", document->text()); #endif } @@ -129,7 +129,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText }; document->remove(range); -#ifdef DEBUG_FILE_CONTENT +#if DEBUG_FILE_CONTENT dbgln("{}", document->text()); #endif } diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.cpp b/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.cpp index cf71dc2134..93b2b11a65 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.cpp @@ -104,7 +104,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText } GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() }; document->insert_at(start_position, message.text(), &s_default_document_client); -#ifdef DEBUG_FILE_CONTENT +#if DEBUG_FILE_CONTENT dbgln("{}", document->text()); #endif } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 3c88b1bdd5..f9f0a04eab 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -28,6 +28,7 @@ #include "MmapRegion.h" #include "SimpleRegion.h" #include "SoftCPU.h" +#include #include #include #include @@ -59,8 +60,6 @@ # pragma GCC optimize("O3") #endif -// #define DEBUG_SPAM - namespace UserspaceEmulator { static constexpr u32 stack_location = 0x10000000; @@ -344,7 +343,7 @@ void Emulator::dump_backtrace() u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function); #endif switch (function) { diff --git a/Userland/Libraries/LibCore/Gzip.cpp b/Userland/Libraries/LibCore/Gzip.cpp index afa2bb6319..a2fc706cc1 100644 --- a/Userland/Libraries/LibCore/Gzip.cpp +++ b/Userland/Libraries/LibCore/Gzip.cpp @@ -52,7 +52,7 @@ static Optional get_gzip_payload(const ByteBuffer& data) return data[current++]; }; -#ifdef DEBUG_GZIP +#if DEBUG_GZIP dbgln("get_gzip_payload: Skipping over gzip header."); #endif @@ -135,7 +135,7 @@ Optional Gzip::decompress(const ByteBuffer& data) source.data(), &source_len); if (puff_ret == 0) { -#ifdef DEBUG_GZIP +#if DEBUG_GZIP dbgln("Gzip::decompress: Decompression success."); #endif destination.trim(destination_len); @@ -144,7 +144,7 @@ Optional Gzip::decompress(const ByteBuffer& data) if (puff_ret == 1) { // FIXME: Find a better way of decompressing without needing to try over and over again. -#ifdef DEBUG_GZIP +#if DEBUG_GZIP dbgln("Gzip::decompress: Output buffer exhausted. Growing."); #endif destination.grow(destination.size() * 2); diff --git a/Userland/Libraries/LibCore/NetworkJob.cpp b/Userland/Libraries/LibCore/NetworkJob.cpp index 1c981e3ad9..8a9827d94d 100644 --- a/Userland/Libraries/LibCore/NetworkJob.cpp +++ b/Userland/Libraries/LibCore/NetworkJob.cpp @@ -68,7 +68,7 @@ void NetworkJob::did_fail(Error error) NonnullRefPtr protector(*this); m_error = error; -#ifdef CNETWORKJOB_DEBUG +#if CNETWORKJOB_DEBUG dbgprintf("%s{%p} job did_fail! error: %u (%s)\n", class_name(), this, (unsigned)error, to_string(error)); #endif ASSERT(on_finish); diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp index 71f16d284e..c939bfb6c5 100644 --- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp +++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp @@ -221,7 +221,7 @@ UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b) GCD_without_allocation(a, b, temp_a, temp_b, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder, gcd_output); if (gcd_output == 0) { -#ifdef NT_DEBUG +#if NT_DEBUG dbgln("GCD is zero"); #endif return output; diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index 0cc00b6284..04285c7c5d 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -25,6 +25,7 @@ */ #include "DebugInfo.h" +#include #include #include #include @@ -32,8 +33,6 @@ #include #include -//#define DEBUG_SPAM - namespace Debug { DebugInfo::DebugInfo(NonnullOwnPtr elf, String source_root, FlatPtr base_address) @@ -63,13 +62,13 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die) return; if (child.get_attribute(Dwarf::Attribute::Inline).has_value()) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM dbgln("DWARF inlined functions are not supported"); #endif return; } if (child.get_attribute(Dwarf::Attribute::Ranges).has_value()) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM dbgln("DWARF ranges are not supported"); #endif return; @@ -82,7 +81,7 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die) scope.name = name.value().data.as_string; if (!child.get_attribute(Dwarf::Attribute::LowPc).has_value()) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM dbgln("DWARF: Couldn't find attribute LowPc for scope"); #endif return; diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp index 180c0f7c95..9dab951d2f 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp @@ -48,7 +48,7 @@ void LineProgram::parse_unit_header() ASSERT(m_unit_header.version == DWARF_VERSION); ASSERT(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE); -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("unit length: {}", m_unit_header.length); #endif } @@ -60,7 +60,7 @@ void LineProgram::parse_source_directories() while (m_stream.peek_or_error()) { String directory; m_stream >> directory; -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("directory: {}", directory); #endif m_source_directories.append(move(directory)); @@ -81,7 +81,7 @@ void LineProgram::parse_source_files() size_t _unused = 0; m_stream.read_LEB128_unsigned(_unused); // skip modification time m_stream.read_LEB128_unsigned(_unused); // skip file size -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("file: {}, directory index: {}", file_name, directory_index); #endif m_source_files.append({ file_name, directory_index }); @@ -92,7 +92,7 @@ void LineProgram::parse_source_files() void LineProgram::append_to_line_info() { -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("appending line info: {:p}, {}:{}", m_address, m_source_files[m_file_index].name, m_line); #endif if (!m_is_statement) @@ -133,20 +133,20 @@ void LineProgram::handle_extended_opcode() case ExtendedOpcodes::SetAddress: { ASSERT(length == sizeof(size_t) + 1); m_stream >> m_address; -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("SetAddress: {:p}", m_address); #endif break; } case ExtendedOpcodes::SetDiscriminator: { -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("SetDiscriminator"); #endif m_stream.discard_or_error(1); break; } default: -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("offset: {:p}", m_stream.offset()); #endif ASSERT_NOT_REACHED(); @@ -163,7 +163,7 @@ void LineProgram::handle_standard_opcode(u8 opcode) size_t operand = 0; m_stream.read_LEB128_unsigned(operand); size_t delta = operand * m_unit_header.min_instruction_length; -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("AdvancePC by: {} to: {:p}", delta, m_address + delta); #endif m_address += delta; @@ -172,7 +172,7 @@ void LineProgram::handle_standard_opcode(u8 opcode) case StandardOpcodes::SetFile: { size_t new_file_index = 0; m_stream.read_LEB128_unsigned(new_file_index); -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("SetFile: new file index: {}", new_file_index); #endif m_file_index = new_file_index; @@ -180,7 +180,7 @@ void LineProgram::handle_standard_opcode(u8 opcode) } case StandardOpcodes::SetColumn: { // not implemented -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("SetColumn"); #endif size_t new_column; @@ -193,13 +193,13 @@ void LineProgram::handle_standard_opcode(u8 opcode) m_stream.read_LEB128_signed(line_delta); ASSERT(line_delta >= 0 || m_line >= (size_t)(-line_delta)); m_line += line_delta; -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("AdvanceLine: {}", m_line); #endif break; } case StandardOpcodes::NegateStatement: { -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("NegateStatement"); #endif m_is_statement = !m_is_statement; @@ -209,7 +209,7 @@ void LineProgram::handle_standard_opcode(u8 opcode) u8 adjusted_opcode = 255 - SPECIAL_OPCODES_BASE; ssize_t address_increment = (adjusted_opcode / m_unit_header.line_range) * m_unit_header.min_instruction_length; address_increment *= m_unit_header.min_instruction_length; -#ifdef DWARF_DEBUG +#if DWARF_DEBUG dbgln("ConstAddPc: advance pc by: {} to: {}", address_increment, (m_address + address_increment)); #endif m_address += address_increment; diff --git a/Userland/Libraries/LibGemini/Job.cpp b/Userland/Libraries/LibGemini/Job.cpp index ee75cdc742..5cad2399f9 100644 --- a/Userland/Libraries/LibGemini/Job.cpp +++ b/Userland/Libraries/LibGemini/Job.cpp @@ -152,7 +152,7 @@ void Job::on_socket_connected() }); if (!is_established()) { -#ifdef JOB_DEBUG +#if JOB_DEBUG dbgln("Connection appears to have closed, finishing up"); #endif finish_up(); diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp index 1e625986e9..0418244d93 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/GIFLoader.cpp @@ -355,7 +355,7 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index) while (true) { Optional code = decoder.next_code(); if (!code.has_value()) { -#ifdef GIF_DEBUG +#if GIF_DEBUG dbgln("Unexpectedly reached end of gif frame data"); #endif return false; @@ -504,7 +504,7 @@ static bool load_gif_frame_descriptors(GIFLoadingContext& context) if (extension_type == 0xF9) { if (sub_block.size() != 4) { -#ifdef GIF_DEBUG +#if GIF_DEBUG dbgln("Unexpected graphic control size"); #endif continue; diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index 8994b3c26d..33f03daeeb 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -267,7 +267,7 @@ static Optional get_next_symbol(HuffmanStreamState& hstream, const HuffmanTa } } -#ifdef JPG_DEBUG +#if JPG_DEBUG dbgln("If you're seeing this...the jpeg decoder needs to support more kinds of JPEGs!"); #endif return {}; diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index fd0b32fdd0..868cf1f0ab 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -526,7 +526,7 @@ static bool decode_png_header(PNGLoadingContext& context) return true; if (!context.data || context.data_size < sizeof(png_header)) { -#ifdef PNG_DEBUG +#if PNG_DEBUG dbgln("Missing PNG header"); #endif context.state = PNGLoadingContext::State::Error; @@ -534,7 +534,7 @@ static bool decode_png_header(PNGLoadingContext& context) } if (memcmp(context.data, png_header, sizeof(png_header)) != 0) { -#ifdef PNG_DEBUG +#if PNG_DEBUG dbgln("Invalid PNG header"); #endif context.state = PNGLoadingContext::State::Error; @@ -874,7 +874,7 @@ static bool process_IHDR(ReadonlyBytes data, PNGLoadingContext& context) context.filter_method = ihdr.filter_method; context.interlace_method = ihdr.interlace_method; -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("PNG: %dx%d (%d bpp)\n", context.width, context.height, context.bit_depth); printf(" Color type: %d\n", context.color_type); printf("Compress Method: %d\n", context.compression_method); @@ -883,7 +883,7 @@ static bool process_IHDR(ReadonlyBytes data, PNGLoadingContext& context) #endif if (context.interlace_method != PngInterlaceMethod::Null && context.interlace_method != PngInterlaceMethod::Adam7) { -#ifdef PNG_DEBUG +#if PNG_DEBUG dbgln("PNGLoader::process_IHDR: unknown interlace method: {}", context.interlace_method); #endif return false; @@ -947,7 +947,7 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context) { u32 chunk_size; if (!streamer.read(chunk_size)) { -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("Bail at chunk_size\n"); #endif return false; @@ -955,26 +955,26 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context) u8 chunk_type[5]; chunk_type[4] = '\0'; if (!streamer.read_bytes(chunk_type, 4)) { -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("Bail at chunk_type\n"); #endif return false; } ReadonlyBytes chunk_data; if (!streamer.wrap_bytes(chunk_data, chunk_size)) { -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("Bail at chunk_data\n"); #endif return false; } u32 chunk_crc; if (!streamer.read(chunk_crc)) { -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("Bail at chunk_crc\n"); #endif return false; } -#ifdef PNG_DEBUG +#if PNG_DEBUG printf("Chunk type: '%s', size: %u, crc: %x\n", chunk_type, chunk_size, chunk_crc); #endif diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index e98cec2c8a..89dc36b6e9 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1620,7 +1620,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule) quick_sort(active_list, [](const auto& line0, const auto& line1) { return line1.x < line0.x; }); -#ifdef FILL_PATH_DEBUG +#if FILL_PATH_DEBUG if ((int)scanline % 10 == 0) { draw_text(IntRect(active_list.last().x - 20, scanline, 20, 10), String::number((int)scanline)); } @@ -1692,7 +1692,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule) } } -#ifdef FILL_PATH_DEBUG +#if FILL_PATH_DEBUG size_t i { 0 }; for (auto& segment : segments) { draw_line(Point(segment.from), Point(segment.to), Color::from_hsv(i++ * 360.0 / segments.size(), 1.0, 1.0), 1); diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 707cd3efbd..0c69848dab 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -331,7 +331,7 @@ void Job::on_socket_connected() }); if (!is_established()) { -#ifdef JOB_DEBUG +#if JOB_DEBUG dbgln("Connection appears to have closed, finishing up"); #endif finish_up(); diff --git a/Userland/Libraries/LibMarkdown/Text.cpp b/Userland/Libraries/LibMarkdown/Text.cpp index 9361e05d60..21d167874a 100644 --- a/Userland/Libraries/LibMarkdown/Text.cpp +++ b/Userland/Libraries/LibMarkdown/Text.cpp @@ -24,13 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include #include -//#define DEBUG_MARKDOWN - namespace Markdown { static String unescape(const StringView& text) @@ -243,7 +242,7 @@ Optional Text::parse(const StringView& str) current_link_is_actually_img = true; break; case '[': -#ifdef DEBUG_MARKDOWN +#if DEBUG_MARKDOWN if (first_span_in_the_current_link != -1) dbgln("Dropping the outer link"); #endif @@ -251,7 +250,7 @@ Optional Text::parse(const StringView& str) break; case ']': { if (first_span_in_the_current_link == -1) { -#ifdef DEBUG_MARKDOWN +#if DEBUG_MARKDOWN dbgln("Unmatched ]"); #endif continue; diff --git a/Userland/Libraries/LibRegex/RegexDebug.h b/Userland/Libraries/LibRegex/RegexDebug.h index c90c587d29..5b48fc8a2d 100644 --- a/Userland/Libraries/LibRegex/RegexDebug.h +++ b/Userland/Libraries/LibRegex/RegexDebug.h @@ -28,10 +28,9 @@ #include "AK/StringBuilder.h" #include "LibRegex/RegexMatcher.h" +#include -//#define REGEX_DEBUG - -#ifdef REGEX_DEBUG +#if REGEX_DEBUG namespace regex { diff --git a/Userland/Libraries/LibRegex/RegexLexer.cpp b/Userland/Libraries/LibRegex/RegexLexer.cpp index c7e154e307..e61708a4c4 100644 --- a/Userland/Libraries/LibRegex/RegexLexer.cpp +++ b/Userland/Libraries/LibRegex/RegexLexer.cpp @@ -26,6 +26,7 @@ #include "RegexLexer.h" #include +#include #include #include @@ -150,7 +151,7 @@ Token Lexer::next() case '\\': return 2; default: -#ifdef REGEX_DEBUG +#if REGEX_DEBUG fprintf(stderr, "[LEXER] Found invalid escape sequence: \\%c (the parser will have to deal with this!)\n", peek(1)); #endif return 0; diff --git a/Userland/Libraries/LibRegex/RegexMatcher.cpp b/Userland/Libraries/LibRegex/RegexMatcher.cpp index 14c461fbb4..cadc74fece 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.cpp +++ b/Userland/Libraries/LibRegex/RegexMatcher.cpp @@ -34,7 +34,7 @@ namespace regex { -#ifdef REGEX_DEBUG +#if REGEX_DEBUG static RegexDebug s_regex_dbg(stderr); #endif @@ -138,7 +138,7 @@ RegexResult Matcher::match(const Vector views, Optional } }; -#ifdef REGEX_DEBUG +#if REGEX_DEBUG s_regex_dbg.print_header(); #endif @@ -314,7 +314,7 @@ Optional Matcher::execute(const MatchInput& input, MatchState& sta return {}; } -#ifdef REGEX_DEBUG +#if REGEX_DEBUG s_regex_dbg.print_opcode("VM", *opcode, state, recursion_level, false); #endif @@ -326,7 +326,7 @@ Optional Matcher::execute(const MatchInput& input, MatchState& sta result = opcode->execute(input, state, output); } -#ifdef REGEX_DEBUG +#if REGEX_DEBUG s_regex_dbg.print_result(*opcode, bytecode, input, state, result); #endif @@ -369,14 +369,14 @@ ALWAYS_INLINE Optional Matcher::execute_low_prio_forks(const Match for (auto& state : states) { state.instruction_position = state.fork_at_position; -#ifdef REGEX_DEBUG +#if REGEX_DEBUG fprintf(stderr, "Forkstay... ip = %lu, sp = %lu\n", state.instruction_position, state.string_position); #endif auto success = execute(input, state, output, recursion_level); if (!success.has_value()) return {}; if (success.value()) { -#ifdef REGEX_DEBUG +#if REGEX_DEBUG fprintf(stderr, "Forkstay succeeded... ip = %lu, sp = %lu\n", state.instruction_position, state.string_position); #endif original_state = state; diff --git a/Userland/Libraries/LibRegex/RegexParser.cpp b/Userland/Libraries/LibRegex/RegexParser.cpp index ba82b3f9d8..6ed5e2e217 100644 --- a/Userland/Libraries/LibRegex/RegexParser.cpp +++ b/Userland/Libraries/LibRegex/RegexParser.cpp @@ -141,7 +141,7 @@ Parser::Result Parser::parse(Optional regex_options) else set_error(Error::InvalidPattern); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG fprintf(stderr, "[PARSER] Produced bytecode with %lu entries (opcodes + arguments)\n", m_parser_state.bytecode.size()); #endif return { @@ -454,7 +454,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si if (match(TokenType::EscapeSequence)) { length = 1; Token t = consume(); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG printf("[PARSER] EscapeSequence with substring %s\n", String(t.value()).characters()); #endif diff --git a/Userland/Libraries/LibRegex/Tests/Regex.cpp b/Userland/Libraries/LibRegex/Tests/Regex.cpp index fc920140d0..ffd585e8d3 100644 --- a/Userland/Libraries/LibRegex/Tests/Regex.cpp +++ b/Userland/Libraries/LibRegex/Tests/Regex.cpp @@ -376,7 +376,7 @@ TEST_CASE(ini_file_entries) Regex re("[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]"); RegexResult result; -#ifdef REGEX_DEBUG +#if REGEX_DEBUG RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); regex_dbg.print_header(); @@ -387,7 +387,7 @@ TEST_CASE(ini_file_entries) EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true); EXPECT_EQ(result.count, 3u); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG for (auto& v : result.matches) fprintf(stderr, "%s\n", v.view.to_string().characters()); #endif @@ -425,7 +425,7 @@ TEST_CASE(named_capture_group) Regex re("[[:alpha:]]*=(?[[:digit:]]*)"); RegexResult result; -#ifdef REGEX_DEBUG +#if REGEX_DEBUG RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); regex_dbg.print_header(); @@ -446,7 +446,7 @@ TEST_CASE(a_star) Regex re("a*"); RegexResult result; -#ifdef REGEX_DEBUG +#if REGEX_DEBUG RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); regex_dbg.print_header(); @@ -506,7 +506,7 @@ TEST_CASE(ECMA262_parse) for (auto& test : tests) { Regex re(test.pattern); EXPECT_EQ(re.parser_result.error, test.expected_error); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG dbgln("\n"); RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); @@ -551,7 +551,7 @@ TEST_CASE(ECMA262_match) for (auto& test : tests) { Regex re(test.pattern, test.options); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG dbgln("\n"); RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); @@ -584,7 +584,7 @@ TEST_CASE(replace) for (auto& test : tests) { Regex re(test.pattern, test.options); -#ifdef REGEX_DEBUG +#if REGEX_DEBUG dbgln("\n"); RegexDebug regex_dbg(stderr); regex_dbg.print_raw_bytecode(re); diff --git a/Userland/Libraries/LibTLS/ClientHandshake.cpp b/Userland/Libraries/LibTLS/ClientHandshake.cpp index ddd754e785..99ebc72822 100644 --- a/Userland/Libraries/LibTLS/ClientHandshake.cpp +++ b/Userland/Libraries/LibTLS/ClientHandshake.cpp @@ -91,7 +91,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe if (session_length && session_length <= 32) { memcpy(m_context.session_id, buffer.offset_pointer(res), session_length); m_context.session_id_size = session_length; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("Remote session ID:"); print_buffer(ReadonlyBytes { m_context.session_id, session_length }); #endif @@ -228,7 +228,7 @@ ssize_t TLSv12::handle_finished(ReadonlyBytes buffer, WritePacketStage& write_pa } // TODO: Compare Hashes -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("FIXME: handle_finished :: Check message validity"); #endif m_context.connection_status = ConnectionStatus::Established; @@ -276,7 +276,7 @@ void TLSv12::build_random(PacketBuilder& builder) } auto& certificate = m_context.certificates[certificate_option.value()]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("PreMaster secret"); print_buffer(m_context.premaster_key); #endif @@ -287,7 +287,7 @@ void TLSv12::build_random(PacketBuilder& builder) auto outbuf = Bytes { out, rsa.output_size() }; rsa.encrypt(m_context.premaster_key, outbuf); -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("Encrypted: "); print_buffer(outbuf); #endif @@ -305,7 +305,7 @@ void TLSv12::build_random(PacketBuilder& builder) ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) { if (m_context.connection_status == ConnectionStatus::Established) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("Renegotiation attempt ignored"); #endif // FIXME: We should properly say "NoRenegotiation", but that causes a handshake failure @@ -359,7 +359,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[2]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("server hello"); #endif if (m_context.is_server) { @@ -380,7 +380,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[4]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("certificate"); #endif if (m_context.connection_status == ConnectionStatus::Negotiating) { @@ -415,7 +415,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[5]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("server key exchange"); #endif if (m_context.is_server) { @@ -451,7 +451,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[7]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("server hello done"); #endif if (m_context.is_server) { @@ -470,7 +470,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[8]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("certificate verify"); #endif if (m_context.connection_status == ConnectionStatus::KeyExchange) { @@ -486,7 +486,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[9]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("client key exchange"); #endif if (m_context.is_server) { @@ -506,7 +506,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; } ++m_context.handshake_messages[10]; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("finished"); #endif payload_res = handle_finished(buffer.slice(1, payload_size), write_packets); @@ -593,7 +593,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) break; case WritePacketStage::ClientHandshake: if (m_context.client_verified == VerificationNeeded) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> Client Certificate"); #endif auto packet = build_certificate(); @@ -601,14 +601,14 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) m_context.client_verified = Verified; } { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> Key exchange"); #endif auto packet = build_client_key_exchange(); write_packet(packet); } { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> change cipher spec"); #endif auto packet = build_change_cipher_spec(); @@ -617,7 +617,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) m_context.cipher_spec_set = 1; m_context.local_sequence_number = 0; { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> client finished"); #endif auto packet = build_finished(); @@ -633,14 +633,14 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) case WritePacketStage::Finished: // finished { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> change cipher spec"); #endif auto packet = build_change_cipher_spec(); write_packet(packet); } { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("> client finished"); #endif auto packet = build_finished(); diff --git a/Userland/Libraries/LibTLS/Exchange.cpp b/Userland/Libraries/LibTLS/Exchange.cpp index de10d568af..9f3ea55eb9 100644 --- a/Userland/Libraries/LibTLS/Exchange.cpp +++ b/Userland/Libraries/LibTLS/Exchange.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -72,7 +73,7 @@ bool TLSv12::expand_key() auto server_iv = key + offset; offset += iv_size; -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("client key"); print_buffer(client_key, key_size); dbgln("server key"); @@ -171,7 +172,7 @@ bool TLSv12::compute_master_secret(size_t length) ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) }); m_context.premaster_key.clear(); -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("master key:"); print_buffer(m_context.master_key); #endif @@ -213,7 +214,7 @@ ByteBuffer TLSv12::build_certificate() builder.append((u8)HandshakeType::CertificateMessage); if (!total_certificate_size) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("No certificates, sending empty certificate message"); #endif builder.append_u24(certificate_vector_header_size); diff --git a/Userland/Libraries/LibTLS/Record.cpp b/Userland/Libraries/LibTLS/Record.cpp index 1850e03818..5cdb816fa9 100644 --- a/Userland/Libraries/LibTLS/Record.cpp +++ b/Userland/Libraries/LibTLS/Record.cpp @@ -200,7 +200,7 @@ ByteBuffer TLSv12::hmac_message(const ReadonlyBytes& buf, const Optional 4 || octets > size - position) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("could not read the certificate"); #endif return position; @@ -216,7 +216,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8* position += octets; if (size - position < length) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("not enough data for sequence"); #endif return (i8)Error::NeedMoreData; @@ -415,7 +415,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8* auto fingerprint = hash.digest(); cert.fingerprint.grow(fingerprint.data_length()); cert.fingerprint.overwrite(0, fingerprint.immutable_data(), fingerprint.data_length()); -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("Certificate fingerprint:"); print_buffer(cert.fingerprint); #endif @@ -446,7 +446,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer) ssize_t res = 0; if (buffer.size() < 3) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("not enough certificate header data"); #endif return (i8)Error::NeedMoreData; @@ -462,7 +462,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer) res += 3; if (certificate_total_length > buffer.size() - res) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("not enough data for claimed total cert length"); #endif return (i8)Error::NeedMoreData; @@ -475,7 +475,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer) while (size > 0) { ++index; if (buffer.size() - res < 3) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("not enough data for certificate length"); #endif return (i8)Error::NeedMoreData; @@ -484,7 +484,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer) res += 3; if (buffer.size() - res < certificate_size) { -#ifdef TLS_DEBUG +#if TLS_DEBUG dbgln("not enough data for certificate body"); #endif return (i8)Error::NeedMoreData; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp index 28213ffe62..2ea70af30c 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp @@ -36,7 +36,7 @@ namespace Web::HTML { #pragma GCC diagnostic ignored "-Wunused-label" -#ifdef TOKENIZER_TRACE +#if TOKENIZER_TRACE # define PARSE_ERROR() \ do { \ dbgln("Parse error (tokenization) {} @ {}", __PRETTY_FUNCTION__, __LINE__) \ diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp index be5f38a5fd..666654a05f 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -94,7 +94,7 @@ void Resource::did_load(Badge, ReadonlyBytes data, const HashMap auto content_type = headers.get("Content-Type"); if (content_type.has_value()) { -#ifdef RESOURCE_DEBUG +#if RESOURCE_DEBUG dbgln("Content-Type header: '{}'", content_type.value()); #endif m_encoding = encoding_from_content_type(content_type.value()); @@ -104,7 +104,7 @@ void Resource::did_load(Badge, ReadonlyBytes data, const HashMap m_encoding = "utf-8"; // FIXME: This doesn't seem nice. m_mime_type = url().data_mime_type(); } else { -#ifdef RESOURCE_DEBUG +#if RESOURCE_DEBUG dbgln("No Content-Type header to go on! Guessing based on filename..."); #endif m_encoding = "utf-8"; // FIXME: This doesn't seem nice. diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index c98418e1ef..4a4a56085d 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -64,7 +64,7 @@ void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateCon void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelection&) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM dbgln("handle: WebContentClient::DidChangeSelection!"); #endif m_view.notify_server_did_change_selection({}); @@ -96,7 +96,7 @@ void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& me void WebContentClient::handle(const Messages::WebContentClient::DidUnhoverLink&) { -#ifdef DEBUG_SPAM +#if DEBUG_SPAM dbgln("handle: WebContentClient::DidUnhoverLink!"); #endif m_view.notify_server_did_unhover_link({}); diff --git a/Userland/Services/ImageDecoder/ClientConnection.cpp b/Userland/Services/ImageDecoder/ClientConnection.cpp index e6cb73cbfb..9b7115c0e2 100644 --- a/Userland/Services/ImageDecoder/ClientConnection.cpp +++ b/Userland/Services/ImageDecoder/ClientConnection.cpp @@ -61,7 +61,7 @@ OwnPtr ClientConnection::hand { auto encoded_buffer = message.data(); if (!encoded_buffer.is_valid()) { -#ifdef IMAGE_DECODER_DEBUG +#if IMAGE_DECODER_DEBUG dbgln("Encoded data is invalid"); #endif return {}; @@ -71,7 +71,7 @@ OwnPtr ClientConnection::hand auto bitmap = decoder->bitmap(); if (!bitmap) { -#ifdef IMAGE_DECODER_DEBUG +#if IMAGE_DECODER_DEBUG dbgln("Could not decode image from encoded data"); #endif return make(Gfx::ShareableBitmap()); diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 38156ac218..b9beeaec47 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -863,7 +863,7 @@ void Compositor::recompute_occlusions() return IterationDecision::Continue; }); -#ifdef OCCLUSIONS_DEBUG +#if OCCLUSIONS_DEBUG dbgln("OCCLUSIONS:"); #endif diff --git a/Userland/Services/WindowServer/Screen.cpp b/Userland/Services/WindowServer/Screen.cpp index dac462cc52..a10ab03d60 100644 --- a/Userland/Services/WindowServer/Screen.cpp +++ b/Userland/Services/WindowServer/Screen.cpp @@ -144,12 +144,12 @@ void Screen::on_receive_mouse_data(const MousePacket& packet) auto prev_location = m_physical_cursor_location / m_scale_factor; if (packet.is_relative) { m_physical_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor); -#ifdef WSSCREEN_DEBUG +#if WSSCREEN_DEBUG dbgln("Screen: New Relative mouse point @ {}", m_physical_cursor_location); #endif } else { m_physical_cursor_location = { packet.x * physical_width() / 0xffff, packet.y * physical_height() / 0xffff }; -#ifdef WSSCREEN_DEBUG +#if WSSCREEN_DEBUG dbgln("Screen: New Absolute mouse point @ {}", m_physical_cursor_location); #endif }