From c6ebca5b4555c4a0480c11dcb9de245d7328d4de Mon Sep 17 00:00:00 2001 From: asynts Date: Thu, 14 Jan 2021 22:37:57 +0100 Subject: 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. --- Kernel/Net/LocalSocket.cpp | 23 ++++++++--------------- Kernel/Net/Socket.cpp | 14 ++++---------- Kernel/Net/TCPSocket.cpp | 21 ++++++--------------- 3 files changed, 18 insertions(+), 40 deletions(-) (limited to 'Kernel/Net') diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 6f50ebe4ae..4ad67b810c 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -75,9 +76,7 @@ LocalSocket::LocalSocket(int type) evaluate_block_conditions(); }); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} created with type=" << type; -#endif + dbgln("LocalSocket({}) created with type={}", this, type); } LocalSocket::~LocalSocket() @@ -113,9 +112,7 @@ KResult LocalSocket::bind(Userspace user_address, socklen_t add auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path))); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} bind(" << path << ")"; -#endif + dbgln("LocalSocket({}) bind({})", this, path); mode_t mode = S_IFSOCK | (m_prebind_mode & 04777); UidAndGid owner { m_prebind_uid, m_prebind_gid }; @@ -159,9 +156,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace("LocalSocket({}) connect({})", this, safe_address); auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory()); if (description_or_error.is_error()) @@ -197,9 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state())); if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) { set_connect_side_role(Role::None); @@ -218,9 +211,9 @@ KResult LocalSocket::listen(size_t backlog) auto previous_role = m_role; m_role = Role::Listener; set_connect_side_role(Role::Listener, previous_role != m_role); -#ifdef DEBUG_LOCAL_SOCKET - dbg() << "LocalSocket{" << this << "} listening with backlog=" << backlog; -#endif + + dbgln("LocalSocket({}) listening with backlog={}", this, backlog); + return KSuccess; } diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index f17934e656..2bd9d3f875 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -65,10 +66,7 @@ Socket::~Socket() void Socket::set_setup_state(SetupState new_setup_state) { -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} setup state moving from " << to_string(m_setup_state) << " to " << to_string(new_setup_state); -#endif - + dbgln("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state)); m_setup_state = new_setup_state; evaluate_block_conditions(); } @@ -78,9 +76,7 @@ RefPtr Socket::accept() LOCKER(m_lock); if (m_pending.is_empty()) return nullptr; -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} de-queueing connection"; -#endif + dbgln("Socket({}) de-queueing connection", this); auto client = m_pending.take_first(); ASSERT(!client->is_connected()); auto& process = *Process::current(); @@ -94,9 +90,7 @@ RefPtr Socket::accept() KResult Socket::queue_connection_from(NonnullRefPtr peer) { -#ifdef SOCKET_DEBUG - dbg() << "Socket{" << this << "} queueing connection"; -#endif + dbgln("Socket({}) queueing connection", this); LOCKER(m_lock); if (m_pending.size() >= m_backlog) return ECONNREFUSED; diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 08bda1251f..e10c9031f7 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -48,9 +49,7 @@ void TCPSocket::for_each(Function callback) void TCPSocket::set_state(State new_state) { -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket{" << this << "} state moving from " << to_string(m_state) << " to " << to_string(new_state); -#endif + dbgln("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state)); auto was_disconnected = protocol_is_disconnected(); auto previous_role = m_role; @@ -157,9 +156,7 @@ TCPSocket::~TCPSocket() LOCKER(sockets_by_tuple().lock()); sockets_by_tuple().resource().remove(tuple()); -#ifdef TCP_SOCKET_DEBUG - dbg() << "~TCPSocket in state " << to_string(state()); -#endif + dbgln("~TCPSocket in state {}", to_string(state())); } NonnullRefPtr TCPSocket::create(int protocol) @@ -278,18 +275,14 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) if (packet.has_ack()) { u32 ack_number = packet.ack_number(); -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: receive_tcp_packet: " << ack_number; -#endif + dbgln("TCPSocket: receive_tcp_packet: {}", ack_number); int removed = 0; LOCKER(m_not_acked_lock); while (!m_not_acked.is_empty()) { auto& packet = m_not_acked.first(); -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: iterate: " << packet.ack_number; -#endif + dbgln("TCPSocket: iterate: {}", packet.ack_number); if (packet.ack_number <= ack_number) { m_not_acked.take_first(); @@ -299,9 +292,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) } } -#ifdef TCP_SOCKET_DEBUG - dbg() << "TCPSocket: receive_tcp_packet acknowledged " << removed << " packets"; -#endif + dbgln("TCPSocket: receive_tcp_packet acknowledged {} packets", removed); } m_packets_in++; -- cgit v1.2.3