1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:58:12 +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:
asynts 2021-01-14 00:10:32 +01:00 committed by Andreas Kling
parent 78b2be5a2a
commit 67583bc424
8 changed files with 69 additions and 55 deletions

View file

@ -129,3 +129,33 @@ constexpr bool debug_vmware_backdoor = true;
#else #else
constexpr bool debug_vmware_backdoor = false; constexpr bool debug_vmware_backdoor = false;
#endif #endif
#ifdef FILEDESCRIPTION_DEBUG
constexpr bool debug_file_description = true;
#else
constexpr bool debug_file_description = false;
#endif
#ifdef PROCFS_DEBUG
constexpr bool debug_procfs = true;
#else
constexpr bool debug_procfs = false;
#endif
#ifdef VFS_DEBUG
constexpr bool debug_vfs = true;
#else
constexpr bool debug_vfs = false;
#endif
#ifdef IOAPIC_DEBUG
constexpr bool debug_ioapic = true;
#else
constexpr bool debug_ioapic = false;
#endif
#ifdef IRQ_DEBUG
constexpr bool debug_irq = true;
#else
constexpr bool debug_irq = false;
#endif

View file

@ -124,7 +124,7 @@ struct alignas(16) TransferDescriptor final {
void print() void print()
{ {
// FIXME: Use dbg() or klog() when we have something working. // FIXME: Use dbgln() or klog() when we have something working.
// We're using kprintf() for now because the output stands out from the rest of the text in the log // We're using kprintf() for now because the output stands out from the rest of the text in the log
kprintf("UHCI: TD(%p) @ 0x%08x: link_ptr=0x%08x, status=0x%08x, token=0x%08x, buffer_ptr=0x%08x\n", this, m_paddr, m_link_ptr, m_control_status, m_token, m_buffer_ptr); kprintf("UHCI: TD(%p) @ 0x%08x: link_ptr=0x%08x, status=0x%08x, token=0x%08x, buffer_ptr=0x%08x\n", this, m_paddr, m_link_ptr, m_control_status, m_token, m_buffer_ptr);

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/MemoryStream.h> #include <AK/MemoryStream.h>
#include <Kernel/Devices/BlockDevice.h> #include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Devices/CharacterDevice.h> #include <Kernel/Devices/CharacterDevice.h>
@ -40,8 +41,6 @@
#include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/MemoryManager.h>
#include <LibC/errno_numbers.h> #include <LibC/errno_numbers.h>
//#define FILEDESCRIPTION_DEBUG
namespace Kernel { namespace Kernel {
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custody) KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custody)
@ -50,9 +49,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
description->m_custody = custody; description->m_custody = custody;
auto result = description->attach(); auto result = description->attach();
if (result.is_error()) { if (result.is_error()) {
#ifdef FILEDESCRIPTION_DEBUG dbgln<debug_file_description>("Failed to create file description for custody: {}", result);
dbg() << "Failed to create file description for custody: " << result;
#endif
return result; return result;
} }
return description; return description;
@ -63,9 +60,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(File& file)
auto description = adopt(*new FileDescription(file)); auto description = adopt(*new FileDescription(file));
auto result = description->attach(); auto result = description->attach();
if (result.is_error()) { if (result.is_error()) {
#ifdef FILEDESCRIPTION_DEBUG dbgln<debug_file_description>("Failed to create file description for file: {}", result);
dbg() << "Failed to create file description for file: " << result;
#endif
return result; return result;
} }
return description; return description;

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/JsonArraySerializer.h> #include <AK/JsonArraySerializer.h>
#include <AK/JsonObject.h> #include <AK/JsonObject.h>
#include <AK/JsonObjectSerializer.h> #include <AK/JsonObjectSerializer.h>
@ -987,9 +988,7 @@ NonnullRefPtr<Inode> ProcFS::root_inode() const
RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
{ {
#ifdef PROCFS_DEBUG dbgln<debug_procfs>("ProcFS::get_inode({})", inode_id.index());
dbg() << "ProcFS::get_inode(" << inode_id.index() << ")";
#endif
if (inode_id == root_inode()->identifier()) if (inode_id == root_inode()->identifier())
return m_root_inode; return m_root_inode;
@ -1102,9 +1101,7 @@ void ProcFSInode::did_seek(FileDescription& description, off_t new_offset)
InodeMetadata ProcFSInode::metadata() const InodeMetadata ProcFSInode::metadata() const
{ {
#ifdef PROCFS_DEBUG dbgln<debug_procfs>("ProcFSInode::metadata({})", index());
dbg() << "ProcFSInode::metadata(" << index() << ")";
#endif
InodeMetadata metadata; InodeMetadata metadata;
metadata.inode = identifier(); metadata.inode = identifier();
metadata.ctime = mepoch; metadata.ctime = mepoch;
@ -1113,9 +1110,7 @@ InodeMetadata ProcFSInode::metadata() const
auto proc_parent_directory = to_proc_parent_directory(identifier()); auto proc_parent_directory = to_proc_parent_directory(identifier());
auto proc_file_type = to_proc_file_type(identifier()); auto proc_file_type = to_proc_file_type(identifier());
#ifdef PROCFS_DEBUG dbgln<debug_procfs>(" -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory);
dbg() << " -> pid: " << to_pid(identifier()).value() << ", fi: " << proc_file_type << ", pdi: " << proc_parent_directory;
#endif
if (is_process_related_file(identifier())) { if (is_process_related_file(identifier())) {
ProcessID pid = to_pid(identifier()); ProcessID pid = to_pid(identifier());
@ -1180,18 +1175,14 @@ InodeMetadata ProcFSInode::metadata() const
ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
{ {
#ifdef PROCFS_DEBUG dbgln<debug_procfs>("ProcFS: read_bytes offset: {} count: {}", offset, count);
dbg() << "ProcFS: read_bytes offset: " << offset << " count: " << count;
#endif
ASSERT(offset >= 0); ASSERT(offset >= 0);
ASSERT(buffer.user_or_kernel_ptr()); ASSERT(buffer.user_or_kernel_ptr());
if (!description) if (!description)
return -EIO; return -EIO;
if (!description->data()) { if (!description->data()) {
#ifdef PROCFS_DEBUG dbgln<debug_procfs>("ProcFS: Do not have cached data!");
dbgln("ProcFS: Do not have cached data!");
#endif
return -EIO; return -EIO;
} }
@ -1215,9 +1206,7 @@ InodeIdentifier ProcFS::ProcFSDirectoryEntry::identifier(unsigned fsid) const
KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
{ {
#ifdef PROCFS_DEBUG dbgln<debug_procfs>("ProcFS: traverse_as_directory {}", index());
dbg() << "ProcFS: traverse_as_directory " << index();
#endif
if (!Kernel::is_directory(identifier())) if (!Kernel::is_directory(identifier()))
return ENOTDIR; return ENOTDIR;

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/LexicalPath.h> #include <AK/LexicalPath.h>
#include <AK/Singleton.h> #include <AK/Singleton.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
@ -132,7 +133,7 @@ KResult VFS::unmount(Inode& guest_inode)
} }
} }
dbg() << "VFS: Nothing mounted on inode " << guest_inode.identifier(); dbgln("VFS: Nothing mounted on inode {}", guest_inode.identifier());
return ENODEV; return ENODEV;
} }
@ -401,9 +402,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
return EROFS; return EROFS;
LexicalPath p(path); LexicalPath p(path);
#ifdef VFS_DEBUG dbgln<debug_vfs>("VFS::create: '{}' in {}", p.basename(), parent_inode.identifier());
dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier();
#endif
uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid(); uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid();
gid_t gid = owner.has_value() ? owner.value().gid : current_process->egid(); gid_t gid = owner.has_value() ? owner.value().gid : current_process->egid();
auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid); auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid);
@ -445,9 +444,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
return EROFS; return EROFS;
LexicalPath p(path); LexicalPath p(path);
#ifdef VFS_DEBUG dbgln<debug_vfs>("VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier());
dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier();
#endif
return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result(); return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result();
} }

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/StringView.h> #include <AK/StringView.h>
#include <Kernel/ACPI/MultiProcessorParser.h> #include <Kernel/ACPI/MultiProcessorParser.h>
@ -201,13 +202,14 @@ void IOAPIC::configure_redirection_entry(int index, u8 interrupt_vector, u8 deli
u32 redirection_entry1 = interrupt_vector | (delivery_mode & 0b111) << 8 | logical_destination << 11 | active_low << 13 | trigger_level_mode << 15 | masked << 16; u32 redirection_entry1 = interrupt_vector | (delivery_mode & 0b111) << 8 | logical_destination << 11 | active_low << 13 | trigger_level_mode << 15 | masked << 16;
u32 redirection_entry2 = destination << 24; u32 redirection_entry2 = destination << 24;
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1); write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1);
#ifdef IOAPIC_DEBUG
dbg() << "IOAPIC Value: 0x" << String::format("%x", read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET)); if constexpr (debug_ioapic)
#endif dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET));
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET + 1, redirection_entry2); write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET + 1, redirection_entry2);
#ifdef IOAPIC_DEBUG
dbg() << "IOAPIC Value: 0x" << String::format("%x", read_register((index << 1) + 0x11)); if constexpr (debug_ioapic)
#endif dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + 0x11));
} }
void IOAPIC::mask_all_redirection_entries() const void IOAPIC::mask_all_redirection_entries() const
@ -319,17 +321,15 @@ void IOAPIC::write_register(u32 index, u32 value) const
InterruptDisabler disabler; InterruptDisabler disabler;
m_regs->select = index; m_regs->select = index;
m_regs->window = value; m_regs->window = value;
#ifdef IOAPIC_DEBUG
dbg() << "IOAPIC Writing, Value 0x" << String::format("%x", m_regs->window) << " @ offset 0x" << String::format("%x", m_regs->select); dbgln<debug_ioapic>("IOAPIC Writing, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
#endif
} }
u32 IOAPIC::read_register(u32 index) const u32 IOAPIC::read_register(u32 index) const
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
m_regs->select = index; m_regs->select = index;
#ifdef IOAPIC_DEBUG dbgln<debug_ioapic>("IOAPIC Reading, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
dbg() << "IOAPIC Reading, Value 0x" << String::format("%x", m_regs->window) << " @ offset 0x" << String::format("%x", m_regs->select);
#endif
return m_regs->window; return m_regs->window;
} }
} }

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <Kernel/Arch/i386/CPU.h> #include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Interrupts/IRQHandler.h> #include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Interrupts/InterruptManagement.h>
@ -45,9 +46,7 @@ IRQHandler::~IRQHandler()
bool IRQHandler::eoi() bool IRQHandler::eoi()
{ {
#ifdef IRQ_DEBUG dbgln<debug_irq>("EOI IRQ {}", interrupt_number());
dbg() << "EOI IRQ " << interrupt_number();
#endif
if (!m_shared_with_others) { if (!m_shared_with_others) {
ASSERT(!m_responsible_irq_controller.is_null()); ASSERT(!m_responsible_irq_controller.is_null());
m_responsible_irq_controller->eoi(*this); m_responsible_irq_controller->eoi(*this);
@ -58,9 +57,7 @@ bool IRQHandler::eoi()
void IRQHandler::enable_irq() void IRQHandler::enable_irq()
{ {
#ifdef IRQ_DEBUG dbgln<debug_irq>("Enable IRQ {}", interrupt_number());
dbg() << "Enable IRQ " << interrupt_number();
#endif
m_enabled = true; m_enabled = true;
if (!m_shared_with_others) if (!m_shared_with_others)
m_responsible_irq_controller->enable(*this); m_responsible_irq_controller->enable(*this);
@ -68,9 +65,7 @@ void IRQHandler::enable_irq()
void IRQHandler::disable_irq() void IRQHandler::disable_irq()
{ {
#ifdef IRQ_DEBUG dbgln<debug_irq>("Disable IRQ {}", interrupt_number());
dbg() << "Disable IRQ " << interrupt_number();
#endif
m_enabled = false; m_enabled = false;
if (!m_shared_with_others) if (!m_shared_with_others)
m_responsible_irq_controller->disable(*this); m_responsible_irq_controller->disable(*this);

View file

@ -177,3 +177,11 @@ private:
}; };
} }
template<>
struct AK::Formatter<Kernel::KResult> : Formatter<int> {
void format(FormatBuilder& builder, Kernel::KResult value)
{
return Formatter<int>::format(builder, value);
}
};