mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
Everywhere: Hook up remaining debug macros to Debug.h.
This commit is contained in:
parent
da69de1f1b
commit
eea72b9b5c
63 changed files with 458 additions and 287 deletions
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/Lock.h>
|
||||
#include <Kernel/Net/ARP.h>
|
||||
#include <Kernel/Net/EtherType.h>
|
||||
|
@ -89,7 +90,7 @@ void NetworkTask_main(void*)
|
|||
return;
|
||||
packet_size = adapter.dequeue_packet(buffer, buffer_size, packet_timestamp);
|
||||
pending_packets--;
|
||||
#ifdef NETWORK_TASK_DEBUG
|
||||
#if NETWORK_TASK_DEBUG
|
||||
klog() << "NetworkTask: Dequeued packet from " << adapter.name().characters() << " (" << packet_size << " bytes)";
|
||||
#endif
|
||||
});
|
||||
|
@ -113,11 +114,11 @@ void NetworkTask_main(void*)
|
|||
continue;
|
||||
}
|
||||
auto& eth = *(const EthernetFrameHeader*)buffer;
|
||||
#ifdef ETHERNET_DEBUG
|
||||
#if ETHERNET_DEBUG
|
||||
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
|
||||
#if ETHERNET_VERY_DEBUG
|
||||
for (size_t i = 0; i < packet_size; i++) {
|
||||
klog() << String::format("%#02x", buffer[i]);
|
||||
|
||||
|
@ -170,7 +171,7 @@ void handle_arp(const EthernetFrameHeader& eth, size_t frame_size)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ARP_DEBUG
|
||||
#if ARP_DEBUG
|
||||
dbgln("handle_arp: operation={:#04x}, sender={}/{}, target={}/{}",
|
||||
packet.operation(),
|
||||
packet.sender_hardware_address().to_string(),
|
||||
|
@ -224,7 +225,7 @@ void handle_ipv4(const EthernetFrameHeader& eth, size_t frame_size, const timeva
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef IPV4_DEBUG
|
||||
#if IPV4_DEBUG
|
||||
klog() << "handle_ipv4: source=" << packet.source().to_string().characters() << ", target=" << packet.destination().to_string().characters();
|
||||
#endif
|
||||
|
||||
|
@ -244,7 +245,7 @@ void handle_ipv4(const EthernetFrameHeader& eth, size_t frame_size, const timeva
|
|||
void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
||||
{
|
||||
auto& icmp_header = *static_cast<const ICMPHeader*>(ipv4_packet.payload());
|
||||
#ifdef ICMP_DEBUG
|
||||
#if ICMP_DEBUG
|
||||
dbgln("handle_icmp: source={}, destination={}, type={:#02x}, code={:#02x}", ipv4_packet.source().to_string(), ipv4_packet.destination().to_string(), icmp_header.type(), icmp_header.code());
|
||||
#endif
|
||||
|
||||
|
@ -299,7 +300,7 @@ void handle_udp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
}
|
||||
|
||||
auto& udp_packet = *static_cast<const UDPPacket*>(ipv4_packet.payload());
|
||||
#ifdef UDP_DEBUG
|
||||
#if UDP_DEBUG
|
||||
klog() << "handle_udp: source=" << ipv4_packet.source().to_string().characters() << ":" << udp_packet.source_port() << ", destination=" << ipv4_packet.destination().to_string().characters() << ":" << udp_packet.destination_port() << " length=" << udp_packet.length();
|
||||
#endif
|
||||
|
||||
|
@ -336,7 +337,7 @@ 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
|
||||
#if TCP_DEBUG
|
||||
dbgln("handle_tcp: source={}:{}, destination={}:{}, seq_no={}, ack_no={}, flags={:#04x} ({}{}{}{}), window_size={}, payload_size={}",
|
||||
ipv4_packet.source().to_string(),
|
||||
tcp_packet.source_port(),
|
||||
|
@ -361,7 +362,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
|
||||
IPv4SocketTuple tuple(ipv4_packet.destination(), tcp_packet.destination_port(), ipv4_packet.source(), tcp_packet.source_port());
|
||||
|
||||
#ifdef TCP_DEBUG
|
||||
#if TCP_DEBUG
|
||||
klog() << "handle_tcp: looking for socket; tuple=" << tuple.to_string().characters();
|
||||
#endif
|
||||
|
||||
|
@ -389,7 +390,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
ASSERT(socket->type() == SOCK_STREAM);
|
||||
ASSERT(socket->local_port() == tcp_packet.destination_port());
|
||||
|
||||
#ifdef TCP_DEBUG
|
||||
#if TCP_DEBUG
|
||||
klog() << "handle_tcp: got socket; state=" << socket->tuple().to_string().characters() << " " << TCPSocket::to_string(socket->state());
|
||||
#endif
|
||||
|
||||
|
@ -409,7 +410,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
case TCPSocket::State::Listen:
|
||||
switch (tcp_packet.flags()) {
|
||||
case TCPFlags::SYN: {
|
||||
#ifdef TCP_DEBUG
|
||||
#if TCP_DEBUG
|
||||
klog() << "handle_tcp: incoming connection";
|
||||
#endif
|
||||
auto& local_address = ipv4_packet.destination();
|
||||
|
@ -420,7 +421,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
return;
|
||||
}
|
||||
LOCKER(client->lock());
|
||||
#ifdef TCP_DEBUG
|
||||
#if TCP_DEBUG
|
||||
klog() << "handle_tcp: created new client socket with tuple " << client->tuple().to_string().characters();
|
||||
#endif
|
||||
client->set_sequence_number(1000);
|
||||
|
@ -584,7 +585,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet, const timeval& packet_timestamp)
|
|||
|
||||
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
|
||||
|
||||
#ifdef TCP_DEBUG
|
||||
#if TCP_DEBUG
|
||||
klog() << "Got packet with ack_no=" << tcp_packet.ack_number() << ", seq_no=" << tcp_packet.sequence_number() << ", payload_size=" << payload_size << ", acking it with new ack_no=" << socket->ack_number() << ", seq_no=" << socket->sequence_number();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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/RTL8139NetworkAdapter.h>
|
||||
|
@ -185,7 +186,7 @@ void RTL8139NetworkAdapter::handle_irq(const RegisterState&)
|
|||
|
||||
m_entropy_source.add_random_event(status);
|
||||
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter::handle_irq status=0x" << String::format("%x", status);
|
||||
#endif
|
||||
|
||||
|
@ -193,7 +194,7 @@ void RTL8139NetworkAdapter::handle_irq(const RegisterState&)
|
|||
break;
|
||||
|
||||
if (status & INT_RXOK) {
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter: rx ready";
|
||||
#endif
|
||||
receive();
|
||||
|
@ -203,7 +204,7 @@ void RTL8139NetworkAdapter::handle_irq(const RegisterState&)
|
|||
reset();
|
||||
}
|
||||
if (status & INT_TXOK) {
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter: tx complete";
|
||||
#endif
|
||||
}
|
||||
|
@ -291,7 +292,7 @@ void RTL8139NetworkAdapter::read_mac_address()
|
|||
|
||||
void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
|
||||
{
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter::send_raw length=" << payload.size();
|
||||
#endif
|
||||
|
||||
|
@ -315,7 +316,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
klog() << "RTL8139NetworkAdapter: hardware buffers full; discarding packet";
|
||||
return;
|
||||
} else {
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter: chose buffer " << hw_buffer << " @ " << PhysicalAddress(m_tx_buffers[hw_buffer]);
|
||||
#endif
|
||||
m_tx_next_buffer = (hw_buffer + 1) % 4;
|
||||
|
@ -330,7 +331,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
// 60 bytes if necessary to make sure the whole thing is large enough.
|
||||
auto length = payload.size();
|
||||
if (length < 60) {
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter: adjusting payload size from " << length << " to 60";
|
||||
#endif
|
||||
length = 60;
|
||||
|
@ -346,7 +347,7 @@ void RTL8139NetworkAdapter::receive()
|
|||
u16 status = *(const u16*)(start_of_packet + 0);
|
||||
u16 length = *(const u16*)(start_of_packet + 2);
|
||||
|
||||
#ifdef RTL8139_DEBUG
|
||||
#if RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter::receive status=0x" << String::format("%x", status) << " length=" << length << " offset=" << m_rx_buffer_offset;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Net/LoopbackAdapter.h>
|
||||
|
@ -179,7 +180,7 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
|
|||
return { local_adapter, local_adapter->mac_address() };
|
||||
|
||||
if (!local_adapter && !gateway_adapter) {
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Couldn't find a suitable adapter for route to " << target.to_string().characters();
|
||||
#endif
|
||||
return { nullptr, {} };
|
||||
|
@ -189,13 +190,13 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
|
|||
IPv4Address next_hop_ip;
|
||||
|
||||
if (local_adapter) {
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Got adapter for route (direct): " << local_adapter->name().characters() << " (" << local_adapter->ipv4_address().to_string().characters() << "/" << local_adapter->ipv4_netmask().to_string().characters() << ") for " << target.to_string().characters();
|
||||
#endif
|
||||
adapter = local_adapter;
|
||||
next_hop_ip = target;
|
||||
} else if (gateway_adapter) {
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Got adapter for route (using gateway " << gateway_adapter->ipv4_gateway().to_string().characters() << "): " << gateway_adapter->name().characters() << " (" << gateway_adapter->ipv4_address().to_string().characters() << "/" << gateway_adapter->ipv4_netmask().to_string().characters() << ") for " << target.to_string().characters();
|
||||
#endif
|
||||
adapter = gateway_adapter;
|
||||
|
@ -208,14 +209,14 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
|
|||
LOCKER(arp_table().lock());
|
||||
auto addr = arp_table().resource().get(next_hop_ip);
|
||||
if (addr.has_value()) {
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Using cached ARP entry for " << next_hop_ip.to_string().characters() << " (" << addr.value().to_string().characters() << ")";
|
||||
#endif
|
||||
return { adapter, addr.value() };
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Sending ARP request via adapter " << adapter->name().characters() << " for IPv4 address " << next_hop_ip.to_string().characters();
|
||||
#endif
|
||||
|
||||
|
@ -230,14 +231,14 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
|
|||
Optional<MACAddress> addr;
|
||||
if (!Thread::current()->block<ARPTableBlocker>({}, next_hop_ip, addr).was_interrupted()) {
|
||||
if (addr.has_value()) {
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Got ARP response using adapter " << adapter->name().characters() << " for " << next_hop_ip.to_string().characters() << " (" << addr.value().to_string().characters() << ")";
|
||||
#endif
|
||||
return { adapter, addr.value() };
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ROUTING_DEBUG
|
||||
#if ROUTING_DEBUG
|
||||
klog() << "Routing: Couldn't find route using adapter " << adapter->name().characters() << " for " << target.to_string().characters();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue