瀏覽代碼

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 4 年之前
父節點
當前提交
4e8fd0216b
共有 7 個文件被更改,包括 51 次插入13 次删除
  1. 2 2
      Kernel/ACPI/MultiProcessorParser.cpp
  2. 6 6
      Kernel/ACPI/Parser.cpp
  3. 8 0
      Kernel/IO.h
  4. 10 0
      Kernel/PCI/Definitions.h
  5. 8 0
      Kernel/PhysicalAddress.h
  6. 10 3
      Kernel/Thread.cpp
  7. 7 2
      Kernel/Thread.h

+ 2 - 2
Kernel/ACPI/MultiProcessorParser.cpp

@@ -57,7 +57,7 @@ void MultiProcessorParser::parse_floating_pointer_data()
 {
     auto floating_pointer = map_typed<MultiProcessor::FloatingPointer>(m_floating_pointer);
     m_configuration_table = PhysicalAddress(floating_pointer->physical_address_ptr);
-    dbg() << "Features " << floating_pointer->feature_info[0] << ", IMCR? " << (floating_pointer->feature_info[0] & (1 << 7));
+    dbgln("Features {}, IMCR? {}", floating_pointer->feature_info[0], (floating_pointer->feature_info[0] & (1 << 7)));
 }
 
 void MultiProcessorParser::parse_configuration_table()
@@ -126,7 +126,7 @@ Vector<u8> MultiProcessorParser::get_pci_bus_ids() const
 
 Vector<PCIInterruptOverrideMetadata> MultiProcessorParser::get_pci_interrupt_redirections()
 {
-    dbg() << "MultiProcessor: Get PCI IOAPIC redirections";
+    dbgln("MultiProcessor: Get PCI IOAPIC redirections");
     Vector<PCIInterruptOverrideMetadata> overrides;
     auto pci_bus_ids = get_pci_bus_ids();
     for (auto& entry : m_io_interrupt_assignment_entries) {

+ 6 - 6
Kernel/ACPI/Parser.cpp

@@ -150,15 +150,15 @@ void Parser::access_generic_address(const Structures::GenericAddressStructure& s
     switch ((GenericAddressStructure::AddressSpace)structure.address_space) {
     case GenericAddressStructure::AddressSpace::SystemIO: {
         IOAddress address(structure.address);
-        dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << address;
+        dbgln("ACPI: Sending value {:x} to {:p}", value, address);
         switch (structure.access_size) {
         case (u8)GenericAddressStructure::AccessSize::QWord: {
-            dbg() << "Trying to send QWord to IO port";
+            dbgln("Trying to send QWord to IO port");
             ASSERT_NOT_REACHED();
             break;
         }
         case (u8)GenericAddressStructure::AccessSize::Undefined: {
-            dbg() << "ACPI Warning: Unknown access size " << structure.access_size;
+            dbgln("ACPI Warning: Unknown access size {}", structure.access_size);
             ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::QWord);
             ASSERT(structure.bit_width != (u8)GenericAddressStructure::BitWidth::Undefined);
             dbg() << "ACPI: Bit Width - " << structure.bit_width << " bits";
@@ -172,7 +172,7 @@ void Parser::access_generic_address(const Structures::GenericAddressStructure& s
         return;
     }
     case GenericAddressStructure::AddressSpace::SystemMemory: {
-        dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << PhysicalAddress(structure.address);
+        dbgln("ACPI: Sending value {:x} to {}", value, PhysicalAddress(structure.address));
         switch ((GenericAddressStructure::AccessSize)structure.access_size) {
         case GenericAddressStructure::AccessSize::Byte:
             *map_typed<u8>(PhysicalAddress(structure.address)) = value;
@@ -195,10 +195,10 @@ void Parser::access_generic_address(const Structures::GenericAddressStructure& s
     case GenericAddressStructure::AddressSpace::PCIConfigurationSpace: {
         // According to the ACPI specification 6.2, page 168, PCI addresses must be confined to devices on Segment group 0, bus 0.
         auto pci_address = PCI::Address(0, 0, ((structure.address >> 24) & 0xFF), ((structure.address >> 16) & 0xFF));
-        dbg() << "ACPI: Sending value 0x" << String::format("%x", value) << " to " << pci_address;
+        dbgln("ACPI: Sending value {:x} to {}", value, pci_address);
         u32 offset_in_pci_address = structure.address & 0xFFFF;
         if (structure.access_size == (u8)GenericAddressStructure::AccessSize::QWord) {
-            dbg() << "Trying to send QWord to PCI configuration space";
+            dbgln("Trying to send QWord to PCI configuration space");
             ASSERT_NOT_REACHED();
         }
         ASSERT(structure.access_size != (u8)GenericAddressStructure::AccessSize::Undefined);

+ 8 - 0
Kernel/IO.h

@@ -176,3 +176,11 @@ inline const LogStream& operator<<(const LogStream& stream, IOAddress value)
 {
     return stream << "IO " << String::format("%x", value.get());
 }
+
+template<>
+struct AK::Formatter<IOAddress> : AK::Formatter<FormatString> {
+    void format(FormatBuilder& builder, IOAddress value)
+    {
+        return Formatter<FormatString>::format(builder, "IO {:x}", value.get());
+    }
+};

+ 10 - 0
Kernel/PCI/Definitions.h

@@ -247,3 +247,13 @@ class Device;
 }
 
 }
+
+template<>
+struct AK::Formatter<Kernel::PCI::Address> : Formatter<FormatString> {
+    void format(FormatBuilder& builder, Kernel::PCI::Address value)
+    {
+        return Formatter<FormatString>::format(
+            builder,
+            "PCI [{:04x}:{:02x}:{:02x}:{:02x}]", value.seg(), value.bus(), value.slot(), value.function());
+    }
+};

+ 8 - 0
Kernel/PhysicalAddress.h

@@ -65,3 +65,11 @@ inline const LogStream& operator<<(const LogStream& stream, PhysicalAddress valu
 {
     return stream << 'P' << value.as_ptr();
 }
+
+template<>
+struct AK::Formatter<PhysicalAddress> : AK::Formatter<FormatString> {
+    void format(FormatBuilder& builder, PhysicalAddress value)
+    {
+        return AK::Formatter<FormatString>::format(builder, "P{}", value.as_ptr());
+    }
+};

+ 10 - 3
Kernel/Thread.cpp

@@ -238,7 +238,7 @@ void Thread::die_if_needed()
     // actual context switch
     u32 prev_flags;
     Processor::current().clear_critical(prev_flags, false);
-    dbg() << "die_if_needed returned from clear_critical!!! in irq: " << Processor::current().in_irq();
+    dbgln("die_if_needed returned from clear_critical!!! in irq: {}", Processor::current().in_irq());
     // We should never get here, but the scoped scheduler lock
     // will be released by Scheduler::context_switch again
     ASSERT_NOT_REACHED();
@@ -377,7 +377,7 @@ void Thread::finalize()
     }
 
     if (m_dump_backtrace_on_finalization)
-        dbg() << backtrace_impl();
+        dbgln("{}", backtrace_impl());
 
     kfree_aligned(m_fpu_state);
     drop_thread_count(false);
@@ -897,7 +897,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
         if (previous_state == Invalid) {
             // If we were *just* created, we may have already pending signals
             if (has_unmasked_pending_signals()) {
-                dbg() << "Dispatch pending signals to new thread " << *this;
+                dbgln("Dispatch pending signals to new thread {}", *this);
                 dispatch_one_pending_signal();
             }
         }
@@ -1115,3 +1115,10 @@ bool Thread::should_be_stopped() const
 }
 
 }
+
+void AK::Formatter<Kernel::Thread>::format(FormatBuilder& builder, const Kernel::Thread& value)
+{
+    return AK::Formatter<FormatString>::format(
+        builder,
+        "{}({}:{})", value.process().name(), value.pid().value(), value.tid().value());
+}

+ 7 - 2
Kernel/Thread.h

@@ -822,13 +822,13 @@ public:
             scheduler_lock.lock();
             ScopedSpinLock block_lock2(m_block_lock);
             if (should_be_stopped() || state() == Stopped) {
-                dbg() << "Thread should be stopped, current state: " << state_string();
+                dbgln("Thread should be stopped, current state: {}", state_string());
                 set_state(Thread::Blocked);
                 continue;
             }
             if (m_blocker && !m_blocker->can_be_interrupted() && !m_should_die) {
                 block_lock2.unlock();
-                dbg() << "Thread should not be unblocking, current state: " << state_string();
+                dbgln("Thread should not be unblocking, current state: ", state_string());
                 set_state(Thread::Blocked);
                 continue;
             }
@@ -1311,3 +1311,8 @@ inline IterationDecision Scheduler::for_each_nonrunnable(Callback callback)
 }
 
 }
+
+template<>
+struct AK::Formatter<Kernel::Thread> : AK::Formatter<FormatString> {
+    void format(FormatBuilder&, const Kernel::Thread&);
+};