Quellcode durchsuchen

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.
asynts vor 4 Jahren
Ursprung
Commit
843ebbd2c3

+ 12 - 0
Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp

@@ -731,3 +731,15 @@ ALWAYS_INLINE u32 UnsignedBigInteger::shift_left_get_one_word(
     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());
+}

+ 5 - 0
Libraries/LibCrypto/BigInt/UnsignedBigInteger.h

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

+ 8 - 8
Libraries/LibCrypto/PK/RSA.cpp

@@ -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[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)) {
         // 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, &e)) {
             // something was fucked up
-            dbg() << "bad pubkey: " << e << " in " << n;
+            dbgln("bad pubkey: e={} n={}", e, n);
             return keypair;
         }
         // correct public key
@@ -97,7 +97,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
                 ASN1::Kind::Integer, 1, &n,
                 ASN1::Kind::Integer, 1, &e,
                 ASN1::Kind::Integer, 1, &d)) {
-            dbg() << "bad privkey " << n << " " << e << " " << d;
+            dbgln("bad privkey n={} e={} d={}", n, e, d);
             return keypair;
         }
         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 outsize = out.size();
     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);
     }
 }
@@ -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;
     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);
         return;
     }
@@ -283,18 +283,18 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out)
     RSA::decrypt(in, out);
 
     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);
         return;
     }
 
     if (out[0] != 0x00) {
-        dbg() << "invalid padding byte 0 : " << out[0];
+        dbgln("invalid padding byte 0 : {}", out[0]);
         return;
     }
 
     if (out[1] != 0x02) {
-        dbg() << "invalid padding byte 1" << out[1];
+        dbgln("invalid padding byte 1 : {}", out[1]);
         return;
     }
 

+ 1 - 1
Libraries/LibCrypto/PK/RSA.h

@@ -137,7 +137,7 @@ public:
         auto n = p.multiplied_by(q);
 
         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 {
             { n, e },
             { n, d, e }

+ 0 - 1
Libraries/LibELF/DynamicLoader.cpp

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

+ 1 - 1
Libraries/LibGUI/ColumnsView.cpp

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

+ 1 - 1
Libraries/LibGUI/Desktop.cpp

@@ -71,7 +71,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config)
 
     if (ret_val && save_config) {
         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->sync();
     }

+ 2 - 2
Libraries/LibGUI/Dialog.cpp

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

+ 4 - 0
Libraries/LibGUI/Dialog.h

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

+ 1 - 1
Libraries/LibGUI/FileSystemModel.cpp

@@ -145,7 +145,7 @@ void FileSystemModel::Node::traverse_if_needed()
         return;
     }
     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->on_ready_to_read = [this] {
         char buffer[32];

+ 1 - 1
Libraries/LibGemini/Line.cpp

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

+ 7 - 2
Libraries/LibGfx/Bitmap.cpp

@@ -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);
     if (expected_size_min > actual_size || actual_size > expected_size_max) {
         // 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 << ".";
-        dbg() << "However, we were given " << actual_size << " bytes, which is outside this range?! Refusing cowardly.";
+        dbgln("Constructing a shared bitmap for format {} and size {}, which demands {} bytes, which rounds up to at most {}.",
+            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 true;

+ 1 - 1
Libraries/LibGfx/BitmapFont.cpp

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

+ 1 - 1
Libraries/LibGfx/ShareableBitmap.cpp

@@ -62,7 +62,7 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
     if (shbuf_id == -1)
         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);
     if (!shared_buffer)

+ 1 - 1
Libraries/LibGfx/SystemTheme.cpp

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