1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +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:
asynts 2021-01-14 22:37:57 +01:00 committed by Andreas Kling
parent dd727d1fec
commit c6ebca5b45
8 changed files with 68 additions and 106 deletions

View file

@ -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>
@ -75,9 +76,7 @@ LocalSocket::LocalSocket(int type)
evaluate_block_conditions();
});
#ifdef DEBUG_LOCAL_SOCKET
dbg() << "LocalSocket{" << this << "} created with type=" << type;
#endif
dbgln<debug_local_socket>("LocalSocket({}) created with type={}", this, type);
}
LocalSocket::~LocalSocket()
@ -113,9 +112,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)));
#ifdef DEBUG_LOCAL_SOCKET
dbg() << "LocalSocket{" << this << "} bind(" << path << ")";
#endif
dbgln<debug_local_socket>("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<const socka
return EFAULT;
safe_address[sizeof(safe_address) - 1] = '\0';
#ifdef DEBUG_LOCAL_SOCKET
dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ")";
#endif
dbgln<debug_local_socket>("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<const socka
return EINTR;
}
#ifdef DEBUG_LOCAL_SOCKET
dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ") status is " << to_string(setup_state());
#endif
dbgln<debug_local_socket>("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<debug_local_socket>("LocalSocket({}) listening with backlog={}", this, backlog);
return KSuccess;
}

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <Kernel/FileSystem/FileDescription.h>
@ -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<debug_socket>("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> Socket::accept()
LOCKER(m_lock);
if (m_pending.is_empty())
return nullptr;
#ifdef SOCKET_DEBUG
dbg() << "Socket{" << this << "} de-queueing connection";
#endif
dbgln<debug_socket>("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> Socket::accept()
KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer)
{
#ifdef SOCKET_DEBUG
dbg() << "Socket{" << this << "} queueing connection";
#endif
dbgln<debug_socket>("Socket({}) queueing connection", this);
LOCKER(m_lock);
if (m_pending.size() >= m_backlog)
return ECONNREFUSED;

View file

@ -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/Time.h>
#include <Kernel/Devices/RandomDevice.h>
@ -48,9 +49,7 @@ void TCPSocket::for_each(Function<void(const TCPSocket&)> 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<debug_tcp_socket>("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<debug_tcp_socket>("~TCPSocket in state {}", to_string(state()));
}
NonnullRefPtr<TCPSocket> 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<debug_tcp_socket>("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<debug_tcp_socket>("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<debug_tcp_socket>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed);
}
m_packets_in++;