mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 13:35:07 +00:00
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
parent
67583bc424
commit
dd727d1fec
4 changed files with 63 additions and 55 deletions
19
AK/Debug.h
19
AK/Debug.h
|
@ -159,3 +159,22 @@ constexpr bool debug_irq = true;
|
|||
#else
|
||||
constexpr bool debug_irq = false;
|
||||
#endif
|
||||
|
||||
#ifdef INTERRUPT_DEBUG
|
||||
constexpr bool debug_interrupt = true;
|
||||
#else
|
||||
constexpr bool debug_interrupt = false;
|
||||
#endif
|
||||
|
||||
#ifdef E1000_DEBUG
|
||||
constexpr bool debug_e1000 = true;
|
||||
#else
|
||||
constexpr bool debug_e1000 = false;
|
||||
#endif
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
constexpr bool debug_ipv4_socket = true;
|
||||
#else
|
||||
constexpr bool debug_ipv4_socket = false;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
#include <Kernel/Assertions.h>
|
||||
#include <Kernel/Interrupts/IRQHandler.h>
|
||||
|
@ -59,9 +60,7 @@ void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler)
|
|||
|
||||
bool SharedIRQHandler::eoi()
|
||||
{
|
||||
#ifdef INTERRUPT_DEBUG
|
||||
dbg() << "EOI IRQ " << interrupt_number();
|
||||
#endif
|
||||
dbgln<debug_interrupt>("EOI IRQ {}", interrupt_number());
|
||||
m_responsible_irq_controller->eoi(*this);
|
||||
return true;
|
||||
}
|
||||
|
@ -87,21 +86,19 @@ SharedIRQHandler::~SharedIRQHandler()
|
|||
void SharedIRQHandler::handle_interrupt(const RegisterState& regs)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
#ifdef INTERRUPT_DEBUG
|
||||
dbg() << "Interrupt @ " << interrupt_number();
|
||||
dbg() << "Interrupt Handlers registered - " << m_handlers.size();
|
||||
#endif
|
||||
|
||||
if constexpr (debug_interrupt) {
|
||||
dbgln("Interrupt @ {}", interrupt_number());
|
||||
dbgln("Interrupt Handlers registered - {}", m_handlers.size());
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (auto* handler : m_handlers) {
|
||||
#ifdef INTERRUPT_DEBUG
|
||||
dbg() << "Going for Interrupt Handling @ " << i << ", Shared Interrupt " << interrupt_number();
|
||||
#endif
|
||||
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number());
|
||||
ASSERT(handler != nullptr);
|
||||
handler->increment_invoking_counter();
|
||||
handler->handle_interrupt(regs);
|
||||
#ifdef INTERRUPT_DEBUG
|
||||
dbg() << "Going for Interrupt Handling @ " << i << ", Shared Interrupt " << interrupt_number() << " - End";
|
||||
#endif
|
||||
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/MACAddress.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/Net/E1000NetworkAdapter.h>
|
||||
|
@ -363,9 +364,7 @@ void E1000NetworkAdapter::initialize_tx_descriptors()
|
|||
|
||||
void E1000NetworkAdapter::out8(u16 address, u8 data)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: OUT8 0x" << String::format("%02x", data) << " @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: OUT8 {:#02x} @ {:#04x}", data, address);
|
||||
if (m_use_mmio) {
|
||||
auto* ptr = (volatile u8*)(m_mmio_base.get() + address);
|
||||
*ptr = data;
|
||||
|
@ -376,9 +375,7 @@ void E1000NetworkAdapter::out8(u16 address, u8 data)
|
|||
|
||||
void E1000NetworkAdapter::out16(u16 address, u16 data)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: OUT16 0x" << String::format("%04x", data) << " @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: OUT16 {:#04x} @ {:#04x}", data, address);
|
||||
if (m_use_mmio) {
|
||||
auto* ptr = (volatile u16*)(m_mmio_base.get() + address);
|
||||
*ptr = data;
|
||||
|
@ -389,9 +386,7 @@ void E1000NetworkAdapter::out16(u16 address, u16 data)
|
|||
|
||||
void E1000NetworkAdapter::out32(u16 address, u32 data)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: OUT32 0x" << String::format("%08x", data) << " @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: OUT32 {:#08x} @ {:#04x}", data, address);
|
||||
if (m_use_mmio) {
|
||||
auto* ptr = (volatile u32*)(m_mmio_base.get() + address);
|
||||
*ptr = data;
|
||||
|
@ -402,9 +397,7 @@ void E1000NetworkAdapter::out32(u16 address, u32 data)
|
|||
|
||||
u8 E1000NetworkAdapter::in8(u16 address)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: IN8 @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: IN8 @ {:#04x}", address);
|
||||
if (m_use_mmio)
|
||||
return *(volatile u8*)(m_mmio_base.get() + address);
|
||||
return m_io_base.offset(address).in<u8>();
|
||||
|
@ -412,9 +405,7 @@ u8 E1000NetworkAdapter::in8(u16 address)
|
|||
|
||||
u16 E1000NetworkAdapter::in16(u16 address)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: IN16 @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: IN16 @ {:#04x}", address);
|
||||
if (m_use_mmio)
|
||||
return *(volatile u16*)(m_mmio_base.get() + address);
|
||||
return m_io_base.offset(address).in<u16>();
|
||||
|
@ -422,9 +413,7 @@ u16 E1000NetworkAdapter::in16(u16 address)
|
|||
|
||||
u32 E1000NetworkAdapter::in32(u16 address)
|
||||
{
|
||||
#ifdef E1000_DEBUG
|
||||
dbg() << "E1000: IN32 @ 0x" << String::format("%04x", address);
|
||||
#endif
|
||||
dbgln<debug_e1000>("E1000: IN32 @ {:#04x}", address);
|
||||
if (m_use_mmio)
|
||||
return *(volatile u32*)(m_mmio_base.get() + address);
|
||||
return m_io_base.offset(address).in<u32>();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
|
@ -67,9 +68,7 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
|
|||
IPv4Socket::IPv4Socket(int type, int protocol)
|
||||
: Socket(AF_INET, type, protocol)
|
||||
{
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "IPv4Socket{" << this << "} created with type=" << type << ", protocol=" << protocol;
|
||||
#endif
|
||||
dbgln<debug_ipv4_socket>("IPv4Socket({}) created with type={}, protocol={}", this, type, protocol);
|
||||
m_buffer_mode = type == SOCK_STREAM ? BufferMode::Bytes : BufferMode::Packets;
|
||||
if (m_buffer_mode == BufferMode::Bytes) {
|
||||
m_scratch_buffer = KBuffer::create_with_size(65536);
|
||||
|
@ -122,9 +121,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_port = requested_local_port;
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "IPv4Socket::bind " << class_name() << "{" << this << "} to " << m_local_address << ":" << m_local_port;
|
||||
#endif
|
||||
dbgln<debug_ipv4_socket>("IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port);
|
||||
|
||||
return protocol_bind();
|
||||
}
|
||||
|
@ -140,9 +137,7 @@ KResult IPv4Socket::listen(size_t backlog)
|
|||
m_role = Role::Listener;
|
||||
evaluate_block_conditions();
|
||||
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "IPv4Socket{" << this << "} listening with backlog=" << backlog;
|
||||
#endif
|
||||
dbgln<debug_ipv4_socket>("IPv4Socket({}) listening with backlog={}", this, backlog);
|
||||
|
||||
return protocol_listen();
|
||||
}
|
||||
|
@ -293,9 +288,11 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||
if (!m_receive_queue.is_empty()) {
|
||||
packet = m_receive_queue.take_first();
|
||||
set_can_read(!m_receive_queue.is_empty());
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "IPv4Socket(" << this << "): recvfrom without blocking " << packet.data.value().size() << " bytes, packets in queue: " << m_receive_queue.size();
|
||||
#endif
|
||||
|
||||
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom without blocking {} bytes, packets in queue: {}",
|
||||
this,
|
||||
packet.data.value().size(),
|
||||
m_receive_queue.size());
|
||||
}
|
||||
}
|
||||
if (!packet.data.has_value()) {
|
||||
|
@ -320,18 +317,18 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
|
|||
ASSERT(!m_receive_queue.is_empty());
|
||||
packet = m_receive_queue.take_first();
|
||||
set_can_read(!m_receive_queue.is_empty());
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "IPv4Socket(" << this << "): recvfrom with blocking " << packet.data.value().size() << " bytes, packets in queue: " << m_receive_queue.size();
|
||||
#endif
|
||||
|
||||
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom with blocking {} bytes, packets in queue: {}",
|
||||
this,
|
||||
packet.data.value().size(),
|
||||
m_receive_queue.size());
|
||||
}
|
||||
ASSERT(packet.data.has_value());
|
||||
|
||||
packet_timestamp = packet.timestamp;
|
||||
|
||||
if (addr) {
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
dbg() << "Incoming packet is from: " << packet.peer_address << ":" << packet.peer_port;
|
||||
#endif
|
||||
dbgln<debug_ipv4_socket>("Incoming packet is from: {}:{}", packet.peer_address, packet.peer_port);
|
||||
|
||||
sockaddr_in out_addr {};
|
||||
memcpy(&out_addr.sin_addr, &packet.peer_address, sizeof(IPv4Address));
|
||||
|
@ -415,12 +412,18 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port,
|
|||
set_can_read(true);
|
||||
}
|
||||
m_bytes_received += packet_size;
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
|
||||
if constexpr (debug_ipv4_socket) {
|
||||
if (buffer_mode() == BufferMode::Bytes)
|
||||
dbg() << "IPv4Socket(" << this << "): did_receive " << packet_size << " bytes, total_received=" << m_bytes_received;
|
||||
dbgln("IPv4Socket({}): did_receive {} bytes, total_received={}", this, packet_size, m_bytes_received);
|
||||
else
|
||||
dbg() << "IPv4Socket(" << this << "): did_receive " << packet_size << " bytes, total_received=" << m_bytes_received << ", packets in queue: " << m_receive_queue.size();
|
||||
#endif
|
||||
dbgln("IPv4Socket({}): did_receive {} bytes, total_received={}, packets in queue: {}",
|
||||
this,
|
||||
packet_size,
|
||||
m_bytes_received,
|
||||
m_receive_queue.size());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue