mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +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
27bc48e06c
commit
9229ba0fe9
Notes:
sideshowbarker
2024-07-18 22:58:49 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/9229ba0fe9b Pull-request: https://github.com/SerenityOS/serenity/pull/5012 Reviewed-by: https://github.com/alimpfard
14 changed files with 130 additions and 80 deletions
54
AK/Debug.h
54
AK/Debug.h
|
@ -297,3 +297,57 @@ constexpr bool debug_gzip = true;
|
|||
#else
|
||||
constexpr bool debug_gzip = false;
|
||||
#endif
|
||||
|
||||
#ifdef CNETWORKJOB_DEBUG
|
||||
constexpr bool debug_cnetworkjob = true;
|
||||
#else
|
||||
constexpr bool debug_cnetworkjob = false;
|
||||
#endif
|
||||
|
||||
#ifdef CSOCKET_DEBUG
|
||||
constexpr bool debug_csocket = true;
|
||||
#else
|
||||
constexpr bool debug_csocket = false;
|
||||
#endif
|
||||
|
||||
#ifdef SAFE_SYSCALL_DEBUG
|
||||
constexpr bool debug_safe_syscall = true;
|
||||
#else
|
||||
constexpr bool debug_safe_syscall = false;
|
||||
#endif
|
||||
|
||||
#ifdef GHASH_PROCESS_DEBUG
|
||||
constexpr bool debug_ghash_process = true;
|
||||
#else
|
||||
constexpr bool debug_ghash_process = false;
|
||||
#endif
|
||||
|
||||
#ifdef NT_DEBUG
|
||||
constexpr bool debug_nt = true;
|
||||
#else
|
||||
constexpr bool debug_nt = false;
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_DEBUG
|
||||
constexpr bool debug_crypto = true;
|
||||
#else
|
||||
constexpr bool debug_crypto = false;
|
||||
#endif
|
||||
|
||||
#ifdef DWARF_DEBUG
|
||||
constexpr bool debug_dwarf = true;
|
||||
#else
|
||||
constexpr bool debug_dwarf = false;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_HUNKS
|
||||
constexpr bool debug_hunks = true;
|
||||
#else
|
||||
constexpr bool debug_hunks = false;
|
||||
#endif
|
||||
|
||||
#ifdef JOB_DEBUG
|
||||
constexpr bool debug_job = true;
|
||||
#else
|
||||
constexpr bool debug_job = false;
|
||||
#endif
|
||||
|
|
|
@ -148,6 +148,14 @@ inline const LogStream& operator<<(const LogStream& stream, const IPv4Address& v
|
|||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
template<>
|
||||
struct Formatter<IPv4Address> : Formatter<String> {
|
||||
void format(FormatBuilder& builder, IPv4Address value)
|
||||
{
|
||||
return Formatter<String>::format(builder, value.to_string());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::IPv4Address;
|
||||
|
|
|
@ -24,12 +24,11 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCore/NetworkJob.h>
|
||||
#include <LibCore/NetworkResponse.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//#define CNETWORKJOB_DEBUG
|
||||
|
||||
namespace Core {
|
||||
|
||||
NetworkJob::NetworkJob(OutputStream& output_stream)
|
||||
|
@ -56,9 +55,7 @@ void NetworkJob::did_finish(NonnullRefPtr<NetworkResponse>&& response)
|
|||
NonnullRefPtr<NetworkJob> protector(*this);
|
||||
|
||||
m_response = move(response);
|
||||
#ifdef CNETWORKJOB_DEBUG
|
||||
dbg() << *this << " job did_finish!";
|
||||
#endif
|
||||
dbgln<debug_cnetworkjob>("{} job did_finish", *this);
|
||||
ASSERT(on_finish);
|
||||
on_finish(true);
|
||||
shutdown();
|
||||
|
|
|
@ -81,3 +81,7 @@ private:
|
|||
const char* to_string(NetworkJob::Error);
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::NetworkJob> : Formatter<Core::Object> {
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
@ -37,8 +38,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//#define CSOCKET_DEBUG
|
||||
|
||||
namespace Core {
|
||||
|
||||
Socket::Socket(Type type, Object* parent)
|
||||
|
@ -80,9 +79,7 @@ bool Socket::connect(const String& hostname, int port)
|
|||
}
|
||||
|
||||
IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << "Socket::connect: Resolved '" << hostname << "' to " << host_address;
|
||||
#endif
|
||||
dbgln<debug_csocket>("Socket::connect: Resolved '{}' to {}", hostname, host_address);
|
||||
return connect(host_address, port);
|
||||
}
|
||||
|
||||
|
@ -101,9 +98,7 @@ bool Socket::connect(const SocketAddress& address, int port)
|
|||
{
|
||||
ASSERT(!is_connected());
|
||||
ASSERT(address.type() == SocketAddress::Type::IPv4);
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << *this << " connecting to " << address << "...";
|
||||
#endif
|
||||
dbgln<debug_csocket>("{} connecting to {}...", *this, address);
|
||||
|
||||
ASSERT(port > 0 && port <= 65535);
|
||||
|
||||
|
@ -124,9 +119,7 @@ bool Socket::connect(const SocketAddress& address)
|
|||
{
|
||||
ASSERT(!is_connected());
|
||||
ASSERT(address.type() == SocketAddress::Type::Local);
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << *this << " connecting to " << address << "...";
|
||||
#endif
|
||||
dbgln<debug_csocket>("{} connecting to {}...", *this, address);
|
||||
|
||||
sockaddr_un saddr;
|
||||
saddr.sun_family = AF_LOCAL;
|
||||
|
@ -145,9 +138,7 @@ bool Socket::connect(const SocketAddress& address)
|
|||
bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
|
||||
{
|
||||
auto connected = [this] {
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << *this << " connected!";
|
||||
#endif
|
||||
dbgln<debug_csocket>("{} connected!", *this);
|
||||
if (!m_connected) {
|
||||
m_connected = true;
|
||||
ensure_read_notifier();
|
||||
|
@ -162,9 +153,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
|
|||
int rc = ::connect(fd(), addr, addrlen);
|
||||
if (rc < 0) {
|
||||
if (errno == EINPROGRESS) {
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << *this << " connection in progress (EINPROGRESS)";
|
||||
#endif
|
||||
dbgln<debug_csocket>("{} connection in progress (EINPROGRESS)", *this);
|
||||
m_notifier = Notifier::construct(fd(), Notifier::Event::Write, this);
|
||||
m_notifier->on_ready_to_write = move(connected);
|
||||
return true;
|
||||
|
@ -174,9 +163,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
|
|||
errno = saved_errno;
|
||||
return false;
|
||||
}
|
||||
#ifdef CSOCKET_DEBUG
|
||||
dbg() << *this << " connected ok!";
|
||||
#endif
|
||||
dbgln<debug_csocket>("{} connected ok!", *this);
|
||||
connected();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -87,3 +87,7 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::Socket> : Formatter<Core::Object> {
|
||||
};
|
||||
|
|
|
@ -113,3 +113,11 @@ private:
|
|||
const LogStream& operator<<(const LogStream&, const SocketAddress&);
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<String> {
|
||||
void format(FormatBuilder& builder, const Core::SocketAddress& value)
|
||||
{
|
||||
return Formatter<String>::format(builder, value.to_string());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <errno.h>
|
||||
|
@ -41,10 +42,11 @@ inline int safe_syscall(Syscall syscall, Args&&... args)
|
|||
for (;;) {
|
||||
int sysret = syscall(forward<Args>(args)...);
|
||||
if (sysret == -1) {
|
||||
#ifdef SAFE_SYSCALL_DEBUG
|
||||
int saved_errno = errno;
|
||||
dbg() << "Core::safe_syscall: " << sysret << " (" << saved_errno << ": " << strerror(saved_errno) << ")";
|
||||
#endif
|
||||
if constexpr (debug_safe_syscall) {
|
||||
int saved_errno = errno;
|
||||
dbgln<debug_safe_syscall>("Core::safe_syscall: {} ({}: {})", sysret, saved_errno, strerror(saved_errno));
|
||||
}
|
||||
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -88,21 +89,18 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher)
|
|||
auto high = [](u64 value) -> u32 { return value >> 32; };
|
||||
auto low = [](u64 value) -> u32 { return value & 0xffffffff; };
|
||||
|
||||
#ifdef GHASH_PROCESS_DEBUG
|
||||
dbg() << "AAD bits: " << high(aad_bits) << " : " << low(aad_bits);
|
||||
dbg() << "Cipher bits: " << high(cipher_bits) << " : " << low(cipher_bits);
|
||||
|
||||
dbg() << "Tag bits: " << tag[0] << " : " << tag[1] << " : " << tag[2] << " : " << tag[3];
|
||||
#endif
|
||||
if constexpr (debug_ghash_process) {
|
||||
dbgln("AAD bits: {} : {}", high(aad_bits), low(aad_bits));
|
||||
dbgln("Cipher bits: {} : {}", high(cipher_bits), low(cipher_bits));
|
||||
dbgln("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]);
|
||||
}
|
||||
|
||||
tag[0] ^= high(aad_bits);
|
||||
tag[1] ^= low(aad_bits);
|
||||
tag[2] ^= high(cipher_bits);
|
||||
tag[3] ^= low(cipher_bits);
|
||||
|
||||
#ifdef GHASH_PROCESS_DEBUG
|
||||
dbg() << "Tag bits: " << tag[0] << " : " << tag[1] << " : " << tag[2] << " : " << tag[3];
|
||||
#endif
|
||||
dbgln<debug_ghash_process>("Tag bits: {} : {} : {} : {}", tag[0], tag[1], tag[2], tag[3]);
|
||||
|
||||
galois_multiply(tag, m_key, tag);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCrypto/NumberTheory/ModularFunctions.h>
|
||||
|
||||
namespace Crypto {
|
||||
|
@ -230,9 +231,7 @@ UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b)
|
|||
UnsignedBigInteger::divide_without_allocation(a, gcd_output, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder);
|
||||
UnsignedBigInteger::multiply_without_allocation(temp_quotient, b, temp_1, temp_2, temp_3, temp_4, output);
|
||||
|
||||
#ifdef NT_DEBUG
|
||||
dbg() << "quot: " << temp_quotient << " rem: " << temp_remainder << " out: " << output;
|
||||
#endif
|
||||
dbgln<debug_nt>("quot: {} rem: {} out: {}", temp_quotient, temp_remainder, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Random.h>
|
||||
#include <LibCrypto/ASN1/ASN1.h>
|
||||
#include <LibCrypto/ASN1/DER.h>
|
||||
|
@ -115,9 +116,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
|
|||
|
||||
void RSA::encrypt(ReadonlyBytes in, Bytes& out)
|
||||
{
|
||||
#ifdef CRYPTO_DEBUG
|
||||
dbg() << "in size: " << in.size();
|
||||
#endif
|
||||
dbgln<debug_crypto>("in size: {}", in.size());
|
||||
auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size());
|
||||
if (!(in_integer < m_public_key.modulus())) {
|
||||
dbgln("value too large for key");
|
||||
|
@ -231,9 +230,7 @@ VerificationConsistency RSA_EMSA_PSS<HashFunction>::verify(ReadonlyBytes in)
|
|||
void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
|
||||
{
|
||||
auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8;
|
||||
#ifdef CRYPTO_DEBUG
|
||||
dbg() << "key size: " << mod_len;
|
||||
#endif
|
||||
dbgln<debug_crypto>("key size: {}", mod_len);
|
||||
if (in.size() > mod_len - 11) {
|
||||
dbgln("message too long :(");
|
||||
out = out.trim(0);
|
||||
|
@ -265,9 +262,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
|
|||
out.overwrite(3 + ps_length, in.data(), in.size());
|
||||
out = out.trim(3 + ps_length + in.size()); // should be a single block
|
||||
|
||||
#ifdef CRYPTO_DEBUG
|
||||
dbg() << "padded output size: " << 3 + ps_length + in.size() << " buffer size: " << out.size();
|
||||
#endif
|
||||
dbgln<debug_crypto>("padded output size: {} buffer size: {}", 3 + ps_length + in.size(), out.size());
|
||||
|
||||
RSA::encrypt(out, out);
|
||||
}
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
*/
|
||||
|
||||
#include "LineProgram.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
//#define DWARF_DEBUG
|
||||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
LineProgram::LineProgram(InputMemoryStream& stream)
|
||||
|
@ -236,10 +235,10 @@ void LineProgram::handle_sepcial_opcode(u8 opcode)
|
|||
m_address += address_increment;
|
||||
m_line += line_increment;
|
||||
|
||||
#ifdef DWARF_DEBUG
|
||||
dbgln("Special adjusted_opcode: {}, address_increment: {}, line_increment: {}", adjusted_opcode, address_increment, line_increment);
|
||||
dbg() << "Address is now:" << (void*)m_address << ", and line is: " << m_source_files[m_file_index].name << ":" << m_line;
|
||||
#endif
|
||||
if constexpr (debug_dwarf) {
|
||||
dbgln("Special adjusted_opcode: {}, address_increment: {}, line_increment: {}", adjusted_opcode, address_increment, line_increment);
|
||||
dbgln("Address is now: {:p}, and line is: {}:{}", m_address, m_source_files[m_file_index].name, m_line);
|
||||
}
|
||||
|
||||
append_to_line_info();
|
||||
}
|
||||
|
@ -252,9 +251,7 @@ void LineProgram::run_program()
|
|||
u8 opcode = 0;
|
||||
m_stream >> opcode;
|
||||
|
||||
#ifdef DWARF_DEBUG
|
||||
dbg() << (void*)(m_stream.offset() - 1) << ": opcode: " << opcode;
|
||||
#endif
|
||||
dbgln<debug_dwarf>("{:p}: opcode: {}", m_stream.offset() - 1, opcode);
|
||||
|
||||
if (opcode == 0) {
|
||||
handle_extended_opcode();
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "Hunks.h"
|
||||
|
||||
// #define DEBUG_HUNKS
|
||||
#include <AK/Debug.h>
|
||||
|
||||
namespace Diff {
|
||||
Vector<Hunk> parse_hunks(const String& diff)
|
||||
|
@ -78,21 +77,19 @@ Vector<Hunk> parse_hunks(const String& diff)
|
|||
hunks.append(hunk);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_HUNKS
|
||||
for (const auto& hunk : hunks) {
|
||||
dbgln("Hunk location:");
|
||||
dbg() << "orig: " << hunk.original_start_line;
|
||||
dbg() << "target: " << hunk.target_start_line;
|
||||
dbgln("removed:");
|
||||
for (const auto& line : hunk.removed_lines) {
|
||||
dbg() << "- " << line;
|
||||
}
|
||||
dbgln("added:");
|
||||
for (const auto& line : hunk.added_lines) {
|
||||
dbg() << "+ " << line;
|
||||
if constexpr (debug_hunks) {
|
||||
for (const auto& hunk : hunks) {
|
||||
dbgln("Hunk location:");
|
||||
dbgln(" orig: {}", hunk.original_start_line);
|
||||
dbgln(" target: {}", hunk.target_start_line);
|
||||
dbgln(" removed:");
|
||||
for (const auto& line : hunk.removed_lines)
|
||||
dbgln("- {}", line);
|
||||
dbgln(" added:");
|
||||
for (const auto& line : hunk.added_lines)
|
||||
dbgln("+ {}", line);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return hunks;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,12 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibGemini/GeminiResponse.h>
|
||||
#include <LibGemini/Job.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//#define JOB_DEBUG
|
||||
|
||||
namespace Gemini {
|
||||
|
||||
Job::Job(const GeminiRequest& request, OutputStream& output_stream)
|
||||
|
@ -67,10 +66,11 @@ void Job::on_socket_connected()
|
|||
return;
|
||||
m_sent_data = true;
|
||||
auto raw_request = m_request.to_raw_request();
|
||||
#ifdef JOB_DEBUG
|
||||
dbgln("Job: raw_request:");
|
||||
dbg() << String::copy(raw_request).characters();
|
||||
#endif
|
||||
|
||||
if constexpr (debug_job) {
|
||||
dbgln("Job: raw_request:");
|
||||
dbgln("{}", String::copy(raw_request));
|
||||
}
|
||||
bool success = write(raw_request);
|
||||
if (!success)
|
||||
deferred_invoke([this](auto&) { did_fail(Core::NetworkJob::Error::TransmissionFailed); });
|
||||
|
|
Loading…
Reference in a new issue