diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index fa87ddc06f7..0fd229bd1fb 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -386,10 +386,6 @@ struct PrintfImpl { m_putch(m_bufptr, '%'); return 1; } - ALWAYS_INLINE int format_w(const ModifierState& state, ArgumentListRefT ap) const - { - return print_hex(m_putch, m_bufptr, NextArgument()(ap), false, state.alternate_form, false, true, 4); - } ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const { char c = NextArgument()(ap); @@ -511,7 +507,6 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm PRINTF_IMPL_DELEGATE_TO_IMPL(q); PRINTF_IMPL_DELEGATE_TO_IMPL(s); PRINTF_IMPL_DELEGATE_TO_IMPL(u); - PRINTF_IMPL_DELEGATE_TO_IMPL(w); PRINTF_IMPL_DELEGATE_TO_IMPL(x); default: ret += impl.format_unrecognized(*p, fmt, state, ap); diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index fee823fd783..9241474cf19 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -123,7 +123,7 @@ void NetworkTask_main(void*) } auto& eth = *(const EthernetFrameHeader*)buffer; #ifdef ETHERNET_DEBUG - klog() << "NetworkTask: From " << eth.source().to_string().characters() << " to " << eth.destination().to_string().characters() << ", ether_type=" << String::format("%w", eth.ether_type()) << ", packet_length=" << packet_size; + dbgln("NetworkTask: From {} to {}, ether_type={:#04x}, packet_size={}", eth.source().to_string(), eth.destination().to_string(), eth.ether_type(), packet_size); #endif #ifdef ETHERNET_VERY_DEBUG @@ -171,16 +171,21 @@ void handle_arp(const EthernetFrameHeader& eth, size_t frame_size) } auto& packet = *static_cast(eth.payload()); if (packet.hardware_type() != 1 || packet.hardware_address_length() != sizeof(MACAddress)) { - klog() << "handle_arp: Hardware type not ethernet (" << String::format("%w", packet.hardware_type()) << ", len=" << packet.hardware_address_length() << ")"; + dbgln("handle_arp: Hardware type not ethernet ({:#04x}, len={})", packet.hardware_type(), packet.hardware_address_length()); return; } if (packet.protocol_type() != EtherType::IPv4 || packet.protocol_address_length() != sizeof(IPv4Address)) { - klog() << "handle_arp: Protocol type not IPv4 (" << String::format("%w", packet.hardware_type()) << ", len=" << packet.protocol_address_length() << ")"; + dbgln("handle_arp: Protocol type not IPv4 ({:#04x}, len={})", packet.protocol_type(), packet.protocol_address_length()); return; } #ifdef ARP_DEBUG - klog() << "handle_arp: operation=" << String::format("%w", packet.operation()) << ", sender=" << packet.sender_hardware_address().to_string().characters() << "/" << packet.sender_protocol_address().to_string().characters() << ", target=" << packet.target_hardware_address().to_string().characters() << "/" << packet.target_protocol_address().to_string().characters(); + dbgln("handle_arp: operation={:#04x}, sender={}/{}, target={}/{}", + packet.operation(), + packet.sender_hardware_address().to_string(), + packet.sender_protocol_address().to_string(), + packet.target_hardware_address().to_string(), + packet.target_protocol_address().to_string()); #endif if (!packet.sender_hardware_address().is_zero() && !packet.sender_protocol_address().is_zero()) { @@ -341,7 +346,20 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp) size_t payload_size = ipv4_packet.payload_size() - tcp_packet.header_size(); #ifdef TCP_DEBUG - klog() << "handle_tcp: source=" << ipv4_packet.source().to_string().characters() << ":" << tcp_packet.source_port() << ", destination=" << ipv4_packet.destination().to_string().characters() << ":" << tcp_packet.destination_port() << " seq_no=" << tcp_packet.sequence_number() << ", ack_no=" << tcp_packet.ack_number() << ", flags=" << String::format("%w", tcp_packet.flags()) << " (" << (tcp_packet.has_syn() ? "SYN " : "") << (tcp_packet.has_ack() ? "ACK " : "") << (tcp_packet.has_fin() ? "FIN " : "") << (tcp_packet.has_rst() ? "RST " : "") << "), window_size=" << tcp_packet.window_size() << ", payload_size=" << payload_size; + dbgln("handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}", + ipv4_packet.source().to_string(), + tcp_packet.source_port(), + ipv4_packet.destination().to_string(), + tcp_packet.destination_port(), + tcp_packet.sequence_number(), + tcp_packet.ack_number(), + tcp_packet.flags(), + tcp_packet.has_syn() ? "SYN " : "", + tcp_packet.has_ack() ? "ACK " : "", + tcp_packet.has_fin() ? "FIN " : "", + tcp_packet.has_rst() ? "RST " : "", + tcp_packet.window_size(), + payload_size); #endif auto adapter = NetworkAdapter::from_ipv4_address(ipv4_packet.destination()); @@ -358,8 +376,20 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp) auto socket = TCPSocket::from_tuple(tuple); if (!socket) { - klog() << "handle_tcp: No TCP socket for tuple " << tuple.to_string().characters(); - klog() << "handle_tcp: source=" << ipv4_packet.source().to_string().characters() << ":" << tcp_packet.source_port() << ", destination=" << ipv4_packet.destination().to_string().characters() << ":" << tcp_packet.destination_port() << " seq_no=" << tcp_packet.sequence_number() << ", ack_no=" << tcp_packet.ack_number() << ", flags=" << String::format("%w", tcp_packet.flags()) << " (" << (tcp_packet.has_syn() ? "SYN " : "") << (tcp_packet.has_ack() ? "ACK " : "") << (tcp_packet.has_fin() ? "FIN " : "") << (tcp_packet.has_rst() ? "RST " : "") << "), window_size=" << tcp_packet.window_size() << ", payload_size=" << payload_size; + dbgln("handle_tcp: No TCP socket for tuple {}", tuple.to_string()); + dbgln("handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}", + ipv4_packet.source().to_string(), tcp_packet.source_port(), + ipv4_packet.destination().to_string(), + tcp_packet.destination_port(), + tcp_packet.sequence_number(), + tcp_packet.ack_number(), + tcp_packet.flags(), + tcp_packet.has_syn() ? "SYN " : "", + tcp_packet.has_ack() ? "ACK " : "", + tcp_packet.has_fin() ? "FIN " : "", + tcp_packet.has_rst() ? "RST " : "", + tcp_packet.window_size(), + payload_size); return; } diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h index 944b41f40c8..49a9b43825e 100644 --- a/Kernel/PCI/Definitions.h +++ b/Kernel/PCI/Definitions.h @@ -87,7 +87,7 @@ struct ID { }; inline const LogStream& operator<<(const LogStream& stream, const ID value) { - return stream << "(" << String::format("%w", value.vendor_id) << ":" << String::format("%w", value.device_id) << ")"; + return stream << String::formatted("({:04x}:{:04x})", value.vendor_id, value.device_id); } struct Address { public: diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index e5b0aa8adc2..f5dc03e6f5a 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -141,15 +141,15 @@ bool Scheduler::pick_next() dbg() << "Scheduler[" << Processor::current().id() << "]: Non-runnables:"; Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision { if (thread.state() == Thread::Dying) - dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip) << " Finalizable: " << thread.is_finalizable(); + dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip) << " Finalizable: " << thread.is_finalizable(); else - dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip); + dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip); return IterationDecision::Continue; }); dbg() << "Scheduler[" << Processor::current().id() << "]: Runnables:"; Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision { - dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip); + dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::formatted("{:04x}:{:08x}", thread.tss().cs, thread.tss().eip); return IterationDecision::Continue; }); #endif @@ -331,7 +331,7 @@ bool Scheduler::context_switch(Thread* thread) from_thread->set_state(Thread::Runnable); #ifdef LOG_EVERY_CONTEXT_SWITCH - dbg() << "Scheduler[" << Processor::current().id() << "]: " << *from_thread << " -> " << *thread << " [" << thread->priority() << "] " << String::format("%w", thread->tss().cs) << ":" << String::format("%x", thread->tss().eip); + dbgln("Scheduler[{}]: {} -> {} [prio={}] {:04x}:{:08x}", Processor::current().id(), from_thread->tid().value(), thread->tid().value(), thread->priority(), thread->tss().cs, thread->tss().eip); #endif } diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 7d32a2e3c7f..cb215a42b21 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -77,7 +77,7 @@ pid_t Process::sys$fork(RegisterState& regs) child_tss.ss = regs.userspace_ss; #ifdef FORK_DEBUG - dbg() << "fork: child will begin executing at " << String::format("%w", child_tss.cs) << ":" << String::format("%x", child_tss.eip) << " with stack " << String::format("%w", child_tss.ss) << ":" << String::format("%x", child_tss.esp) << ", kstack " << String::format("%w", child_tss.ss0) << ":" << String::format("%x", child_tss.esp0); + dbgln("fork: child will begin executing at {:04x}:{:08x} with stack {:04x}:{:08x}, kstack {:04x}:{:08x}", child_tss.cs, child_tss.eip, child_tss.ss, child_tss.esp, child_tss.ss0, child_tss.esp0); #endif SharedBuffer::share_all_shared_buffers(*this, *child); diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index ba8475a833e..e1b1bd5e5a9 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -830,7 +830,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) regs.eip = g_return_to_ring3_from_signal_trampoline.get(); #ifdef SIGNAL_DEBUG - klog() << "signal: Okay, " << *this << " {" << state_string() << "} has been primed with signal handler " << String::format("%w", m_tss.cs) << ":" << String::format("%x", m_tss.eip) << " to deliver " << signal; + dbgln("signal: Thread in state '{}' has been primed with signal handler {:04x}:{:08x} to deliver {}", state_string(), m_tss.cs, m_tss.eip, signal); #endif return DispatchSignalResult::Continue; } diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 28e975577e5..b2f3dcd30f2 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -374,7 +374,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault) return PageFaultResponse::ShouldCrash; } #ifdef PAGE_FAULT_DEBUG - dbg() << "MM: CPU[" << Processor::current().id() << "] handle_page_fault(" << String::format("%w", fault.code()) << ") at " << fault.vaddr(); + dbgln("MM: CPU[{}] handle_page_fault({:#04x}) at {}", Processor::current().id(), fault.code(), fault.vaddr()); #endif auto* region = find_region_from_vaddr(fault.vaddr()); if (!region) {