Skip to content

Commit

Permalink
Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Browse files Browse the repository at this point in the history
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
  • Loading branch information
alimpfard authored and awesomekling committed Feb 8, 2021
1 parent 1f8a633 commit 09a4396
Show file tree
Hide file tree
Showing 95 changed files with 427 additions and 425 deletions.
2 changes: 2 additions & 0 deletions AK/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,5 @@ using AK::dbgln;

using AK::FormatIfSupported;
using AK::FormatString;

#define dbgln_if(flag, format, ...) dbgln<flag>(format, ##__VA_ARGS__)
2 changes: 1 addition & 1 deletion Kernel/ACPI/MultiProcessorParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void MultiProcessorParser::parse_configuration_table()
size_t entry_count = config_table->entry_count;
auto* entry = config_table->entries;
while (entry_count > 0) {
dbgln<MULTIPROCESSOR_DEBUG>("MultiProcessor: Entry Type {} detected.", entry->entry_type);
dbgln_if(MULTIPROCESSOR_DEBUG, "MultiProcessor: Entry Type {} detected.", entry->entry_type);
switch (entry->entry_type) {
case ((u8)MultiProcessor::ConfigurationTableEntryType::Processor):
entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry);
Expand Down
18 changes: 9 additions & 9 deletions Kernel/ACPI/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ void Parser::locate_static_data()

PhysicalAddress Parser::find_table(const StringView& signature)
{
dbgln<ACPI_DEBUG>("ACPI: Calling Find Table method!");
dbgln_if(ACPI_DEBUG, "ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) {
auto sdt = map_typed<Structures::SDTHeader>(p_sdt);
dbgln<ACPI_DEBUG>("ACPI: Examining Table @ {}", p_sdt);
dbgln_if(ACPI_DEBUG, "ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
dbgln<ACPI_DEBUG>("ACPI: Found Table @ {}", p_sdt);
dbgln_if(ACPI_DEBUG, "ACPI: Found Table @ {}", p_sdt);
return p_sdt;
}
}
Expand All @@ -93,7 +93,7 @@ void Parser::init_fadt()

auto sdt = map_typed<Structures::FADT>(m_fadt);

dbgln<ACPI_DEBUG>("ACPI: FADT @ V{}, {}", &sdt, m_fadt);
dbgln_if(ACPI_DEBUG, "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);
Expand Down Expand Up @@ -219,7 +219,7 @@ void Parser::try_acpi_reboot()
klog() << "ACPI: Reboot, Not supported!";
return;
}
dbgln<ACPI_DEBUG>("ACPI: Rebooting, Probing FADT ({})", m_fadt);
dbgln_if(ACPI_DEBUG, "ACPI: Rebooting, Probing FADT ({})", m_fadt);

auto fadt = map_typed<Structures::FADT>(m_fadt);
ASSERT(validate_reset_register());
Expand Down Expand Up @@ -267,18 +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;
dbgln<ACPI_DEBUG>("ACPI: XSDT pointer @ V{}", &xsdt);
dbgln_if(ACPI_DEBUG, "ACPI: XSDT pointer @ V{}", &xsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
dbgln<ACPI_DEBUG>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
dbgln_if(ACPI_DEBUG, "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;
dbgln<ACPI_DEBUG>("ACPI: RSDT pointer @ V{}", &rsdt);
dbgln_if(ACPI_DEBUG, "ACPI: RSDT pointer @ V{}", &rsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
dbgln<ACPI_DEBUG>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
dbgln_if(ACPI_DEBUG, "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]));
}
}
Expand Down
16 changes: 8 additions & 8 deletions Kernel/Arch/i386/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
ASSERT(m_in_critical == 1);
ASSERT(is_kernel_mode());

dbgln<CONTEXT_SWITCH_DEBUG>("switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread);
dbgln_if(CONTEXT_SWITCH_DEBUG, "switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread);
from_thread->save_critical(m_in_critical);

// clang-format off
Expand Down Expand Up @@ -1360,7 +1360,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
);
// clang-format on

dbgln<CONTEXT_SWITCH_DEBUG>("switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
dbgln_if(CONTEXT_SWITCH_DEBUG, "switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);

Processor::current().restore_in_critical(to_thread->saved_critical());
}
Expand All @@ -1370,7 +1370,7 @@ extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe
ASSERT(!are_interrupts_enabled());
ASSERT(is_kernel_mode());

dbgln<CONTEXT_SWITCH_DEBUG>("switch_context <-- from {} {} to {} {} (context_first_init)", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
dbgln_if(CONTEXT_SWITCH_DEBUG, "switch_context <-- from {} {} to {} {} (context_first_init)", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);

ASSERT(to_thread == Thread::current());

Expand Down Expand Up @@ -1553,7 +1553,7 @@ asm(

void Processor::assume_context(Thread& thread, u32 flags)
{
dbgln<CONTEXT_SWITCH_DEBUG>("Assume context for thread {} {}", VirtualAddress(&thread), thread);
dbgln_if(CONTEXT_SWITCH_DEBUG, "Assume context for thread {} {}", VirtualAddress(&thread), thread);

ASSERT_INTERRUPTS_DISABLED();
Scheduler::prepare_after_exec();
Expand Down Expand Up @@ -1860,7 +1860,7 @@ bool Processor::smp_process_pending_messages()
next_msg = cur_msg->next;
auto msg = cur_msg->msg;

dbgln<SMP_DEBUG>("SMP[{}]: Processing message {}", id(), VirtualAddress(msg));
dbgln_if(SMP_DEBUG, "SMP[{}]: Processing message {}", id(), VirtualAddress(msg));

switch (msg->type) {
case ProcessorMessage::Callback:
Expand All @@ -1875,7 +1875,7 @@ bool Processor::smp_process_pending_messages()
ASSERT(is_user_range(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count * PAGE_SIZE));
if (read_cr3() != msg->flush_tlb.page_directory->cr3()) {
// This processor isn't using this page directory right now, we can ignore this request
dbgln<SMP_DEBUG>("SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
dbgln_if(SMP_DEBUG, "SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
break;
}
}
Expand Down Expand Up @@ -1925,7 +1925,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg)
{
auto& cur_proc = Processor::current();

dbgln<SMP_DEBUG>("SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.get_id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc));
dbgln_if(SMP_DEBUG, "SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.get_id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc));

atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release);
ASSERT(msg.refs > 0);
Expand Down Expand Up @@ -1994,7 +1994,7 @@ void Processor::smp_unicast_message(u32 cpu, ProcessorMessage& msg, bool async)
auto& target_proc = processors()[cpu];
msg.async = async;

dbgln<SMP_DEBUG>("SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.get_id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc));
dbgln_if(SMP_DEBUG, "SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.get_id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc));

atomic_store(&msg.refs, 1u, AK::MemoryOrder::memory_order_release);
if (target_proc->smp_queue_message(msg)) {
Expand Down
8 changes: 4 additions & 4 deletions Kernel/Devices/BXVGADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void BXVGADevice::revert_resolution()

void BXVGADevice::set_resolution_registers(size_t width, size_t height)
{
dbgln<BXVGA_DEBUG>("BXVGADevice resolution registers set to - {}x{}", width, height);
dbgln_if(BXVGA_DEBUG, "BXVGADevice resolution registers set to - {}x{}", width, height);
set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
set_register(VBE_DISPI_INDEX_XRES, (u16)width);
set_register(VBE_DISPI_INDEX_YRES, (u16)height);
Expand All @@ -119,7 +119,7 @@ void BXVGADevice::set_resolution_registers(size_t width, size_t height)

bool BXVGADevice::test_resolution(size_t width, size_t height)
{
dbgln<BXVGA_DEBUG>("BXVGADevice resolution test - {}x{}", width, height);
dbgln_if(BXVGA_DEBUG, "BXVGADevice resolution test - {}x{}", width, height);
set_resolution_registers(width, height);
bool resolution_changed = validate_setup_resolution(width, height);
revert_resolution();
Expand Down Expand Up @@ -241,15 +241,15 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT)
return -EINVAL;
if (!set_resolution(resolution.width, resolution.height)) {
dbgln<BXVGA_DEBUG>("Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
dbgln_if(BXVGA_DEBUG, "Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
resolution.pitch = m_framebuffer_pitch;
resolution.width = m_framebuffer_width;
resolution.height = m_framebuffer_height;
if (!copy_to_user(user_resolution, &resolution))
return -EFAULT;
return -EINVAL;
}
dbgln<BXVGA_DEBUG>("New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
dbgln_if(BXVGA_DEBUG, "New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
resolution.pitch = m_framebuffer_pitch;
resolution.width = m_framebuffer_width;
resolution.height = m_framebuffer_height;
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Devices/PS2MouseDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte)

auto commit_packet = [&] {
m_data_state = 0;
dbgln<PS2MOUSE_DEBUG>("PS2Mouse: {}, {} {} {}",
dbgln_if(PS2MOUSE_DEBUG, "PS2Mouse: {}, {} {} {}",
m_data.bytes[1],
m_data.bytes[2],
(m_data.bytes[0] & 1) ? "Left" : "",
Expand Down
6 changes: 3 additions & 3 deletions Kernel/Devices/VMWareBackdoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command)
{
vmware_high_bandwidth_send(command);

dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln_if(VMWARE_BACKDOOR_DEBUG, "VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
Expand All @@ -188,7 +188,7 @@ void VMWareBackdoor::get_high_bandwidth(VMWareCommand& command)
{
vmware_high_bandwidth_get(command);

dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln_if(VMWARE_BACKDOOR_DEBUG, "VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
Expand All @@ -199,7 +199,7 @@ void VMWareBackdoor::send(VMWareCommand& command)
{
vmware_out(command);

dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln_if(VMWARE_BACKDOOR_DEBUG, "VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/FileDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
description->m_custody = custody;
auto result = description->attach();
if (result.is_error()) {
dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for custody: {}", result);
dbgln_if(FILEDESCRIPTION_DEBUG, "Failed to create file description for custody: {}", result);
return result;
}
return description;
Expand All @@ -60,7 +60,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(File& file)
auto description = adopt(*new FileDescription(file));
auto result = description->attach();
if (result.is_error()) {
dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for file: {}", result);
dbgln_if(FILEDESCRIPTION_DEBUG, "Failed to create file description for file: {}", result);
return result;
}
return description;
Expand Down
12 changes: 6 additions & 6 deletions Kernel/FileSystem/ProcFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ NonnullRefPtr<Inode> ProcFS::root_inode() const

RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
{
dbgln<PROCFS_DEBUG>("ProcFS::get_inode({})", inode_id.index());
dbgln_if(PROCFS_DEBUG, "ProcFS::get_inode({})", inode_id.index());
if (inode_id == root_inode()->identifier())
return m_root_inode;

Expand Down Expand Up @@ -1128,7 +1128,7 @@ void ProcFSInode::did_seek(FileDescription& description, off_t new_offset)

InodeMetadata ProcFSInode::metadata() const
{
dbgln<PROCFS_DEBUG>("ProcFSInode::metadata({})", index());
dbgln_if(PROCFS_DEBUG, "ProcFSInode::metadata({})", index());
InodeMetadata metadata;
metadata.inode = identifier();
metadata.ctime = mepoch;
Expand All @@ -1137,7 +1137,7 @@ InodeMetadata ProcFSInode::metadata() const
auto proc_parent_directory = to_proc_parent_directory(identifier());
auto proc_file_type = to_proc_file_type(identifier());

dbgln<PROCFS_DEBUG>(" -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory);
dbgln_if(PROCFS_DEBUG, " -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory);

if (is_process_related_file(identifier())) {
ProcessID pid = to_pid(identifier());
Expand Down Expand Up @@ -1210,14 +1210,14 @@ InodeMetadata ProcFSInode::metadata() const

ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
{
dbgln<PROCFS_DEBUG>("ProcFS: read_bytes offset: {} count: {}", offset, count);
dbgln_if(PROCFS_DEBUG, "ProcFS: read_bytes offset: {} count: {}", offset, count);
ASSERT(offset >= 0);
ASSERT(buffer.user_or_kernel_ptr());

if (!description)
return -EIO;
if (!description->data()) {
dbgln<PROCFS_DEBUG>("ProcFS: Do not have cached data!");
dbgln_if(PROCFS_DEBUG, "ProcFS: Do not have cached data!");
return -EIO;
}

Expand All @@ -1241,7 +1241,7 @@ InodeIdentifier ProcFS::ProcFSDirectoryEntry::identifier(unsigned fsid) const

KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
{
dbgln<PROCFS_DEBUG>("ProcFS: traverse_as_directory {}", index());
dbgln_if(PROCFS_DEBUG, "ProcFS: traverse_as_directory {}", index());

if (!Kernel::is_directory(identifier()))
return ENOTDIR;
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
if (parent_custody.is_readonly())
return EROFS;

dbgln<VFS_DEBUG>("VFS::create: '{}' in {}", p.basename(), parent_inode.identifier());
dbgln_if(VFS_DEBUG, "VFS::create: '{}' in {}", p.basename(), parent_inode.identifier());
uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid();
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);
Expand Down Expand Up @@ -442,7 +442,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
return EROFS;

LexicalPath p(path);
dbgln<VFS_DEBUG>("VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier());
dbgln_if(VFS_DEBUG, "VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier());
return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result();
}

Expand Down
Loading

0 comments on commit 09a4396

Please sign in to comment.