1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:28:11 +00:00

Everywhere: Debug macros instead of constexpr.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
This commit is contained in:
asynts 2021-01-23 23:59:27 +01:00 committed by Andreas Kling
parent bb483f7ef4
commit 8465683dcf
98 changed files with 414 additions and 972 deletions

View file

@ -42,7 +42,7 @@
#cmakedefine01 SMP_DEBUG #cmakedefine01 SMP_DEBUG
#cmakedefine01 BXVGA_DEBUG #cmakedefine01 BXVGA_DEBUG
#cmakedefine01 PS2MOUSE_DEBUG #cmakedefine01 PS2MOUSE_DEBUG
#cmakedefine01 VMWAREBACKDOOR_DEBUG #cmakedefine01 VMWARE_BACKDOOR_DEBUG
#cmakedefine01 FILEDESCRIPTION_DEBUG #cmakedefine01 FILEDESCRIPTION_DEBUG
#cmakedefine01 PROCFS_DEBUG #cmakedefine01 PROCFS_DEBUG
#cmakedefine01 VFS_DEBUG #cmakedefine01 VFS_DEBUG
@ -92,9 +92,9 @@
#cmakedefine01 REGEX_DEBUG #cmakedefine01 REGEX_DEBUG
#cmakedefine01 TLS_DEBUG #cmakedefine01 TLS_DEBUG
#cmakedefine01 SPAM_DEBUG #cmakedefine01 SPAM_DEBUG
#cmakedefine01 WRAPPER_GERNERATOR_DEBUG #cmakedefine01 WRAPPER_GENERATOR_DEBUG
#cmakedefine01 PARSER_DEBUG #cmakedefine01 PARSER_DEBUG
#cmakedefine01 TOKENIZER_TRACE #cmakedefine01 TOKENIZER_TRACE_DEBUG
#cmakedefine01 IMAGE_LOADER_DEBUG #cmakedefine01 IMAGE_LOADER_DEBUG
#cmakedefine01 RESOURCE_DEBUG #cmakedefine01 RESOURCE_DEBUG
#cmakedefine01 CACHE_DEBUG #cmakedefine01 CACHE_DEBUG
@ -113,567 +113,9 @@
#cmakedefine01 RESIZE_DEBUG #cmakedefine01 RESIZE_DEBUG
#cmakedefine01 MOVE_DEBUG #cmakedefine01 MOVE_DEBUG
#cmakedefine01 DOUBLECLICK_DEBUG #cmakedefine01 DOUBLECLICK_DEBUG
#cmakedefine01 DISASM_DUMP #cmakedefine01 DISASM_DUMP_DEBUG
#cmakedefine01 PATH_DEBUG #cmakedefine01 PATH_DEBUG
#cmakedefine01 LOCK_TRACE_DEBUG #cmakedefine01 LOCK_TRACE_DEBUG
#cmakedefine01 LOCK_RESTORE_DEBUG #cmakedefine01 LOCK_RESTORE_DEBUG
#cmakedefine01 FUTEXQUEUE_DEBUG #cmakedefine01 FUTEXQUEUE_DEBUG
#cmakedefine01 FUTEX_DEBUG #cmakedefine01 FUTEX_DEBUG
#if PROCESS_DEBUG
constexpr bool debug_process = true;
#else
constexpr bool debug_process = false;
#endif
#if SCHEDULER_DEBUG
constexpr bool debug_scheduler = true;
#else
constexpr bool debug_scheduler = false;
#endif
#if SCHEDULER_RUNNABLE_DEBUG
constexpr bool debug_scheduler_runnable = true;
#else
constexpr bool debug_scheduler_runnable = false;
#endif
#if THREAD_DEBUG
constexpr bool debug_thread = true;
#else
constexpr bool debug_thread = false;
#endif
#if LOCK_DEBUG
constexpr bool debug_lock = true;
#else
constexpr bool debug_lock = false;
#endif
#if SIGNAL_DEBUG
constexpr bool debug_signal = true;
#else
constexpr bool debug_signal = false;
#endif
#if BMP_DEBUG
constexpr bool debug_bmp = true;
#else
constexpr bool debug_bmp = false;
#endif
#if WAITBLOCK_DEBUG
constexpr bool debug_waitblock = true;
#else
constexpr bool debug_waitblock = false;
#endif
#if WAITQUEUE_DEBUG
constexpr bool debug_waitqueue = true;
#else
constexpr bool debug_waitqueue = false;
#endif
#if MULTIPROCESSOR_DEBUG
constexpr bool debug_multiprocessor = true;
#else
constexpr bool debug_multiprocessor = false;
#endif
#if ACPI_DEBUG
constexpr bool debug_acpi = true;
#else
constexpr bool debug_acpi = false;
#endif
#if PAGE_FAULT_DEBUG
constexpr bool debug_page_fault = true;
#else
constexpr bool debug_page_fault = false;
#endif
#if CONTEXT_SWITCH_DEBUG
constexpr bool debug_context_switch = true;
#else
constexpr bool debug_context_switch = false;
#endif
#if SMP_DEBUG
constexpr bool debug_smp = true;
#else
constexpr bool debug_smp = false;
#endif
#if BXVGA_DEBUG
constexpr bool debug_bxvga = true;
#else
constexpr bool debug_bxvga = false;
#endif
#if PS2MOUSE_DEBUG
constexpr bool debug_ps2mouse = true;
#else
constexpr bool debug_ps2mouse = false;
#endif
#if VMWAREBACKDOOR_DEBUG
constexpr bool debug_vmware_backdoor = true;
#else
constexpr bool debug_vmware_backdoor = false;
#endif
#if FILEDESCRIPTION_DEBUG
constexpr bool debug_file_description = true;
#else
constexpr bool debug_file_description = false;
#endif
#if PROCFS_DEBUG
constexpr bool debug_procfs = true;
#else
constexpr bool debug_procfs = false;
#endif
#if VFS_DEBUG
constexpr bool debug_vfs = true;
#else
constexpr bool debug_vfs = false;
#endif
#if IOAPIC_DEBUG
constexpr bool debug_ioapic = true;
#else
constexpr bool debug_ioapic = false;
#endif
#if IRQ_DEBUG
constexpr bool debug_irq = true;
#else
constexpr bool debug_irq = false;
#endif
#if INTERRUPT_DEBUG
constexpr bool debug_interrupt = true;
#else
constexpr bool debug_interrupt = false;
#endif
#if E1000_DEBUG
constexpr bool debug_e1000 = true;
#else
constexpr bool debug_e1000 = false;
#endif
#if IPV4_SOCKET_DEBUG
constexpr bool debug_ipv4_socket = true;
#else
constexpr bool debug_ipv4_socket = false;
#endif
#if LOCAL_SOCKET_DEBUG
constexpr bool debug_local_socket = true;
#else
constexpr bool debug_local_socket = false;
#endif
#if SOCKET_DEBUG
constexpr bool debug_socket = true;
#else
constexpr bool debug_socket = false;
#endif
#if TCP_SOCKET_DEBUG
constexpr bool debug_tcp_socket = true;
#else
constexpr bool debug_tcp_socket = false;
#endif
#if PCI_DEBUG
constexpr bool debug_pci = true;
#else
constexpr bool debug_pci = false;
#endif
#if PATA_DEBUG
constexpr bool debug_pata = true;
#else
constexpr bool debug_pata = false;
#endif
#if IO_DEBUG
constexpr bool debug_io = true;
#else
constexpr bool debug_io = false;
#endif
#if FORK_DEBUG
constexpr bool debug_fork = true;
#else
constexpr bool debug_fork = false;
#endif
#if POLL_SELECT_DEBUG
constexpr bool debug_poll_select = true;
#else
constexpr bool debug_poll_select = false;
#endif
#if HPET_DEBUG
constexpr bool debug_hpet = true;
#else
constexpr bool debug_hpet = false;
#endif
#if HPET_COMPARATOR_DEBUG
constexpr bool debug_hpet_comperator = true;
#else
constexpr bool debug_hpet_comperator = false;
#endif
#if MASTERPTY_DEBUG
constexpr bool debug_masterpty = true;
#else
constexpr bool debug_masterpty = false;
#endif
#if SLAVEPTY_DEBUG
constexpr bool debug_slavepty = true;
#else
constexpr bool debug_slavepty = false;
#endif
#if PTMX_DEBUG
constexpr bool debug_ptmx = true;
#else
constexpr bool debug_ptmx = false;
#endif
#if TTY_DEBUG
constexpr bool debug_tty = true;
#else
constexpr bool debug_tty = false;
#endif
#if CONTIGUOUS_VMOBJECT_DEBUG
constexpr bool debug_contiguous_vmobject = true;
#else
constexpr bool debug_contiguous_vmobject = false;
#endif
#if VRA_DEBUG
constexpr bool debug_vra = true;
#else
constexpr bool debug_vra = false;
#endif
#if COPY_DEBUG
constexpr bool debug_copy = true;
#else
constexpr bool debug_copy = false;
#endif
#if CURSOR_TOOL_DEBUG
constexpr bool debug_cursor_tool = true;
#else
constexpr bool debug_cursor_tool = false;
#endif
#if FILE_CONTENT_DEBUG
constexpr bool debug_file_content = true;
#else
constexpr bool debug_file_content = false;
#endif
#if GZIP_DEBUG
constexpr bool debug_gzip = true;
#else
constexpr bool debug_gzip = false;
#endif
#if CNETWORKJOB_DEBUG
constexpr bool debug_cnetworkjob = true;
#else
constexpr bool debug_cnetworkjob = false;
#endif
#if CSOCKET_DEBUG
constexpr bool debug_csocket = true;
#else
constexpr bool debug_csocket = false;
#endif
#if SAFE_SYSCALL_DEBUG
constexpr bool debug_safe_syscall = true;
#else
constexpr bool debug_safe_syscall = false;
#endif
#if GHASH_PROCESS_DEBUG
constexpr bool debug_ghash_process = true;
#else
constexpr bool debug_ghash_process = false;
#endif
#if NT_DEBUG
constexpr bool debug_nt = true;
#else
constexpr bool debug_nt = false;
#endif
#if CRYPTO_DEBUG
constexpr bool debug_crypto = true;
#else
constexpr bool debug_crypto = false;
#endif
#if DWARF_DEBUG
constexpr bool debug_dwarf = true;
#else
constexpr bool debug_dwarf = false;
#endif
#if HUNKS_DEBUG
constexpr bool debug_hunks = true;
#else
constexpr bool debug_hunks = false;
#endif
#if JOB_DEBUG
constexpr bool debug_job = true;
#else
constexpr bool debug_job = false;
#endif
#if GIF_DEBUG
constexpr bool debug_gif = true;
#else
constexpr bool debug_gif = false;
#endif
#if JPG_DEBUG
constexpr bool debug_jpg = true;
#else
constexpr bool debug_jpg = false;
#endif
#if EMOJI_DEBUG
constexpr bool debug_emoji = true;
#else
constexpr bool debug_emoji = false;
#endif
#if FILL_PATH_DEBUG
constexpr bool debug_fill_path = true;
#else
constexpr bool debug_fill_path = false;
#endif
#if PNG_DEBUG
constexpr bool debug_png = true;
#else
constexpr bool debug_png = false;
#endif
#if PORTABLE_IMAGE_LOADER_DEBUG
constexpr bool debug_portable_image_loader = true;
#else
constexpr bool debug_portable_image_loader = false;
#endif
#if SYNTAX_HIGHLIGHTING_DEBUG
constexpr bool debug_syntax_highlighting = true;
#else
constexpr bool debug_syntax_highlighting = false;
#endif
#if KEYBOARD_SHORTCUTS_DEBUG
constexpr bool debug_keyboard_shortcuts = true;
#else
constexpr bool debug_keyboard_shortcuts = false;
#endif
#if MARKDOWN_DEBUG
constexpr bool debug_markdown = true;
#else
constexpr bool debug_markdown = false;
#endif
#if REGEX_DEBUG
constexpr bool debug_regex = true;
#else
constexpr bool debug_regex = false;
#endif
#if TLS_DEBUG
constexpr bool debug_tls = true;
#else
constexpr bool debug_tls = false;
#endif
#if SPAM_DEBUG
constexpr bool debug_spam = true;
#else
constexpr bool debug_spam = false;
#endif
#if WRAPPER_GERNERATOR_DEBUG
constexpr bool debug_wrapper_generator = true;
#else
constexpr bool debug_wrapper_generator = false;
#endif
#if PARSER_DEBUG
constexpr bool debug_parser = true;
#else
constexpr bool debug_parser = false;
#endif
#if TOKENIZER_TRACE
constexpr bool debug_trace_tokenizer = true;
#else
constexpr bool debug_trace_tokenizer = false;
#endif
#if IMAGE_LOADER_DEBUG
constexpr bool debug_image_loader = true;
#else
constexpr bool debug_image_loader = false;
#endif
#if RESOURCE_DEBUG
constexpr bool debug_resource = true;
#else
constexpr bool debug_resource = false;
#endif
#if CACHE_DEBUG
constexpr bool debug_cache = true;
#else
constexpr bool debug_cache = false;
#endif
#if DHCPV4_DEBUG
constexpr bool debug_dhcpv4 = true;
#else
constexpr bool debug_dhcpv4 = false;
#endif
#if DHCPV4CLIENT_DEBUG
constexpr bool debug_dhcpv4_client = true;
#else
constexpr bool debug_dhcpv4_client = false;
#endif
#if IMAGE_DECODER_DEBUG
constexpr bool debug_image_decoder = true;
#else
constexpr bool debug_image_decoder = false;
#endif
#if SYSTEM_MENU_DEBUG
constexpr bool debug_system_menu = true;
#else
constexpr bool debug_system_menu = false;
#endif
#if SYSTEMSERVER_DEBUG
constexpr bool debug_system_server = true;
#else
constexpr bool debug_system_server = false;
#endif
#if SERVICE_DEBUG
constexpr bool debug_service = true;
#else
constexpr bool debug_service = false;
#endif
#if COMPOSE_DEBUG
constexpr bool debug_compose = true;
#else
constexpr bool debug_compose = false;
#endif
#if MINIMIZE_ANIMATION_DEBUG
constexpr bool debug_minimize_animation = true;
#else
constexpr bool debug_minimize_animation = false;
#endif
#if OCCLUSIONS_DEBUG
constexpr bool debug_occlusions = true;
#else
constexpr bool debug_occlusions = false;
#endif
#if MENUS_DEBUG
constexpr bool debug_menus = true;
#else
constexpr bool debug_menus = false;
#endif
#if WSSCREEN_DEBUG
constexpr bool debug_wsscreen = true;
#else
constexpr bool debug_wsscreen = false;
#endif
#if WINDOWMANAGER_DEBUG
constexpr bool debug_window_manager = true;
#else
constexpr bool debug_window_manager = false;
#endif
#if RESIZE_DEBUG
constexpr bool debug_resize = true;
#else
constexpr bool debug_resize = false;
#endif
#if MOVE_DEBUG
constexpr bool debug_move = true;
#else
constexpr bool debug_move = false;
#endif
#if DOUBLECLICK_DEBUG
constexpr bool debug_double_click = true;
#else
constexpr bool debug_double_click = false;
#endif
#if DISASM_DUMP
constexpr bool debug_disasm_dump = true;
#else
constexpr bool debug_disasm_dump = false;
#endif
#if PATH_DEBUG
constexpr bool debug_path = true;
#else
constexpr bool debug_path = false;
#endif
#if LOCK_TRACE_DEBUG
constexpr bool debug_lock_trace = true;
#else
constexpr bool debug_lock_trace = false;
#endif
#if LOCK_RESTORE_DEBUG
constexpr bool debug_lock_restore = true;
#else
constexpr bool debug_lock_restore = false;
#endif
#if FUTEXQUEUE_DEBUG
constexpr bool debug_futex_queue = true;
#else
constexpr bool debug_futex_queue = false;
#endif
#if FUTEX_DEBUG
constexpr bool debug_futex = true;
#else
constexpr bool debug_futex = false;
#endif

View file

@ -67,7 +67,7 @@ void MultiProcessorParser::parse_configuration_table()
size_t entry_count = config_table->entry_count; size_t entry_count = config_table->entry_count;
auto* entry = config_table->entries; auto* entry = config_table->entries;
while (entry_count > 0) { while (entry_count > 0) {
dbgln<debug_multiprocessor>("MultiProcessor: Entry Type {} detected.", entry->entry_type); dbgln<MULTIPROCESSOR_DEBUG>("MultiProcessor: Entry Type {} detected.", entry->entry_type);
switch (entry->entry_type) { switch (entry->entry_type) {
case ((u8)MultiProcessor::ConfigurationTableEntryType::Processor): case ((u8)MultiProcessor::ConfigurationTableEntryType::Processor):
entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry); entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry);

View file

@ -66,12 +66,12 @@ void Parser::locate_static_data()
PhysicalAddress Parser::find_table(const StringView& signature) PhysicalAddress Parser::find_table(const StringView& signature)
{ {
dbgln<debug_acpi>("ACPI: Calling Find Table method!"); dbgln<ACPI_DEBUG>("ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) { for (auto p_sdt : m_sdt_pointers) {
auto sdt = map_typed<Structures::SDTHeader>(p_sdt); auto sdt = map_typed<Structures::SDTHeader>(p_sdt);
dbgln<debug_acpi>("ACPI: Examining Table @ {}", p_sdt); dbgln<ACPI_DEBUG>("ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) { if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
dbgln<debug_acpi>("ACPI: Found Table @ {}", p_sdt); dbgln<ACPI_DEBUG>("ACPI: Found Table @ {}", p_sdt);
return p_sdt; return p_sdt;
} }
} }
@ -93,7 +93,7 @@ void Parser::init_fadt()
auto sdt = map_typed<Structures::FADT>(m_fadt); auto sdt = map_typed<Structures::FADT>(m_fadt);
dbgln<debug_acpi>("ACPI: FADT @ V{}, {}", &sdt, m_fadt); dbgln<ACPI_DEBUG>("ACPI: FADT @ V{}, {}", &sdt, m_fadt);
klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes"; klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes";
klog() << "ACPI: DSDT " << PhysicalAddress(sdt->dsdt_ptr); klog() << "ACPI: DSDT " << PhysicalAddress(sdt->dsdt_ptr);
@ -219,7 +219,7 @@ void Parser::try_acpi_reboot()
klog() << "ACPI: Reboot, Not supported!"; klog() << "ACPI: Reboot, Not supported!";
return; return;
} }
dbgln<debug_acpi>("ACPI: Rebooting, Probing FADT ({})", m_fadt); dbgln<ACPI_DEBUG>("ACPI: Rebooting, Probing FADT ({})", m_fadt);
auto fadt = map_typed<Structures::FADT>(m_fadt); auto fadt = map_typed<Structures::FADT>(m_fadt);
ASSERT(validate_reset_register()); ASSERT(validate_reset_register());
@ -267,18 +267,18 @@ void Parser::initialize_main_system_description_table()
auto& xsdt = (const Structures::XSDT&)*sdt; auto& xsdt = (const Structures::XSDT&)*sdt;
klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table; klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length; klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length;
dbgln<debug_acpi>("ACPI: XSDT pointer @ V{}", &xsdt); dbgln<ACPI_DEBUG>("ACPI: XSDT pointer @ V{}", &xsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) { for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]); dbgln<ACPI_DEBUG>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i])); m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i]));
} }
} else { } else {
auto& rsdt = (const Structures::RSDT&)*sdt; auto& rsdt = (const Structures::RSDT&)*sdt;
klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table; klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length; klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length;
dbgln<debug_acpi>("ACPI: RSDT pointer @ V{}", &rsdt); dbgln<ACPI_DEBUG>("ACPI: RSDT pointer @ V{}", &rsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) { for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]); dbgln<ACPI_DEBUG>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(rsdt.table_ptrs[i])); m_sdt_pointers.append(PhysicalAddress(rsdt.table_ptrs[i]));
} }
} }

View file

@ -229,7 +229,7 @@ void page_fault_handler(TrapFrame* trap)
asm("movl %%cr2, %%eax" asm("movl %%cr2, %%eax"
: "=a"(fault_address)); : "=a"(fault_address));
if constexpr (debug_page_fault) { if constexpr (PAGE_FAULT_DEBUG) {
u32 fault_page_directory = read_cr3(); u32 fault_page_directory = read_cr3();
dbgln("CPU #{} ring {} {} page fault in PD={:#x}, {}{} {}", dbgln("CPU #{} ring {} {} page fault in PD={:#x}, {}{} {}",
Processor::is_initialized() ? Processor::current().id() : 0, Processor::is_initialized() ? Processor::current().id() : 0,
@ -1307,7 +1307,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
ASSERT(m_in_critical == 1); ASSERT(m_in_critical == 1);
ASSERT(is_kernel_mode()); ASSERT(is_kernel_mode());
dbgln<debug_context_switch>("switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread); dbgln<CONTEXT_SWITCH_DEBUG>("switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread);
// Switch to new thread context, passing from_thread and to_thread // Switch to new thread context, passing from_thread and to_thread
// through to the new context using registers edx and eax // through to the new context using registers edx and eax
@ -1349,7 +1349,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
[to_thread] "a" (to_thread) [to_thread] "a" (to_thread)
); );
dbgln<debug_context_switch>("switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread); dbgln<CONTEXT_SWITCH_DEBUG>("switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
} }
extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe_unused]] Thread* to_thread, [[maybe_unused]] TrapFrame* trap) extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe_unused]] Thread* to_thread, [[maybe_unused]] TrapFrame* trap)
@ -1357,7 +1357,7 @@ extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe
ASSERT(!are_interrupts_enabled()); ASSERT(!are_interrupts_enabled());
ASSERT(is_kernel_mode()); ASSERT(is_kernel_mode());
dbgln<debug_context_switch>("switch_context <-- from {} {} to {} {} (context_first_init)", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread); dbgln<CONTEXT_SWITCH_DEBUG>("switch_context <-- from {} {} to {} {} (context_first_init)", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
ASSERT(to_thread == Thread::current()); ASSERT(to_thread == Thread::current());
@ -1465,7 +1465,7 @@ u32 Processor::init_context(Thread& thread, bool leave_crit)
stack_top -= sizeof(u32); // pointer to TrapFrame stack_top -= sizeof(u32); // pointer to TrapFrame
*reinterpret_cast<u32*>(stack_top) = stack_top + 4; *reinterpret_cast<u32*>(stack_top) = stack_top + 4;
if constexpr (debug_context_switch) { if constexpr (CONTEXT_SWITCH_DEBUG) {
if (return_to_user) { if (return_to_user) {
dbgln("init_context {} ({}) set up to execute at eip={}:{}, esp={}, stack_top={}, user_top={}:{}", dbgln("init_context {} ({}) set up to execute at eip={}:{}, esp={}, stack_top={}, user_top={}:{}",
thread, thread,
@ -1532,7 +1532,7 @@ asm(
void Processor::assume_context(Thread& thread, u32 flags) void Processor::assume_context(Thread& thread, u32 flags)
{ {
dbgln<debug_context_switch>("Assume context for thread {} {}", VirtualAddress(&thread), thread); dbgln<CONTEXT_SWITCH_DEBUG>("Assume context for thread {} {}", VirtualAddress(&thread), thread);
ASSERT_INTERRUPTS_DISABLED(); ASSERT_INTERRUPTS_DISABLED();
Scheduler::prepare_after_exec(); Scheduler::prepare_after_exec();
@ -1756,7 +1756,7 @@ bool Processor::smp_process_pending_messages()
next_msg = cur_msg->next; next_msg = cur_msg->next;
auto msg = cur_msg->msg; auto msg = cur_msg->msg;
dbgln<debug_smp>("SMP[{}]: Processing message {}", id(), VirtualAddress(msg)); dbgln<SMP_DEBUG>("SMP[{}]: Processing message {}", id(), VirtualAddress(msg));
switch (msg->type) { switch (msg->type) {
case ProcessorMessage::Callback: case ProcessorMessage::Callback:
@ -1771,7 +1771,7 @@ bool Processor::smp_process_pending_messages()
ASSERT(is_user_range(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count * PAGE_SIZE)); ASSERT(is_user_range(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count * PAGE_SIZE));
if (read_cr3() != msg->flush_tlb.page_directory->cr3()) { if (read_cr3() != msg->flush_tlb.page_directory->cr3()) {
// This processor isn't using this page directory right now, we can ignore this request // This processor isn't using this page directory right now, we can ignore this request
dbgln<debug_smp>("SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr)); dbgln<SMP_DEBUG>("SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
break; break;
} }
} }
@ -1821,7 +1821,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg)
{ {
auto& cur_proc = Processor::current(); auto& cur_proc = Processor::current();
dbgln<debug_smp>("SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc)); dbgln<SMP_DEBUG>("SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc));
atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release); atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release);
ASSERT(msg.refs > 0); ASSERT(msg.refs > 0);
@ -1890,7 +1890,7 @@ void Processor::smp_unicast_message(u32 cpu, ProcessorMessage& msg, bool async)
auto& target_proc = processors()[cpu]; auto& target_proc = processors()[cpu];
msg.async = async; msg.async = async;
dbgln<debug_smp>("SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc)); dbgln<SMP_DEBUG>("SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc));
atomic_store(&msg.refs, 1u, AK::MemoryOrder::memory_order_release); atomic_store(&msg.refs, 1u, AK::MemoryOrder::memory_order_release);
if (target_proc->smp_queue_message(msg)) { if (target_proc->smp_queue_message(msg)) {

View file

@ -106,7 +106,7 @@ void BXVGADevice::revert_resolution()
void BXVGADevice::set_resolution_registers(size_t width, size_t height) void BXVGADevice::set_resolution_registers(size_t width, size_t height)
{ {
dbgln<debug_bxvga>("BXVGADevice resolution registers set to - {}x{}", width, height); dbgln<BXVGA_DEBUG>("BXVGADevice resolution registers set to - {}x{}", width, height);
set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED); set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
set_register(VBE_DISPI_INDEX_XRES, (u16)width); set_register(VBE_DISPI_INDEX_XRES, (u16)width);
set_register(VBE_DISPI_INDEX_YRES, (u16)height); set_register(VBE_DISPI_INDEX_YRES, (u16)height);
@ -119,7 +119,7 @@ void BXVGADevice::set_resolution_registers(size_t width, size_t height)
bool BXVGADevice::test_resolution(size_t width, size_t height) bool BXVGADevice::test_resolution(size_t width, size_t height)
{ {
dbgln<debug_bxvga>("BXVGADevice resolution test - {}x{}", width, height); dbgln<BXVGA_DEBUG>("BXVGADevice resolution test - {}x{}", width, height);
set_resolution_registers(width, height); set_resolution_registers(width, height);
bool resolution_changed = validate_setup_resolution(width, height); bool resolution_changed = validate_setup_resolution(width, height);
revert_resolution(); revert_resolution();
@ -239,7 +239,7 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT) if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT)
return -EINVAL; return -EINVAL;
if (!set_resolution(resolution.width, resolution.height)) { if (!set_resolution(resolution.width, resolution.height)) {
dbgln<debug_bxvga>("Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height); dbgln<BXVGA_DEBUG>("Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
resolution.pitch = m_framebuffer_pitch; resolution.pitch = m_framebuffer_pitch;
resolution.width = m_framebuffer_width; resolution.width = m_framebuffer_width;
resolution.height = m_framebuffer_height; resolution.height = m_framebuffer_height;
@ -247,7 +247,7 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
return -EFAULT; return -EFAULT;
return -EINVAL; return -EINVAL;
} }
dbgln<debug_bxvga>("New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height); dbgln<BXVGA_DEBUG>("New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
resolution.pitch = m_framebuffer_pitch; resolution.pitch = m_framebuffer_pitch;
resolution.width = m_framebuffer_width; resolution.width = m_framebuffer_width;
resolution.height = m_framebuffer_height; resolution.height = m_framebuffer_height;

View file

@ -99,7 +99,7 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte)
auto commit_packet = [&] { auto commit_packet = [&] {
m_data_state = 0; m_data_state = 0;
dbgln<debug_ps2mouse>("PS2Mouse: {}, {} {} {}", dbgln<PS2MOUSE_DEBUG>("PS2Mouse: {}, {} {} {}",
m_data.bytes[1], m_data.bytes[1],
m_data.bytes[2], m_data.bytes[2],
(m_data.bytes[0] & 1) ? "Left" : "", (m_data.bytes[0] & 1) ? "Left" : "",
@ -283,7 +283,7 @@ KResultOr<size_t> PS2MouseDevice::read(FileDescription&, size_t, UserOrKernelBuf
auto packet = m_queue.dequeue(); auto packet = m_queue.dequeue();
lock.unlock(); lock.unlock();
if constexpr (debug_ps2mouse) { if constexpr (PS2MOUSE_DEBUG) {
dbgln("PS2 Mouse Read: Buttons {:x}", packet.buttons); dbgln("PS2 Mouse Read: Buttons {:x}", packet.buttons);
dbgln("PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons); dbgln("PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons);
dbgln("PS2 Mouse Read: Filter packets"); dbgln("PS2 Mouse Read: Filter packets");

View file

@ -177,7 +177,7 @@ void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command)
{ {
vmware_high_bandwidth_send(command); vmware_high_bandwidth_send(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax, command.ax,
command.bx, command.bx,
command.cx, command.cx,
@ -188,7 +188,7 @@ void VMWareBackdoor::get_high_bandwidth(VMWareCommand& command)
{ {
vmware_high_bandwidth_get(command); vmware_high_bandwidth_get(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax, command.ax,
command.bx, command.bx,
command.cx, command.cx,
@ -199,7 +199,7 @@ void VMWareBackdoor::send(VMWareCommand& command)
{ {
vmware_out(command); vmware_out(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax, command.ax,
command.bx, command.bx,
command.cx, command.cx,
@ -233,7 +233,7 @@ Optional<MousePacket> VMWareBackdoor::receive_mouse_packet()
int y = (command.cx); int y = (command.cx);
int z = (command.dx); int z = (command.dx);
if constexpr (debug_ps2mouse) { if constexpr (PS2MOUSE_DEBUG) {
dbgln("Absolute Mouse: Buttons {:x}", buttons); dbgln("Absolute Mouse: Buttons {:x}", buttons);
dbgln("Mouse: x={}, y={}, z={}", x, y, z); dbgln("Mouse: x={}, y={}, z={}", x, y, z);
} }

View file

@ -49,7 +49,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
description->m_custody = custody; description->m_custody = custody;
auto result = description->attach(); auto result = description->attach();
if (result.is_error()) { if (result.is_error()) {
dbgln<debug_file_description>("Failed to create file description for custody: {}", result); dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for custody: {}", result);
return result; return result;
} }
return description; return description;
@ -60,7 +60,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(File& file)
auto description = adopt(*new FileDescription(file)); auto description = adopt(*new FileDescription(file));
auto result = description->attach(); auto result = description->attach();
if (result.is_error()) { if (result.is_error()) {
dbgln<debug_file_description>("Failed to create file description for file: {}", result); dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for file: {}", result);
return result; return result;
} }
return description; return description;

View file

@ -986,7 +986,7 @@ NonnullRefPtr<Inode> ProcFS::root_inode() const
RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
{ {
dbgln<debug_procfs>("ProcFS::get_inode({})", inode_id.index()); dbgln<PROCFS_DEBUG>("ProcFS::get_inode({})", inode_id.index());
if (inode_id == root_inode()->identifier()) if (inode_id == root_inode()->identifier())
return m_root_inode; return m_root_inode;
@ -1099,7 +1099,7 @@ void ProcFSInode::did_seek(FileDescription& description, off_t new_offset)
InodeMetadata ProcFSInode::metadata() const InodeMetadata ProcFSInode::metadata() const
{ {
dbgln<debug_procfs>("ProcFSInode::metadata({})", index()); dbgln<PROCFS_DEBUG>("ProcFSInode::metadata({})", index());
InodeMetadata metadata; InodeMetadata metadata;
metadata.inode = identifier(); metadata.inode = identifier();
metadata.ctime = mepoch; metadata.ctime = mepoch;
@ -1108,7 +1108,7 @@ InodeMetadata ProcFSInode::metadata() const
auto proc_parent_directory = to_proc_parent_directory(identifier()); auto proc_parent_directory = to_proc_parent_directory(identifier());
auto proc_file_type = to_proc_file_type(identifier()); auto proc_file_type = to_proc_file_type(identifier());
dbgln<debug_procfs>(" -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory); dbgln<PROCFS_DEBUG>(" -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory);
if (is_process_related_file(identifier())) { if (is_process_related_file(identifier())) {
ProcessID pid = to_pid(identifier()); ProcessID pid = to_pid(identifier());
@ -1173,14 +1173,14 @@ InodeMetadata ProcFSInode::metadata() const
ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
{ {
dbgln<debug_procfs>("ProcFS: read_bytes offset: {} count: {}", offset, count); dbgln<PROCFS_DEBUG>("ProcFS: read_bytes offset: {} count: {}", offset, count);
ASSERT(offset >= 0); ASSERT(offset >= 0);
ASSERT(buffer.user_or_kernel_ptr()); ASSERT(buffer.user_or_kernel_ptr());
if (!description) if (!description)
return -EIO; return -EIO;
if (!description->data()) { if (!description->data()) {
dbgln<debug_procfs>("ProcFS: Do not have cached data!"); dbgln<PROCFS_DEBUG>("ProcFS: Do not have cached data!");
return -EIO; return -EIO;
} }
@ -1204,7 +1204,7 @@ InodeIdentifier ProcFS::ProcFSDirectoryEntry::identifier(unsigned fsid) const
KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
{ {
dbgln<debug_procfs>("ProcFS: traverse_as_directory {}", index()); dbgln<PROCFS_DEBUG>("ProcFS: traverse_as_directory {}", index());
if (!Kernel::is_directory(identifier())) if (!Kernel::is_directory(identifier()))
return ENOTDIR; return ENOTDIR;

View file

@ -400,7 +400,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
return EROFS; return EROFS;
LexicalPath p(path); LexicalPath p(path);
dbgln<debug_vfs>("VFS::create: '{}' in {}", p.basename(), parent_inode.identifier()); dbgln<VFS_DEBUG>("VFS::create: '{}' in {}", p.basename(), parent_inode.identifier());
uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid(); uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid();
gid_t gid = owner.has_value() ? owner.value().gid : current_process->egid(); gid_t gid = owner.has_value() ? owner.value().gid : current_process->egid();
auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid); auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid);
@ -442,7 +442,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
return EROFS; return EROFS;
LexicalPath p(path); LexicalPath p(path);
dbgln<debug_vfs>("VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier()); dbgln<VFS_DEBUG>("VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier());
return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result(); return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result();
} }

View file

@ -36,7 +36,7 @@ bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
ASSERT(m_lock.is_locked()); ASSERT(m_lock.is_locked());
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex); ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
dbgln<debug_futex_queue>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data)); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data));
return true; return true;
} }
@ -46,7 +46,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
is_empty_target = false; is_empty_target = false;
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
u32 did_wake = 0, did_requeue = 0; u32 did_wake = 0, did_requeue = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) { do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
@ -54,7 +54,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex); ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b); auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data)); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data));
ASSERT(did_wake < wake_count); ASSERT(did_wake < wake_count);
if (blocker.unblock()) { if (blocker.unblock()) {
if (++did_wake >= wake_count) if (++did_wake >= wake_count)
@ -68,7 +68,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
auto blockers_to_requeue = do_take_blockers(requeue_count); auto blockers_to_requeue = do_take_blockers(requeue_count);
if (!blockers_to_requeue.is_empty()) { if (!blockers_to_requeue.is_empty()) {
if (auto* target_futex_queue = get_target_queue()) { if (auto* target_futex_queue = get_target_queue()) {
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue);
// While still holding m_lock, notify each blocker // While still holding m_lock, notify each blocker
for (auto& info : blockers_to_requeue) { for (auto& info : blockers_to_requeue) {
@ -91,7 +91,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
target_futex_queue->do_append_blockers(move(blockers_to_requeue)); target_futex_queue->do_append_blockers(move(blockers_to_requeue));
is_empty_target = target_futex_queue->is_empty_locked(); is_empty_target = target_futex_queue->is_empty_locked();
} else { } else {
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size()); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size());
do_append_blockers(move(blockers_to_requeue)); do_append_blockers(move(blockers_to_requeue));
} }
} }
@ -104,14 +104,14 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
if (wake_count == 0) if (wake_count == 0)
return 0; // should we assert instead? return 0; // should we assert instead?
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n({})", this, wake_count); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0; u32 did_wake = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) { do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data); ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex); ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b); auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data)); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data));
ASSERT(did_wake < wake_count); ASSERT(did_wake < wake_count);
if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) { if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) {
if (++did_wake >= wake_count) if (++did_wake >= wake_count)
@ -127,13 +127,13 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
u32 FutexQueue::wake_all(bool& is_empty) u32 FutexQueue::wake_all(bool& is_empty)
{ {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all", this); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_all", this);
u32 did_wake = 0; u32 did_wake = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool&) { do_unblock([&](Thread::Blocker& b, void* data, bool&) {
ASSERT(data); ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex); ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b); auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data)); dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data));
if (blocker.unblock(true)) { if (blocker.unblock(true)) {
did_wake++; did_wake++;
return true; return true;

View file

@ -201,12 +201,12 @@ void IOAPIC::configure_redirection_entry(int index, u8 interrupt_vector, u8 deli
u32 redirection_entry2 = destination << 24; u32 redirection_entry2 = destination << 24;
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1); write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1);
if constexpr (debug_ioapic) if constexpr (IOAPIC_DEBUG)
dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET)); dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET));
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET + 1, redirection_entry2); write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET + 1, redirection_entry2);
if constexpr (debug_ioapic) if constexpr (IOAPIC_DEBUG)
dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + 0x11)); dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + 0x11));
} }
@ -320,13 +320,13 @@ void IOAPIC::write_register(u32 index, u32 value) const
m_regs->select = index; m_regs->select = index;
m_regs->window = value; m_regs->window = value;
dbgln<debug_ioapic>("IOAPIC Writing, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select); dbgln<IOAPIC_DEBUG>("IOAPIC Writing, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
} }
u32 IOAPIC::read_register(u32 index) const u32 IOAPIC::read_register(u32 index) const
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
m_regs->select = index; m_regs->select = index;
dbgln<debug_ioapic>("IOAPIC Reading, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select); dbgln<IOAPIC_DEBUG>("IOAPIC Reading, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
return m_regs->window; return m_regs->window;
} }

View file

@ -44,7 +44,7 @@ IRQHandler::~IRQHandler()
bool IRQHandler::eoi() bool IRQHandler::eoi()
{ {
dbgln<debug_irq>("EOI IRQ {}", interrupt_number()); dbgln<IRQ_DEBUG>("EOI IRQ {}", interrupt_number());
if (!m_shared_with_others) { if (!m_shared_with_others) {
ASSERT(!m_responsible_irq_controller.is_null()); ASSERT(!m_responsible_irq_controller.is_null());
m_responsible_irq_controller->eoi(*this); m_responsible_irq_controller->eoi(*this);
@ -55,7 +55,7 @@ bool IRQHandler::eoi()
void IRQHandler::enable_irq() void IRQHandler::enable_irq()
{ {
dbgln<debug_irq>("Enable IRQ {}", interrupt_number()); dbgln<IRQ_DEBUG>("Enable IRQ {}", interrupt_number());
m_enabled = true; m_enabled = true;
if (!m_shared_with_others) if (!m_shared_with_others)
m_responsible_irq_controller->enable(*this); m_responsible_irq_controller->enable(*this);
@ -63,7 +63,7 @@ void IRQHandler::enable_irq()
void IRQHandler::disable_irq() void IRQHandler::disable_irq()
{ {
dbgln<debug_irq>("Disable IRQ {}", interrupt_number()); dbgln<IRQ_DEBUG>("Disable IRQ {}", interrupt_number());
m_enabled = false; m_enabled = false;
if (!m_shared_with_others) if (!m_shared_with_others)
m_responsible_irq_controller->disable(*this); m_responsible_irq_controller->disable(*this);

View file

@ -59,7 +59,7 @@ void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler)
bool SharedIRQHandler::eoi() bool SharedIRQHandler::eoi()
{ {
dbgln<debug_interrupt>("EOI IRQ {}", interrupt_number()); dbgln<INTERRUPT_DEBUG>("EOI IRQ {}", interrupt_number());
m_responsible_irq_controller->eoi(*this); m_responsible_irq_controller->eoi(*this);
return true; return true;
} }
@ -86,18 +86,18 @@ void SharedIRQHandler::handle_interrupt(const RegisterState& regs)
{ {
ASSERT_INTERRUPTS_DISABLED(); ASSERT_INTERRUPTS_DISABLED();
if constexpr (debug_interrupt) { if constexpr (INTERRUPT_DEBUG) {
dbgln("Interrupt @ {}", interrupt_number()); dbgln("Interrupt @ {}", interrupt_number());
dbgln("Interrupt Handlers registered - {}", m_handlers.size()); dbgln("Interrupt Handlers registered - {}", m_handlers.size());
} }
int i = 0; int i = 0;
for (auto* handler : m_handlers) { for (auto* handler : m_handlers) {
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number()); dbgln<INTERRUPT_DEBUG>("Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number());
ASSERT(handler != nullptr); ASSERT(handler != nullptr);
handler->increment_invoking_counter(); handler->increment_invoking_counter();
handler->handle_interrupt(regs); handler->handle_interrupt(regs);
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number()); dbgln<INTERRUPT_DEBUG>("Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number());
i++; i++;
} }
} }

View file

@ -56,7 +56,7 @@ void Lock::lock(Mode mode)
Mode current_mode = m_mode; Mode current_mode = m_mode;
switch (current_mode) { switch (current_mode) {
case Mode::Unlocked: { case Mode::Unlocked: {
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently unlocked", this, mode_to_string(mode)); dbgln<LOCK_TRACE_DEBUG>("Lock::lock @ {}: acquire {}, currently unlocked", this, mode_to_string(mode));
m_mode = mode; m_mode = mode;
ASSERT(!m_holder); ASSERT(!m_holder);
ASSERT(m_shared_holders.is_empty()); ASSERT(m_shared_holders.is_empty());
@ -80,7 +80,7 @@ void Lock::lock(Mode mode)
break; break;
ASSERT(m_shared_holders.is_empty()); ASSERT(m_shared_holders.is_empty());
if constexpr (debug_lock_trace) { if constexpr (LOCK_TRACE_DEBUG) {
if (mode == Mode::Exclusive) if (mode == Mode::Exclusive)
dbgln("Lock::lock @ {}: acquire {}, currently exclusive, holding: {}", this, mode_to_string(mode), m_times_locked); dbgln("Lock::lock @ {}: acquire {}, currently exclusive, holding: {}", this, mode_to_string(mode), m_times_locked);
else else
@ -101,7 +101,7 @@ void Lock::lock(Mode mode)
if (mode != Mode::Shared) if (mode != Mode::Shared)
break; break;
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently shared, locks held {}", this, mode_to_string(mode), m_times_locked); dbgln<LOCK_TRACE_DEBUG>("Lock::lock @ {}: acquire {}, currently shared, locks held {}", this, mode_to_string(mode), m_times_locked);
ASSERT(m_times_locked > 0); ASSERT(m_times_locked > 0);
m_times_locked++; m_times_locked++;
@ -139,7 +139,7 @@ void Lock::unlock()
for (;;) { for (;;) {
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) { if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
Mode current_mode = m_mode; Mode current_mode = m_mode;
if constexpr (debug_lock_trace) { if constexpr (LOCK_TRACE_DEBUG) {
if (current_mode == Mode::Shared) if (current_mode == Mode::Shared)
dbgln("Lock::unlock @ {}: release {}, locks held: {}", this, mode_to_string(current_mode), m_times_locked); dbgln("Lock::unlock @ {}: release {}, locks held: {}", this, mode_to_string(current_mode), m_times_locked);
else else
@ -211,7 +211,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked; return Mode::Unlocked;
} }
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked); dbgln<LOCK_RESTORE_DEBUG>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
m_holder = nullptr; m_holder = nullptr;
ASSERT(m_times_locked > 0); ASSERT(m_times_locked > 0);
@ -234,7 +234,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked; return Mode::Unlocked;
} }
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}", dbgln<LOCK_RESTORE_DEBUG>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
this, it->value, m_times_locked); this, it->value, m_times_locked);
ASSERT(it->value > 0); ASSERT(it->value > 0);
@ -293,7 +293,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Exclusive)) if (!m_mode.compare_exchange_strong(expected_mode, Mode::Exclusive))
break; break;
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count); dbgln<LOCK_RESTORE_DEBUG>("Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count);
ASSERT(m_times_locked == 0); ASSERT(m_times_locked == 0);
m_times_locked = lock_count; m_times_locked = lock_count;
@ -311,7 +311,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Shared) && expected_mode != Mode::Shared) if (!m_mode.compare_exchange_strong(expected_mode, Mode::Shared) && expected_mode != Mode::Shared)
break; break;
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was {}", dbgln<LOCK_RESTORE_DEBUG>("Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
this, mode_to_string(mode), lock_count, mode_to_string(expected_mode)); this, mode_to_string(mode), lock_count, mode_to_string(expected_mode));
ASSERT(expected_mode == Mode::Shared || m_times_locked == 0); ASSERT(expected_mode == Mode::Shared || m_times_locked == 0);

View file

@ -362,7 +362,7 @@ void E1000NetworkAdapter::initialize_tx_descriptors()
void E1000NetworkAdapter::out8(u16 address, u8 data) void E1000NetworkAdapter::out8(u16 address, u8 data)
{ {
dbgln<debug_e1000>("E1000: OUT8 {:#02x} @ {:#04x}", data, address); dbgln<E1000_DEBUG>("E1000: OUT8 {:#02x} @ {:#04x}", data, address);
if (m_use_mmio) { if (m_use_mmio) {
auto* ptr = (volatile u8*)(m_mmio_base.get() + address); auto* ptr = (volatile u8*)(m_mmio_base.get() + address);
*ptr = data; *ptr = data;
@ -373,7 +373,7 @@ void E1000NetworkAdapter::out8(u16 address, u8 data)
void E1000NetworkAdapter::out16(u16 address, u16 data) void E1000NetworkAdapter::out16(u16 address, u16 data)
{ {
dbgln<debug_e1000>("E1000: OUT16 {:#04x} @ {:#04x}", data, address); dbgln<E1000_DEBUG>("E1000: OUT16 {:#04x} @ {:#04x}", data, address);
if (m_use_mmio) { if (m_use_mmio) {
auto* ptr = (volatile u16*)(m_mmio_base.get() + address); auto* ptr = (volatile u16*)(m_mmio_base.get() + address);
*ptr = data; *ptr = data;
@ -384,7 +384,7 @@ void E1000NetworkAdapter::out16(u16 address, u16 data)
void E1000NetworkAdapter::out32(u16 address, u32 data) void E1000NetworkAdapter::out32(u16 address, u32 data)
{ {
dbgln<debug_e1000>("E1000: OUT32 {:#08x} @ {:#04x}", data, address); dbgln<E1000_DEBUG>("E1000: OUT32 {:#08x} @ {:#04x}", data, address);
if (m_use_mmio) { if (m_use_mmio) {
auto* ptr = (volatile u32*)(m_mmio_base.get() + address); auto* ptr = (volatile u32*)(m_mmio_base.get() + address);
*ptr = data; *ptr = data;
@ -395,7 +395,7 @@ void E1000NetworkAdapter::out32(u16 address, u32 data)
u8 E1000NetworkAdapter::in8(u16 address) u8 E1000NetworkAdapter::in8(u16 address)
{ {
dbgln<debug_e1000>("E1000: IN8 @ {:#04x}", address); dbgln<E1000_DEBUG>("E1000: IN8 @ {:#04x}", address);
if (m_use_mmio) if (m_use_mmio)
return *(volatile u8*)(m_mmio_base.get() + address); return *(volatile u8*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u8>(); return m_io_base.offset(address).in<u8>();
@ -403,7 +403,7 @@ u8 E1000NetworkAdapter::in8(u16 address)
u16 E1000NetworkAdapter::in16(u16 address) u16 E1000NetworkAdapter::in16(u16 address)
{ {
dbgln<debug_e1000>("E1000: IN16 @ {:#04x}", address); dbgln<E1000_DEBUG>("E1000: IN16 @ {:#04x}", address);
if (m_use_mmio) if (m_use_mmio)
return *(volatile u16*)(m_mmio_base.get() + address); return *(volatile u16*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u16>(); return m_io_base.offset(address).in<u16>();
@ -411,7 +411,7 @@ u16 E1000NetworkAdapter::in16(u16 address)
u32 E1000NetworkAdapter::in32(u16 address) u32 E1000NetworkAdapter::in32(u16 address)
{ {
dbgln<debug_e1000>("E1000: IN32 @ {:#04x}", address); dbgln<E1000_DEBUG>("E1000: IN32 @ {:#04x}", address);
if (m_use_mmio) if (m_use_mmio)
return *(volatile u32*)(m_mmio_base.get() + address); return *(volatile u32*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u32>(); return m_io_base.offset(address).in<u32>();

View file

@ -66,7 +66,7 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
IPv4Socket::IPv4Socket(int type, int protocol) IPv4Socket::IPv4Socket(int type, int protocol)
: Socket(AF_INET, type, protocol) : Socket(AF_INET, type, protocol)
{ {
dbgln<debug_ipv4_socket>("IPv4Socket({}) created with type={}, protocol={}", this, type, protocol); dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}) created with type={}, protocol={}", this, type, protocol);
m_buffer_mode = type == SOCK_STREAM ? BufferMode::Bytes : BufferMode::Packets; m_buffer_mode = type == SOCK_STREAM ? BufferMode::Bytes : BufferMode::Packets;
if (m_buffer_mode == BufferMode::Bytes) { if (m_buffer_mode == BufferMode::Bytes) {
m_scratch_buffer = KBuffer::create_with_size(65536); m_scratch_buffer = KBuffer::create_with_size(65536);
@ -119,7 +119,7 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t addr
m_local_address = IPv4Address((const u8*)&address.sin_addr.s_addr); m_local_address = IPv4Address((const u8*)&address.sin_addr.s_addr);
m_local_port = requested_local_port; m_local_port = requested_local_port;
dbgln<debug_ipv4_socket>("IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port); dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port);
return protocol_bind(); return protocol_bind();
} }
@ -135,7 +135,7 @@ KResult IPv4Socket::listen(size_t backlog)
m_role = Role::Listener; m_role = Role::Listener;
evaluate_block_conditions(); evaluate_block_conditions();
dbgln<debug_ipv4_socket>("IPv4Socket({}) listening with backlog={}", this, backlog); dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}) listening with backlog={}", this, backlog);
return protocol_listen(); return protocol_listen();
} }
@ -287,7 +287,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet = m_receive_queue.take_first(); packet = m_receive_queue.take_first();
set_can_read(!m_receive_queue.is_empty()); set_can_read(!m_receive_queue.is_empty());
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom without blocking {} bytes, packets in queue: {}", dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}): recvfrom without blocking {} bytes, packets in queue: {}",
this, this,
packet.data.value().size(), packet.data.value().size(),
m_receive_queue.size()); m_receive_queue.size());
@ -316,7 +316,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet = m_receive_queue.take_first(); packet = m_receive_queue.take_first();
set_can_read(!m_receive_queue.is_empty()); set_can_read(!m_receive_queue.is_empty());
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom with blocking {} bytes, packets in queue: {}", dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}): recvfrom with blocking {} bytes, packets in queue: {}",
this, this,
packet.data.value().size(), packet.data.value().size(),
m_receive_queue.size()); m_receive_queue.size());
@ -326,7 +326,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet_timestamp = packet.timestamp; packet_timestamp = packet.timestamp;
if (addr) { if (addr) {
dbgln<debug_ipv4_socket>("Incoming packet is from: {}:{}", packet.peer_address, packet.peer_port); dbgln<IPV4_SOCKET_DEBUG>("Incoming packet is from: {}:{}", packet.peer_address, packet.peer_port);
sockaddr_in out_addr {}; sockaddr_in out_addr {};
memcpy(&out_addr.sin_addr, &packet.peer_address, sizeof(IPv4Address)); memcpy(&out_addr.sin_addr, &packet.peer_address, sizeof(IPv4Address));
@ -411,7 +411,7 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port,
} }
m_bytes_received += packet_size; m_bytes_received += packet_size;
if constexpr (debug_ipv4_socket) { if constexpr (IPV4_SOCKET_DEBUG) {
if (buffer_mode() == BufferMode::Bytes) if (buffer_mode() == BufferMode::Bytes)
dbgln("IPv4Socket({}): did_receive {} bytes, total_received={}", this, packet_size, m_bytes_received); dbgln("IPv4Socket({}): did_receive {} bytes, total_received={}", this, packet_size, m_bytes_received);
else else

View file

@ -74,7 +74,7 @@ LocalSocket::LocalSocket(int type)
evaluate_block_conditions(); evaluate_block_conditions();
}); });
dbgln<debug_local_socket>("LocalSocket({}) created with type={}", this, type); dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) created with type={}", this, type);
} }
LocalSocket::~LocalSocket() LocalSocket::~LocalSocket()
@ -110,7 +110,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add
auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path))); auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path)));
dbgln<debug_local_socket>("LocalSocket({}) bind({})", this, path); dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) bind({})", this, path);
mode_t mode = S_IFSOCK | (m_prebind_mode & 0777); mode_t mode = S_IFSOCK | (m_prebind_mode & 0777);
UidAndGid owner { m_prebind_uid, m_prebind_gid }; UidAndGid owner { m_prebind_uid, m_prebind_gid };
@ -154,7 +154,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
return EFAULT; return EFAULT;
safe_address[sizeof(safe_address) - 1] = '\0'; safe_address[sizeof(safe_address) - 1] = '\0';
dbgln<debug_local_socket>("LocalSocket({}) connect({})", this, safe_address); dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) connect({})", this, safe_address);
auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory()); auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory());
if (description_or_error.is_error()) if (description_or_error.is_error())
@ -190,7 +190,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
return EINTR; return EINTR;
} }
dbgln<debug_local_socket>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state())); dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state()));
if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) { if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) {
set_connect_side_role(Role::None); set_connect_side_role(Role::None);
@ -210,7 +210,7 @@ KResult LocalSocket::listen(size_t backlog)
m_role = Role::Listener; m_role = Role::Listener;
set_connect_side_role(Role::Listener, previous_role != m_role); set_connect_side_role(Role::Listener, previous_role != m_role);
dbgln<debug_local_socket>("LocalSocket({}) listening with backlog={}", this, backlog); dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) listening with backlog={}", this, backlog);
return KSuccess; return KSuccess;
} }

View file

@ -64,7 +64,7 @@ Socket::~Socket()
void Socket::set_setup_state(SetupState new_setup_state) void Socket::set_setup_state(SetupState new_setup_state)
{ {
dbgln<debug_socket>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state)); dbgln<SOCKET_DEBUG>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state));
m_setup_state = new_setup_state; m_setup_state = new_setup_state;
evaluate_block_conditions(); evaluate_block_conditions();
} }
@ -74,7 +74,7 @@ RefPtr<Socket> Socket::accept()
LOCKER(m_lock); LOCKER(m_lock);
if (m_pending.is_empty()) if (m_pending.is_empty())
return nullptr; return nullptr;
dbgln<debug_socket>("Socket({}) de-queueing connection", this); dbgln<SOCKET_DEBUG>("Socket({}) de-queueing connection", this);
auto client = m_pending.take_first(); auto client = m_pending.take_first();
ASSERT(!client->is_connected()); ASSERT(!client->is_connected());
auto& process = *Process::current(); auto& process = *Process::current();
@ -88,7 +88,7 @@ RefPtr<Socket> Socket::accept()
KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer) KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer)
{ {
dbgln<debug_socket>("Socket({}) queueing connection", this); dbgln<SOCKET_DEBUG>("Socket({}) queueing connection", this);
LOCKER(m_lock); LOCKER(m_lock);
if (m_pending.size() >= m_backlog) if (m_pending.size() >= m_backlog)
return ECONNREFUSED; return ECONNREFUSED;

View file

@ -47,7 +47,7 @@ void TCPSocket::for_each(Function<void(const TCPSocket&)> callback)
void TCPSocket::set_state(State new_state) void TCPSocket::set_state(State new_state)
{ {
dbgln<debug_tcp_socket>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state)); dbgln<TCP_SOCKET_DEBUG>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state));
auto was_disconnected = protocol_is_disconnected(); auto was_disconnected = protocol_is_disconnected();
auto previous_role = m_role; auto previous_role = m_role;
@ -154,7 +154,7 @@ TCPSocket::~TCPSocket()
LOCKER(sockets_by_tuple().lock()); LOCKER(sockets_by_tuple().lock());
sockets_by_tuple().resource().remove(tuple()); sockets_by_tuple().resource().remove(tuple());
dbgln<debug_tcp_socket>("~TCPSocket in state {}", to_string(state())); dbgln<TCP_SOCKET_DEBUG>("~TCPSocket in state {}", to_string(state()));
} }
NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol) NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
@ -273,14 +273,14 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
if (packet.has_ack()) { if (packet.has_ack()) {
u32 ack_number = packet.ack_number(); u32 ack_number = packet.ack_number();
dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet: {}", ack_number); dbgln<TCP_SOCKET_DEBUG>("TCPSocket: receive_tcp_packet: {}", ack_number);
int removed = 0; int removed = 0;
LOCKER(m_not_acked_lock); LOCKER(m_not_acked_lock);
while (!m_not_acked.is_empty()) { while (!m_not_acked.is_empty()) {
auto& packet = m_not_acked.first(); auto& packet = m_not_acked.first();
dbgln<debug_tcp_socket>("TCPSocket: iterate: {}", packet.ack_number); dbgln<TCP_SOCKET_DEBUG>("TCPSocket: iterate: {}", packet.ack_number);
if (packet.ack_number <= ack_number) { if (packet.ack_number <= ack_number) {
m_not_acked.take_first(); m_not_acked.take_first();
@ -290,7 +290,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
} }
} }
dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed); dbgln<TCP_SOCKET_DEBUG>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed);
} }
m_packets_in++; m_packets_in++;

View file

@ -74,34 +74,34 @@ PhysicalID Access::get_physical_id(Address address) const
u8 Access::early_read8_field(Address address, u32 field) u8 Access::early_read8_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: Early reading 8-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: Early reading 8-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in8(PCI_VALUE_PORT + (field & 3)); return IO::in8(PCI_VALUE_PORT + (field & 3));
} }
u16 Access::early_read16_field(Address address, u32 field) u16 Access::early_read16_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: Early reading 16-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: Early reading 16-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in16(PCI_VALUE_PORT + (field & 2)); return IO::in16(PCI_VALUE_PORT + (field & 2));
} }
u32 Access::early_read32_field(Address address, u32 field) u32 Access::early_read32_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: Early reading 32-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: Early reading 32-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in32(PCI_VALUE_PORT); return IO::in32(PCI_VALUE_PORT);
} }
u16 Access::early_read_type(Address address) u16 Access::early_read_type(Address address)
{ {
dbgln<debug_pci>("PCI: Early reading type for {}", address); dbgln<PCI_DEBUG>("PCI: Early reading type for {}", address);
return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS); return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS);
} }
void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback) void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback)
{ {
dbgln<debug_pci>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function); dbgln<PCI_DEBUG>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function);
Address address(0, bus, slot, function); Address address(0, bus, slot, function);
if (type == -1 || type == early_read_type(address)) if (type == -1 || type == early_read_type(address))
callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) }); callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) });
@ -117,7 +117,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Functio
void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback) void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback)
{ {
dbgln<debug_pci>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot); dbgln<PCI_DEBUG>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot);
Address address(0, bus, slot, 0); Address address(0, bus, slot, 0);
if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE) if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE)
return; return;
@ -133,7 +133,7 @@ void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID
void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback) void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback)
{ {
dbgln<debug_pci>("PCI: Enumerating bus type={}, bus={}", type, bus); dbgln<PCI_DEBUG>("PCI: Enumerating bus type={}, bus={}", type, bus);
for (u8 slot = 0; slot < 32; ++slot) for (u8 slot = 0; slot < 32; ++slot)
enumerate_slot(type, bus, slot, callback); enumerate_slot(type, bus, slot, callback);
} }
@ -152,12 +152,12 @@ void enumerate(Function<void(Address, ID)> callback)
Optional<u8> get_capabilities_pointer(Address address) Optional<u8> get_capabilities_pointer(Address address)
{ {
dbgln<debug_pci>("PCI: Getting capabilities pointer for {}", address); dbgln<PCI_DEBUG>("PCI: Getting capabilities pointer for {}", address);
if (PCI::read16(address, PCI_STATUS) & (1 << 4)) { if (PCI::read16(address, PCI_STATUS) & (1 << 4)) {
dbgln<debug_pci>("PCI: Found capabilities pointer for {}", address); dbgln<PCI_DEBUG>("PCI: Found capabilities pointer for {}", address);
return PCI::read8(address, PCI_CAPABILITIES_POINTER); return PCI::read8(address, PCI_CAPABILITIES_POINTER);
} }
dbgln<debug_pci>("PCI: No capabilities pointer for {}", address); dbgln<PCI_DEBUG>("PCI: No capabilities pointer for {}", address);
return {}; return {};
} }
@ -168,16 +168,16 @@ PhysicalID get_physical_id(Address address)
Vector<Capability> get_capabilities(Address address) Vector<Capability> get_capabilities(Address address)
{ {
dbgln<debug_pci>("PCI: Getting capabilities for {}", address); dbgln<PCI_DEBUG>("PCI: Getting capabilities for {}", address);
auto capabilities_pointer = PCI::get_capabilities_pointer(address); auto capabilities_pointer = PCI::get_capabilities_pointer(address);
if (!capabilities_pointer.has_value()) { if (!capabilities_pointer.has_value()) {
dbgln<debug_pci>("PCI: No capabilities for {}", address); dbgln<PCI_DEBUG>("PCI: No capabilities for {}", address);
return {}; return {};
} }
Vector<Capability> capabilities; Vector<Capability> capabilities;
auto capability_pointer = capabilities_pointer.value(); auto capability_pointer = capabilities_pointer.value();
while (capability_pointer != 0) { while (capability_pointer != 0) {
dbgln<debug_pci>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address); dbgln<PCI_DEBUG>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address);
u16 capability_header = PCI::read16(address, capability_pointer); u16 capability_header = PCI::read16(address, capability_pointer);
u8 capability_id = capability_header & 0xff; u8 capability_id = capability_header & 0xff;
capability_pointer = capability_header >> 8; capability_pointer = capability_header >> 8;

View file

@ -194,7 +194,7 @@ public:
, m_id(id) , m_id(id)
, m_capabilities(capabilities) , m_capabilities(capabilities)
{ {
if constexpr (debug_pci) { if constexpr (PCI_DEBUG) {
for (auto capability : capabilities) for (auto capability : capabilities)
dbgln("{} has capability {}", address, capability.m_id); dbgln("{} has capability {}", address, capability.m_id);
} }

View file

@ -35,7 +35,7 @@ void IOAccess::initialize()
{ {
if (!Access::is_initialized()) { if (!Access::is_initialized()) {
new IOAccess(); new IOAccess();
dbgln<debug_pci>("PCI: IO access initialised."); dbgln<PCI_DEBUG>("PCI: IO access initialised.");
} }
} }
@ -49,37 +49,37 @@ IOAccess::IOAccess()
u8 IOAccess::read8_field(Address address, u32 field) u8 IOAccess::read8_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address);
return Access::early_read8_field(address, field); return Access::early_read8_field(address, field);
} }
u16 IOAccess::read16_field(Address address, u32 field) u16 IOAccess::read16_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address);
return Access::early_read16_field(address, field); return Access::early_read16_field(address, field);
} }
u32 IOAccess::read32_field(Address address, u32 field) u32 IOAccess::read32_field(Address address, u32 field)
{ {
dbgln<debug_pci>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address);
return Access::early_read32_field(address, field); return Access::early_read32_field(address, field);
} }
void IOAccess::write8_field(Address address, u32 field, u8 value) void IOAccess::write8_field(Address address, u32 field, u8 value)
{ {
dbgln<debug_pci>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out8(PCI_VALUE_PORT + (field & 3), value); IO::out8(PCI_VALUE_PORT + (field & 3), value);
} }
void IOAccess::write16_field(Address address, u32 field, u16 value) void IOAccess::write16_field(Address address, u32 field, u16 value)
{ {
dbgln<debug_pci>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out16(PCI_VALUE_PORT + (field & 2), value); IO::out16(PCI_VALUE_PORT + (field & 2), value);
} }
void IOAccess::write32_field(Address address, u32 field, u32 value) void IOAccess::write32_field(Address address, u32 field, u32 value)
{ {
dbgln<debug_pci>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out32(PCI_VALUE_PORT, value); IO::out32(PCI_VALUE_PORT, value);
} }

View file

@ -109,7 +109,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write); auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write);
auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr(); auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr();
dbgln<debug_pci>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get())); dbgln<PCI_DEBUG>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
for (u32 index = 0; index < ((mcfg.header.length - sizeof(ACPI::Structures::MCFG)) / sizeof(ACPI::Structures::PCI_MMIO_Descriptor)); index++) { for (u32 index = 0; index < ((mcfg.header.length - sizeof(ACPI::Structures::MCFG)) / sizeof(ACPI::Structures::PCI_MMIO_Descriptor)); index++) {
u8 start_bus = mcfg.descriptors[index].start_pci_bus; u8 start_bus = mcfg.descriptors[index].start_pci_bus;
@ -127,26 +127,26 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
enumerate_hardware([&](const Address& address, ID id) { enumerate_hardware([&](const Address& address, ID id) {
m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value())); m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value()));
m_physical_ids.append({ address, id, get_capabilities(address) }); m_physical_ids.append({ address, id, get_capabilities(address) });
dbgln<debug_pci>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr()); dbgln<PCI_DEBUG>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr());
}); });
} }
Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address) Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
{ {
dbgln<debug_pci>("PCI: Getting device configuration space for {}", address); dbgln<PCI_DEBUG>("PCI: Getting device configuration space for {}", address);
for (auto& mapping : m_mapped_device_regions) { for (auto& mapping : m_mapped_device_regions) {
auto checked_address = mapping.address(); auto checked_address = mapping.address();
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address); dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address);
if (address.seg() == checked_address.seg() if (address.seg() == checked_address.seg()
&& address.bus() == checked_address.bus() && address.bus() == checked_address.bus()
&& address.slot() == checked_address.slot() && address.slot() == checked_address.slot()
&& address.function() == checked_address.function()) { && address.function() == checked_address.function()) {
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Found {}", checked_address); dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Found {}", checked_address);
return mapping.vaddr(); return mapping.vaddr();
} }
} }
dbgln<debug_pci>("PCI: No device configuration space found for {}", address); dbgln<PCI_DEBUG>("PCI: No device configuration space found for {}", address);
return {}; return {};
} }
@ -154,7 +154,7 @@ u8 MMIOAccess::read8_field(Address address, u32 field)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field <= 0xfff); ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
return *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff))); return *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
} }
@ -162,7 +162,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field < 0xfff); ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
return *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff))); return *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
} }
@ -170,7 +170,7 @@ u32 MMIOAccess::read32_field(Address address, u32 field)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field <= 0xffc); ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address); dbgln<PCI_DEBUG>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
return *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff))); return *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
} }
@ -178,28 +178,28 @@ void MMIOAccess::write8_field(Address address, u32 field, u8 value)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field <= 0xfff); ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value; *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
} }
void MMIOAccess::write16_field(Address address, u32 field, u16 value) void MMIOAccess::write16_field(Address address, u32 field, u16 value)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field < 0xfff); ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value; *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
} }
void MMIOAccess::write32_field(Address address, u32 field, u32 value) void MMIOAccess::write32_field(Address address, u32 field, u32 value)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
ASSERT(field <= 0xffc); ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address); dbgln<PCI_DEBUG>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value; *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
} }
void MMIOAccess::enumerate_hardware(Function<void(Address, ID)> callback) void MMIOAccess::enumerate_hardware(Function<void(Address, ID)> callback)
{ {
for (u16 seg = 0; seg < m_segments.size(); seg++) { for (u16 seg = 0; seg < m_segments.size(); seg++) {
dbgln<debug_pci>("PCI: Enumerating Memory mapped IO segment {}", seg); dbgln<PCI_DEBUG>("PCI: Enumerating Memory mapped IO segment {}", seg);
// Single PCI host controller. // Single PCI host controller.
if ((early_read8_field(Address(seg), PCI_HEADER_TYPE) & 0x80) == 0) { if ((early_read8_field(Address(seg), PCI_HEADER_TYPE) & 0x80) == 0) {
enumerate_bus(-1, 0, callback); enumerate_bus(-1, 0, callback);

View file

@ -351,7 +351,7 @@ Process::Process(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gi
, m_ppid(ppid) , m_ppid(ppid)
, m_wait_block_condition(*this) , m_wait_block_condition(*this)
{ {
dbgln<debug_process>("Created new process {}({})", m_name, m_pid.value()); dbgln<PROCESS_DEBUG>("Created new process {}({})", m_name, m_pid.value());
m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr); m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
@ -615,7 +615,7 @@ void Process::finalize()
{ {
ASSERT(Thread::current() == g_finalizer); ASSERT(Thread::current() == g_finalizer);
dbgln<debug_process>("Finalizing process {}", *this); dbgln<PROCESS_DEBUG>("Finalizing process {}", *this);
if (is_dumpable()) { if (is_dumpable()) {
if (m_should_dump_core) if (m_should_dump_core)

View file

@ -129,13 +129,13 @@ bool Scheduler::pick_next()
// Scheduler::enter_current because we don't want to allow it to // Scheduler::enter_current because we don't want to allow it to
// transition back to user mode. // transition back to user mode.
if constexpr (debug_scheduler) if constexpr (SCHEDULER_DEBUG)
dbgln("Scheduler[{}]: Thread {} is dying", Processor::current().id(), *current_thread); dbgln("Scheduler[{}]: Thread {} is dying", Processor::current().id(), *current_thread);
current_thread->set_state(Thread::Dying); current_thread->set_state(Thread::Dying);
} }
if constexpr (debug_scheduler_runnable) { if constexpr (SCHEDULER_RUNNABLE_DEBUG) {
dbgln("Scheduler[{}j]: Non-runnables:", Processor::current().id()); dbgln("Scheduler[{}j]: Non-runnables:", Processor::current().id());
Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision { Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision {
if (thread.state() == Thread::Dying) { if (thread.state() == Thread::Dying) {
@ -196,7 +196,7 @@ bool Scheduler::pick_next()
// but since we're still holding the scheduler lock we're still in a critical section // but since we're still holding the scheduler lock we're still in a critical section
critical.leave(); critical.leave();
dbgln<debug_scheduler>("Processing pending donate to {} reason={}", *thread_to_schedule, reason); dbgln<SCHEDULER_DEBUG>("Processing pending donate to {} reason={}", *thread_to_schedule, reason);
return donate_to_and_switch(thread_to_schedule, reason); return donate_to_and_switch(thread_to_schedule, reason);
} }
@ -224,7 +224,7 @@ bool Scheduler::pick_next()
if (!thread_to_schedule) if (!thread_to_schedule)
thread_to_schedule = Processor::current().idle_thread(); thread_to_schedule = Processor::current().idle_thread();
if constexpr (debug_scheduler) { if constexpr (SCHEDULER_DEBUG) {
dbgln("Scheduler[{}]: Switch to {} @ {:04x}:{:08x}", dbgln("Scheduler[{}]: Switch to {} @ {:04x}:{:08x}",
Processor::current().id(), Processor::current().id(),
*thread_to_schedule, *thread_to_schedule,
@ -250,7 +250,7 @@ bool Scheduler::yield()
scheduler_data.m_pending_donate_reason = nullptr; scheduler_data.m_pending_donate_reason = nullptr;
auto current_thread = Thread::current(); auto current_thread = Thread::current();
dbgln<debug_scheduler>("Scheduler[{}]: yielding thread {} in_irq={}", proc.id(), *current_thread, proc.in_irq()); dbgln<SCHEDULER_DEBUG>("Scheduler[{}]: yielding thread {} in_irq={}", proc.id(), *current_thread, proc.in_irq());
ASSERT(current_thread != nullptr); ASSERT(current_thread != nullptr);
if (proc.in_irq() || proc.in_critical()) { if (proc.in_irq() || proc.in_critical()) {
// If we're handling an IRQ we can't switch context, or we're in // If we're handling an IRQ we can't switch context, or we're in
@ -263,7 +263,7 @@ bool Scheduler::yield()
if (!Scheduler::pick_next()) if (!Scheduler::pick_next())
return false; return false;
if constexpr (debug_scheduler) if constexpr (SCHEDULER_DEBUG)
dbgln("Scheduler[{}]: yield returns to thread {} in_irq={}", Processor::current().id(), *current_thread, Processor::current().in_irq()); dbgln("Scheduler[{}]: yield returns to thread {} in_irq={}", Processor::current().id(), *current_thread, Processor::current().in_irq());
return true; return true;
} }
@ -280,7 +280,7 @@ bool Scheduler::donate_to_and_switch(Thread* beneficiary, [[maybe_unused]] const
return Scheduler::yield(); return Scheduler::yield();
unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(*beneficiary)); unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(*beneficiary));
dbgln<debug_scheduler>("Scheduler[{}]: Donating {} ticks to {}, reason={}", proc.id(), ticks_to_donate, *beneficiary, reason); dbgln<SCHEDULER_DEBUG>("Scheduler[{}]: Donating {} ticks to {}, reason={}", proc.id(), ticks_to_donate, *beneficiary, reason);
beneficiary->set_ticks_left(ticks_to_donate); beneficiary->set_ticks_left(ticks_to_donate);
return Scheduler::context_switch(beneficiary); return Scheduler::context_switch(beneficiary);

View file

@ -176,7 +176,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu
// which could cause page faults. Note that this may be called immediately // which could cause page faults. Note that this may be called immediately
// before Processor::deferred_call_queue returns! // before Processor::deferred_call_queue returns!
Processor::deferred_call_queue([this, result]() { Processor::deferred_call_queue([this, result]() {
dbgln<debug_pata>("IDEChannel::complete_current_request result: {}", (int)result); dbgln<PATA_DEBUG>("IDEChannel::complete_current_request result: {}", (int)result);
ASSERT(m_current_request); ASSERT(m_current_request);
auto& request = *m_current_request; auto& request = *m_current_request;
m_current_request = nullptr; m_current_request = nullptr;
@ -364,7 +364,7 @@ void IDEChannel::ata_read_sectors_with_dma(bool slave_request)
{ {
auto& request = *m_current_request; auto& request = *m_current_request;
u32 lba = request.block_index(); u32 lba = request.block_index();
dbgln<debug_pata>("IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count()); dbgln<PATA_DEBUG>("IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count());
prdt().offset = m_dma_buffer_page->paddr(); prdt().offset = m_dma_buffer_page->paddr();
prdt().size = 512 * request.block_count(); prdt().size = 512 * request.block_count();
@ -483,7 +483,7 @@ void IDEChannel::ata_write_sectors_with_dma(bool slave_request)
{ {
auto& request = *m_current_request; auto& request = *m_current_request;
u32 lba = request.block_index(); u32 lba = request.block_index();
dbgln<debug_pata>("IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count()); dbgln<PATA_DEBUG>("IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count());
prdt().offset = m_dma_buffer_page->paddr(); prdt().offset = m_dma_buffer_page->paddr();
prdt().size = 512 * request.block_count(); prdt().size = 512 * request.block_count();

View file

@ -33,7 +33,7 @@ namespace Kernel {
int Process::sys$fcntl(int fd, int cmd, u32 arg) int Process::sys$fcntl(int fd, int cmd, u32 arg)
{ {
REQUIRE_PROMISE(stdio); REQUIRE_PROMISE(stdio);
dbgln<debug_io>("sys$fcntl: fd={}, cmd={}, arg={}", fd, cmd, arg); dbgln<IO_DEBUG>("sys$fcntl: fd={}, cmd={}, arg={}", fd, cmd, arg);
auto description = file_description(fd); auto description = file_description(fd);
if (!description) if (!description)
return -EBADF; return -EBADF;

View file

@ -50,7 +50,7 @@ pid_t Process::sys$fork(RegisterState& regs)
child->m_pg = m_pg; child->m_pg = m_pg;
child->m_umask = m_umask; child->m_umask = m_umask;
dbgln<debug_fork>("fork: child={}", child); dbgln<FORK_DEBUG>("fork: child={}", child);
child->m_extra_gids = m_extra_gids; child->m_extra_gids = m_extra_gids;
@ -79,7 +79,7 @@ pid_t Process::sys$fork(RegisterState& regs)
{ {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
for (auto& region : m_regions) { for (auto& region : m_regions) {
dbgln<debug_fork>("fork: cloning Region({}) '{}' @ {}", &region, region.name(), region.vaddr()); dbgln<FORK_DEBUG>("fork: cloning Region({}) '{}' @ {}", &region, region.name(), region.vaddr());
auto region_clone = region.clone(*child); auto region_clone = region.clone(*child);
if (!region_clone) { if (!region_clone) {
dbgln("fork: Cannot clone region, insufficient memory"); dbgln("fork: Cannot clone region, insufficient memory");

View file

@ -39,7 +39,7 @@ FutexQueue::FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject)
: m_user_address_or_offset(user_address_or_offset) : m_user_address_or_offset(user_address_or_offset)
, m_is_global(vmobject != nullptr) , m_is_global(vmobject != nullptr)
{ {
dbgln<debug_futex>("Futex @ {}{}", dbgln<FUTEX_DEBUG>("Futex @ {}{}",
this, this,
m_is_global ? " (global)" : " (local)"); m_is_global ? " (global)" : " (local)");
@ -56,7 +56,7 @@ FutexQueue::~FutexQueue()
if (auto vmobject = m_vmobject.strong_ref()) if (auto vmobject = m_vmobject.strong_ref())
vmobject->unregister_on_deleted_handler(*this); vmobject->unregister_on_deleted_handler(*this);
} }
dbgln<debug_futex>("~Futex @ {}{}", dbgln<FUTEX_DEBUG>("~Futex @ {}{}",
this, this,
m_is_global ? " (global)" : " (local)"); m_is_global ? " (global)" : " (local)");
} }
@ -68,7 +68,7 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
// to make sure we have at last a reference until we're done // to make sure we have at last a reference until we're done
NonnullRefPtr<FutexQueue> own_ref(*this); NonnullRefPtr<FutexQueue> own_ref(*this);
dbgln<debug_futex>("Futex::vmobject_deleted @ {}{}", dbgln<FUTEX_DEBUG>("Futex::vmobject_deleted @ {}{}",
this, this,
m_is_global ? " (global)" : " (local)"); m_is_global ? " (global)" : " (local)");
@ -84,7 +84,7 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
bool did_wake_all; bool did_wake_all;
auto wake_count = wake_all(did_wake_all); auto wake_count = wake_all(did_wake_all);
if constexpr (debug_futex) { if constexpr (FUTEX_DEBUG) {
if (wake_count > 0) if (wake_count > 0)
dbgln("Futex @ {} unblocked {} waiters due to vmobject free", this, wake_count); dbgln("Futex @ {} unblocked {} waiters due to vmobject free", this, wake_count);
} }

View file

@ -63,7 +63,7 @@ int Process::sys$open(Userspace<const Syscall::SC_open_params*> user_params)
if (path.is_error()) if (path.is_error())
return path.error(); return path.error();
dbgln<debug_io>("sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode); dbgln<IO_DEBUG>("sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode);
int fd = alloc_fd(); int fd = alloc_fd();
if (fd < 0) if (fd < 0)
return fd; return fd;
@ -99,7 +99,7 @@ int Process::sys$close(int fd)
{ {
REQUIRE_PROMISE(stdio); REQUIRE_PROMISE(stdio);
auto description = file_description(fd); auto description = file_description(fd);
dbgln<debug_io>("sys$close({}) {}", fd, description.ptr()); dbgln<IO_DEBUG>("sys$close({}) {}", fd, description.ptr());
if (!description) if (!description)
return -EBADF; return -EBADF;
int rc = description->close(); int rc = description->close();

View file

@ -37,7 +37,7 @@ ssize_t Process::sys$read(int fd, Userspace<u8*> buffer, ssize_t size)
return -EINVAL; return -EINVAL;
if (size == 0) if (size == 0)
return 0; return 0;
dbgln<debug_io>("sys$read({}, {}, {})", fd, buffer.ptr(), size); dbgln<IO_DEBUG>("sys$read({}, {}, {})", fd, buffer.ptr(), size);
auto description = file_description(fd); auto description = file_description(fd);
if (!description) if (!description)
return -EBADF; return -EBADF;

View file

@ -95,11 +95,11 @@ int Process::sys$select(const Syscall::SC_select_params* user_params)
fds.append(fd); fds.append(fd);
} }
if constexpr (debug_io || debug_poll_select) if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
dbgln("selecting on {} fds, timeout={}", fds_info.size(), params.timeout); dbgln("selecting on {} fds, timeout={}", fds_info.size(), params.timeout);
if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted()) { if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted()) {
dbgln<debug_poll_select>("select was interrupted"); dbgln<POLL_SELECT_DEBUG>("select was interrupted");
return -EINTR; return -EINTR;
} }
@ -198,7 +198,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
current_thread->update_signal_mask(previous_signal_mask); current_thread->update_signal_mask(previous_signal_mask);
}); });
if constexpr (debug_io || debug_poll_select) if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
dbgln("polling on {} fds, timeout={}", fds_info.size(), params.timeout); dbgln("polling on {} fds, timeout={}", fds_info.size(), params.timeout);
if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted()) if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted())

View file

@ -55,7 +55,7 @@ pid_t Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> user_param
if (!copy_from_user(&params, user_params)) if (!copy_from_user(&params, user_params))
return -EFAULT; return -EFAULT;
dbgln<debug_process>("sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options); dbgln<PROCESS_DEBUG>("sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options);
auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options); auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options);
if (siginfo_or_error.is_error()) if (siginfo_or_error.is_error())

View file

@ -125,7 +125,7 @@ ssize_t Process::sys$write(int fd, const u8* data, ssize_t size)
if (size == 0) if (size == 0)
return 0; return 0;
dbgln<debug_io>("sys$write({}, {}, {})", fd, data, size); dbgln<IO_DEBUG>("sys$write({}, {}, {})", fd, data, size);
auto description = file_description(fd); auto description = file_description(fd);
if (!description) if (!description)
return -EBADF; return -EBADF;

View file

@ -53,7 +53,7 @@ MasterPTY::MasterPTY(unsigned index)
MasterPTY::~MasterPTY() MasterPTY::~MasterPTY()
{ {
dbgln<debug_masterpty>("~MasterPTY({})", m_index); dbgln<MASTERPTY_DEBUG>("~MasterPTY({})", m_index);
PTYMultiplexer::the().notify_master_destroyed({}, m_index); PTYMultiplexer::the().notify_master_destroyed({}, m_index);
} }
@ -91,7 +91,7 @@ bool MasterPTY::can_write(const FileDescription&, size_t) const
void MasterPTY::notify_slave_closed(Badge<SlavePTY>) void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
{ {
dbgln<debug_masterpty>("MasterPTY({}): slave closed, my retains: {}, slave retains: {}", m_index, ref_count(), m_slave->ref_count()); dbgln<MASTERPTY_DEBUG>("MasterPTY({}): slave closed, my retains: {}, slave retains: {}", m_index, ref_count(), m_slave->ref_count());
// +1 ref for my MasterPTY::m_slave // +1 ref for my MasterPTY::m_slave
// +1 ref for FileDescription::m_device // +1 ref for FileDescription::m_device
if (m_slave->ref_count() == 2) if (m_slave->ref_count() == 2)

View file

@ -61,7 +61,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
return EBUSY; return EBUSY;
auto master_index = m_freelist.take_last(); auto master_index = m_freelist.take_last();
auto master = adopt(*new MasterPTY(master_index)); auto master = adopt(*new MasterPTY(master_index));
dbgln<debug_ptmx>("PTYMultiplexer::open: Vending master {}", master->index()); dbgln<PTMX_DEBUG>("PTYMultiplexer::open: Vending master {}", master->index());
auto description = FileDescription::create(move(master)); auto description = FileDescription::create(move(master));
if (!description.is_error()) { if (!description.is_error()) {
description.value()->set_rw_mode(options); description.value()->set_rw_mode(options);
@ -74,7 +74,7 @@ void PTYMultiplexer::notify_master_destroyed(Badge<MasterPTY>, unsigned index)
{ {
LOCKER(m_lock); LOCKER(m_lock);
m_freelist.append(index); m_freelist.append(index);
dbgln<debug_ptmx>("PTYMultiplexer: {} added to freelist", index); dbgln<PTMX_DEBUG>("PTYMultiplexer: {} added to freelist", index);
} }
} }

View file

@ -47,7 +47,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index)
SlavePTY::~SlavePTY() SlavePTY::~SlavePTY()
{ {
dbgln<debug_slavepty>("~SlavePTY({})", m_index); dbgln<SLAVEPTY_DEBUG>("~SlavePTY({})", m_index);
DevPtsFS::unregister_slave_pty(*this); DevPtsFS::unregister_slave_pty(*this);
} }

View file

@ -304,7 +304,7 @@ void TTY::set_termios(const termios& t)
{ {
m_termios = t; m_termios = t;
dbgln<debug_tty>("{} set_termios: ECHO={}, ISIG={}, ICANON={}, ECHOE={}, ECHOK={}, ECHONL={}, ISTRIP={}, ICRNL={}, INLCR={}, IGNCR={}", dbgln<TTY_DEBUG>("{} set_termios: ECHO={}, ISIG={}, ICANON={}, ECHOE={}, ECHOK={}, ECHONL={}, ISTRIP={}, ICRNL={}, INLCR={}, IGNCR={}",
tty_name(), tty_name(),
should_echo_input(), should_echo_input(),
should_generate_signals(), should_generate_signals(),

View file

@ -59,7 +59,7 @@ Thread::Thread(NonnullRefPtr<Process> process)
} else { } else {
m_tid = Process::allocate_pid().value(); m_tid = Process::allocate_pid().value();
} }
if constexpr (debug_thread) if constexpr (THREAD_DEBUG)
dbgln("Created new thread {}({}:{})", m_process->name(), m_process->pid().value(), m_tid.value()); dbgln("Created new thread {}({}:{})", m_process->name(), m_process->pid().value(), m_tid.value());
set_default_signal_dispositions(); set_default_signal_dispositions();
m_fpu_state = (FPUState*)kmalloc_aligned<16>(sizeof(FPUState)); m_fpu_state = (FPUState*)kmalloc_aligned<16>(sizeof(FPUState));
@ -370,7 +370,7 @@ void Thread::finalize()
{ {
ScopedSpinLock lock(g_scheduler_lock); ScopedSpinLock lock(g_scheduler_lock);
dbgln<debug_thread>("Finalizing thread {}", *this); dbgln<THREAD_DEBUG>("Finalizing thread {}", *this);
set_state(Thread::State::Dead); set_state(Thread::State::Dead);
m_join_condition.thread_finalizing(); m_join_condition.thread_finalizing();
} }
@ -476,11 +476,11 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
// FIXME: Figure out what to do for masked signals. Should we also ignore them here? // FIXME: Figure out what to do for masked signals. Should we also ignore them here?
if (should_ignore_signal(signal)) { if (should_ignore_signal(signal)) {
dbgln<debug_signal>("Signal {} was ignored by {}", signal, process()); dbgln<SIGNAL_DEBUG>("Signal {} was ignored by {}", signal, process());
return; return;
} }
if constexpr (debug_signal) { if constexpr (SIGNAL_DEBUG) {
if (sender) if (sender)
dbgln("Signal: {} sent {} to {}", *sender, signal, process()); dbgln("Signal: {} sent {} to {}", *sender, signal, process());
else else
@ -493,12 +493,12 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
if (m_state == Stopped) { if (m_state == Stopped) {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
if (pending_signals_for_state()) { if (pending_signals_for_state()) {
dbgln<debug_signal>("Signal: Resuming stopped {} to deliver signal {}", *this, signal); dbgln<SIGNAL_DEBUG>("Signal: Resuming stopped {} to deliver signal {}", *this, signal);
resume_from_stopped(); resume_from_stopped();
} }
} else { } else {
ScopedSpinLock block_lock(m_block_lock); ScopedSpinLock block_lock(m_block_lock);
dbgln<debug_signal>("Signal: Unblocking {} to deliver signal {}", *this, signal); dbgln<SIGNAL_DEBUG>("Signal: Unblocking {} to deliver signal {}", *this, signal);
unblock(signal); unblock(signal);
} }
} }
@ -710,7 +710,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
auto& process = this->process(); auto& process = this->process();
auto tracer = process.tracer(); auto tracer = process.tracer();
if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) { if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) {
dbgln<debug_signal>("signal: signal {} sopping thread {}", signal, *this); dbgln<SIGNAL_DEBUG>("signal: signal {} sopping thread {}", signal, *this);
set_state(State::Stopped, signal); set_state(State::Stopped, signal);
return DispatchSignalResult::Yield; return DispatchSignalResult::Yield;
} }
@ -873,13 +873,13 @@ void Thread::set_state(State new_state, u8 stop_signal)
if (previous_state == Invalid) { if (previous_state == Invalid) {
// If we were *just* created, we may have already pending signals // If we were *just* created, we may have already pending signals
if (has_unmasked_pending_signals()) { if (has_unmasked_pending_signals()) {
dbgln<debug_thread>("Dispatch pending signals to new thread {}", *this); dbgln<THREAD_DEBUG>("Dispatch pending signals to new thread {}", *this);
dispatch_one_pending_signal(); dispatch_one_pending_signal();
} }
} }
m_state = new_state; m_state = new_state;
dbgln<debug_thread>("Set thread {} state to {}", *this, state_string()); dbgln<THREAD_DEBUG>("Set thread {} state to {}", *this, state_string());
} }
if (m_process->pid() != 0) { if (m_process->pid() != 0) {
@ -894,7 +894,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) { process.for_each_thread([&](auto& thread) {
if (&thread == this || !thread.is_stopped()) if (&thread == this || !thread.is_stopped())
return IterationDecision::Continue; return IterationDecision::Continue;
dbgln<debug_thread>("Resuming peer thread {}", thread); dbgln<THREAD_DEBUG>("Resuming peer thread {}", thread);
thread.resume_from_stopped(); thread.resume_from_stopped();
return IterationDecision::Continue; return IterationDecision::Continue;
}); });
@ -910,7 +910,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) { process.for_each_thread([&](auto& thread) {
if (&thread == this || thread.is_stopped()) if (&thread == this || thread.is_stopped())
return IterationDecision::Continue; return IterationDecision::Continue;
dbgln<debug_thread>("Stopping peer thread {}", thread); dbgln<THREAD_DEBUG>("Stopping peer thread {}", thread);
thread.set_state(Stopped, stop_signal); thread.set_state(Stopped, stop_signal);
return IterationDecision::Continue; return IterationDecision::Continue;
}); });

View file

@ -462,9 +462,9 @@ void Thread::WaitBlockCondition::try_unblock(Thread::WaitBlocker& blocker)
if (blocker.is_wait()) { if (blocker.is_wait()) {
if (info.flags == Thread::WaitBlocker::UnblockFlags::Terminated) { if (info.flags == Thread::WaitBlocker::UnblockFlags::Terminated) {
m_processes.remove(i); m_processes.remove(i);
dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, remove {}", m_process, *info.process); dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] terminated, remove {}", m_process, *info.process);
} else { } else {
dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, mark as waited {}", m_process, *info.process); dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] terminated, mark as waited {}", m_process, *info.process);
info.was_waited = true; info.was_waited = true;
} }
} }
@ -488,7 +488,7 @@ void Thread::WaitBlockCondition::disowned_by_waiter(Process& process)
ASSERT(did_unblock); // disowning must unblock everyone ASSERT(did_unblock); // disowning must unblock everyone
return true; return true;
}); });
dbgln<debug_waitblock>("WaitBlockCondition[{}] disowned {}", m_process, *info.process); dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] disowned {}", m_process, *info.process);
m_processes.remove(i); m_processes.remove(i);
continue; continue;
} }
@ -541,13 +541,13 @@ bool Thread::WaitBlockCondition::unblock(Process& process, WaitBlocker::UnblockF
info.flags = flags; info.flags = flags;
info.signal = signal; info.signal = signal;
info.was_waited = did_wait; info.was_waited = did_wait;
dbgln<debug_waitblock>("WaitBlockCondition[{}] update {} flags={}, waited={}", m_process, process, (int)flags, info.was_waited); dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] update {} flags={}, waited={}", m_process, process, (int)flags, info.was_waited);
updated_existing = true; updated_existing = true;
break; break;
} }
} }
if (!updated_existing) { if (!updated_existing) {
dbgln<debug_waitblock>("WaitBlockCondition[{}] add {} flags: {}", m_process, process, (int)flags); dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] add {} flags: {}", m_process, process, (int)flags);
m_processes.append(ProcessBlockInfo(process, flags, signal)); m_processes.append(ProcessBlockInfo(process, flags, signal));
} }
} }

View file

@ -206,7 +206,7 @@ void HPET::update_periodic_comparator_value()
// and we can only write the period into the comparator value... // and we can only write the period into the comparator value...
timer.capabilities = timer.capabilities | (u32)HPETFlags::TimerConfiguration::ValueSet; timer.capabilities = timer.capabilities | (u32)HPETFlags::TimerConfiguration::ValueSet;
u64 value = frequency() / comparator.ticks_per_second(); u64 value = frequency() / comparator.ticks_per_second();
dbgln<debug_hpet>("HPET: Update periodic comparator {} comparator value to {} main value was: {}", dbgln<HPET_DEBUG>("HPET: Update periodic comparator {} comparator value to {} main value was: {}",
comparator.comparator_number(), comparator.comparator_number(),
value, value,
previous_main_value); previous_main_value);
@ -217,7 +217,7 @@ void HPET::update_periodic_comparator_value()
// Set the new target comparator value to the delta to the remaining ticks // Set the new target comparator value to the delta to the remaining ticks
u64 current_value = (u64)timer.comparator_value.low | ((u64)timer.comparator_value.high << 32); u64 current_value = (u64)timer.comparator_value.low | ((u64)timer.comparator_value.high << 32);
u64 value = current_value - previous_main_value; u64 value = current_value - previous_main_value;
dbgln<debug_hpet>("HPET: Update non-periodic comparator {} comparator value from {} to {} main value was: {}", dbgln<HPET_DEBUG>("HPET: Update non-periodic comparator {} comparator value from {} to {} main value was: {}",
comparator.comparator_number(), comparator.comparator_number(),
current_value, current_value,
value, value,

View file

@ -109,7 +109,7 @@ bool HPETComparator::try_to_set_frequency(size_t frequency)
m_frequency = frequency; m_frequency = frequency;
m_enabled = true; m_enabled = true;
dbgln<debug_hpet_comperator>("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic()); dbgln<HPET_COMPARATOR_DEBUG>("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic());
if (is_periodic()) { if (is_periodic()) {
HPET::the().update_periodic_comparator_value(); HPET::the().update_periodic_comparator_value();

View file

@ -472,7 +472,7 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
} }
u8* dest_ptr = MM.quickmap_page(*page); u8* dest_ptr = MM.quickmap_page(*page);
dbgln<debug_page_fault>(" >> COW {} <- {}", page->paddr(), page_slot->paddr()); dbgln<PAGE_FAULT_DEBUG>(" >> COW {} <- {}", page->paddr(), page_slot->paddr());
{ {
SmapDisabler disabler; SmapDisabler disabler;
void* fault_at; void* fault_at;

View file

@ -42,7 +42,7 @@ ContiguousVMObject::ContiguousVMObject(size_t size)
auto contiguous_physical_pages = MM.allocate_contiguous_supervisor_physical_pages(size); auto contiguous_physical_pages = MM.allocate_contiguous_supervisor_physical_pages(size);
for (size_t i = 0; i < page_count(); i++) { for (size_t i = 0; i < page_count(); i++) {
physical_pages()[i] = contiguous_physical_pages[i]; physical_pages()[i] = contiguous_physical_pages[i];
dbgln<debug_contiguous_vmobject>("Contiguous page[{}]: {}", i, physical_pages()[i]->paddr()); dbgln<CONTIGUOUS_VMOBJECT_DEBUG>("Contiguous page[{}]: {}", i, physical_pages()[i]->paddr());
} }
} }

View file

@ -79,7 +79,7 @@ Vector<Range, 2> Range::carve(const Range& taken)
if (taken.end() < end()) if (taken.end() < end())
parts.append({ taken.end(), end().get() - taken.end().get() }); parts.append({ taken.end(), end().get() - taken.end().get() });
if constexpr (debug_vra) { if constexpr (VRA_DEBUG) {
dbgln("VRA: carve: take {:x}-{:x} from {:x}-{:x}", dbgln("VRA: carve: take {:x}-{:x} from {:x}-{:x}",
taken.base().get(), taken.base().get(),
taken.end().get() - 1, taken.end().get() - 1,
@ -129,13 +129,13 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
Range allocated_range(VirtualAddress(aligned_base), size); Range allocated_range(VirtualAddress(aligned_base), size);
if (available_range == allocated_range) { if (available_range == allocated_range) {
dbgln<debug_vra>("VRA: Allocated perfect-fit anywhere({}, {}): {}", size, alignment, allocated_range.base().get()); dbgln<VRA_DEBUG>("VRA: Allocated perfect-fit anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
m_available_ranges.remove(i); m_available_ranges.remove(i);
return allocated_range; return allocated_range;
} }
carve_at_index(i, allocated_range); carve_at_index(i, allocated_range);
if constexpr (debug_vra) { if constexpr (VRA_DEBUG) {
dbgln<debug_vra>("VRA: Allocated anywhere({}, {}): {}", size, alignment, allocated_range.base().get()); dbgln<VRA_DEBUG>("VRA: Allocated anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
dump(); dump();
} }
return allocated_range; return allocated_range;
@ -161,7 +161,7 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
} }
carve_at_index(i, allocated_range); carve_at_index(i, allocated_range);
if constexpr (debug_vra) { if constexpr (VRA_DEBUG) {
dbgln("VRA: Allocated specific({}): {}", size, available_range.base().get()); dbgln("VRA: Allocated specific({}): {}", size, available_range.base().get());
dump(); dump();
} }
@ -179,7 +179,7 @@ void RangeAllocator::deallocate(Range range)
ASSERT(range.size()); ASSERT(range.size());
ASSERT(range.base() < range.end()); ASSERT(range.base() < range.end());
if constexpr (debug_vra) { if constexpr (VRA_DEBUG) {
dbgln("VRA: Deallocate: {}({})", range.base().get(), range.size()); dbgln("VRA: Deallocate: {}({})", range.base().get(), range.size());
dump(); dump();
} }

View file

@ -410,7 +410,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
return PageFaultResponse::ShouldCrash; return PageFaultResponse::ShouldCrash;
} }
if (vmobject().is_inode()) { if (vmobject().is_inode()) {
dbgln<debug_page_fault>("NP(inode) fault in Region({})[{}]", this, page_index_in_region); dbgln<PAGE_FAULT_DEBUG>("NP(inode) fault in Region({})[{}]", this, page_index_in_region);
return handle_inode_fault(page_index_in_region); return handle_inode_fault(page_index_in_region);
} }
@ -435,10 +435,10 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
} }
ASSERT(fault.type() == PageFault::Type::ProtectionViolation); ASSERT(fault.type() == PageFault::Type::ProtectionViolation);
if (fault.access() == PageFault::Access::Write && is_writable() && should_cow(page_index_in_region)) { if (fault.access() == PageFault::Access::Write && is_writable() && should_cow(page_index_in_region)) {
dbgln<debug_page_fault>("PV(cow) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr()); dbgln<PAGE_FAULT_DEBUG>("PV(cow) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
auto* phys_page = physical_page(page_index_in_region); auto* phys_page = physical_page(page_index_in_region);
if (phys_page->is_shared_zero_page() || phys_page->is_lazy_committed_page()) { if (phys_page->is_shared_zero_page() || phys_page->is_lazy_committed_page()) {
dbgln<debug_page_fault>("NP(zero) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr()); dbgln<PAGE_FAULT_DEBUG>("NP(zero) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
return handle_zero_fault(page_index_in_region); return handle_zero_fault(page_index_in_region);
} }
return handle_cow_fault(page_index_in_region); return handle_cow_fault(page_index_in_region);
@ -472,14 +472,14 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
if (page_slot->is_lazy_committed_page()) { if (page_slot->is_lazy_committed_page()) {
page_slot = static_cast<AnonymousVMObject&>(*m_vmobject).allocate_committed_page(page_index_in_vmobject); page_slot = static_cast<AnonymousVMObject&>(*m_vmobject).allocate_committed_page(page_index_in_vmobject);
dbgln<debug_page_fault>(" >> ALLOCATED COMMITTED {}", page_slot->paddr()); dbgln<PAGE_FAULT_DEBUG>(" >> ALLOCATED COMMITTED {}", page_slot->paddr());
} else { } else {
page_slot = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes); page_slot = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
if (page_slot.is_null()) { if (page_slot.is_null()) {
klog() << "MM: handle_zero_fault was unable to allocate a physical page"; klog() << "MM: handle_zero_fault was unable to allocate a physical page";
return PageFaultResponse::OutOfMemory; return PageFaultResponse::OutOfMemory;
} }
dbgln<debug_page_fault>(" >> ALLOCATED {}", page_slot->paddr()); dbgln<PAGE_FAULT_DEBUG>(" >> ALLOCATED {}", page_slot->paddr());
} }
if (!remap_vmobject_page(page_index_in_vmobject)) { if (!remap_vmobject_page(page_index_in_vmobject)) {
@ -518,10 +518,10 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region); auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region);
auto& vmobject_physical_page_entry = inode_vmobject.physical_pages()[page_index_in_vmobject]; auto& vmobject_physical_page_entry = inode_vmobject.physical_pages()[page_index_in_vmobject];
dbgln<debug_page_fault>("Inode fault in {} page index: {}", name(), page_index_in_region); dbgln<PAGE_FAULT_DEBUG>("Inode fault in {} page index: {}", name(), page_index_in_region);
if (!vmobject_physical_page_entry.is_null()) { if (!vmobject_physical_page_entry.is_null()) {
dbgln<debug_page_fault>("MM: page_in_from_inode() but page already present. Fine with me!"); dbgln<PAGE_FAULT_DEBUG>("MM: page_in_from_inode() but page already present. Fine with me!");
if (!remap_vmobject_page(page_index_in_vmobject)) if (!remap_vmobject_page(page_index_in_vmobject))
return PageFaultResponse::OutOfMemory; return PageFaultResponse::OutOfMemory;
return PageFaultResponse::Continue; return PageFaultResponse::Continue;

View file

@ -37,22 +37,22 @@ bool WaitQueue::should_add_blocker(Thread::Blocker& b, void* data)
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue); ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
if (m_wake_requested) { if (m_wake_requested) {
m_wake_requested = false; m_wake_requested = false;
dbgln<debug_waitqueue>("WaitQueue @ {}: do not block thread {}, wake was pending", this, data); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: do not block thread {}, wake was pending", this, data);
return false; return false;
} }
dbgln<debug_waitqueue>("WaitQueue @ {}: should block thread {}", this, data); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: should block thread {}", this, data);
return true; return true;
} }
void WaitQueue::wake_one() void WaitQueue::wake_one()
{ {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one", this); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_one", this);
bool did_unblock_one = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) { bool did_unblock_one = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data); ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue); ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b); auto& blocker = static_cast<Thread::QueueBlocker&>(b);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one unblocking {}", this, data); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_one unblocking {}", this, data);
if (blocker.unblock()) { if (blocker.unblock()) {
stop_iterating = true; stop_iterating = true;
return true; return true;
@ -67,14 +67,14 @@ u32 WaitQueue::wake_n(u32 wake_count)
if (wake_count == 0) if (wake_count == 0)
return 0; // should we assert instead? return 0; // should we assert instead?
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n({})", this, wake_count); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0; u32 did_wake = 0;
bool did_unblock_some = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) { bool did_unblock_some = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data); ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue); ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b); auto& blocker = static_cast<Thread::QueueBlocker&>(b);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n unblocking {}", this, data); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_n unblocking {}", this, data);
ASSERT(did_wake < wake_count); ASSERT(did_wake < wake_count);
if (blocker.unblock()) { if (blocker.unblock()) {
if (++did_wake >= wake_count) if (++did_wake >= wake_count)
@ -91,7 +91,7 @@ u32 WaitQueue::wake_all()
{ {
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all", this); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_all", this);
u32 did_wake = 0; u32 did_wake = 0;
bool did_unblock_any = do_unblock([&](Thread::Blocker& b, void* data, bool&) { bool did_unblock_any = do_unblock([&](Thread::Blocker& b, void* data, bool&) {
@ -99,7 +99,7 @@ u32 WaitQueue::wake_all()
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue); ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b); auto& blocker = static_cast<Thread::QueueBlocker&>(b);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all unblocking {}", this, data); dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_all unblocking {}", this, data);
if (blocker.unblock()) { if (blocker.unblock()) {
did_wake++; did_wake++;

View file

@ -353,7 +353,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
auto& target = to.first(); auto& target = to.first();
for (auto& position : from) { for (auto& position : from) {
dbgln<debug_copy>("Paste from '{}' to '{}'", position.to_url(), target.to_url()); dbgln<COPY_DEBUG>("Paste from '{}' to '{}'", position.to_url(), target.to_url());
copy_to(position, resolve_relative_to.has_value() ? offset_relative_to(target, position, resolve_relative_to.value()) : target); copy_to(position, resolve_relative_to.has_value() ? offset_relative_to(target, position, resolve_relative_to.value()) : target);
} }
@ -364,7 +364,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
// Fill the target selection with the single cell. // Fill the target selection with the single cell.
auto& source = from.first(); auto& source = from.first();
for (auto& position : to) { for (auto& position : to) {
dbgln<debug_copy>("Paste from '{}' to '{}'", source.to_url(), position.to_url()); dbgln<COPY_DEBUG>("Paste from '{}' to '{}'", source.to_url(), position.to_url());
copy_to(source, resolve_relative_to.has_value() ? offset_relative_to(position, source, resolve_relative_to.value()) : position); copy_to(source, resolve_relative_to.has_value() ? offset_relative_to(position, source, resolve_relative_to.value()) : position);
} }
return; return;

View file

@ -48,7 +48,7 @@ void CursorTool::on_mousedown(GUI::MouseEvent& event)
m_editor.selection().toggle(*result.widget); m_editor.selection().toggle(*result.widget);
} else if (!event.modifiers()) { } else if (!event.modifiers()) {
if (!m_editor.selection().contains(*result.widget)) { if (!m_editor.selection().contains(*result.widget)) {
dbgln<debug_cursor_tool>("Selection didn't contain {}, making it the only selected one", *result.widget); dbgln<CURSOR_TOOL_DEBUG>("Selection didn't contain {}, making it the only selected one", *result.widget);
m_editor.selection().set(*result.widget); m_editor.selection().set(*result.widget);
} }

View file

@ -87,7 +87,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
auto document = GUI::TextDocument::create(&s_default_document_client); auto document = GUI::TextDocument::create(&s_default_document_client);
document->set_text(content_view); document->set_text(content_view);
m_open_files.set(message.file_name(), document); m_open_files.set(message.file_name(), document);
dbgln<debug_file_content>("{}", document->text()); dbgln<FILE_CONTENT_DEBUG>("{}", document->text());
} }
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message) void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)

View file

@ -87,7 +87,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
auto document = GUI::TextDocument::create(&s_default_document_client); auto document = GUI::TextDocument::create(&s_default_document_client);
document->set_text(content_view); document->set_text(content_view);
m_open_files.set(message.file_name(), document); m_open_files.set(message.file_name(), document);
dbgln<debug_file_content>("{}", document->text()); dbgln<FILE_CONTENT_DEBUG>("{}", document->text());
} }
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message) void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
@ -129,7 +129,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText
}; };
document->remove(range); document->remove(range);
dbgln<debug_file_content>("{}", document->text()); dbgln<FILE_CONTENT_DEBUG>("{}", document->text());
} }
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message) void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)

View file

@ -102,7 +102,7 @@ static Optional<ByteBuffer> get_gzip_payload(const ByteBuffer& data)
} }
auto new_size = data.size() - current; auto new_size = data.size() - current;
dbgln<debug_gzip>("get_gzip_payload: Returning slice from {} with size {}", current, new_size); dbgln<GZIP_DEBUG>("get_gzip_payload: Returning slice from {} with size {}", current, new_size);
return data.slice(current, new_size); return data.slice(current, new_size);
} }
@ -110,7 +110,7 @@ Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
{ {
ASSERT(is_compressed(data)); ASSERT(is_compressed(data));
dbgln<debug_gzip>("Gzip::decompress: Decompressing gzip compressed data. size={}", data.size()); dbgln<GZIP_DEBUG>("Gzip::decompress: Decompressing gzip compressed data. size={}", data.size());
auto optional_payload = get_gzip_payload(data); auto optional_payload = get_gzip_payload(data);
if (!optional_payload.has_value()) { if (!optional_payload.has_value()) {
return Optional<ByteBuffer>(); return Optional<ByteBuffer>();
@ -122,7 +122,7 @@ Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
while (true) { while (true) {
unsigned long destination_len = destination.size(); unsigned long destination_len = destination.size();
if constexpr (debug_gzip) { if constexpr (GZIP_DEBUG) {
dbgln("Gzip::decompress: Calling puff()"); dbgln("Gzip::decompress: Calling puff()");
dbgln(" destination_data = {}", destination.data()); dbgln(" destination_data = {}", destination.data());
dbgln(" destination_len = {}", destination_len); dbgln(" destination_len = {}", destination_len);

View file

@ -55,7 +55,7 @@ void NetworkJob::did_finish(NonnullRefPtr<NetworkResponse>&& response)
NonnullRefPtr<NetworkJob> protector(*this); NonnullRefPtr<NetworkJob> protector(*this);
m_response = move(response); m_response = move(response);
dbgln<debug_cnetworkjob>("{} job did_finish", *this); dbgln<CNETWORKJOB_DEBUG>("{} job did_finish", *this);
ASSERT(on_finish); ASSERT(on_finish);
on_finish(true); on_finish(true);
shutdown(); shutdown();

View file

@ -79,7 +79,7 @@ bool Socket::connect(const String& hostname, int port)
} }
IPv4Address host_address((const u8*)hostent->h_addr_list[0]); IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
dbgln<debug_csocket>("Socket::connect: Resolved '{}' to {}", hostname, host_address); dbgln<CSOCKET_DEBUG>("Socket::connect: Resolved '{}' to {}", hostname, host_address);
return connect(host_address, port); return connect(host_address, port);
} }
@ -98,7 +98,7 @@ bool Socket::connect(const SocketAddress& address, int port)
{ {
ASSERT(!is_connected()); ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::IPv4); ASSERT(address.type() == SocketAddress::Type::IPv4);
dbgln<debug_csocket>("{} connecting to {}...", *this, address); dbgln<CSOCKET_DEBUG>("{} connecting to {}...", *this, address);
ASSERT(port > 0 && port <= 65535); ASSERT(port > 0 && port <= 65535);
@ -119,7 +119,7 @@ bool Socket::connect(const SocketAddress& address)
{ {
ASSERT(!is_connected()); ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::Local); ASSERT(address.type() == SocketAddress::Type::Local);
dbgln<debug_csocket>("{} connecting to {}...", *this, address); dbgln<CSOCKET_DEBUG>("{} connecting to {}...", *this, address);
sockaddr_un saddr; sockaddr_un saddr;
saddr.sun_family = AF_LOCAL; saddr.sun_family = AF_LOCAL;
@ -138,7 +138,7 @@ bool Socket::connect(const SocketAddress& address)
bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen) bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
{ {
auto connected = [this] { auto connected = [this] {
dbgln<debug_csocket>("{} connected!", *this); dbgln<CSOCKET_DEBUG>("{} connected!", *this);
if (!m_connected) { if (!m_connected) {
m_connected = true; m_connected = true;
ensure_read_notifier(); ensure_read_notifier();
@ -153,7 +153,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
int rc = ::connect(fd(), addr, addrlen); int rc = ::connect(fd(), addr, addrlen);
if (rc < 0) { if (rc < 0) {
if (errno == EINPROGRESS) { if (errno == EINPROGRESS) {
dbgln<debug_csocket>("{} connection in progress (EINPROGRESS)", *this); dbgln<CSOCKET_DEBUG>("{} connection in progress (EINPROGRESS)", *this);
m_notifier = Notifier::construct(fd(), Notifier::Event::Write, this); m_notifier = Notifier::construct(fd(), Notifier::Event::Write, this);
m_notifier->on_ready_to_write = move(connected); m_notifier->on_ready_to_write = move(connected);
return true; return true;
@ -163,7 +163,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
errno = saved_errno; errno = saved_errno;
return false; return false;
} }
dbgln<debug_csocket>("{} connected ok!", *this); dbgln<CSOCKET_DEBUG>("{} connected ok!", *this);
connected(); connected();
return true; return true;
} }

View file

@ -42,9 +42,9 @@ inline int safe_syscall(Syscall syscall, Args&&... args)
for (;;) { for (;;) {
int sysret = syscall(forward<Args>(args)...); int sysret = syscall(forward<Args>(args)...);
if (sysret == -1) { if (sysret == -1) {
if constexpr (debug_safe_syscall) { if constexpr (SAFE_SYSCALL_DEBUG) {
int saved_errno = errno; int saved_errno = errno;
dbgln<debug_safe_syscall>("Core::safe_syscall: {} ({}: {})", sysret, saved_errno, strerror(saved_errno)); dbgln<SAFE_SYSCALL_DEBUG>("Core::safe_syscall: {} ({}: {})", sysret, saved_errno, strerror(saved_errno));
} }
if (errno == EINTR) if (errno == EINTR)

View file

@ -89,7 +89,7 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher)
auto high = [](u64 value) -> u32 { return value >> 32; }; auto high = [](u64 value) -> u32 { return value >> 32; };
auto low = [](u64 value) -> u32 { return value & 0xffffffff; }; auto low = [](u64 value) -> u32 { return value & 0xffffffff; };
if constexpr (debug_ghash_process) { if constexpr (GHASH_PROCESS_DEBUG) {
dbgln("AAD bits: {} : {}", high(aad_bits), low(aad_bits)); dbgln("AAD bits: {} : {}", high(aad_bits), low(aad_bits));
dbgln("Cipher bits: {} : {}", high(cipher_bits), low(cipher_bits)); dbgln("Cipher bits: {} : {}", high(cipher_bits), low(cipher_bits));
dbgln("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]); dbgln("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]);
@ -100,7 +100,7 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher)
tag[2] ^= high(cipher_bits); tag[2] ^= high(cipher_bits);
tag[3] ^= low(cipher_bits); tag[3] ^= low(cipher_bits);
dbgln<debug_ghash_process>("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]); dbgln<GHASH_PROCESS_DEBUG>("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]);
galois_multiply(tag, m_key, tag); galois_multiply(tag, m_key, tag);

View file

@ -231,7 +231,7 @@ UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b)
UnsignedBigInteger::divide_without_allocation(a, gcd_output, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder); UnsignedBigInteger::divide_without_allocation(a, gcd_output, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder);
UnsignedBigInteger::multiply_without_allocation(temp_quotient, b, temp_1, temp_2, temp_3, temp_4, output); UnsignedBigInteger::multiply_without_allocation(temp_quotient, b, temp_1, temp_2, temp_3, temp_4, output);
dbgln<debug_nt>("quot: {} rem: {} out: {}", temp_quotient, temp_remainder, output); dbgln<NT_DEBUG>("quot: {} rem: {} out: {}", temp_quotient, temp_remainder, output);
return output; return output;
} }

View file

@ -116,7 +116,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
void RSA::encrypt(ReadonlyBytes in, Bytes& out) void RSA::encrypt(ReadonlyBytes in, Bytes& out)
{ {
dbgln<debug_crypto>("in size: {}", in.size()); dbgln<CRYPTO_DEBUG>("in size: {}", in.size());
auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size()); auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size());
if (!(in_integer < m_public_key.modulus())) { if (!(in_integer < m_public_key.modulus())) {
dbgln("value too large for key"); dbgln("value too large for key");
@ -230,7 +230,7 @@ VerificationConsistency RSA_EMSA_PSS<HashFunction>::verify(ReadonlyBytes in)
void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out) void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
{ {
auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8; auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8;
dbgln<debug_crypto>("key size: {}", mod_len); dbgln<CRYPTO_DEBUG>("key size: {}", mod_len);
if (in.size() > mod_len - 11) { if (in.size() > mod_len - 11) {
dbgln("message too long :("); dbgln("message too long :(");
out = out.trim(0); out = out.trim(0);
@ -262,7 +262,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
out.overwrite(3 + ps_length, in.data(), in.size()); out.overwrite(3 + ps_length, in.data(), in.size());
out = out.trim(3 + ps_length + in.size()); // should be a single block out = out.trim(3 + ps_length + in.size()); // should be a single block
dbgln<debug_crypto>("padded output size: {} buffer size: {}", 3 + ps_length + in.size(), out.size()); dbgln<CRYPTO_DEBUG>("padded output size: {} buffer size: {}", 3 + ps_length + in.size(), out.size());
RSA::encrypt(out, out); RSA::encrypt(out, out);
} }

View file

@ -235,7 +235,7 @@ void LineProgram::handle_sepcial_opcode(u8 opcode)
m_address += address_increment; m_address += address_increment;
m_line += line_increment; m_line += line_increment;
if constexpr (debug_dwarf) { if constexpr (DWARF_DEBUG) {
dbgln("Special adjusted_opcode: {}, address_increment: {}, line_increment: {}", adjusted_opcode, address_increment, line_increment); dbgln("Special adjusted_opcode: {}, address_increment: {}, line_increment: {}", adjusted_opcode, address_increment, line_increment);
dbgln("Address is now: {:p}, and line is: {}:{}", m_address, m_source_files[m_file_index].name, m_line); dbgln("Address is now: {:p}, and line is: {}:{}", m_address, m_source_files[m_file_index].name, m_line);
} }
@ -251,7 +251,7 @@ void LineProgram::run_program()
u8 opcode = 0; u8 opcode = 0;
m_stream >> opcode; m_stream >> opcode;
dbgln<debug_dwarf>("{:p}: opcode: {}", m_stream.offset() - 1, opcode); dbgln<DWARF_DEBUG>("{:p}: opcode: {}", m_stream.offset() - 1, opcode);
if (opcode == 0) { if (opcode == 0) {
handle_extended_opcode(); handle_extended_opcode();

View file

@ -77,7 +77,7 @@ Vector<Hunk> parse_hunks(const String& diff)
hunks.append(hunk); hunks.append(hunk);
} }
if constexpr (debug_hunks) { if constexpr (HUNKS_DEBUG) {
for (const auto& hunk : hunks) { for (const auto& hunk : hunks) {
dbgln("Hunk location:"); dbgln("Hunk location:");
dbgln(" orig: {}", hunk.original_start_line); dbgln(" orig: {}", hunk.original_start_line);

View file

@ -84,7 +84,7 @@ void CppSyntaxHighlighter::rehighlight(Gfx::Palette palette)
Vector<GUI::TextDocumentSpan> spans; Vector<GUI::TextDocumentSpan> spans;
for (auto& token : tokens) { for (auto& token : tokens) {
dbgln<debug_syntax_highlighting>("{} @ {}:{} - {}:{}", token.to_string(), token.m_start.line, token.m_start.column, token.m_end.line, token.m_end.column); dbgln<SYNTAX_HIGHLIGHTING_DEBUG>("{} @ {}:{} - {}:{}", token.to_string(), token.m_start.line, token.m_start.column, token.m_end.line, token.m_end.column);
GUI::TextDocumentSpan span; GUI::TextDocumentSpan span;
span.range.set_start({ token.m_start.line, token.m_start.column }); span.range.set_start({ token.m_start.line, token.m_start.column });
span.range.set_end({ token.m_end.line, token.m_end.column }); span.range.set_end({ token.m_end.line, token.m_end.column });

View file

@ -108,7 +108,7 @@ void JSSyntaxHighlighter::rehighlight(Gfx::Palette palette)
spans.append(span); spans.append(span);
advance_position(str[str.length() - 1]); advance_position(str[str.length() - 1]);
dbgln<debug_syntax_highlighting>("{}{} @ '{}' {}:{} - {}:{}", dbgln<SYNTAX_HIGHLIGHTING_DEBUG>("{}{} @ '{}' {}:{} - {}:{}",
token.name(), token.name(),
is_trivia ? " (trivia)" : "", is_trivia ? " (trivia)" : "",
token.value(), token.value(),

View file

@ -141,25 +141,25 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode()); auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode());
Action* action = nullptr; Action* action = nullptr;
dbgln<debug_keyboard_shortcuts>("Looking up action for {}", key_event->to_string()); dbgln<KEYBOARD_SHORTCUTS_DEBUG>("Looking up action for {}", key_event->to_string());
if (auto* focused_widget = window->focused_widget()) { if (auto* focused_widget = window->focused_widget()) {
for (auto* widget = focused_widget; widget && !action; widget = widget->parent_widget()) { for (auto* widget = focused_widget; widget && !action; widget = widget->parent_widget()) {
action = widget->action_for_key_event(*key_event); action = widget->action_for_key_event(*key_event);
dbgln<debug_keyboard_shortcuts>(" > Focused widget {} gave action: {}", *widget, action); dbgln<KEYBOARD_SHORTCUTS_DEBUG>(" > Focused widget {} gave action: {}", *widget, action);
} }
} }
if (!action) { if (!action) {
action = window->action_for_key_event(*key_event); action = window->action_for_key_event(*key_event);
dbgln<debug_keyboard_shortcuts>(" > Asked window {}, got action: {}", *window, action); dbgln<KEYBOARD_SHORTCUTS_DEBUG>(" > Asked window {}, got action: {}", *window, action);
} }
// NOTE: Application-global shortcuts are ignored while a modal window is up. // NOTE: Application-global shortcuts are ignored while a modal window is up.
if (!action && !window->is_modal()) { if (!action && !window->is_modal()) {
action = Application::the()->action_for_key_event(*key_event); action = Application::the()->action_for_key_event(*key_event);
dbgln<debug_keyboard_shortcuts>(" > Asked application, got action: {}", action); dbgln<KEYBOARD_SHORTCUTS_DEBUG>(" > Asked application, got action: {}", action);
} }
if (action) { if (action) {

View file

@ -67,7 +67,7 @@ void Job::on_socket_connected()
m_sent_data = true; m_sent_data = true;
auto raw_request = m_request.to_raw_request(); auto raw_request = m_request.to_raw_request();
if constexpr (debug_job) { if constexpr (JOB_DEBUG) {
dbgln("Job: raw_request:"); dbgln("Job: raw_request:");
dbgln("{}", String::copy(raw_request)); dbgln("{}", String::copy(raw_request));
} }

View file

@ -317,7 +317,7 @@ static u8 get_scaled_color(u32 data, u8 mask_size, i8 mask_shift)
// to scale the values in order to reach the proper value of 255. // to scale the values in order to reach the proper value of 255.
static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data) static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
{ {
dbgln<debug_bmp>("DIB info sizes before access: #masks={}, #mask_sizes={}, #mask_shifts={}", dbgln<BMP_DEBUG>("DIB info sizes before access: #masks={}, #mask_sizes={}, #mask_shifts={}",
context.dib.info.masks.size(), context.dib.info.masks.size(),
context.dib.info.mask_sizes.size(), context.dib.info.mask_sizes.size(),
context.dib.info.mask_shifts.size()); context.dib.info.mask_shifts.size());
@ -465,7 +465,7 @@ static bool decode_bmp_header(BMPLoadingContext& context)
return true; return true;
if (!context.file_bytes || context.file_size < bmp_header_size) { if (!context.file_bytes || context.file_size < bmp_header_size) {
dbgln<debug_bmp>("Missing BMP header"); dbgln<BMP_DEBUG>("Missing BMP header");
context.state = BMPLoadingContext::State::Error; context.state = BMPLoadingContext::State::Error;
return false; return false;
} }
@ -474,7 +474,7 @@ static bool decode_bmp_header(BMPLoadingContext& context)
u16 header = streamer.read_u16(); u16 header = streamer.read_u16();
if (header != 0x4d42) { if (header != 0x4d42) {
dbgln<debug_bmp>("BMP has invalid magic header number: {:#04x}", header); dbgln<BMP_DEBUG>("BMP has invalid magic header number: {:#04x}", header);
context.state = BMPLoadingContext::State::Error; context.state = BMPLoadingContext::State::Error;
return false; return false;
} }
@ -490,13 +490,13 @@ static bool decode_bmp_header(BMPLoadingContext& context)
streamer.drop_bytes(4); streamer.drop_bytes(4);
context.data_offset = streamer.read_u32(); context.data_offset = streamer.read_u32();
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP file size: {}", context.file_size); dbgln("BMP file size: {}", context.file_size);
dbgln("BMP data offset: {}", context.data_offset); dbgln("BMP data offset: {}", context.data_offset);
} }
if (context.data_offset >= context.file_size) { if (context.data_offset >= context.file_size) {
dbgln<debug_bmp>("BMP data offset is beyond file end?!"); dbgln<BMP_DEBUG>("BMP data offset is beyond file end?!");
return false; return false;
} }
@ -549,7 +549,7 @@ static bool decode_bmp_core_dib(BMPLoadingContext& context, Streamer& streamer)
return false; return false;
} }
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP width: {}", core.width); dbgln("BMP width: {}", core.width);
dbgln("BMP height: {}", core.height); dbgln("BMP height: {}", core.height);
dbgln("BMP bits_per_pixel: {}", core.bpp); dbgln("BMP bits_per_pixel: {}", core.bpp);
@ -598,7 +598,7 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
return false; return false;
} }
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP width: {}", core.width); dbgln("BMP width: {}", core.width);
dbgln("BMP height: {}", core.height); dbgln("BMP height: {}", core.height);
dbgln("BMP bits_per_pixel: {}", core.bpp); dbgln("BMP bits_per_pixel: {}", core.bpp);
@ -638,7 +638,7 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
// ColorEncoding (4) + Identifier (4) // ColorEncoding (4) + Identifier (4)
streamer.drop_bytes(8); streamer.drop_bytes(8);
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP compression: {}", info.compression); dbgln("BMP compression: {}", info.compression);
dbgln("BMP image size: {}", info.image_size); dbgln("BMP image size: {}", info.image_size);
dbgln("BMP horizontal res: {}", info.horizontal_resolution); dbgln("BMP horizontal res: {}", info.horizontal_resolution);
@ -678,7 +678,7 @@ static bool decode_bmp_info_dib(BMPLoadingContext& context, Streamer& streamer)
if (info.number_of_important_palette_colors == 0) if (info.number_of_important_palette_colors == 0)
info.number_of_important_palette_colors = info.number_of_palette_colors; info.number_of_important_palette_colors = info.number_of_palette_colors;
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP compression: {}", info.compression); dbgln("BMP compression: {}", info.compression);
dbgln("BMP image size: {}", info.image_size); dbgln("BMP image size: {}", info.image_size);
dbgln("BMP horizontal res: {}", info.horizontal_resolution); dbgln("BMP horizontal res: {}", info.horizontal_resolution);
@ -699,7 +699,7 @@ static bool decode_bmp_v2_dib(BMPLoadingContext& context, Streamer& streamer)
context.dib.info.masks.append(streamer.read_u32()); context.dib.info.masks.append(streamer.read_u32());
context.dib.info.masks.append(streamer.read_u32()); context.dib.info.masks.append(streamer.read_u32());
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP red mask: {:#08x}", context.dib.info.masks[0]); dbgln("BMP red mask: {:#08x}", context.dib.info.masks[0]);
dbgln("BMP green mask: {:#08x}", context.dib.info.masks[1]); dbgln("BMP green mask: {:#08x}", context.dib.info.masks[1]);
dbgln("BMP blue mask: {:#08x}", context.dib.info.masks[2]); dbgln("BMP blue mask: {:#08x}", context.dib.info.masks[2]);
@ -719,12 +719,12 @@ static bool decode_bmp_v3_dib(BMPLoadingContext& context, Streamer& streamer)
// suite results. // suite results.
if (context.dib.info.compression == Compression::ALPHABITFIELDS) { if (context.dib.info.compression == Compression::ALPHABITFIELDS) {
context.dib.info.masks.append(streamer.read_u32()); context.dib.info.masks.append(streamer.read_u32());
dbgln<debug_bmp>("BMP alpha mask: {:#08x}", context.dib.info.masks[3]); dbgln<BMP_DEBUG>("BMP alpha mask: {:#08x}", context.dib.info.masks[3]);
} else if (context.dib_size() >= 56 && context.dib.core.bpp >= 16) { } else if (context.dib_size() >= 56 && context.dib.core.bpp >= 16) {
auto mask = streamer.read_u32(); auto mask = streamer.read_u32();
if ((context.dib.core.bpp == 32 && mask != 0) || context.dib.core.bpp == 16) { if ((context.dib.core.bpp == 32 && mask != 0) || context.dib.core.bpp == 16) {
context.dib.info.masks.append(mask); context.dib.info.masks.append(mask);
dbgln<debug_bmp>("BMP alpha mask: {:#08x}", mask); dbgln<BMP_DEBUG>("BMP alpha mask: {:#08x}", mask);
} }
} else { } else {
streamer.drop_bytes(4); streamer.drop_bytes(4);
@ -745,7 +745,7 @@ static bool decode_bmp_v4_dib(BMPLoadingContext& context, Streamer& streamer)
v4.blue_endpoint = { streamer.read_i32(), streamer.read_i32(), streamer.read_i32() }; v4.blue_endpoint = { streamer.read_i32(), streamer.read_i32(), streamer.read_i32() };
v4.gamma_endpoint = { streamer.read_u32(), streamer.read_u32(), streamer.read_u32() }; v4.gamma_endpoint = { streamer.read_u32(), streamer.read_u32(), streamer.read_u32() };
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP color space: {}", v4.color_space); dbgln("BMP color space: {}", v4.color_space);
dbgln("BMP red endpoint: {}", v4.red_endpoint); dbgln("BMP red endpoint: {}", v4.red_endpoint);
dbgln("BMP green endpoint: {}", v4.green_endpoint); dbgln("BMP green endpoint: {}", v4.green_endpoint);
@ -766,7 +766,7 @@ static bool decode_bmp_v5_dib(BMPLoadingContext& context, Streamer& streamer)
v5.profile_data = streamer.read_u32(); v5.profile_data = streamer.read_u32();
v5.profile_size = streamer.read_u32(); v5.profile_size = streamer.read_u32();
if constexpr (debug_bmp) { if constexpr (BMP_DEBUG) {
dbgln("BMP intent: {}", v5.intent); dbgln("BMP intent: {}", v5.intent);
dbgln("BMP profile data: {}", v5.profile_data); dbgln("BMP profile data: {}", v5.profile_data);
dbgln("BMP profile size: {}", v5.profile_size); dbgln("BMP profile size: {}", v5.profile_size);
@ -801,7 +801,7 @@ static bool decode_bmp_dib(BMPLoadingContext& context)
streamer = Streamer(context.file_bytes + bmp_header_size + 4, context.data_offset - bmp_header_size - 4); streamer = Streamer(context.file_bytes + bmp_header_size + 4, context.data_offset - bmp_header_size - 4);
dbgln<debug_bmp>("BMP dib size: {}", dib_size); dbgln<BMP_DEBUG>("BMP dib size: {}", dib_size);
bool error = false; bool error = false;
@ -931,7 +931,7 @@ static bool uncompress_bmp_rle_data(BMPLoadingContext& context, ByteBuffer& buff
{ {
// RLE-compressed images cannot be stored top-down // RLE-compressed images cannot be stored top-down
if (context.dib.core.height < 0) { if (context.dib.core.height < 0) {
dbgln<debug_bmp>("BMP is top-down and RLE compressed"); dbgln<BMP_DEBUG>("BMP is top-down and RLE compressed");
context.state = BMPLoadingContext::State::Error; context.state = BMPLoadingContext::State::Error;
return false; return false;
} }

View file

@ -212,13 +212,13 @@ public:
} }
if (m_current_code > m_code_table.size()) { if (m_current_code > m_code_table.size()) {
dbgln<debug_gif>("Corrupted LZW stream, invalid code: {} at bit index {}, code table size: {}", dbgln<GIF_DEBUG>("Corrupted LZW stream, invalid code: {} at bit index {}, code table size: {}",
m_current_code, m_current_code,
m_current_bit_index, m_current_bit_index,
m_code_table.size()); m_code_table.size());
return {}; return {};
} else if (m_current_code == m_code_table.size() && m_output.is_empty()) { } else if (m_current_code == m_code_table.size() && m_output.is_empty()) {
dbgln<debug_gif>("Corrupted LZW stream, valid new code but output buffer is empty: {} at bit index {}, code table size: {}", dbgln<GIF_DEBUG>("Corrupted LZW stream, valid new code but output buffer is empty: {} at bit index {}, code table size: {}",
m_current_code, m_current_code,
m_current_bit_index, m_current_bit_index,
m_code_table.size()); m_code_table.size());
@ -527,12 +527,12 @@ static bool load_gif_frame_descriptors(GIFLoadingContext& context)
if (extension_type == 0xFF) { if (extension_type == 0xFF) {
if (sub_block.size() != 14) { if (sub_block.size() != 14) {
dbgln<debug_gif>("Unexpected application extension size: {}", sub_block.size()); dbgln<GIF_DEBUG>("Unexpected application extension size: {}", sub_block.size());
continue; continue;
} }
if (sub_block[11] != 1) { if (sub_block[11] != 1) {
dbgln<debug_gif>("Unexpected application extension format"); dbgln<GIF_DEBUG>("Unexpected application extension format");
continue; continue;
} }

View file

@ -230,13 +230,13 @@ static void generate_huffman_codes(HuffmanTableSpec& table)
static Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1) static Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1)
{ {
if (count > (8 * sizeof(size_t))) { if (count > (8 * sizeof(size_t))) {
dbgln<debug_jpg>("Can't read {} bits at once!", count); dbgln<JPG_DEBUG>("Can't read {} bits at once!", count);
return {}; return {};
} }
size_t value = 0; size_t value = 0;
while (count--) { while (count--) {
if (hstream.byte_offset >= hstream.stream.size()) { if (hstream.byte_offset >= hstream.stream.size()) {
dbgln<debug_jpg>("Huffman stream exhausted. This could be an error!"); dbgln<JPG_DEBUG>("Huffman stream exhausted. This could be an error!");
return {}; return {};
} }
u8 current_byte = hstream.stream[hstream.byte_offset]; u8 current_byte = hstream.stream[hstream.byte_offset];
@ -313,7 +313,7 @@ static bool build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& ma
// For DC coefficients, symbol encodes the length of the coefficient. // For DC coefficients, symbol encodes the length of the coefficient.
auto dc_length = symbol_or_error.release_value(); auto dc_length = symbol_or_error.release_value();
if (dc_length > 11) { if (dc_length > 11) {
dbgln<debug_jpg>("DC coefficient too long: {}!", dc_length); dbgln<JPG_DEBUG>("DC coefficient too long: {}!", dc_length);
return false; return false;
} }
@ -350,13 +350,13 @@ static bool build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& ma
j += run_length; j += run_length;
if (j >= 64) { if (j >= 64) {
dbgln<debug_jpg>("Run-length exceeded boundaries. Cursor: {}, Skipping: {}!", j, run_length); dbgln<JPG_DEBUG>("Run-length exceeded boundaries. Cursor: {}, Skipping: {}!", j, run_length);
return false; return false;
} }
u8 coeff_length = ac_symbol & 0x0F; u8 coeff_length = ac_symbol & 0x0F;
if (coeff_length > 10) { if (coeff_length > 10) {
dbgln<debug_jpg>("AC coefficient too long: {}!", coeff_length); dbgln<JPG_DEBUG>("AC coefficient too long: {}!", coeff_length);
return false; return false;
} }
@ -383,7 +383,7 @@ static Optional<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& con
Vector<Macroblock> macroblocks; Vector<Macroblock> macroblocks;
macroblocks.resize(context.mblock_meta.padded_total); macroblocks.resize(context.mblock_meta.padded_total);
if constexpr (debug_jpg) { if constexpr (JPG_DEBUG) {
dbgln("Image width: {}", context.frame.width); dbgln("Image width: {}", context.frame.width);
dbgln("Image height: {}", context.frame.height); dbgln("Image height: {}", context.frame.height);
dbgln("Macroblocks in a row: {}", context.mblock_meta.hpadded_count); dbgln("Macroblocks in a row: {}", context.mblock_meta.hpadded_count);
@ -422,7 +422,7 @@ static Optional<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& con
} }
if (!build_macroblocks(context, macroblocks, hcursor, vcursor)) { if (!build_macroblocks(context, macroblocks, hcursor, vcursor)) {
if constexpr (debug_jpg) { if constexpr (JPG_DEBUG) {
dbgln("Failed to build Macroblock {}", i); dbgln("Failed to build Macroblock {}", i);
dbgln("Huffman stream byte offset {}", context.huffman_stream.byte_offset); dbgln("Huffman stream byte offset {}", context.huffman_stream.byte_offset);
dbgln("Huffman stream bit offset {}", context.huffman_stream.bit_offset); dbgln("Huffman stream bit offset {}", context.huffman_stream.bit_offset);
@ -445,7 +445,7 @@ static inline bool is_valid_marker(const Marker marker)
if (marker >= JPG_APPN0 && marker <= JPG_APPNF) { if (marker >= JPG_APPN0 && marker <= JPG_APPNF) {
if (marker != JPG_APPN0) if (marker != JPG_APPN0)
dbgln<debug_jpg>("{:#04x} not supported yet. The decoder may fail!", marker); dbgln<JPG_DEBUG>("{:#04x} not supported yet. The decoder may fail!", marker);
return true; return true;
} }
if (marker >= JPG_RESERVED1 && marker <= JPG_RESERVEDD) if (marker >= JPG_RESERVED1 && marker <= JPG_RESERVEDD)
@ -467,7 +467,7 @@ static inline bool is_valid_marker(const Marker marker)
if (marker >= 0xFFC0 && marker <= 0xFFCF) { if (marker >= 0xFFC0 && marker <= 0xFFCF) {
if (marker != 0xFFC4 && marker != 0xFFC8 && marker != 0xFFCC) { if (marker != 0xFFC4 && marker != 0xFFC8 && marker != 0xFFCC) {
dbgln<debug_jpg>("Decoding this frame-type (SOF{}) is not currently supported. Decoder will fail!", marker & 0xf); dbgln<JPG_DEBUG>("Decoding this frame-type (SOF{}) is not currently supported. Decoder will fail!", marker & 0xf);
return false; return false;
} }
} }
@ -504,7 +504,7 @@ static inline Marker read_marker_at_cursor(InputMemoryStream& stream)
static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& context) static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& context)
{ {
if (context.state < JPGLoadingContext::State::FrameDecoded) { if (context.state < JPGLoadingContext::State::FrameDecoded) {
dbgln<debug_jpg>("{}: SOS found before reading a SOF!", stream.offset()); dbgln<JPG_DEBUG>("{}: SOS found before reading a SOF!", stream.offset());
return false; return false;
} }
@ -519,7 +519,7 @@ static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& con
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (component_count != context.component_count) { if (component_count != context.component_count) {
dbgln<debug_jpg>("{}: Unsupported number of components: {}!", stream.offset(), component_count); dbgln<JPG_DEBUG>("{}: Unsupported number of components: {}!", stream.offset(), component_count);
return false; return false;
} }
@ -538,7 +538,7 @@ static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& con
return false; return false;
} }
} else { } else {
dbgln<debug_jpg>("{}: Unsupported component id: {}!", stream.offset(), component_id); dbgln<JPG_DEBUG>("{}: Unsupported component id: {}!", stream.offset(), component_id);
return false; return false;
} }
@ -551,17 +551,17 @@ static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& con
component->ac_destination_id = table_ids & 0x0F; component->ac_destination_id = table_ids & 0x0F;
if (context.dc_tables.size() != context.ac_tables.size()) { if (context.dc_tables.size() != context.ac_tables.size()) {
dbgln<debug_jpg>("{}: DC & AC table count mismatch!", stream.offset()); dbgln<JPG_DEBUG>("{}: DC & AC table count mismatch!", stream.offset());
return false; return false;
} }
if (!context.dc_tables.contains(component->dc_destination_id)) { if (!context.dc_tables.contains(component->dc_destination_id)) {
dbgln<debug_jpg>("DC table (id: {}) does not exist!", component->dc_destination_id); dbgln<JPG_DEBUG>("DC table (id: {}) does not exist!", component->dc_destination_id);
return false; return false;
} }
if (!context.ac_tables.contains(component->ac_destination_id)) { if (!context.ac_tables.contains(component->ac_destination_id)) {
dbgln<debug_jpg>("AC table (id: {}) does not exist!", component->ac_destination_id); dbgln<JPG_DEBUG>("AC table (id: {}) does not exist!", component->ac_destination_id);
return false; return false;
} }
} }
@ -580,7 +580,7 @@ static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& con
return false; return false;
// The three values should be fixed for baseline JPEGs utilizing sequential DCT. // The three values should be fixed for baseline JPEGs utilizing sequential DCT.
if (spectral_selection_start != 0 || spectral_selection_end != 63 || successive_approximation != 0) { if (spectral_selection_start != 0 || spectral_selection_end != 63 || successive_approximation != 0) {
dbgln<debug_jpg>("{}: ERROR! Start of Selection: {}, End of Selection: {}, Successive Approximation: {}!", dbgln<JPG_DEBUG>("{}: ERROR! Start of Selection: {}, End of Selection: {}, Successive Approximation: {}!",
stream.offset(), stream.offset(),
spectral_selection_start, spectral_selection_start,
spectral_selection_end, spectral_selection_end,
@ -597,7 +597,7 @@ static bool read_reset_marker(InputMemoryStream& stream, JPGLoadingContext& cont
return false; return false;
bytes_to_read -= 2; bytes_to_read -= 2;
if (bytes_to_read != 2) { if (bytes_to_read != 2) {
dbgln<debug_jpg>("{}: Malformed reset marker found!", stream.offset()); dbgln<JPG_DEBUG>("{}: Malformed reset marker found!", stream.offset());
return false; return false;
} }
context.dc_reset_interval = read_be_word(stream); context.dc_reset_interval = read_be_word(stream);
@ -623,11 +623,11 @@ static bool read_huffman_table(InputMemoryStream& stream, JPGLoadingContext& con
u8 table_type = table_info >> 4; u8 table_type = table_info >> 4;
u8 table_destination_id = table_info & 0x0F; u8 table_destination_id = table_info & 0x0F;
if (table_type > 1) { if (table_type > 1) {
dbgln<debug_jpg>("{}: Unrecognized huffman table: {}!", stream.offset(), table_type); dbgln<JPG_DEBUG>("{}: Unrecognized huffman table: {}!", stream.offset(), table_type);
return false; return false;
} }
if (table_destination_id > 1) { if (table_destination_id > 1) {
dbgln<debug_jpg>("{}: Invalid huffman table destination id: {}!", stream.offset(), table_destination_id); dbgln<JPG_DEBUG>("{}: Invalid huffman table destination id: {}!", stream.offset(), table_destination_id);
return false; return false;
} }
@ -667,7 +667,7 @@ static bool read_huffman_table(InputMemoryStream& stream, JPGLoadingContext& con
} }
if (bytes_to_read != 0) { if (bytes_to_read != 0) {
dbgln<debug_jpg>("{}: Extra bytes detected in huffman header!", stream.offset()); dbgln<JPG_DEBUG>("{}: Extra bytes detected in huffman header!", stream.offset());
return false; return false;
} }
return true; return true;
@ -683,7 +683,7 @@ static inline bool validate_luma_and_modify_context(const ComponentSpec& luma, J
context.hsample_factor = luma.hsample_factor; context.hsample_factor = luma.hsample_factor;
context.vsample_factor = luma.vsample_factor; context.vsample_factor = luma.vsample_factor;
if constexpr (debug_jpg) { if constexpr (JPG_DEBUG) {
dbgln("Horizontal Subsampling Factor: {}", luma.hsample_factor); dbgln("Horizontal Subsampling Factor: {}", luma.hsample_factor);
dbgln("Vertical Subsampling Factor: {}", luma.vsample_factor); dbgln("Vertical Subsampling Factor: {}", luma.vsample_factor);
} }
@ -705,7 +705,7 @@ static inline void set_macroblock_metadata(JPGLoadingContext& context)
static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& context) static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& context)
{ {
if (context.state == JPGLoadingContext::FrameDecoded) { if (context.state == JPGLoadingContext::FrameDecoded) {
dbgln<debug_jpg>("{}: SOF repeated!", stream.offset()); dbgln<JPG_DEBUG>("{}: SOF repeated!", stream.offset());
return false; return false;
} }
@ -721,7 +721,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (context.frame.precision != 8) { if (context.frame.precision != 8) {
dbgln<debug_jpg>("{}: SOF precision != 8!", stream.offset()); dbgln<JPG_DEBUG>("{}: SOF precision != 8!", stream.offset());
return false; return false;
} }
@ -732,7 +732,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (!context.frame.width || !context.frame.height) { if (!context.frame.width || !context.frame.height) {
dbgln<debug_jpg>("{}: ERROR! Image height: {}, Image width: {}!", stream.offset(), context.frame.height, context.frame.width); dbgln<JPG_DEBUG>("{}: ERROR! Image height: {}, Image width: {}!", stream.offset(), context.frame.height, context.frame.width);
return false; return false;
} }
@ -747,7 +747,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (context.component_count != 1 && context.component_count != 3) { if (context.component_count != 1 && context.component_count != 3) {
dbgln<debug_jpg>("{}: Unsupported number of components in SOF: {}!", stream.offset(), context.component_count); dbgln<JPG_DEBUG>("{}: Unsupported number of components in SOF: {}!", stream.offset(), context.component_count);
return false; return false;
} }
@ -770,7 +770,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
// By convention, downsampling is applied only on chroma components. So we should // By convention, downsampling is applied only on chroma components. So we should
// hope to see the maximum sampling factor in the luma component. // hope to see the maximum sampling factor in the luma component.
if (!validate_luma_and_modify_context(component, context)) { if (!validate_luma_and_modify_context(component, context)) {
dbgln<debug_jpg>("{}: Unsupported luma subsampling factors: horizontal: {}, vertical: {}", dbgln<JPG_DEBUG>("{}: Unsupported luma subsampling factors: horizontal: {}, vertical: {}",
stream.offset(), stream.offset(),
component.hsample_factor, component.hsample_factor,
component.vsample_factor); component.vsample_factor);
@ -778,7 +778,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
} }
} else { } else {
if (component.hsample_factor != 1 || component.vsample_factor != 1) { if (component.hsample_factor != 1 || component.vsample_factor != 1) {
dbgln<debug_jpg>("{}: Unsupported chroma subsampling factors: horizontal: {}, vertical: {}", dbgln<JPG_DEBUG>("{}: Unsupported chroma subsampling factors: horizontal: {}, vertical: {}",
stream.offset(), stream.offset(),
component.hsample_factor, component.hsample_factor,
component.vsample_factor); component.vsample_factor);
@ -790,7 +790,7 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (component.qtable_id > 1) { if (component.qtable_id > 1) {
dbgln<debug_jpg>("{}: Unsupported quantization table id: {}!", stream.offset(), component.qtable_id); dbgln<JPG_DEBUG>("{}: Unsupported quantization table id: {}!", stream.offset(), component.qtable_id);
return false; return false;
} }
@ -815,12 +815,12 @@ static bool read_quantization_table(InputMemoryStream& stream, JPGLoadingContext
return false; return false;
u8 element_unit_hint = info_byte >> 4; u8 element_unit_hint = info_byte >> 4;
if (element_unit_hint > 1) { if (element_unit_hint > 1) {
dbgln<debug_jpg>("{}: Unsupported unit hint in quantization table: {}!", stream.offset(), element_unit_hint); dbgln<JPG_DEBUG>("{}: Unsupported unit hint in quantization table: {}!", stream.offset(), element_unit_hint);
return false; return false;
} }
u8 table_id = info_byte & 0x0F; u8 table_id = info_byte & 0x0F;
if (table_id > 1) { if (table_id > 1) {
dbgln<debug_jpg>("{}: Unsupported quantization table id: {}!", stream.offset(), table_id); dbgln<JPG_DEBUG>("{}: Unsupported quantization table id: {}!", stream.offset(), table_id);
return false; return false;
} }
u32* table = table_id == 0 ? context.luma_table : context.chroma_table; u32* table = table_id == 0 ? context.luma_table : context.chroma_table;
@ -843,7 +843,7 @@ static bool read_quantization_table(InputMemoryStream& stream, JPGLoadingContext
bytes_to_read -= 1 + (element_unit_hint == 0 ? 64 : 128); bytes_to_read -= 1 + (element_unit_hint == 0 ? 64 : 128);
} }
if (bytes_to_read != 0) { if (bytes_to_read != 0) {
dbgln<debug_jpg>("{}: Invalid length for one or more quantization tables!", stream.offset()); dbgln<JPG_DEBUG>("{}: Invalid length for one or more quantization tables!", stream.offset());
return false; return false;
} }
@ -1109,7 +1109,7 @@ static bool parse_header(InputMemoryStream& stream, JPGLoadingContext& context)
if (stream.handle_any_error()) if (stream.handle_any_error())
return false; return false;
if (marker != JPG_SOI) { if (marker != JPG_SOI) {
dbgln<debug_jpg>("{}: SOI not found: {:x}!", stream.offset(), marker); dbgln<JPG_DEBUG>("{}: SOI not found: {:x}!", stream.offset(), marker);
return false; return false;
} }
for (;;) { for (;;) {
@ -1137,7 +1137,7 @@ static bool parse_header(InputMemoryStream& stream, JPGLoadingContext& context)
case JPG_RST7: case JPG_RST7:
case JPG_SOI: case JPG_SOI:
case JPG_EOI: case JPG_EOI:
dbgln<debug_jpg>("{}: Unexpected marker {:x}!", stream.offset(), marker); dbgln<JPG_DEBUG>("{}: Unexpected marker {:x}!", stream.offset(), marker);
return false; return false;
case JPG_SOF0: case JPG_SOF0:
if (!read_start_of_frame(stream, context)) if (!read_start_of_frame(stream, context))
@ -1160,7 +1160,7 @@ static bool parse_header(InputMemoryStream& stream, JPGLoadingContext& context)
return read_start_of_scan(stream, context); return read_start_of_scan(stream, context);
default: default:
if (!skip_marker_with_length(stream)) { if (!skip_marker_with_length(stream)) {
dbgln<debug_jpg>("{}: Error skipping marker: {:x}!", stream.offset(), marker); dbgln<JPG_DEBUG>("{}: Error skipping marker: {:x}!", stream.offset(), marker);
return false; return false;
} }
break; break;
@ -1182,7 +1182,7 @@ static bool scan_huffman_stream(InputMemoryStream& stream, JPGLoadingContext& co
last_byte = current_byte; last_byte = current_byte;
stream >> current_byte; stream >> current_byte;
if (stream.handle_any_error()) { if (stream.handle_any_error()) {
dbgln<debug_jpg>("{}: EOI not found!", stream.offset()); dbgln<JPG_DEBUG>("{}: EOI not found!", stream.offset());
return false; return false;
} }
@ -1206,7 +1206,7 @@ static bool scan_huffman_stream(InputMemoryStream& stream, JPGLoadingContext& co
return false; return false;
continue; continue;
} }
dbgln<debug_jpg>("{}: Invalid marker: {:x}!", stream.offset(), marker); dbgln<JPG_DEBUG>("{}: Invalid marker: {:x}!", stream.offset(), marker);
return false; return false;
} else { } else {
context.huffman_stream.stream.append(last_byte); context.huffman_stream.stream.append(last_byte);
@ -1227,7 +1227,7 @@ static bool decode_jpg(JPGLoadingContext& context)
auto result = decode_huffman_stream(context); auto result = decode_huffman_stream(context);
if (!result.has_value()) { if (!result.has_value()) {
dbgln<debug_jpg>("{}: Failed to decode Macroblocks!", stream.offset()); dbgln<JPG_DEBUG>("{}: Failed to decode Macroblocks!", stream.offset());
return false; return false;
} }

View file

@ -613,7 +613,7 @@ static bool decode_png_bitmap_simple(PNGLoadingContext& context)
} }
if (filter > 4) { if (filter > 4) {
dbgln<debug_png>("Invalid PNG filter: {}", filter); dbgln<PNG_DEBUG>("Invalid PNG filter: {}", filter);
context.state = PNGLoadingContext::State::Error; context.state = PNGLoadingContext::State::Error;
return false; return false;
} }
@ -715,7 +715,7 @@ static bool decode_adam7_pass(PNGLoadingContext& context, Streamer& streamer, in
} }
if (filter > 4) { if (filter > 4) {
dbgln<debug_png>("Invalid PNG filter: {}", filter); dbgln<PNG_DEBUG>("Invalid PNG filter: {}", filter);
context.state = PNGLoadingContext::State::Error; context.state = PNGLoadingContext::State::Error;
return false; return false;
} }

View file

@ -925,7 +925,7 @@ void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 code_point, const F
// Perhaps it's an emoji? // Perhaps it's an emoji?
auto* emoji = Emoji::emoji_for_code_point(code_point); auto* emoji = Emoji::emoji_for_code_point(code_point);
if (emoji == nullptr) { if (emoji == nullptr) {
dbgln<debug_emoji>("Failed to find an emoji for code_point {}", code_point); dbgln<EMOJI_DEBUG>("Failed to find an emoji for code_point {}", code_point);
draw_glyph(point, '?', font, color); draw_glyph(point, '?', font, color);
return; return;
} }
@ -1639,7 +1639,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
// The points between this segment and the previous are // The points between this segment and the previous are
// inside the shape // inside the shape
dbgln<debug_fill_path>("y={}: {} at {}: {} -- {}", scanline, winding_number, i, from, to); dbgln<FILL_PATH_DEBUG>("y={}: {} at {}: {} -- {}", scanline, winding_number, i, from, to);
draw_line(from, to, color, 1); draw_line(from, to, color, 1);
} }

View file

@ -104,14 +104,14 @@ static bool read_magic_number(TContext& context, Streamer& streamer)
if (!context.data || context.data_size < 2) { if (!context.data || context.data_size < 2) {
context.state = TContext::State::Error; context.state = TContext::State::Error;
dbgln<debug_portable_image_loader>("There is no enough data for {}", TContext::image_type); dbgln<PORTABLE_IMAGE_LOADER_DEBUG>("There is no enough data for {}", TContext::image_type);
return false; return false;
} }
u8 magic_number[2] {}; u8 magic_number[2] {};
if (!streamer.read_bytes(magic_number, 2)) { if (!streamer.read_bytes(magic_number, 2)) {
context.state = TContext::State::Error; context.state = TContext::State::Error;
dbgln<debug_portable_image_loader>("We can't read magic number for {}", TContext::image_type); dbgln<PORTABLE_IMAGE_LOADER_DEBUG>("We can't read magic number for {}", TContext::image_type);
return false; return false;
} }
@ -128,7 +128,7 @@ static bool read_magic_number(TContext& context, Streamer& streamer)
} }
context.state = TContext::State::Error; context.state = TContext::State::Error;
dbgln<debug_portable_image_loader>("Magic number is not valid for {}{}{}", magic_number[0], magic_number[1], TContext::image_type); dbgln<PORTABLE_IMAGE_LOADER_DEBUG>("Magic number is not valid for {}{}{}", magic_number[0], magic_number[1], TContext::image_type);
return false; return false;
} }
@ -186,7 +186,7 @@ static bool read_max_val(TContext& context, Streamer& streamer)
} }
if (context.max_val > 255) { if (context.max_val > 255) {
dbgln<debug_portable_image_loader>("We can't parse 2 byte color for {}", TContext::image_type); dbgln<PORTABLE_IMAGE_LOADER_DEBUG>("We can't parse 2 byte color for {}", TContext::image_type);
context.state = TContext::Error; context.state = TContext::Error;
return false; return false;
} }

View file

@ -36,14 +36,14 @@ namespace HTTP {
static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding) static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding)
{ {
dbgln<debug_job>("Job::handle_content_encoding: buf has content_encoding={}", content_encoding); dbgln<JOB_DEBUG>("Job::handle_content_encoding: buf has content_encoding={}", content_encoding);
if (content_encoding == "gzip") { if (content_encoding == "gzip") {
if (!Core::Gzip::is_compressed(buf)) { if (!Core::Gzip::is_compressed(buf)) {
dbgln("Job::handle_content_encoding: buf is not gzip compressed!"); dbgln("Job::handle_content_encoding: buf is not gzip compressed!");
} }
dbgln<debug_job>("Job::handle_content_encoding: buf is gzip compressed!"); dbgln<JOB_DEBUG>("Job::handle_content_encoding: buf is gzip compressed!");
auto uncompressed = Core::Gzip::decompress(buf); auto uncompressed = Core::Gzip::decompress(buf);
if (!uncompressed.has_value()) { if (!uncompressed.has_value()) {
@ -51,7 +51,7 @@ static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& c
return buf; return buf;
} }
if constexpr (debug_job) { if constexpr (JOB_DEBUG) {
dbgln("Job::handle_content_encoding: Gzip::decompress() successful."); dbgln("Job::handle_content_encoding: Gzip::decompress() successful.");
dbgln(" Input size: {}", buf.size()); dbgln(" Input size: {}", buf.size());
dbgln(" Output size: {}", uncompressed.value().size()); dbgln(" Output size: {}", uncompressed.value().size());
@ -77,7 +77,7 @@ void Job::flush_received_buffers()
{ {
if (!m_can_stream_response || m_buffered_size == 0) if (!m_can_stream_response || m_buffered_size == 0)
return; return;
dbgln<debug_job>("Job: Flushing received buffers: have {} bytes in {} buffers", m_buffered_size, m_received_buffers.size()); dbgln<JOB_DEBUG>("Job: Flushing received buffers: have {} bytes in {} buffers", m_buffered_size, m_received_buffers.size());
for (size_t i = 0; i < m_received_buffers.size(); ++i) { for (size_t i = 0; i < m_received_buffers.size(); ++i) {
auto& payload = m_received_buffers[i]; auto& payload = m_received_buffers[i];
auto written = do_write(payload); auto written = do_write(payload);
@ -92,7 +92,7 @@ void Job::flush_received_buffers()
payload = payload.slice(written, payload.size() - written); payload = payload.slice(written, payload.size() - written);
break; break;
} }
dbgln<debug_job>("Job: Flushing received buffers done: have {} bytes in {} buffers", m_buffered_size, m_received_buffers.size()); dbgln<JOB_DEBUG>("Job: Flushing received buffers done: have {} bytes in {} buffers", m_buffered_size, m_received_buffers.size());
} }
void Job::on_socket_connected() void Job::on_socket_connected()
@ -103,7 +103,7 @@ void Job::on_socket_connected()
m_sent_data = true; m_sent_data = true;
auto raw_request = m_request.to_raw_request(); auto raw_request = m_request.to_raw_request();
if constexpr (debug_job) { if constexpr (JOB_DEBUG) {
dbgln("Job: raw_request:"); dbgln("Job: raw_request:");
dbgln("{}", String::copy(raw_request)); dbgln("{}", String::copy(raw_request));
} }
@ -198,10 +198,10 @@ void Job::on_socket_connected()
m_headers.set(name, value); m_headers.set(name, value);
if (name.equals_ignoring_case("Content-Encoding")) { if (name.equals_ignoring_case("Content-Encoding")) {
// Assume that any content-encoding means that we can't decode it as a stream :( // Assume that any content-encoding means that we can't decode it as a stream :(
dbgln<debug_job>("Content-Encoding {} detected, cannot stream output :(", value); dbgln<JOB_DEBUG>("Content-Encoding {} detected, cannot stream output :(", value);
m_can_stream_response = false; m_can_stream_response = false;
} }
dbgln<debug_job>("Job: [{}] = '{}'", name, value); dbgln<JOB_DEBUG>("Job: [{}] = '{}'", name, value);
return; return;
} }
ASSERT(m_state == State::InBody); ASSERT(m_state == State::InBody);
@ -216,7 +216,7 @@ void Job::on_socket_connected()
// read size // read size
auto size_data = read_line(PAGE_SIZE); auto size_data = read_line(PAGE_SIZE);
auto size_lines = size_data.view().lines(); auto size_lines = size_data.view().lines();
dbgln<debug_job>("Job: Received a chunk with size '{}'", size_data); dbgln<JOB_DEBUG>("Job: Received a chunk with size '{}'", size_data);
if (size_lines.size() == 0) { if (size_lines.size() == 0) {
dbgln("Job: Reached end of stream"); dbgln("Job: Reached end of stream");
finish_up(); finish_up();
@ -239,26 +239,26 @@ void Job::on_socket_connected()
m_current_chunk_total_size = 0; m_current_chunk_total_size = 0;
m_current_chunk_remaining_size = 0; m_current_chunk_remaining_size = 0;
dbgln<debug_job>("Job: Received the last chunk with extensions '{}'", size_string.substring_view(1, size_string.length() - 1)); dbgln<JOB_DEBUG>("Job: Received the last chunk with extensions '{}'", size_string.substring_view(1, size_string.length() - 1));
} else { } else {
m_current_chunk_total_size = size; m_current_chunk_total_size = size;
m_current_chunk_remaining_size = size; m_current_chunk_remaining_size = size;
read_size = size; read_size = size;
dbgln<debug_job>("Job: Chunk of size '{}' started", size); dbgln<JOB_DEBUG>("Job: Chunk of size '{}' started", size);
} }
} }
} else { } else {
read_size = remaining; read_size = remaining;
dbgln<debug_job>("Job: Resuming chunk with '{}' bytes left over", remaining); dbgln<JOB_DEBUG>("Job: Resuming chunk with '{}' bytes left over", remaining);
} }
} else { } else {
auto transfer_encoding = m_headers.get("Transfer-Encoding"); auto transfer_encoding = m_headers.get("Transfer-Encoding");
if (transfer_encoding.has_value()) { if (transfer_encoding.has_value()) {
auto encoding = transfer_encoding.value(); auto encoding = transfer_encoding.value();
dbgln<debug_job>("Job: This content has transfer encoding '{}'", encoding); dbgln<JOB_DEBUG>("Job: This content has transfer encoding '{}'", encoding);
if (encoding.equals_ignoring_case("chunked")) { if (encoding.equals_ignoring_case("chunked")) {
m_current_chunk_remaining_size = -1; m_current_chunk_remaining_size = -1;
goto read_chunk_size; goto read_chunk_size;
@ -289,9 +289,9 @@ void Job::on_socket_connected()
if (m_current_chunk_remaining_size.has_value()) { if (m_current_chunk_remaining_size.has_value()) {
auto size = m_current_chunk_remaining_size.value() - payload.size(); auto size = m_current_chunk_remaining_size.value() - payload.size();
dbgln<debug_job>("Job: We have {} bytes left over in this chunk", size); dbgln<JOB_DEBUG>("Job: We have {} bytes left over in this chunk", size);
if (size == 0) { if (size == 0) {
dbgln<debug_job>("Job: Finished a chunk of {} bytes", m_current_chunk_total_size.value()); dbgln<JOB_DEBUG>("Job: Finished a chunk of {} bytes", m_current_chunk_total_size.value());
if (m_current_chunk_total_size.value() == 0) { if (m_current_chunk_total_size.value() == 0) {
m_state = State::Trailers; m_state = State::Trailers;
@ -302,7 +302,7 @@ void Job::on_socket_connected()
size = -1; size = -1;
[[maybe_unused]] auto line = read_line(PAGE_SIZE); [[maybe_unused]] auto line = read_line(PAGE_SIZE);
if constexpr (debug_job) if constexpr (JOB_DEBUG)
dbgln("Line following (should be empty): '{}'", line); dbgln("Line following (should be empty): '{}'", line);
} }
m_current_chunk_remaining_size = size; m_current_chunk_remaining_size = size;

View file

@ -182,7 +182,7 @@ OwnPtr<Table> Table::parse(Vector<StringView>::ConstIterator& lines)
size_t relative_width = delimiter.length(); size_t relative_width = delimiter.length();
for (auto ch : delimiter) { for (auto ch : delimiter) {
if (ch != '-') { if (ch != '-') {
dbgln<debug_markdown>("Invalid character _{}_ in table heading delimiter (ignored)", ch); dbgln<MARKDOWN_DEBUG>("Invalid character _{}_ in table heading delimiter (ignored)", ch);
--relative_width; --relative_width;
} }
} }

View file

@ -370,7 +370,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightNamedCaptureGroup::execute(const M
auto& map = output.named_capture_group_matches.at(input.match_index); auto& map = output.named_capture_group_matches.at(input.match_index);
if constexpr (debug_regex) { if constexpr (REGEX_DEBUG) {
ASSERT(start_position + length <= input.view.length()); ASSERT(start_position + length <= input.view.length());
dbgln("Save named capture group with name={} and content='{}'", capture_group_name, input.view.substring_view(start_position, length)); dbgln("Save named capture group with name={} and content='{}'", capture_group_name, input.view.substring_view(start_position, length));
} }

View file

@ -148,7 +148,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
for (auto& view : views) { for (auto& view : views) {
input.view = view; input.view = view;
dbgln<debug_regex>("[match] Starting match with view ({}): _{}_", view.length(), view); dbgln<REGEX_DEBUG>("[match] Starting match with view ({}): _{}_", view.length(), view);
auto view_length = view.length(); auto view_length = view.length();
size_t view_index = m_pattern.start_offset; size_t view_index = m_pattern.start_offset;
@ -214,7 +214,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
continue; continue;
} }
if constexpr (debug_regex) { if constexpr (REGEX_DEBUG) {
dbgln("state.string_position={}, view_index={}", state.string_position, view_index); dbgln("state.string_position={}, view_index={}", state.string_position, view_index);
dbgln("[match] Found a match (length={}): '{}'", state.string_position - view_index, input.view.substring_view(view_index, state.string_position - view_index)); dbgln("[match] Found a match (length={}): '{}'", state.string_position - view_index, input.view.substring_view(view_index, state.string_position - view_index));
} }

View file

@ -112,7 +112,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
return (i8)Error::NoCommonCipher; return (i8)Error::NoCommonCipher;
} }
m_context.cipher = cipher; m_context.cipher = cipher;
dbgln<debug_tls>("Cipher: {}", (u16)cipher); dbgln<TLS_DEBUG>("Cipher: {}", (u16)cipher);
// The handshake hash function is _always_ SHA256 // The handshake hash function is _always_ SHA256
m_context.handshake_hash.initialize(Crypto::Hash::HashKind::SHA256); m_context.handshake_hash.initialize(Crypto::Hash::HashKind::SHA256);
@ -146,7 +146,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
u16 extension_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res)); u16 extension_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
res += 2; res += 2;
dbgln<debug_tls>("extension {} with length {}", (u16)extension_type, extension_length); dbgln<TLS_DEBUG>("extension {} with length {}", (u16)extension_type, extension_length);
if (extension_length) { if (extension_length) {
if (buffer.size() - res < extension_length) { if (buffer.size() - res < extension_length) {
@ -218,12 +218,12 @@ ssize_t TLSv12::handle_finished(ReadonlyBytes buffer, WritePacketStage& write_pa
u32 size = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2]; u32 size = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2];
if (size < 12) { if (size < 12) {
dbgln<debug_tls>("finished packet smaller than minimum size: {}", size); dbgln<TLS_DEBUG>("finished packet smaller than minimum size: {}", size);
return (i8)Error::BrokenPacket; return (i8)Error::BrokenPacket;
} }
if (size < buffer.size() - index) { if (size < buffer.size() - index) {
dbgln<debug_tls>("not enough data after length: {} > {}", size, buffer.size() - index); dbgln<TLS_DEBUG>("not enough data after length: {} > {}", size, buffer.size() - index);
return (i8)Error::NeedMoreData; return (i8)Error::NeedMoreData;
} }
@ -324,7 +324,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
auto type = buffer[0]; auto type = buffer[0];
auto write_packets { WritePacketStage::Initial }; auto write_packets { WritePacketStage::Initial };
size_t payload_size = buffer[1] * 0x10000 + buffer[2] * 0x100 + buffer[3] + 3; size_t payload_size = buffer[1] * 0x10000 + buffer[2] * 0x100 + buffer[3] + 3;
dbgln<debug_tls>("payload size: {} buffer length: {}", payload_size, buffer_length); dbgln<TLS_DEBUG>("payload size: {} buffer length: {}", payload_size, buffer_length);
if (payload_size + 1 > buffer_length) if (payload_size + 1 > buffer_length)
return (i8)Error::NeedMoreData; return (i8)Error::NeedMoreData;

View file

@ -39,12 +39,12 @@ void TLSv12::write_packet(ByteBuffer& packet)
m_context.tls_buffer.append(packet.data(), packet.size()); m_context.tls_buffer.append(packet.data(), packet.size());
if (m_context.connection_status > ConnectionStatus::Disconnected) { if (m_context.connection_status > ConnectionStatus::Disconnected) {
if (!m_has_scheduled_write_flush) { if (!m_has_scheduled_write_flush) {
dbgln<debug_tls>("Scheduling write of {}", m_context.tls_buffer.size()); dbgln<TLS_DEBUG>("Scheduling write of {}", m_context.tls_buffer.size());
deferred_invoke([this](auto&) { write_into_socket(); }); deferred_invoke([this](auto&) { write_into_socket(); });
m_has_scheduled_write_flush = true; m_has_scheduled_write_flush = true;
} else { } else {
// multiple packet are available, let's flush some out // multiple packet are available, let's flush some out
dbgln<debug_tls>("Flushing scheduled write of {}", m_context.tls_buffer.size()); dbgln<TLS_DEBUG>("Flushing scheduled write of {}", m_context.tls_buffer.size());
write_into_socket(); write_into_socket();
// the deferred invoke is still in place // the deferred invoke is still in place
m_has_scheduled_write_flush = true; m_has_scheduled_write_flush = true;
@ -216,7 +216,7 @@ ByteBuffer TLSv12::hmac_message(const ReadonlyBytes& buf, const Optional<Readonl
auto digest = hmac.digest(); auto digest = hmac.digest();
auto mac = ByteBuffer::copy(digest.immutable_data(), digest.data_length()); auto mac = ByteBuffer::copy(digest.immutable_data(), digest.data_length());
if constexpr (debug_tls) { if constexpr (TLS_DEBUG) {
dbgln("HMAC of the block for sequence number {}", sequence_number); dbgln("HMAC of the block for sequence number {}", sequence_number);
print_buffer(mac); print_buffer(mac);
} }
@ -230,7 +230,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
size_t header_size = res; size_t header_size = res;
ssize_t payload_res = 0; ssize_t payload_res = 0;
dbgln<debug_tls>("buffer size: {}", buffer.size()); dbgln<TLS_DEBUG>("buffer size: {}", buffer.size());
if (buffer.size() < 5) { if (buffer.size() < 5) {
return (i8)Error::NeedMoreData; return (i8)Error::NeedMoreData;
@ -241,7 +241,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
// FIXME: Read the version and verify it // FIXME: Read the version and verify it
if constexpr (debug_tls) { if constexpr (TLS_DEBUG) {
auto version = (Version) * (const u16*)buffer.offset_pointer(buffer_position); auto version = (Version) * (const u16*)buffer.offset_pointer(buffer_position);
dbgln("type={}, version={}", (u8)type, (u16)version); dbgln("type={}, version={}", (u8)type, (u16)version);
} }
@ -249,21 +249,21 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
buffer_position += 2; buffer_position += 2;
auto length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(buffer_position)); auto length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(buffer_position));
dbgln<debug_tls>("record length: {} at offset: {}", length, buffer_position); dbgln<TLS_DEBUG>("record length: {} at offset: {}", length, buffer_position);
buffer_position += 2; buffer_position += 2;
if (buffer_position + length > buffer.size()) { if (buffer_position + length > buffer.size()) {
dbgln<debug_tls>("record length more than what we have: {}", buffer.size()); dbgln<TLS_DEBUG>("record length more than what we have: {}", buffer.size());
return (i8)Error::NeedMoreData; return (i8)Error::NeedMoreData;
} }
dbgln<debug_tls>("message type: {}, length: {}", (u8)type, length); dbgln<TLS_DEBUG>("message type: {}, length: {}", (u8)type, length);
auto plain = buffer.slice(buffer_position, buffer.size() - buffer_position); auto plain = buffer.slice(buffer_position, buffer.size() - buffer_position);
ByteBuffer decrypted; ByteBuffer decrypted;
if (m_context.cipher_spec_set && type != MessageType::ChangeCipher) { if (m_context.cipher_spec_set && type != MessageType::ChangeCipher) {
if constexpr (debug_tls) { if constexpr (TLS_DEBUG) {
dbgln("Encrypted: "); dbgln("Encrypted: ");
print_buffer(buffer.slice(header_size, length)); print_buffer(buffer.slice(header_size, length));
} }
@ -389,7 +389,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage); auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
write_packet(packet); write_packet(packet);
} else { } else {
dbgln<debug_tls>("application data message of size {}", plain.size()); dbgln<TLS_DEBUG>("application data message of size {}", plain.size());
m_context.application_buffer.append(plain.data(), plain.size()); m_context.application_buffer.append(plain.data(), plain.size());
} }
@ -414,9 +414,9 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
} }
break; break;
case MessageType::Alert: case MessageType::Alert:
dbgln<debug_tls>("alert message of length {}", length); dbgln<TLS_DEBUG>("alert message of length {}", length);
if (length >= 2) { if (length >= 2) {
if constexpr (debug_tls) if constexpr (TLS_DEBUG)
print_buffer(plain); print_buffer(plain);
auto level = plain[0]; auto level = plain[0];

View file

@ -174,7 +174,7 @@ void TLSv12::read_from_socket()
void TLSv12::write_into_socket() void TLSv12::write_into_socket()
{ {
dbgln<debug_tls>("Flushing cached records: {} established? {}", m_context.tls_buffer.size(), is_established()); dbgln<TLS_DEBUG>("Flushing cached records: {} established? {}", m_context.tls_buffer.size(), is_established());
m_has_scheduled_write_flush = false; m_has_scheduled_write_flush = false;
if (!check_connection_state(false)) if (!check_connection_state(false))
@ -199,7 +199,7 @@ bool TLSv12::check_connection_state(bool read)
m_context.connection_finished = true; m_context.connection_finished = true;
} }
if (m_context.critical_error) { if (m_context.critical_error) {
dbgln<debug_tls>("CRITICAL ERROR {} :(", m_context.critical_error); dbgln<TLS_DEBUG>("CRITICAL ERROR {} :(", m_context.critical_error);
if (on_tls_error) if (on_tls_error)
on_tls_error((AlertDescription)m_context.critical_error); on_tls_error((AlertDescription)m_context.critical_error);
@ -211,7 +211,7 @@ bool TLSv12::check_connection_state(bool read)
on_tls_finished(); on_tls_finished();
} }
if (m_context.tls_buffer.size()) { if (m_context.tls_buffer.size()) {
dbgln<debug_tls>("connection closed without finishing data transfer, {} bytes still in buffer and {} bytes in application buffer", dbgln<TLS_DEBUG>("connection closed without finishing data transfer, {} bytes still in buffer and {} bytes in application buffer",
m_context.tls_buffer.size(), m_context.tls_buffer.size(),
m_context.application_buffer.size()); m_context.application_buffer.size());
} else { } else {
@ -247,7 +247,7 @@ bool TLSv12::flush()
} }
if (m_context.send_retries++ == 10) { if (m_context.send_retries++ == 10) {
// drop the records, we can't send // drop the records, we can't send
dbgln<debug_tls>("Dropping {} bytes worth of TLS records as max retries has been reached", write_buffer().size()); dbgln<TLS_DEBUG>("Dropping {} bytes worth of TLS records as max retries has been reached", write_buffer().size());
write_buffer().clear(); write_buffer().clear();
m_context.send_retries = 0; m_context.send_retries = 0;
} }

View file

@ -406,7 +406,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8*
hash.initialize(Crypto::Hash::HashKind::SHA512); hash.initialize(Crypto::Hash::HashKind::SHA512);
break; break;
default: default:
dbgln<debug_tls>("Unsupported hash mode {}", (u32)cert.key_algorithm); dbgln<TLS_DEBUG>("Unsupported hash mode {}", (u32)cert.key_algorithm);
// fallback to md5, it will fail later // fallback to md5, it will fail later
hash.initialize(Crypto::Hash::HashKind::MD5); hash.initialize(Crypto::Hash::HashKind::MD5);
break; break;
@ -436,7 +436,7 @@ Optional<Certificate> TLSv12::parse_asn1(ReadonlyBytes buffer, bool) const
_parse_asn1(m_context, cert, buffer.data(), buffer.size(), 1, fields, nullptr, 0, nullptr, nullptr); _parse_asn1(m_context, cert, buffer.data(), buffer.size(), 1, fields, nullptr, 0, nullptr, nullptr);
dbgln<debug_tls>("Certificate issued for {} by {}", cert.subject, cert.issuer_subject); dbgln<TLS_DEBUG>("Certificate issued for {} by {}", cert.subject, cert.issuer_subject);
return cert; return cert;
} }
@ -454,7 +454,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
u32 certificate_total_length = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2]; u32 certificate_total_length = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2];
dbgln<debug_tls>("total length: {}", certificate_total_length); dbgln<TLS_DEBUG>("total length: {}", certificate_total_length);
if (certificate_total_length <= 4) if (certificate_total_length <= 4)
return 3 * certificate_total_length; return 3 * certificate_total_length;
@ -549,7 +549,7 @@ void TLSv12::consume(ReadonlyBytes record)
return; return;
} }
dbgln<debug_tls>("Consuming {} bytes", record.size()); dbgln<TLS_DEBUG>("Consuming {} bytes", record.size());
m_context.message_buffer.append(record.data(), record.size()); m_context.message_buffer.append(record.data(), record.size());
@ -559,17 +559,17 @@ void TLSv12::consume(ReadonlyBytes record)
size_t size_offset { 3 }; // read the common record header size_t size_offset { 3 }; // read the common record header
size_t header_size { 5 }; size_t header_size { 5 };
dbgln<debug_tls>("message buffer length {}", buffer_length); dbgln<TLS_DEBUG>("message buffer length {}", buffer_length);
while (buffer_length >= 5) { while (buffer_length >= 5) {
auto length = AK::convert_between_host_and_network_endian(*(u16*)m_context.message_buffer.offset_pointer(index + size_offset)) + header_size; auto length = AK::convert_between_host_and_network_endian(*(u16*)m_context.message_buffer.offset_pointer(index + size_offset)) + header_size;
if (length > buffer_length) { if (length > buffer_length) {
dbgln<debug_tls>("Need more data: {} > {}", length, buffer_length); dbgln<TLS_DEBUG>("Need more data: {} > {}", length, buffer_length);
break; break;
} }
auto consumed = handle_message(m_context.message_buffer.bytes().slice(index, length)); auto consumed = handle_message(m_context.message_buffer.bytes().slice(index, length));
if constexpr (debug_tls) { if constexpr (TLS_DEBUG) {
if (consumed > 0) if (consumed > 0)
dbgln("consumed {} bytes", consumed); dbgln("consumed {} bytes", consumed);
else else

View file

@ -406,7 +406,7 @@ int main(int argc, char** argv)
interface->fully_qualified_name = interface->name; interface->fully_qualified_name = interface->name;
} }
if constexpr (debug_wrapper_generator) { if constexpr (WRAPPER_GENERATOR_DEBUG) {
dbgln("Attributes:"); dbgln("Attributes:");
for (auto& attribute : interface->attributes) { for (auto& attribute : interface->attributes) {
dbgln(" {}{}{} {}", dbgln(" {}{}{} {}",

View file

@ -141,7 +141,7 @@ void HTMLDocumentParser::run(const URL& url)
break; break;
auto& token = optional_token.value(); auto& token = optional_token.value();
dbgln<debug_parser>("[{}] {}", insertion_mode_name(), token.to_string()); dbgln<PARSER_DEBUG>("[{}] {}", insertion_mode_name(), token.to_string());
// FIXME: If the adjusted current node is a MathML text integration point and the token is a start tag whose tag name is neither "mglyph" nor "malignmark" // FIXME: If the adjusted current node is a MathML text integration point and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"
// FIXME: If the adjusted current node is a MathML text integration point and the token is a character token // FIXME: If the adjusted current node is a MathML text integration point and the token is a character token
@ -157,7 +157,7 @@ void HTMLDocumentParser::run(const URL& url)
} }
if (m_stop_parsing) { if (m_stop_parsing) {
dbgln<debug_parser>("Stop parsing{}! :^)", m_parsing_fragment ? " fragment" : ""); dbgln<PARSER_DEBUG>("Stop parsing{}! :^)", m_parsing_fragment ? " fragment" : "");
break; break;
} }
} }

View file

@ -36,10 +36,10 @@ namespace Web::HTML {
#pragma GCC diagnostic ignored "-Wunused-label" #pragma GCC diagnostic ignored "-Wunused-label"
#if TOKENIZER_TRACE #if TOKENIZER_TRACE_DEBUG
# define PARSE_ERROR() \ # define PARSE_ERROR() \
do { \ do { \
dbgln("Parse error (tokenization) {} @ {}", __PRETTY_FUNCTION__, __LINE__) \ dbgln("Parse error (tokenization) {} @ {}", __PRETTY_FUNCTION__, __LINE__); \
} while (0) } while (0)
#else #else
# define PARSE_ERROR() # define PARSE_ERROR()
@ -221,7 +221,7 @@ Optional<u32> HTMLTokenizer::next_code_point()
return {}; return {};
m_prev_utf8_iterator = m_utf8_iterator; m_prev_utf8_iterator = m_utf8_iterator;
++m_utf8_iterator; ++m_utf8_iterator;
dbgln<debug_trace_tokenizer>("(Tokenizer) Next code_point: {}", (char)*m_prev_utf8_iterator); dbgln<TOKENIZER_TRACE_DEBUG>("(Tokenizer) Next code_point: {}", (char)*m_prev_utf8_iterator);
return *m_prev_utf8_iterator; return *m_prev_utf8_iterator;
} }
@ -2618,17 +2618,17 @@ HTMLTokenizer::HTMLTokenizer(const StringView& input, const String& encoding)
void HTMLTokenizer::will_switch_to([[maybe_unused]] State new_state) void HTMLTokenizer::will_switch_to([[maybe_unused]] State new_state)
{ {
dbgln<debug_trace_tokenizer>("[{}] Switch to {}", state_name(m_state), state_name(new_state)); dbgln<TOKENIZER_TRACE_DEBUG>("[{}] Switch to {}", state_name(m_state), state_name(new_state));
} }
void HTMLTokenizer::will_reconsume_in([[maybe_unused]] State new_state) void HTMLTokenizer::will_reconsume_in([[maybe_unused]] State new_state)
{ {
dbgln<debug_trace_tokenizer>("[{}] Reconsume in {}", state_name(m_state), state_name(new_state)); dbgln<TOKENIZER_TRACE_DEBUG>("[{}] Reconsume in {}", state_name(m_state), state_name(new_state));
} }
void HTMLTokenizer::switch_to(Badge<HTMLDocumentParser>, State new_state) void HTMLTokenizer::switch_to(Badge<HTMLDocumentParser>, State new_state)
{ {
dbgln<debug_trace_tokenizer>("[{}] Parser switches tokenizer state to {}", state_name(m_state), state_name(new_state)); dbgln<TOKENIZER_TRACE_DEBUG>("[{}] Parser switches tokenizer state to {}", state_name(m_state), state_name(new_state));
m_state = new_state; m_state = new_state;
} }

View file

@ -72,7 +72,7 @@ void ImageLoader::resource_did_load()
m_loading_state = LoadingState::Loaded; m_loading_state = LoadingState::Loaded;
if constexpr (debug_image_loader) { if constexpr (IMAGE_LOADER_DEBUG) {
if (!resource()->has_encoded_data()) { if (!resource()->has_encoded_data()) {
dbgln("ImageLoader: Resource did load, no encoded data. URL: {}", resource()->url()); dbgln("ImageLoader: Resource did load, no encoded data. URL: {}", resource()->url());
} else { } else {

View file

@ -100,7 +100,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
m_encoding = encoding_from_content_type(content_type.value()); m_encoding = encoding_from_content_type(content_type.value());
m_mime_type = mime_type_from_content_type(content_type.value()); m_mime_type = mime_type_from_content_type(content_type.value());
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) { } else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
dbgln<debug_resource>("This is a data URL with mime-type _{}_", url().data_mime_type()); dbgln<RESOURCE_DEBUG>("This is a data URL with mime-type _{}_", url().data_mime_type());
m_encoding = "utf-8"; // FIXME: This doesn't seem nice. m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
m_mime_type = url().data_mime_type(); m_mime_type = url().data_mime_type();
} else { } else {

View file

@ -86,7 +86,7 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
if (it->value->type() != type) { if (it->value->type() != type) {
dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url()); dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url());
} else { } else {
dbgln<debug_cache>("Reusing cached resource for: {}", request.url()); dbgln<CACHE_DEBUG>("Reusing cached resource for: {}", request.url());
return it->value; return it->value;
} }
} }

View file

@ -38,7 +38,7 @@ namespace Web::SVG {
static void print_instruction(const PathInstruction& instruction) static void print_instruction(const PathInstruction& instruction)
{ {
ASSERT(debug_path); ASSERT(PATH_DEBUG);
auto& data = instruction.data; auto& data = instruction.data;
@ -463,7 +463,7 @@ Gfx::Path& SVGPathElement::get_path()
auto& absolute = instruction.absolute; auto& absolute = instruction.absolute;
auto& data = instruction.data; auto& data = instruction.data;
if constexpr (debug_path) { if constexpr (PATH_DEBUG) {
print_instruction(instruction); print_instruction(instruction);
} }

View file

@ -56,7 +56,7 @@ void WebContentClient::handle([[maybe_unused]] const Messages::WebContentClient:
void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateContentRect& message) void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateContentRect& message)
{ {
dbgln<debug_spam>("handle: WebContentClient::DidInvalidateContentRect! content_rect={}", message.content_rect()); dbgln<SPAM_DEBUG>("handle: WebContentClient::DidInvalidateContentRect! content_rect={}", message.content_rect());
// FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting // FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting
m_view.notify_server_did_invalidate_content_rect({}, message.content_rect()); m_view.notify_server_did_invalidate_content_rect({}, message.content_rect());
@ -72,25 +72,25 @@ void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelecti
void WebContentClient::handle(const Messages::WebContentClient::DidLayout& message) void WebContentClient::handle(const Messages::WebContentClient::DidLayout& message)
{ {
dbgln<debug_spam>("handle: WebContentClient::DidLayout! content_size={}", message.content_size()); dbgln<SPAM_DEBUG>("handle: WebContentClient::DidLayout! content_size={}", message.content_size());
m_view.notify_server_did_layout({}, message.content_size()); m_view.notify_server_did_layout({}, message.content_size());
} }
void WebContentClient::handle(const Messages::WebContentClient::DidChangeTitle& message) void WebContentClient::handle(const Messages::WebContentClient::DidChangeTitle& message)
{ {
dbgln<debug_spam>("handle: WebContentClient::DidChangeTitle! title={}", message.title()); dbgln<SPAM_DEBUG>("handle: WebContentClient::DidChangeTitle! title={}", message.title());
m_view.notify_server_did_change_title({}, message.title()); m_view.notify_server_did_change_title({}, message.title());
} }
void WebContentClient::handle(const Messages::WebContentClient::DidRequestScrollIntoView& message) void WebContentClient::handle(const Messages::WebContentClient::DidRequestScrollIntoView& message)
{ {
dbgln<debug_spam>("handle: WebContentClient::DidRequestScrollIntoView! rect={}", message.rect()); dbgln<SPAM_DEBUG>("handle: WebContentClient::DidRequestScrollIntoView! rect={}", message.rect());
m_view.notify_server_did_request_scroll_into_view({}, message.rect()); m_view.notify_server_did_request_scroll_into_view({}, message.rect());
} }
void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& message) void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& message)
{ {
dbgln<debug_spam>("handle: WebContentClient::DidHoverLink! url={}", message.url()); dbgln<SPAM_DEBUG>("handle: WebContentClient::DidHoverLink! url={}", message.url());
m_view.notify_server_did_hover_link({}, message.url()); m_view.notify_server_did_hover_link({}, message.url());
} }

View file

@ -44,7 +44,7 @@ ParsedDHCPv4Options DHCPv4Packet::parse_options() const
dbgln("Bogus option length {} assuming forgotten END", length); dbgln("Bogus option length {} assuming forgotten END", length);
break; break;
} }
dbgln<debug_dhcpv4>("DHCP Option {} with length {}", (u8)opt_name, length); dbgln<DHCPV4_DEBUG>("DHCP Option {} with length {}", (u8)opt_name, length);
++index; ++index;
options.options.set(opt_name, { length, &m_options[index] }); options.options.set(opt_name, { length, &m_options[index] });
index += length - 1; index += length - 1;

View file

@ -156,7 +156,7 @@ void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Op
void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options) void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options)
{ {
if constexpr (debug_dhcpv4_client) { if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("The DHCP server handed us {}", packet.yiaddr().to_string()); dbgln("The DHCP server handed us {}", packet.yiaddr().to_string());
dbgln("Here are the options: {}", options.to_string()); dbgln("Here are the options: {}", options.to_string());
} }
@ -207,7 +207,7 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
{ {
auto options = packet.parse_options(); auto options = packet.parse_options();
dbgln<debug_dhcpv4_client>("Here are the options: {}", options.to_string()); dbgln<DHCPV4CLIENT_DEBUG>("Here are the options: {}", options.to_string());
auto value = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType).value(); auto value = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType).value();
switch (value) { switch (value) {
@ -239,7 +239,7 @@ void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface, IPv4Address p
{ {
auto transaction_id = rand(); auto transaction_id = rand();
if constexpr (debug_dhcpv4_client) { if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("Trying to lease an IP for {} with ID {}", iface.m_ifname, transaction_id); dbgln("Trying to lease an IP for {} with ID {}", iface.m_ifname, transaction_id);
if (!previous.is_zero()) if (!previous.is_zero())
dbgln("going to request the server to hand us {}", previous.to_string()); dbgln("going to request the server to hand us {}", previous.to_string());

View file

@ -142,7 +142,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
for (const auto& app : g_apps) { for (const auto& app : g_apps) {
auto icon = GUI::FileIconProvider::icon_for_executable(app.executable).bitmap_for_size(16); auto icon = GUI::FileIconProvider::icon_for_executable(app.executable).bitmap_for_size(16);
if constexpr (debug_system_menu) { if constexpr (SYSTEM_MENU_DEBUG) {
if (icon) if (icon)
dbgln("App {} has icon with size {}", app.name, icon->size()); dbgln("App {} has icon with size {}", app.name, icon->size());
} }

View file

@ -115,7 +115,7 @@ void Service::setup_notifier()
void Service::handle_socket_connection() void Service::handle_socket_connection()
{ {
dbgln<debug_service>("Ready to read on behalf of {}", name()); dbgln<SERVICE_DEBUG>("Ready to read on behalf of {}", name());
if (m_accept_socket_connections) { if (m_accept_socket_connections) {
int accepted_fd = accept(m_socket_fd, nullptr, nullptr); int accepted_fd = accept(m_socket_fd, nullptr, nullptr);
@ -144,7 +144,7 @@ void Service::activate()
void Service::spawn(int socket_fd) void Service::spawn(int socket_fd)
{ {
dbgln<debug_service>("Spawning {}", name()); dbgln<SERVICE_DEBUG>("Spawning {}", name());
m_run_timer.start(); m_run_timer.start();
pid_t pid = fork(); pid_t pid = fork();

View file

@ -54,7 +54,7 @@ static void sigchld_handler(int)
if (pid == 0) if (pid == 0)
break; break;
dbgln<debug_system_server>("Reaped child with pid {}, exit status {}", pid, status); dbgln<SYSTEMSERVER_DEBUG>("Reaped child with pid {}, exit status {}", pid, status);
Service* service = Service::find_by_pid(pid); Service* service = Service::find_by_pid(pid);
if (service == nullptr) { if (service == nullptr) {

View file

@ -80,19 +80,19 @@ void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemThem
void ClientConnection::handle(const Messages::WebContentServer::LoadURL& message) void ClientConnection::handle(const Messages::WebContentServer::LoadURL& message)
{ {
dbgln<debug_spam>("handle: WebContentServer::LoadURL: url={}", message.url()); dbgln<SPAM_DEBUG>("handle: WebContentServer::LoadURL: url={}", message.url());
page().load(message.url()); page().load(message.url());
} }
void ClientConnection::handle(const Messages::WebContentServer::LoadHTML& message) void ClientConnection::handle(const Messages::WebContentServer::LoadHTML& message)
{ {
dbgln<debug_spam>("handle: WebContentServer::LoadHTML: html={}, url={}", message.html(), message.url()); dbgln<SPAM_DEBUG>("handle: WebContentServer::LoadHTML: html={}, url={}", message.html(), message.url());
page().load_html(message.html(), message.url()); page().load_html(message.html(), message.url());
} }
void ClientConnection::handle(const Messages::WebContentServer::SetViewportRect& message) void ClientConnection::handle(const Messages::WebContentServer::SetViewportRect& message)
{ {
dbgln<debug_spam>("handle: WebContentServer::SetViewportRect: rect={}", message.rect()); dbgln<SPAM_DEBUG>("handle: WebContentServer::SetViewportRect: rect={}", message.rect());
m_page_host->set_viewport_rect(message.rect()); m_page_host->set_viewport_rect(message.rect());
} }

View file

@ -194,7 +194,7 @@ void Compositor::compose()
if (m_custom_background_color.has_value()) if (m_custom_background_color.has_value())
background_color = m_custom_background_color.value(); background_color = m_custom_background_color.value();
if constexpr (debug_compose) { if constexpr (COMPOSE_DEBUG) {
dbgln("COMPOSE: invalidated: window: {} cursor: {}, any: {}", m_invalidated_window, m_invalidated_cursor, m_invalidated_any); dbgln("COMPOSE: invalidated: window: {} cursor: {}, any: {}", m_invalidated_window, m_invalidated_cursor, m_invalidated_any);
for (auto& r : dirty_screen_rects.rects()) for (auto& r : dirty_screen_rects.rects())
dbgln("dirty screen: {}", r); dbgln("dirty screen: {}", r);
@ -215,7 +215,7 @@ void Compositor::compose()
}; };
auto prepare_rect = [&](const Gfx::IntRect& rect) { auto prepare_rect = [&](const Gfx::IntRect& rect) {
dbgln<debug_compose>(" -> flush opaque: {}", rect); dbgln<COMPOSE_DEBUG>(" -> flush opaque: {}", rect);
ASSERT(!flush_rects.intersects(rect)); ASSERT(!flush_rects.intersects(rect));
ASSERT(!flush_transparent_rects.intersects(rect)); ASSERT(!flush_transparent_rects.intersects(rect));
flush_rects.add(rect); flush_rects.add(rect);
@ -223,7 +223,7 @@ void Compositor::compose()
}; };
auto prepare_transparency_rect = [&](const Gfx::IntRect& rect) { auto prepare_transparency_rect = [&](const Gfx::IntRect& rect) {
dbgln<debug_compose>(" -> flush transparent: {}", rect); dbgln<COMPOSE_DEBUG>(" -> flush transparent: {}", rect);
ASSERT(!flush_rects.intersects(rect)); ASSERT(!flush_rects.intersects(rect));
bool have_rect = false; bool have_rect = false;
for (auto& r : flush_transparent_rects.rects()) { for (auto& r : flush_transparent_rects.rects()) {
@ -270,7 +270,7 @@ void Compositor::compose()
}; };
m_opaque_wallpaper_rects.for_each_intersected(dirty_screen_rects, [&](const Gfx::IntRect& render_rect) { m_opaque_wallpaper_rects.for_each_intersected(dirty_screen_rects, [&](const Gfx::IntRect& render_rect) {
dbgln<debug_compose>(" render wallpaper opaque: {}", render_rect); dbgln<COMPOSE_DEBUG>(" render wallpaper opaque: {}", render_rect);
prepare_rect(render_rect); prepare_rect(render_rect);
paint_wallpaper(back_painter, render_rect); paint_wallpaper(back_painter, render_rect);
return IterationDecision::Continue; return IterationDecision::Continue;
@ -282,7 +282,7 @@ void Compositor::compose()
return IterationDecision::Continue; return IterationDecision::Continue;
auto frame_rects = frame_rect.shatter(window.rect()); auto frame_rects = frame_rect.shatter(window.rect());
dbgln<debug_compose>(" window {} frame rect: {}", window.title(), frame_rect); dbgln<COMPOSE_DEBUG>(" window {} frame rect: {}", window.title(), frame_rect);
RefPtr<Gfx::Bitmap> backing_store = window.backing_store(); RefPtr<Gfx::Bitmap> backing_store = window.backing_store();
auto compose_window_rect = [&](Gfx::Painter& painter, const Gfx::IntRect& rect) { auto compose_window_rect = [&](Gfx::Painter& painter, const Gfx::IntRect& rect) {
@ -291,7 +291,7 @@ void Compositor::compose()
// TODO: Should optimize this to use a backing buffer // TODO: Should optimize this to use a backing buffer
Gfx::PainterStateSaver saver(painter); Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(intersected_rect); painter.add_clip_rect(intersected_rect);
dbgln<debug_compose>(" render frame: {}", intersected_rect); dbgln<COMPOSE_DEBUG>(" render frame: {}", intersected_rect);
window.frame().paint(painter); window.frame().paint(painter);
return IterationDecision::Continue; return IterationDecision::Continue;
}); });
@ -360,7 +360,7 @@ void Compositor::compose()
auto& dirty_rects = window.dirty_rects(); auto& dirty_rects = window.dirty_rects();
if constexpr (debug_compose) { if constexpr (COMPOSE_DEBUG) {
for (auto& dirty_rect : dirty_rects.rects()) for (auto& dirty_rect : dirty_rects.rects())
dbgln(" dirty: {}", dirty_rect); dbgln(" dirty: {}", dirty_rect);
for (auto& r : window.opaque_rects().rects()) for (auto& r : window.opaque_rects().rects())
@ -373,7 +373,7 @@ void Compositor::compose()
auto& opaque_rects = window.opaque_rects(); auto& opaque_rects = window.opaque_rects();
if (!opaque_rects.is_empty()) { if (!opaque_rects.is_empty()) {
opaque_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) { opaque_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
dbgln<debug_compose>(" render opaque: {}", render_rect); dbgln<COMPOSE_DEBUG>(" render opaque: {}", render_rect);
prepare_rect(render_rect); prepare_rect(render_rect);
Gfx::PainterStateSaver saver(back_painter); Gfx::PainterStateSaver saver(back_painter);
@ -388,7 +388,7 @@ void Compositor::compose()
auto& transparency_wallpaper_rects = window.transparency_wallpaper_rects(); auto& transparency_wallpaper_rects = window.transparency_wallpaper_rects();
if (!transparency_wallpaper_rects.is_empty()) { if (!transparency_wallpaper_rects.is_empty()) {
transparency_wallpaper_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) { transparency_wallpaper_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
dbgln<debug_compose>(" render wallpaper: {}", render_rect); dbgln<COMPOSE_DEBUG>(" render wallpaper: {}", render_rect);
prepare_transparency_rect(render_rect); prepare_transparency_rect(render_rect);
paint_wallpaper(temp_painter, render_rect); paint_wallpaper(temp_painter, render_rect);
@ -398,7 +398,7 @@ void Compositor::compose()
auto& transparency_rects = window.transparency_rects(); auto& transparency_rects = window.transparency_rects();
if (!transparency_rects.is_empty()) { if (!transparency_rects.is_empty()) {
transparency_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) { transparency_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
dbgln<debug_compose>(" render transparent: {}", render_rect); dbgln<COMPOSE_DEBUG>(" render transparent: {}", render_rect);
prepare_transparency_rect(render_rect); prepare_transparency_rect(render_rect);
Gfx::PainterStateSaver saver(temp_painter); Gfx::PainterStateSaver saver(temp_painter);
@ -671,7 +671,7 @@ void Compositor::run_animations(Gfx::DisjointRectSet& flush_rects)
from_rect.height() - (int)(height_delta_per_step * animation_index) from_rect.height() - (int)(height_delta_per_step * animation_index)
}; };
dbgln<debug_minimize_animation>("Minimize animation from {} to {} frame# {} {}", from_rect, to_rect, animation_index, rect); dbgln<MINIMIZE_ANIMATION_DEBUG>("Minimize animation from {} to {} frame# {} {}", from_rect, to_rect, animation_index, rect);
painter.draw_rect(rect, Color::Transparent); // Color doesn't matter, we draw inverted painter.draw_rect(rect, Color::Transparent); // Color doesn't matter, we draw inverted
flush_rects.add(rect); flush_rects.add(rect);
@ -1001,7 +1001,7 @@ void Compositor::recompute_occlusions()
m_opaque_wallpaper_rects = move(visible_rects); m_opaque_wallpaper_rects = move(visible_rects);
} }
if constexpr (debug_occlusions) { if constexpr (OCCLUSIONS_DEBUG) {
for (auto& r : m_opaque_wallpaper_rects.rects()) for (auto& r : m_opaque_wallpaper_rects.rects())
dbgln(" wallpaper opaque: {}", r); dbgln(" wallpaper opaque: {}", r);
} }
@ -1011,7 +1011,7 @@ void Compositor::recompute_occlusions()
if (w.is_minimized() || window_frame_rect.is_empty()) if (w.is_minimized() || window_frame_rect.is_empty())
return IterationDecision::Continue; return IterationDecision::Continue;
if constexpr (debug_occlusions) { if constexpr (OCCLUSIONS_DEBUG) {
dbgln(" Window {} frame rect: {}", w.title(), window_frame_rect); dbgln(" Window {} frame rect: {}", w.title(), window_frame_rect);
for (auto& r : w.opaque_rects().rects()) for (auto& r : w.opaque_rects().rects())
dbgln(" opaque: {}", r); dbgln(" opaque: {}", r);

View file

@ -459,7 +459,7 @@ void MenuManager::set_current_menubar(MenuBar* menubar)
else else
m_current_menubar = nullptr; m_current_menubar = nullptr;
dbgln<debug_menus>("[WM] Current menubar is now {}", menubar); dbgln<MENUS_DEBUG>("[WM] Current menubar is now {}", menubar);
Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 }; Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 };
for_each_active_menubar_menu([&](Menu& menu) { for_each_active_menubar_menu([&](Menu& menu) {

View file

@ -82,7 +82,7 @@ bool Screen::set_resolution(int width, int height, int new_scale_factor)
FBResolution physical_resolution { 0, (unsigned)new_physical_width, (unsigned)new_physical_height }; FBResolution physical_resolution { 0, (unsigned)new_physical_width, (unsigned)new_physical_height };
int rc = fb_set_resolution(m_framebuffer_fd, &physical_resolution); int rc = fb_set_resolution(m_framebuffer_fd, &physical_resolution);
dbgln<debug_wsscreen>("fb_set_resolution() - return code {}", rc); dbgln<WSSCREEN_DEBUG>("fb_set_resolution() - return code {}", rc);
if (rc == 0) { if (rc == 0) {
on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor); on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor);

View file

@ -343,7 +343,7 @@ void WindowManager::notify_title_changed(Window& window)
if (window.type() != WindowType::Normal) if (window.type() != WindowType::Normal)
return; return;
dbgln<debug_window_manager>("[WM] Window({}) title set to '{}'", &window, window.title()); dbgln<WINDOWMANAGER_DEBUG>("[WM] Window({}) title set to '{}'", &window, window.title());
if (m_switcher.is_visible()) if (m_switcher.is_visible())
m_switcher.refresh(); m_switcher.refresh();
@ -356,7 +356,7 @@ void WindowManager::notify_modal_unparented(Window& window)
if (window.type() != WindowType::Normal) if (window.type() != WindowType::Normal)
return; return;
dbgln<debug_window_manager>("[WM] Window({}) was unparented", &window); dbgln<WINDOWMANAGER_DEBUG>("[WM] Window({}) was unparented", &window);
if (m_switcher.is_visible()) if (m_switcher.is_visible())
m_switcher.refresh(); m_switcher.refresh();
@ -366,7 +366,7 @@ void WindowManager::notify_modal_unparented(Window& window)
void WindowManager::notify_rect_changed(Window& window, const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect) void WindowManager::notify_rect_changed(Window& window, const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect)
{ {
dbgln<debug_resize>("[WM] Window({}) rect changed {} -> {}", &window, old_rect, new_rect); dbgln<RESIZE_DEBUG>("[WM] Window({}) rect changed {} -> {}", &window, old_rect, new_rect);
if (m_switcher.is_visible() && window.type() != WindowType::WindowSwitcher) if (m_switcher.is_visible() && window.type() != WindowType::WindowSwitcher)
m_switcher.refresh(); m_switcher.refresh();
@ -431,7 +431,7 @@ bool WindowManager::pick_new_active_window(Window* previous_active)
void WindowManager::start_window_move(Window& window, const MouseEvent& event) void WindowManager::start_window_move(Window& window, const MouseEvent& event)
{ {
dbgln<debug_move>("[WM] Begin moving Window({})", &window); dbgln<MOVE_DEBUG>("[WM] Begin moving Window({})", &window);
move_to_front_and_make_active(window); move_to_front_and_make_active(window);
m_move_window = window; m_move_window = window;
@ -464,7 +464,7 @@ void WindowManager::start_window_resize(Window& window, const Gfx::IntPoint& pos
return; return;
} }
dbgln<debug_resize>("[WM] Begin resizing Window({})", &window); dbgln<RESIZE_DEBUG>("[WM] Begin resizing Window({})", &window);
m_resizing_mouse_button = button; m_resizing_mouse_button = button;
m_resize_window = window; m_resize_window = window;
@ -491,7 +491,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
return false; return false;
if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) { if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) {
dbgln<debug_move>("[WM] Finish moving Window({})", m_move_window); dbgln<MOVE_DEBUG>("[WM] Finish moving Window({})", m_move_window);
m_move_window->invalidate(); m_move_window->invalidate();
if (m_move_window->rect().contains(event.position())) if (m_move_window->rect().contains(event.position()))
@ -509,7 +509,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
return true; return true;
} }
if (event.type() == Event::MouseMove) { if (event.type() == Event::MouseMove) {
if constexpr (debug_move) { if constexpr (MOVE_DEBUG) {
dbgln("[WM] Moving, origin: {}, now: {}", m_move_origin, event.position()); dbgln("[WM] Moving, origin: {}, now: {}", m_move_origin, event.position());
if (m_move_window->is_maximized()) if (m_move_window->is_maximized())
dbgln(" [!] The window is still maximized. Not moving yet."); dbgln(" [!] The window is still maximized. Not moving yet.");
@ -575,7 +575,7 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
return false; return false;
if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) { if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) {
dbgln<debug_resize>("[WM] Finish resizing Window({})", m_resize_window); dbgln<RESIZE_DEBUG>("[WM] Finish resizing Window({})", m_resize_window);
Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect())); Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect()));
m_resize_window->invalidate(); m_resize_window->invalidate();
@ -683,7 +683,7 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
if (m_resize_window->rect() == new_rect) if (m_resize_window->rect() == new_rect)
return true; return true;
dbgln<debug_resize>("[WM] Resizing, original: {}, now: {}", m_resize_window_original_rect, new_rect); dbgln<RESIZE_DEBUG>("[WM] Resizing, original: {}, now: {}", m_resize_window_original_rect, new_rect);
m_resize_window->set_rect(new_rect); m_resize_window->set_rect(new_rect);
Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect)); Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect));
@ -805,7 +805,7 @@ void WindowManager::start_menu_doubleclick(Window& window, const MouseEvent& eve
// we either haven't clicked anywhere, or we haven't clicked on this // we either haven't clicked anywhere, or we haven't clicked on this
// window. set the current click window, and reset the timers. // window. set the current click window, and reset the timers.
dbgln<debug_double_click>("Initial mousedown on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window); dbgln<DOUBLECLICK_DEBUG>("Initial mousedown on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window);
m_double_click_info.m_clicked_window = window; m_double_click_info.m_clicked_window = window;
m_double_click_info.reset(); m_double_click_info.reset();
@ -837,7 +837,7 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev
if (&window != m_double_click_info.m_clicked_window) { if (&window != m_double_click_info.m_clicked_window) {
// we either haven't clicked anywhere, or we haven't clicked on this // we either haven't clicked anywhere, or we haven't clicked on this
// window. set the current click window, and reset the timers. // window. set the current click window, and reset the timers.
dbgln<debug_double_click>("Initial mouseup on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window); dbgln<DOUBLECLICK_DEBUG>("Initial mouseup on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window);
m_double_click_info.m_clicked_window = window; m_double_click_info.m_clicked_window = window;
m_double_click_info.reset(); m_double_click_info.reset();
@ -852,7 +852,7 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev
// clock // clock
metadata.clock.start(); metadata.clock.start();
} else { } else {
dbgln<debug_double_click>("Transforming MouseUp to MouseDoubleClick ({} < {})!", metadata.clock.elapsed(), m_double_click_speed); dbgln<DOUBLECLICK_DEBUG>("Transforming MouseUp to MouseDoubleClick ({} < {})!", metadata.clock.elapsed(), m_double_click_speed);
event = MouseEvent(Event::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta()); event = MouseEvent(Event::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta());
// invalidate this now we've delivered a doubleclick, otherwise // invalidate this now we've delivered a doubleclick, otherwise

View file

@ -99,7 +99,7 @@ int main(int argc, char** argv)
return a.size < b.size; return a.size < b.size;
return a.name < b.name; return a.name < b.name;
}); });
if constexpr (debug_disasm_dump) { if constexpr (DISASM_DUMP_DEBUG) {
for (size_t i = 0; i < symbols.size(); ++i) for (size_t i = 0; i < symbols.size(); ++i)
dbgln("{}: {:p}, {}", symbols[i].name, symbols[i].value, symbols[i].size); dbgln("{}: {:p}, {}", symbols[i].name, symbols[i].value, symbols[i].size);
} }