summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2021-01-13 21:16:18 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-22 22:14:30 +0100
commit5356aae3cc32392870582895a1136bc4871976d6 (patch)
tree14462ea2fdfbea6e13d5168d167266b43360bb27
parent663a6141d8b3f9a25f8774c0cf3751a7da1235c9 (diff)
downloadserenity-5356aae3cc32392870582895a1136bc4871976d6.zip
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.
-rw-r--r--AK/Debug.h24
-rw-r--r--Kernel/ACPI/MultiProcessorParser.cpp5
-rw-r--r--Kernel/ACPI/Parser.cpp38
-rw-r--r--Kernel/ThreadBlockers.cpp21
-rw-r--r--Kernel/WaitQueue.cpp40
5 files changed, 57 insertions, 71 deletions
diff --git a/AK/Debug.h b/AK/Debug.h
index 317344a36b..6c5beff440 100644
--- a/AK/Debug.h
+++ b/AK/Debug.h
@@ -69,3 +69,27 @@ constexpr bool debug_bmp = true;
#else
constexpr bool debug_bmp = false;
#endif
+
+#ifdef WAITBLOCK_DEBUG
+constexpr bool debug_waitblock = true;
+#else
+constexpr bool debug_waitblock = false;
+#endif
+
+#ifdef WAITQUEUE_DEBUG
+constexpr bool debug_waitqueue = true;
+#else
+constexpr bool debug_waitqueue = false;
+#endif
+
+#ifdef MULTIPROCESSOR_DEBUG
+constexpr bool debug_multiprocessor = true;
+#else
+constexpr bool debug_multiprocessor = false;
+#endif
+
+#ifdef ACPI_DEBUG
+constexpr bool debug_acpi = true;
+#else
+constexpr bool debug_acpi = false;
+#endif
diff --git a/Kernel/ACPI/MultiProcessorParser.cpp b/Kernel/ACPI/MultiProcessorParser.cpp
index 5b27d14eeb..295c945ddb 100644
--- a/Kernel/ACPI/MultiProcessorParser.cpp
+++ b/Kernel/ACPI/MultiProcessorParser.cpp
@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Debug.h>
#include <AK/StringView.h>
#include <Kernel/ACPI/MultiProcessorParser.h>
#include <Kernel/Arch/PC/BIOS.h>
@@ -68,9 +69,7 @@ void MultiProcessorParser::parse_configuration_table()
size_t entry_count = config_table->entry_count;
auto* entry = config_table->entries;
while (entry_count > 0) {
-#ifdef MULTIPROCESSOR_DEBUG
- dbg() << "MultiProcessor: Entry Type " << entry->entry_type << " detected.";
-#endif
+ dbgln<debug_multiprocessor>("MultiProcessor: Entry Type {} detected.", entry->entry_type);
switch (entry->entry_type) {
case ((u8)MultiProcessor::ConfigurationTableEntryType::Processor):
entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry);
diff --git a/Kernel/ACPI/Parser.cpp b/Kernel/ACPI/Parser.cpp
index 6a4c9884e4..dcb66ba332 100644
--- a/Kernel/ACPI/Parser.cpp
+++ b/Kernel/ACPI/Parser.cpp
@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Debug.h>
#include <AK/StringView.h>
#include <Kernel/ACPI/Parser.h>
#include <Kernel/Arch/PC/BIOS.h>
@@ -65,18 +66,12 @@ void Parser::locate_static_data()
PhysicalAddress Parser::find_table(const StringView& signature)
{
-#ifdef ACPI_DEBUG
- dbgln("ACPI: Calling Find Table method!");
-#endif
+ dbgln<debug_acpi>("ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) {
auto sdt = map_typed<Structures::SDTHeader>(p_sdt);
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: Examining Table @ P " << p_sdt;
-#endif
+ dbgln<debug_acpi>("ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: Found Table @ P " << p_sdt;
-#endif
+ dbgln<debug_acpi>("ACPI: Found Table @ {}", p_sdt);
return p_sdt;
}
}
@@ -98,9 +93,8 @@ void Parser::init_fadt()
auto sdt = map_typed<Structures::FADT>(m_fadt);
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: FADT @ V " << &sdt << ", P " << (void*)m_fadt.as_ptr();
-#endif
+ dbgln<debug_acpi>("ACPI: FADT @ V{}, {}", &sdt, m_fadt);
+
klog() << "ACPI: Fixed ACPI data, Revision " << sdt->h.revision << ", Length " << sdt->h.length << " bytes";
klog() << "ACPI: DSDT " << PhysicalAddress(sdt->dsdt_ptr);
m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present);
@@ -225,9 +219,7 @@ void Parser::try_acpi_reboot()
klog() << "ACPI: Reboot, Not supported!";
return;
}
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: Rebooting, Probing FADT (" << m_fadt << ")";
-#endif
+ dbgln<debug_acpi>("ACPI: Rebooting, Probing FADT ({})", m_fadt);
auto fadt = map_typed<Structures::FADT>(m_fadt);
ASSERT(validate_reset_register());
@@ -275,26 +267,18 @@ void Parser::initialize_main_system_description_table()
auto& xsdt = (const Structures::XSDT&)*sdt;
klog() << "ACPI: Using XSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length;
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: XSDT pointer @ V " << &xsdt;
-#endif
+ dbgln<debug_acpi>("ACPI: XSDT pointer @ V{}", &xsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: Found new table [" << i << "], @ V " << String::format("%p", &xsdt.table_ptrs[i]) << " - P 0x" << String::format("%llx", xsdt.table_ptrs[i]);
-#endif
+ dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i]));
}
} else {
auto& rsdt = (const Structures::RSDT&)*sdt;
klog() << "ACPI: Using RSDT, Enumerating tables @ " << m_main_system_description_table;
klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length;
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: RSDT pointer @ V " << &rsdt;
-#endif
+ dbgln<debug_acpi>("ACPI: RSDT pointer @ V{}", &rsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
-#ifdef ACPI_DEBUG
- dbg() << "ACPI: Found new table [" << i << "], @ V " << String::format("%p", &rsdt.table_ptrs[i]) << " - P 0x" << String::format("%x", rsdt.table_ptrs[i]);
-#endif
+ dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
m_sdt_pointers.append(PhysicalAddress(rsdt.table_ptrs[i]));
}
}
diff --git a/Kernel/ThreadBlockers.cpp b/Kernel/ThreadBlockers.cpp
index 2e068e2e3d..b8cee3387c 100644
--- a/Kernel/ThreadBlockers.cpp
+++ b/Kernel/ThreadBlockers.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Debug.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Net/Socket.h>
#include <Kernel/Process.h>
@@ -463,13 +464,9 @@ void Thread::WaitBlockCondition::try_unblock(Thread::WaitBlocker& blocker)
if (blocker.is_wait()) {
if (info.flags == Thread::WaitBlocker::UnblockFlags::Terminated) {
m_processes.remove(i);
-#ifdef WAITBLOCK_DEBUG
- dbg() << "WaitBlockCondition[" << m_process << "] terminated, remove " << *info.process;
-#endif
+ dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, remove {}", m_process, *info.process);
} else {
-#ifdef WAITBLOCK_DEBUG
- dbg() << "WaitBlockCondition[" << m_process << "] terminated, mark as waited " << *info.process;
-#endif
+ dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, mark as waited {}", m_process, *info.process);
info.was_waited = true;
}
}
@@ -493,9 +490,7 @@ void Thread::WaitBlockCondition::disowned_by_waiter(Process& process)
ASSERT(did_unblock); // disowning must unblock everyone
return true;
});
-#ifdef WAITBLOCK_DEBUG
- dbg() << "WaitBlockCondition[" << m_process << "] disowned " << *info.process;
-#endif
+ dbgln<debug_waitblock>("WaitBlockCondition[{}] disowned {}", m_process, *info.process);
m_processes.remove(i);
continue;
}
@@ -548,17 +543,13 @@ bool Thread::WaitBlockCondition::unblock(Process& process, WaitBlocker::UnblockF
info.flags = flags;
info.signal = signal;
info.was_waited = did_wait;
-#ifdef WAITBLOCK_DEBUG
- dbg() << "WaitBlockCondition[" << m_process << "] update " << process << " flags: " << (int)flags << " mark as waited: " << info.was_waited;
-#endif
+ dbgln<debug_waitblock>("WaitBlockCondition[{}] update {} flags={}, waited={}", m_process, process, (int)flags, info.was_waited);
updated_existing = true;
break;
}
}
if (!updated_existing) {
-#ifdef WAITBLOCK_DEBUG
- dbg() << "WaitBlockCondition[" << m_process << "] add " << process << " flags: " << (int)flags;
-#endif
+ dbgln<debug_waitblock>("WaitBlockCondition[{}] add {} flags: {}", m_process, process, (int)flags);
m_processes.append(ProcessBlockInfo(process, flags, signal));
}
}
diff --git a/Kernel/WaitQueue.cpp b/Kernel/WaitQueue.cpp
index dff2420398..42e13c30bf 100644
--- a/Kernel/WaitQueue.cpp
+++ b/Kernel/WaitQueue.cpp
@@ -24,11 +24,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Debug.h>
#include <Kernel/Thread.h>
#include <Kernel/WaitQueue.h>
-//#define WAITQUEUE_DEBUG
-
namespace Kernel {
bool WaitQueue::should_add_blocker(Thread::Blocker& b, void* data)
@@ -38,30 +37,22 @@ bool WaitQueue::should_add_blocker(Thread::Blocker& b, void* data)
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
if (m_wake_requested) {
m_wake_requested = false;
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": do not block thread " << *static_cast<Thread*>(data) << ", wake was pending";
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: do not block thread {}, wake was pending", this, data);
return false;
}
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": should block thread " << *static_cast<Thread*>(data);
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: should block thread {}", this, data);
return true;
}
void WaitQueue::wake_one()
{
ScopedSpinLock lock(m_lock);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_one";
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one", this);
bool did_unblock_one = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_one unblocking " << *static_cast<Thread*>(data);
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one unblocking {}", this, data);
if (blocker.unblock()) {
stop_iterating = true;
return true;
@@ -76,17 +67,14 @@ u32 WaitQueue::wake_n(u32 wake_count)
if (wake_count == 0)
return 0; // should we assert instead?
ScopedSpinLock lock(m_lock);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_n(" << wake_count << ")";
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0;
+
bool did_unblock_some = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_n unblocking " << *static_cast<Thread*>(data);
-#endif
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n unblocking {}", this, data);
ASSERT(did_wake < wake_count);
if (blocker.unblock()) {
if (++did_wake >= wake_count)
@@ -102,17 +90,17 @@ u32 WaitQueue::wake_n(u32 wake_count)
u32 WaitQueue::wake_all()
{
ScopedSpinLock lock(m_lock);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_all";
-#endif
+
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all", this);
u32 did_wake = 0;
+
bool did_unblock_any = do_unblock([&](Thread::Blocker& b, void* data, bool&) {
ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
-#ifdef WAITQUEUE_DEBUG
- dbg() << "WaitQueue @ " << this << ": wake_all unblocking " << *static_cast<Thread*>(data);
-#endif
+
+ dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all unblocking {}", this, data);
+
if (blocker.unblock()) {
did_wake++;
return true;