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-11 13:32:26 +01:00 committed by Andreas Kling
parent 6fa42af567
commit 843ebbd2c3
Notes: sideshowbarker 2024-07-18 23:55:25 +09:00
15 changed files with 46 additions and 21 deletions

View file

@ -731,3 +731,15 @@ ALWAYS_INLINE u32 UnsignedBigInteger::shift_left_get_one_word(
return result; return result;
} }
} }
void AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::UnsignedBigInteger& value)
{
if (value.is_invalid())
return Formatter<StringView>::format(fmtbuilder, "invalid");
StringBuilder builder;
for (int i = value.length() - 1; i >= 0; --i)
builder.appendff("{}|", value.words()[i]);
return Formatter<StringView>::format(fmtbuilder, builder.string_view());
}

View file

@ -144,6 +144,11 @@ operator<<(const LogStream& stream, const Crypto::UnsignedBigInteger& value)
return stream; return stream;
} }
template<>
struct AK::Formatter<Crypto::UnsignedBigInteger> : Formatter<StringView> {
void format(FormatBuilder&, const Crypto::UnsignedBigInteger&);
};
inline Crypto::UnsignedBigInteger inline Crypto::UnsignedBigInteger
operator""_bigint(const char* string, size_t length) operator""_bigint(const char* string, size_t length)
{ {

View file

@ -51,7 +51,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::set(pubkey[0], ASN1::Kind::Sequence, &pubkey_hash_oid, 2); ASN1::set(pubkey[0], ASN1::Kind::Sequence, &pubkey_hash_oid, 2);
ASN1::set(pubkey[1], ASN1::Kind::Null, nullptr, 0); ASN1::set(pubkey[1], ASN1::Kind::Null, nullptr, 0);
dbg() << "we were offered " << in.size() << " bytes of input"; dbgln("we were offered {} bytes of input", in.size());
if (der_decode_sequence(in.data(), in.size(), pubkey, 2)) { if (der_decode_sequence(in.data(), in.size(), pubkey, 2)) {
// yay, now we have to reassemble the bitstring to a bytestring // yay, now we have to reassemble the bitstring to a bytestring
@ -72,7 +72,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::Kind::Integer, 1, &n, ASN1::Kind::Integer, 1, &n,
ASN1::Kind::Integer, 1, &e)) { ASN1::Kind::Integer, 1, &e)) {
// something was fucked up // something was fucked up
dbg() << "bad pubkey: " << e << " in " << n; dbgln("bad pubkey: e={} n={}", e, n);
return keypair; return keypair;
} }
// correct public key // correct public key
@ -97,7 +97,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::Kind::Integer, 1, &n, ASN1::Kind::Integer, 1, &n,
ASN1::Kind::Integer, 1, &e, ASN1::Kind::Integer, 1, &e,
ASN1::Kind::Integer, 1, &d)) { ASN1::Kind::Integer, 1, &d)) {
dbg() << "bad privkey " << n << " " << e << " " << d; dbgln("bad privkey n={} e={} d={}", n, e, d);
return keypair; return keypair;
} }
keypair.private_key.set(n, d, e); keypair.private_key.set(n, d, e);
@ -128,7 +128,7 @@ void RSA::encrypt(ReadonlyBytes in, Bytes& out)
auto size = exp.export_data(out); auto size = exp.export_data(out);
auto outsize = out.size(); auto outsize = out.size();
if (size != outsize) { if (size != outsize) {
dbg() << "POSSIBLE RSA BUG!!! Size mismatch: " << outsize << " requested but " << size << " bytes generated"; dbgln("POSSIBLE RSA BUG!!! Size mismatch: {} requested but {} bytes generated", outsize, size);
out = out.slice(outsize - size, size); out = out.slice(outsize - size, size);
} }
} }
@ -275,7 +275,7 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out)
{ {
auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8; auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8;
if (in.size() != mod_len) { if (in.size() != mod_len) {
dbg() << "decryption error: wrong amount of data: " << in.size(); dbgln("decryption error: wrong amount of data: {}", in.size());
out = out.trim(0); out = out.trim(0);
return; return;
} }
@ -283,18 +283,18 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out)
RSA::decrypt(in, out); RSA::decrypt(in, out);
if (out.size() < RSA::output_size()) { if (out.size() < RSA::output_size()) {
dbg() << "decryption error: not enough data after decryption: " << out.size(); dbgln("decryption error: not enough data after decryption: {}", out.size());
out = out.trim(0); out = out.trim(0);
return; return;
} }
if (out[0] != 0x00) { if (out[0] != 0x00) {
dbg() << "invalid padding byte 0 : " << out[0]; dbgln("invalid padding byte 0 : {}", out[0]);
return; return;
} }
if (out[1] != 0x02) { if (out[1] != 0x02) {
dbg() << "invalid padding byte 1" << out[1]; dbgln("invalid padding byte 1 : {}", out[1]);
return; return;
} }

View file

@ -137,7 +137,7 @@ public:
auto n = p.multiplied_by(q); auto n = p.multiplied_by(q);
auto d = NumberTheory::ModularInverse(e, lambda); auto d = NumberTheory::ModularInverse(e, lambda);
dbg() << "Your keys are Pub{n=" << n << ", e=" << e << "} and Priv{n=" << n << ", d=" << d << "}"; dbgln("Your keys are Pub(n={}, e={}) and Priv(n={}, d={})", n, e, n, d);
RSAKeyPair<PublicKeyType, PrivateKeyType> keys { RSAKeyPair<PublicKeyType, PrivateKeyType> keys {
{ n, e }, { n, e },
{ n, d, e } { n, d, e }

View file

@ -180,7 +180,6 @@ bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size)
#endif #endif
if (m_dynamic_object->has_text_relocations()) { if (m_dynamic_object->has_text_relocations()) {
// dbg() << "Someone linked non -fPIC code into " << m_filename << " :(";
ASSERT(m_text_segment_load_address.get() != 0); ASSERT(m_text_segment_load_address.get() != 0);
#ifndef AK_OS_MACOS #ifndef AK_OS_MACOS

View file

@ -188,7 +188,7 @@ void ColumnsView::push_column(const ModelIndex& parent_index)
if (m_columns[i].parent_index == grandparent) if (m_columns[i].parent_index == grandparent)
break; break;
m_columns.shrink(i); m_columns.shrink(i);
dbg() << "Dropping column " << i; dbgln("Dropping column {}", i);
} }
// Add the new column. // Add the new column.

View file

@ -71,7 +71,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config)
if (ret_val && save_config) { if (ret_val && save_config) {
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager"); RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager");
dbg() << "Saving wallpaper path '" << path << "' to config file at " << config->file_name(); dbgln("Saving wallpaper path '{}' to config file at {}", path, config->file_name());
config->write_entry("Background", "Wallpaper", path); config->write_entry("Background", "Wallpaper", path);
config->sync(); config->sync();
} }

View file

@ -58,7 +58,7 @@ int Dialog::exec()
show(); show();
auto result = m_event_loop->exec(); auto result = m_event_loop->exec();
m_event_loop = nullptr; m_event_loop = nullptr;
dbg() << *this << ": Event loop returned with result " << result; dbgln("{}: Event loop returned with result {}", *this, result);
remove_from_parent(); remove_from_parent();
return result; return result;
} }
@ -68,7 +68,7 @@ void Dialog::done(int result)
if (!m_event_loop) if (!m_event_loop)
return; return;
m_result = result; m_result = result;
dbg() << *this << ": Quit event loop with result " << result; dbgln("{}: Quit event loop with result {}", *this, result);
m_event_loop->quit(result); m_event_loop->quit(result);
} }

View file

@ -61,3 +61,7 @@ private:
}; };
} }
template<>
struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> {
};

View file

@ -145,7 +145,7 @@ void FileSystemModel::Node::traverse_if_needed()
return; return;
} }
fcntl(m_watch_fd, F_SETFD, FD_CLOEXEC); fcntl(m_watch_fd, F_SETFD, FD_CLOEXEC);
dbg() << "Watching " << full_path << " for changes, m_watch_fd = " << m_watch_fd; dbgln("Watching {} for changes, m_watch_fd={}", full_path, m_watch_fd);
m_notifier = Core::Notifier::construct(m_watch_fd, Core::Notifier::Event::Read); m_notifier = Core::Notifier::construct(m_watch_fd, Core::Notifier::Event::Read);
m_notifier->on_ready_to_read = [this] { m_notifier->on_ready_to_read = [this] {
char buffer[32]; char buffer[32];

View file

@ -80,7 +80,7 @@ String Control::render_to_html() const
case Kind::UnorderedListEnd: case Kind::UnorderedListEnd:
return "</ul>"; return "</ul>";
default: default:
dbg() << "Unknown control kind _" << m_kind << "_"; dbgln("Unknown control kind _{}_", (int)m_kind);
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return ""; return "";
} }

View file

@ -170,8 +170,13 @@ static bool check_size(const IntSize& size, BitmapFormat format, unsigned actual
unsigned expected_size_max = round_up_to_power_of_two(expected_size_min, PAGE_SIZE); unsigned expected_size_max = round_up_to_power_of_two(expected_size_min, PAGE_SIZE);
if (expected_size_min > actual_size || actual_size > expected_size_max) { if (expected_size_min > actual_size || actual_size > expected_size_max) {
// Getting here is most likely an error. // Getting here is most likely an error.
dbg() << "Constructing a shared bitmap for format " << (int)format << " and size " << size << ", which demands " << expected_size_min << " bytes, which rounds up to at most " << expected_size_max << "."; dbgln("Constructing a shared bitmap for format {} and size {}, which demands {} bytes, which rounds up to at most {}.",
dbg() << "However, we were given " << actual_size << " bytes, which is outside this range?! Refusing cowardly."; static_cast<int>(format),
size,
expected_size_min,
expected_size_max);
dbgln("However, we were given {} bytes, which is outside this range?! Refusing cowardly.", actual_size);
return false; return false;
} }
return true; return true;

View file

@ -167,7 +167,7 @@ size_t BitmapFont::glyph_count_by_type(FontTypes type)
if (type == FontTypes::LatinExtendedA) if (type == FontTypes::LatinExtendedA)
return 384; return 384;
dbg() << "Unknown font type:" << type; dbgln("Unknown font type: {}", (int)type);
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }

View file

@ -62,7 +62,7 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
if (shbuf_id == -1) if (shbuf_id == -1)
return true; return true;
dbg() << "Decoding a ShareableBitmap with shbuf_id=" << shbuf_id << ", size=" << size; dbgln("Decoding a ShareableBitmap with shbuf_id={}, size={}", shbuf_id, size);
auto shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id); auto shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id);
if (!shared_buffer) if (!shared_buffer)

View file

@ -79,7 +79,7 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
case (int)MetricRole::TitleButtonWidth: case (int)MetricRole::TitleButtonWidth:
return 15; return 15;
default: default:
dbg() << "Metric " << name << " has no fallback value!"; dbgln("Metric {} has no fallback value!", name);
return 16; return 16;
} }
} }