1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:17:44 +00:00

Everywhere: Debug macros instead of constexpr.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
This commit is contained in:
asynts 2021-01-23 23:59:27 +01:00 committed by Andreas Kling
parent bb483f7ef4
commit 8465683dcf
98 changed files with 414 additions and 972 deletions

View file

@ -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<debug_multiprocessor>("MultiProcessor: Entry Type {} detected.", entry->entry_type);
dbgln<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);

View file

@ -66,12 +66,12 @@ void Parser::locate_static_data()
PhysicalAddress Parser::find_table(const StringView& signature)
{
dbgln<debug_acpi>("ACPI: Calling Find Table method!");
dbgln<ACPI_DEBUG>("ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) {
auto sdt = map_typed<Structures::SDTHeader>(p_sdt);
dbgln<debug_acpi>("ACPI: Examining Table @ {}", p_sdt);
dbgln<ACPI_DEBUG>("ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
dbgln<debug_acpi>("ACPI: Found Table @ {}", p_sdt);
dbgln<ACPI_DEBUG>("ACPI: Found Table @ {}", p_sdt);
return p_sdt;
}
}
@ -93,7 +93,7 @@ void Parser::init_fadt()
auto sdt = map_typed<Structures::FADT>(m_fadt);
dbgln<debug_acpi>("ACPI: FADT @ V{}, {}", &sdt, m_fadt);
dbgln<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);
@ -219,7 +219,7 @@ void Parser::try_acpi_reboot()
klog() << "ACPI: Reboot, Not supported!";
return;
}
dbgln<debug_acpi>("ACPI: Rebooting, Probing FADT ({})", m_fadt);
dbgln<ACPI_DEBUG>("ACPI: Rebooting, Probing FADT ({})", m_fadt);
auto fadt = map_typed<Structures::FADT>(m_fadt);
ASSERT(validate_reset_register());
@ -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<debug_acpi>("ACPI: XSDT pointer @ V{}", &xsdt);
dbgln<ACPI_DEBUG>("ACPI: XSDT pointer @ V{}", &xsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
dbgln<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<debug_acpi>("ACPI: RSDT pointer @ V{}", &rsdt);
dbgln<ACPI_DEBUG>("ACPI: RSDT pointer @ V{}", &rsdt);
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
dbgln<debug_acpi>("ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
dbgln<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]));
}
}

View file

@ -229,7 +229,7 @@ void page_fault_handler(TrapFrame* trap)
asm("movl %%cr2, %%eax"
: "=a"(fault_address));
if constexpr (debug_page_fault) {
if constexpr (PAGE_FAULT_DEBUG) {
u32 fault_page_directory = read_cr3();
dbgln("CPU #{} ring {} {} page fault in PD={:#x}, {}{} {}",
Processor::is_initialized() ? Processor::current().id() : 0,
@ -1307,7 +1307,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
ASSERT(m_in_critical == 1);
ASSERT(is_kernel_mode());
dbgln<debug_context_switch>("switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread);
dbgln<CONTEXT_SWITCH_DEBUG>("switch_context --> switching out of: {} {}", VirtualAddress(from_thread), *from_thread);
// Switch to new thread context, passing from_thread and to_thread
// through to the new context using registers edx and eax
@ -1349,7 +1349,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
[to_thread] "a" (to_thread)
);
dbgln<debug_context_switch>("switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
dbgln<CONTEXT_SWITCH_DEBUG>("switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
}
extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe_unused]] Thread* to_thread, [[maybe_unused]] TrapFrame* trap)
@ -1357,7 +1357,7 @@ extern "C" void context_first_init([[maybe_unused]] Thread* from_thread, [[maybe
ASSERT(!are_interrupts_enabled());
ASSERT(is_kernel_mode());
dbgln<debug_context_switch>("switch_context <-- from {} {} to {} {} (context_first_init)", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
dbgln<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());
@ -1465,7 +1465,7 @@ u32 Processor::init_context(Thread& thread, bool leave_crit)
stack_top -= sizeof(u32); // pointer to TrapFrame
*reinterpret_cast<u32*>(stack_top) = stack_top + 4;
if constexpr (debug_context_switch) {
if constexpr (CONTEXT_SWITCH_DEBUG) {
if (return_to_user) {
dbgln("init_context {} ({}) set up to execute at eip={}:{}, esp={}, stack_top={}, user_top={}:{}",
thread,
@ -1532,7 +1532,7 @@ asm(
void Processor::assume_context(Thread& thread, u32 flags)
{
dbgln<debug_context_switch>("Assume context for thread {} {}", VirtualAddress(&thread), thread);
dbgln<CONTEXT_SWITCH_DEBUG>("Assume context for thread {} {}", VirtualAddress(&thread), thread);
ASSERT_INTERRUPTS_DISABLED();
Scheduler::prepare_after_exec();
@ -1756,7 +1756,7 @@ bool Processor::smp_process_pending_messages()
next_msg = cur_msg->next;
auto msg = cur_msg->msg;
dbgln<debug_smp>("SMP[{}]: Processing message {}", id(), VirtualAddress(msg));
dbgln<SMP_DEBUG>("SMP[{}]: Processing message {}", id(), VirtualAddress(msg));
switch (msg->type) {
case ProcessorMessage::Callback:
@ -1771,7 +1771,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<debug_smp>("SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
dbgln<SMP_DEBUG>("SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
break;
}
}
@ -1821,7 +1821,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg)
{
auto& cur_proc = Processor::current();
dbgln<debug_smp>("SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc));
dbgln<SMP_DEBUG>("SMP[{}]: Broadcast message {} to cpus: {} proc: {}", cur_proc.id(), VirtualAddress(&msg), count(), VirtualAddress(&cur_proc));
atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release);
ASSERT(msg.refs > 0);
@ -1890,7 +1890,7 @@ void Processor::smp_unicast_message(u32 cpu, ProcessorMessage& msg, bool async)
auto& target_proc = processors()[cpu];
msg.async = async;
dbgln<debug_smp>("SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc));
dbgln<SMP_DEBUG>("SMP[{}]: Send message {} to cpu #{} proc: {}", cur_proc.id(), VirtualAddress(&msg), cpu, VirtualAddress(&target_proc));
atomic_store(&msg.refs, 1u, AK::MemoryOrder::memory_order_release);
if (target_proc->smp_queue_message(msg)) {

View file

@ -106,7 +106,7 @@ void BXVGADevice::revert_resolution()
void BXVGADevice::set_resolution_registers(size_t width, size_t height)
{
dbgln<debug_bxvga>("BXVGADevice resolution registers set to - {}x{}", width, height);
dbgln<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);
@ -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<debug_bxvga>("BXVGADevice resolution test - {}x{}", width, height);
dbgln<BXVGA_DEBUG>("BXVGADevice resolution test - {}x{}", width, height);
set_resolution_registers(width, height);
bool resolution_changed = validate_setup_resolution(width, height);
revert_resolution();
@ -239,7 +239,7 @@ 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<debug_bxvga>("Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
dbgln<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;
@ -247,7 +247,7 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
return -EFAULT;
return -EINVAL;
}
dbgln<debug_bxvga>("New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
dbgln<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;

View file

@ -99,7 +99,7 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte)
auto commit_packet = [&] {
m_data_state = 0;
dbgln<debug_ps2mouse>("PS2Mouse: {}, {} {} {}",
dbgln<PS2MOUSE_DEBUG>("PS2Mouse: {}, {} {} {}",
m_data.bytes[1],
m_data.bytes[2],
(m_data.bytes[0] & 1) ? "Left" : "",
@ -283,7 +283,7 @@ KResultOr<size_t> PS2MouseDevice::read(FileDescription&, size_t, UserOrKernelBuf
auto packet = m_queue.dequeue();
lock.unlock();
if constexpr (debug_ps2mouse) {
if constexpr (PS2MOUSE_DEBUG) {
dbgln("PS2 Mouse Read: Buttons {:x}", packet.buttons);
dbgln("PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons);
dbgln("PS2 Mouse Read: Filter packets");

View file

@ -177,7 +177,7 @@ void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command)
{
vmware_high_bandwidth_send(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
@ -188,7 +188,7 @@ void VMWareBackdoor::get_high_bandwidth(VMWareCommand& command)
{
vmware_high_bandwidth_get(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
@ -199,7 +199,7 @@ void VMWareBackdoor::send(VMWareCommand& command)
{
vmware_out(command);
dbgln<debug_vmware_backdoor>("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
dbgln<VMWARE_BACKDOOR_DEBUG>("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}",
command.ax,
command.bx,
command.cx,
@ -233,7 +233,7 @@ Optional<MousePacket> VMWareBackdoor::receive_mouse_packet()
int y = (command.cx);
int z = (command.dx);
if constexpr (debug_ps2mouse) {
if constexpr (PS2MOUSE_DEBUG) {
dbgln("Absolute Mouse: Buttons {:x}", buttons);
dbgln("Mouse: x={}, y={}, z={}", x, y, z);
}

View file

@ -49,7 +49,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
description->m_custody = custody;
auto result = description->attach();
if (result.is_error()) {
dbgln<debug_file_description>("Failed to create file description for custody: {}", result);
dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for custody: {}", result);
return result;
}
return description;
@ -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<debug_file_description>("Failed to create file description for file: {}", result);
dbgln<FILEDESCRIPTION_DEBUG>("Failed to create file description for file: {}", result);
return result;
}
return description;

View file

@ -986,7 +986,7 @@ NonnullRefPtr<Inode> ProcFS::root_inode() const
RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
{
dbgln<debug_procfs>("ProcFS::get_inode({})", inode_id.index());
dbgln<PROCFS_DEBUG>("ProcFS::get_inode({})", inode_id.index());
if (inode_id == root_inode()->identifier())
return m_root_inode;
@ -1099,7 +1099,7 @@ void ProcFSInode::did_seek(FileDescription& description, off_t new_offset)
InodeMetadata ProcFSInode::metadata() const
{
dbgln<debug_procfs>("ProcFSInode::metadata({})", index());
dbgln<PROCFS_DEBUG>("ProcFSInode::metadata({})", index());
InodeMetadata metadata;
metadata.inode = identifier();
metadata.ctime = mepoch;
@ -1108,7 +1108,7 @@ InodeMetadata ProcFSInode::metadata() const
auto proc_parent_directory = to_proc_parent_directory(identifier());
auto proc_file_type = to_proc_file_type(identifier());
dbgln<debug_procfs>(" -> pid={}, fi={}, pdi={}", to_pid(identifier()).value(), (int)proc_file_type, (int)proc_parent_directory);
dbgln<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());
@ -1173,14 +1173,14 @@ InodeMetadata ProcFSInode::metadata() const
ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
{
dbgln<debug_procfs>("ProcFS: read_bytes offset: {} count: {}", offset, count);
dbgln<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<debug_procfs>("ProcFS: Do not have cached data!");
dbgln<PROCFS_DEBUG>("ProcFS: Do not have cached data!");
return -EIO;
}
@ -1204,7 +1204,7 @@ InodeIdentifier ProcFS::ProcFSDirectoryEntry::identifier(unsigned fsid) const
KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
{
dbgln<debug_procfs>("ProcFS: traverse_as_directory {}", index());
dbgln<PROCFS_DEBUG>("ProcFS: traverse_as_directory {}", index());
if (!Kernel::is_directory(identifier()))
return ENOTDIR;

View file

@ -400,7 +400,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
return EROFS;
LexicalPath p(path);
dbgln<debug_vfs>("VFS::create: '{}' in {}", p.basename(), parent_inode.identifier());
dbgln<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);
@ -442,7 +442,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
return EROFS;
LexicalPath p(path);
dbgln<debug_vfs>("VFS::mkdir: '{}' in {}", p.basename(), parent_inode.identifier());
dbgln<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();
}

View file

@ -36,7 +36,7 @@ bool FutexQueue::should_add_blocker(Thread::Blocker& b, void* data)
ASSERT(m_lock.is_locked());
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
dbgln<debug_futex_queue>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data));
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: should block thread {}", this, *static_cast<Thread*>(data));
return true;
}
@ -46,7 +46,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
is_empty_target = false;
ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
u32 did_wake = 0, did_requeue = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
@ -54,7 +54,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data));
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue unblocking {}", this, *static_cast<Thread*>(data));
ASSERT(did_wake < wake_count);
if (blocker.unblock()) {
if (++did_wake >= wake_count)
@ -68,7 +68,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
auto blockers_to_requeue = do_take_blockers(requeue_count);
if (!blockers_to_requeue.is_empty()) {
if (auto* target_futex_queue = get_target_queue()) {
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue);
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue requeueing {} blockers to {}", this, blockers_to_requeue.size(), target_futex_queue);
// While still holding m_lock, notify each blocker
for (auto& info : blockers_to_requeue) {
@ -91,7 +91,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
target_futex_queue->do_append_blockers(move(blockers_to_requeue));
is_empty_target = target_futex_queue->is_empty_locked();
} else {
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size());
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n_requeue could not get target queue to requeue {} blockers", this, blockers_to_requeue.size());
do_append_blockers(move(blockers_to_requeue));
}
}
@ -104,14 +104,14 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
if (wake_count == 0)
return 0; // should we assert instead?
ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n({})", this, wake_count);
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data));
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_n unblocking {}", this, *static_cast<Thread*>(data));
ASSERT(did_wake < wake_count);
if (bitset.has_value() ? blocker.unblock_bitset(bitset.value()) : blocker.unblock()) {
if (++did_wake >= wake_count)
@ -127,13 +127,13 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
u32 FutexQueue::wake_all(bool& is_empty)
{
ScopedSpinLock lock(m_lock);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all", this);
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_all", this);
u32 did_wake = 0;
do_unblock([&](Thread::Blocker& b, void* data, bool&) {
ASSERT(data);
ASSERT(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
dbgln<debug_futex_queue>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data));
dbgln<FUTEXQUEUE_DEBUG>("FutexQueue @ {}: wake_all unblocking", this, *static_cast<Thread*>(data));
if (blocker.unblock(true)) {
did_wake++;
return true;

View file

@ -201,12 +201,12 @@ void IOAPIC::configure_redirection_entry(int index, u8 interrupt_vector, u8 deli
u32 redirection_entry2 = destination << 24;
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1);
if constexpr (debug_ioapic)
if constexpr (IOAPIC_DEBUG)
dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET));
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET + 1, redirection_entry2);
if constexpr (debug_ioapic)
if constexpr (IOAPIC_DEBUG)
dbgln("IOAPIC Value: {:#x}", read_register((index << 1) + 0x11));
}
@ -320,13 +320,13 @@ void IOAPIC::write_register(u32 index, u32 value) const
m_regs->select = index;
m_regs->window = value;
dbgln<debug_ioapic>("IOAPIC Writing, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
dbgln<IOAPIC_DEBUG>("IOAPIC Writing, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
}
u32 IOAPIC::read_register(u32 index) const
{
InterruptDisabler disabler;
m_regs->select = index;
dbgln<debug_ioapic>("IOAPIC Reading, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
dbgln<IOAPIC_DEBUG>("IOAPIC Reading, Value {:#x} @ offset {:#x}", (u32)m_regs->window, (u32)m_regs->select);
return m_regs->window;
}

View file

@ -44,7 +44,7 @@ IRQHandler::~IRQHandler()
bool IRQHandler::eoi()
{
dbgln<debug_irq>("EOI IRQ {}", interrupt_number());
dbgln<IRQ_DEBUG>("EOI IRQ {}", interrupt_number());
if (!m_shared_with_others) {
ASSERT(!m_responsible_irq_controller.is_null());
m_responsible_irq_controller->eoi(*this);
@ -55,7 +55,7 @@ bool IRQHandler::eoi()
void IRQHandler::enable_irq()
{
dbgln<debug_irq>("Enable IRQ {}", interrupt_number());
dbgln<IRQ_DEBUG>("Enable IRQ {}", interrupt_number());
m_enabled = true;
if (!m_shared_with_others)
m_responsible_irq_controller->enable(*this);
@ -63,7 +63,7 @@ void IRQHandler::enable_irq()
void IRQHandler::disable_irq()
{
dbgln<debug_irq>("Disable IRQ {}", interrupt_number());
dbgln<IRQ_DEBUG>("Disable IRQ {}", interrupt_number());
m_enabled = false;
if (!m_shared_with_others)
m_responsible_irq_controller->disable(*this);

View file

@ -59,7 +59,7 @@ void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler)
bool SharedIRQHandler::eoi()
{
dbgln<debug_interrupt>("EOI IRQ {}", interrupt_number());
dbgln<INTERRUPT_DEBUG>("EOI IRQ {}", interrupt_number());
m_responsible_irq_controller->eoi(*this);
return true;
}
@ -86,18 +86,18 @@ void SharedIRQHandler::handle_interrupt(const RegisterState& regs)
{
ASSERT_INTERRUPTS_DISABLED();
if constexpr (debug_interrupt) {
if constexpr (INTERRUPT_DEBUG) {
dbgln("Interrupt @ {}", interrupt_number());
dbgln("Interrupt Handlers registered - {}", m_handlers.size());
}
int i = 0;
for (auto* handler : m_handlers) {
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number());
dbgln<INTERRUPT_DEBUG>("Going for Interrupt Handling @ {}, Shared Interrupt {}", i, interrupt_number());
ASSERT(handler != nullptr);
handler->increment_invoking_counter();
handler->handle_interrupt(regs);
dbgln<debug_interrupt>("Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number());
dbgln<INTERRUPT_DEBUG>("Going for Interrupt Handling @ {}, Shared Interrupt {} - End", i, interrupt_number());
i++;
}
}

View file

@ -56,7 +56,7 @@ void Lock::lock(Mode mode)
Mode current_mode = m_mode;
switch (current_mode) {
case Mode::Unlocked: {
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently unlocked", this, mode_to_string(mode));
dbgln<LOCK_TRACE_DEBUG>("Lock::lock @ {}: acquire {}, currently unlocked", this, mode_to_string(mode));
m_mode = mode;
ASSERT(!m_holder);
ASSERT(m_shared_holders.is_empty());
@ -80,7 +80,7 @@ void Lock::lock(Mode mode)
break;
ASSERT(m_shared_holders.is_empty());
if constexpr (debug_lock_trace) {
if constexpr (LOCK_TRACE_DEBUG) {
if (mode == Mode::Exclusive)
dbgln("Lock::lock @ {}: acquire {}, currently exclusive, holding: {}", this, mode_to_string(mode), m_times_locked);
else
@ -101,7 +101,7 @@ void Lock::lock(Mode mode)
if (mode != Mode::Shared)
break;
dbgln<debug_lock_trace>("Lock::lock @ {}: acquire {}, currently shared, locks held {}", this, mode_to_string(mode), m_times_locked);
dbgln<LOCK_TRACE_DEBUG>("Lock::lock @ {}: acquire {}, currently shared, locks held {}", this, mode_to_string(mode), m_times_locked);
ASSERT(m_times_locked > 0);
m_times_locked++;
@ -139,7 +139,7 @@ void Lock::unlock()
for (;;) {
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
Mode current_mode = m_mode;
if constexpr (debug_lock_trace) {
if constexpr (LOCK_TRACE_DEBUG) {
if (current_mode == Mode::Shared)
dbgln("Lock::unlock @ {}: release {}, locks held: {}", this, mode_to_string(current_mode), m_times_locked);
else
@ -211,7 +211,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked;
}
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
dbgln<LOCK_RESTORE_DEBUG>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
m_holder = nullptr;
ASSERT(m_times_locked > 0);
@ -234,7 +234,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked;
}
dbgln<debug_lock_restore>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
dbgln<LOCK_RESTORE_DEBUG>("Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
this, it->value, m_times_locked);
ASSERT(it->value > 0);
@ -293,7 +293,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Exclusive))
break;
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count);
dbgln<LOCK_RESTORE_DEBUG>("Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count);
ASSERT(m_times_locked == 0);
m_times_locked = lock_count;
@ -311,7 +311,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
if (!m_mode.compare_exchange_strong(expected_mode, Mode::Shared) && expected_mode != Mode::Shared)
break;
dbgln<debug_lock_restore>("Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
dbgln<LOCK_RESTORE_DEBUG>("Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
this, mode_to_string(mode), lock_count, mode_to_string(expected_mode));
ASSERT(expected_mode == Mode::Shared || m_times_locked == 0);

View file

@ -362,7 +362,7 @@ void E1000NetworkAdapter::initialize_tx_descriptors()
void E1000NetworkAdapter::out8(u16 address, u8 data)
{
dbgln<debug_e1000>("E1000: OUT8 {:#02x} @ {:#04x}", data, address);
dbgln<E1000_DEBUG>("E1000: OUT8 {:#02x} @ {:#04x}", data, address);
if (m_use_mmio) {
auto* ptr = (volatile u8*)(m_mmio_base.get() + address);
*ptr = data;
@ -373,7 +373,7 @@ void E1000NetworkAdapter::out8(u16 address, u8 data)
void E1000NetworkAdapter::out16(u16 address, u16 data)
{
dbgln<debug_e1000>("E1000: OUT16 {:#04x} @ {:#04x}", data, address);
dbgln<E1000_DEBUG>("E1000: OUT16 {:#04x} @ {:#04x}", data, address);
if (m_use_mmio) {
auto* ptr = (volatile u16*)(m_mmio_base.get() + address);
*ptr = data;
@ -384,7 +384,7 @@ void E1000NetworkAdapter::out16(u16 address, u16 data)
void E1000NetworkAdapter::out32(u16 address, u32 data)
{
dbgln<debug_e1000>("E1000: OUT32 {:#08x} @ {:#04x}", data, address);
dbgln<E1000_DEBUG>("E1000: OUT32 {:#08x} @ {:#04x}", data, address);
if (m_use_mmio) {
auto* ptr = (volatile u32*)(m_mmio_base.get() + address);
*ptr = data;
@ -395,7 +395,7 @@ void E1000NetworkAdapter::out32(u16 address, u32 data)
u8 E1000NetworkAdapter::in8(u16 address)
{
dbgln<debug_e1000>("E1000: IN8 @ {:#04x}", address);
dbgln<E1000_DEBUG>("E1000: IN8 @ {:#04x}", address);
if (m_use_mmio)
return *(volatile u8*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u8>();
@ -403,7 +403,7 @@ u8 E1000NetworkAdapter::in8(u16 address)
u16 E1000NetworkAdapter::in16(u16 address)
{
dbgln<debug_e1000>("E1000: IN16 @ {:#04x}", address);
dbgln<E1000_DEBUG>("E1000: IN16 @ {:#04x}", address);
if (m_use_mmio)
return *(volatile u16*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u16>();
@ -411,7 +411,7 @@ u16 E1000NetworkAdapter::in16(u16 address)
u32 E1000NetworkAdapter::in32(u16 address)
{
dbgln<debug_e1000>("E1000: IN32 @ {:#04x}", address);
dbgln<E1000_DEBUG>("E1000: IN32 @ {:#04x}", address);
if (m_use_mmio)
return *(volatile u32*)(m_mmio_base.get() + address);
return m_io_base.offset(address).in<u32>();

View file

@ -66,7 +66,7 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
IPv4Socket::IPv4Socket(int type, int protocol)
: Socket(AF_INET, type, protocol)
{
dbgln<debug_ipv4_socket>("IPv4Socket({}) created with type={}, protocol={}", this, type, protocol);
dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}) created with type={}, protocol={}", this, type, protocol);
m_buffer_mode = type == SOCK_STREAM ? BufferMode::Bytes : BufferMode::Packets;
if (m_buffer_mode == BufferMode::Bytes) {
m_scratch_buffer = KBuffer::create_with_size(65536);
@ -119,7 +119,7 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t addr
m_local_address = IPv4Address((const u8*)&address.sin_addr.s_addr);
m_local_port = requested_local_port;
dbgln<debug_ipv4_socket>("IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port);
dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port);
return protocol_bind();
}
@ -135,7 +135,7 @@ KResult IPv4Socket::listen(size_t backlog)
m_role = Role::Listener;
evaluate_block_conditions();
dbgln<debug_ipv4_socket>("IPv4Socket({}) listening with backlog={}", this, backlog);
dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}) listening with backlog={}", this, backlog);
return protocol_listen();
}
@ -287,7 +287,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet = m_receive_queue.take_first();
set_can_read(!m_receive_queue.is_empty());
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom without blocking {} bytes, packets in queue: {}",
dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}): recvfrom without blocking {} bytes, packets in queue: {}",
this,
packet.data.value().size(),
m_receive_queue.size());
@ -316,7 +316,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet = m_receive_queue.take_first();
set_can_read(!m_receive_queue.is_empty());
dbgln<debug_ipv4_socket>("IPv4Socket({}): recvfrom with blocking {} bytes, packets in queue: {}",
dbgln<IPV4_SOCKET_DEBUG>("IPv4Socket({}): recvfrom with blocking {} bytes, packets in queue: {}",
this,
packet.data.value().size(),
m_receive_queue.size());
@ -326,7 +326,7 @@ KResultOr<size_t> IPv4Socket::receive_packet_buffered(FileDescription& descripti
packet_timestamp = packet.timestamp;
if (addr) {
dbgln<debug_ipv4_socket>("Incoming packet is from: {}:{}", packet.peer_address, packet.peer_port);
dbgln<IPV4_SOCKET_DEBUG>("Incoming packet is from: {}:{}", packet.peer_address, packet.peer_port);
sockaddr_in out_addr {};
memcpy(&out_addr.sin_addr, &packet.peer_address, sizeof(IPv4Address));
@ -411,7 +411,7 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port,
}
m_bytes_received += packet_size;
if constexpr (debug_ipv4_socket) {
if constexpr (IPV4_SOCKET_DEBUG) {
if (buffer_mode() == BufferMode::Bytes)
dbgln("IPv4Socket({}): did_receive {} bytes, total_received={}", this, packet_size, m_bytes_received);
else

View file

@ -74,7 +74,7 @@ LocalSocket::LocalSocket(int type)
evaluate_block_conditions();
});
dbgln<debug_local_socket>("LocalSocket({}) created with type={}", this, type);
dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) created with type={}", this, type);
}
LocalSocket::~LocalSocket()
@ -110,7 +110,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add
auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path)));
dbgln<debug_local_socket>("LocalSocket({}) bind({})", this, path);
dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) bind({})", this, path);
mode_t mode = S_IFSOCK | (m_prebind_mode & 0777);
UidAndGid owner { m_prebind_uid, m_prebind_gid };
@ -154,7 +154,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
return EFAULT;
safe_address[sizeof(safe_address) - 1] = '\0';
dbgln<debug_local_socket>("LocalSocket({}) connect({})", this, safe_address);
dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) connect({})", this, safe_address);
auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory());
if (description_or_error.is_error())
@ -190,7 +190,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka
return EINTR;
}
dbgln<debug_local_socket>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state()));
dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state()));
if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) {
set_connect_side_role(Role::None);
@ -210,7 +210,7 @@ KResult LocalSocket::listen(size_t backlog)
m_role = Role::Listener;
set_connect_side_role(Role::Listener, previous_role != m_role);
dbgln<debug_local_socket>("LocalSocket({}) listening with backlog={}", this, backlog);
dbgln<LOCAL_SOCKET_DEBUG>("LocalSocket({}) listening with backlog={}", this, backlog);
return KSuccess;
}

View file

@ -64,7 +64,7 @@ Socket::~Socket()
void Socket::set_setup_state(SetupState new_setup_state)
{
dbgln<debug_socket>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state));
dbgln<SOCKET_DEBUG>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state));
m_setup_state = new_setup_state;
evaluate_block_conditions();
}
@ -74,7 +74,7 @@ RefPtr<Socket> Socket::accept()
LOCKER(m_lock);
if (m_pending.is_empty())
return nullptr;
dbgln<debug_socket>("Socket({}) de-queueing connection", this);
dbgln<SOCKET_DEBUG>("Socket({}) de-queueing connection", this);
auto client = m_pending.take_first();
ASSERT(!client->is_connected());
auto& process = *Process::current();
@ -88,7 +88,7 @@ RefPtr<Socket> Socket::accept()
KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer)
{
dbgln<debug_socket>("Socket({}) queueing connection", this);
dbgln<SOCKET_DEBUG>("Socket({}) queueing connection", this);
LOCKER(m_lock);
if (m_pending.size() >= m_backlog)
return ECONNREFUSED;

View file

@ -47,7 +47,7 @@ void TCPSocket::for_each(Function<void(const TCPSocket&)> callback)
void TCPSocket::set_state(State new_state)
{
dbgln<debug_tcp_socket>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state));
dbgln<TCP_SOCKET_DEBUG>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state));
auto was_disconnected = protocol_is_disconnected();
auto previous_role = m_role;
@ -154,7 +154,7 @@ TCPSocket::~TCPSocket()
LOCKER(sockets_by_tuple().lock());
sockets_by_tuple().resource().remove(tuple());
dbgln<debug_tcp_socket>("~TCPSocket in state {}", to_string(state()));
dbgln<TCP_SOCKET_DEBUG>("~TCPSocket in state {}", to_string(state()));
}
NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
@ -273,14 +273,14 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
if (packet.has_ack()) {
u32 ack_number = packet.ack_number();
dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet: {}", ack_number);
dbgln<TCP_SOCKET_DEBUG>("TCPSocket: receive_tcp_packet: {}", ack_number);
int removed = 0;
LOCKER(m_not_acked_lock);
while (!m_not_acked.is_empty()) {
auto& packet = m_not_acked.first();
dbgln<debug_tcp_socket>("TCPSocket: iterate: {}", packet.ack_number);
dbgln<TCP_SOCKET_DEBUG>("TCPSocket: iterate: {}", packet.ack_number);
if (packet.ack_number <= ack_number) {
m_not_acked.take_first();
@ -290,7 +290,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
}
}
dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed);
dbgln<TCP_SOCKET_DEBUG>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed);
}
m_packets_in++;

View file

@ -74,34 +74,34 @@ PhysicalID Access::get_physical_id(Address address) const
u8 Access::early_read8_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: Early reading 8-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: Early reading 8-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in8(PCI_VALUE_PORT + (field & 3));
}
u16 Access::early_read16_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: Early reading 16-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: Early reading 16-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in16(PCI_VALUE_PORT + (field & 2));
}
u32 Access::early_read32_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: Early reading 32-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: Early reading 32-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in32(PCI_VALUE_PORT);
}
u16 Access::early_read_type(Address address)
{
dbgln<debug_pci>("PCI: Early reading type for {}", address);
dbgln<PCI_DEBUG>("PCI: Early reading type for {}", address);
return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS);
}
void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback)
{
dbgln<debug_pci>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function);
dbgln<PCI_DEBUG>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function);
Address address(0, bus, slot, function);
if (type == -1 || type == early_read_type(address))
callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) });
@ -117,7 +117,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Functio
void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback)
{
dbgln<debug_pci>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot);
dbgln<PCI_DEBUG>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot);
Address address(0, bus, slot, 0);
if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE)
return;
@ -133,7 +133,7 @@ void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID
void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback)
{
dbgln<debug_pci>("PCI: Enumerating bus type={}, bus={}", type, bus);
dbgln<PCI_DEBUG>("PCI: Enumerating bus type={}, bus={}", type, bus);
for (u8 slot = 0; slot < 32; ++slot)
enumerate_slot(type, bus, slot, callback);
}
@ -152,12 +152,12 @@ void enumerate(Function<void(Address, ID)> callback)
Optional<u8> get_capabilities_pointer(Address address)
{
dbgln<debug_pci>("PCI: Getting capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting capabilities pointer for {}", address);
if (PCI::read16(address, PCI_STATUS) & (1 << 4)) {
dbgln<debug_pci>("PCI: Found capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: Found capabilities pointer for {}", address);
return PCI::read8(address, PCI_CAPABILITIES_POINTER);
}
dbgln<debug_pci>("PCI: No capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: No capabilities pointer for {}", address);
return {};
}
@ -168,16 +168,16 @@ PhysicalID get_physical_id(Address address)
Vector<Capability> get_capabilities(Address address)
{
dbgln<debug_pci>("PCI: Getting capabilities for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting capabilities for {}", address);
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
if (!capabilities_pointer.has_value()) {
dbgln<debug_pci>("PCI: No capabilities for {}", address);
dbgln<PCI_DEBUG>("PCI: No capabilities for {}", address);
return {};
}
Vector<Capability> capabilities;
auto capability_pointer = capabilities_pointer.value();
while (capability_pointer != 0) {
dbgln<debug_pci>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address);
dbgln<PCI_DEBUG>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address);
u16 capability_header = PCI::read16(address, capability_pointer);
u8 capability_id = capability_header & 0xff;
capability_pointer = capability_header >> 8;

View file

@ -194,7 +194,7 @@ public:
, m_id(id)
, m_capabilities(capabilities)
{
if constexpr (debug_pci) {
if constexpr (PCI_DEBUG) {
for (auto capability : capabilities)
dbgln("{} has capability {}", address, capability.m_id);
}

View file

@ -35,7 +35,7 @@ void IOAccess::initialize()
{
if (!Access::is_initialized()) {
new IOAccess();
dbgln<debug_pci>("PCI: IO access initialised.");
dbgln<PCI_DEBUG>("PCI: IO access initialised.");
}
}
@ -49,37 +49,37 @@ IOAccess::IOAccess()
u8 IOAccess::read8_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address);
return Access::early_read8_field(address, field);
}
u16 IOAccess::read16_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address);
return Access::early_read16_field(address, field);
}
u32 IOAccess::read32_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address);
return Access::early_read32_field(address, field);
}
void IOAccess::write8_field(Address address, u32 field, u8 value)
{
dbgln<debug_pci>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out8(PCI_VALUE_PORT + (field & 3), value);
}
void IOAccess::write16_field(Address address, u32 field, u16 value)
{
dbgln<debug_pci>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out16(PCI_VALUE_PORT + (field & 2), value);
}
void IOAccess::write32_field(Address address, u32 field, u32 value)
{
dbgln<debug_pci>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out32(PCI_VALUE_PORT, value);
}

View file

@ -109,7 +109,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write);
auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr();
dbgln<debug_pci>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
dbgln<PCI_DEBUG>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
for (u32 index = 0; index < ((mcfg.header.length - sizeof(ACPI::Structures::MCFG)) / sizeof(ACPI::Structures::PCI_MMIO_Descriptor)); index++) {
u8 start_bus = mcfg.descriptors[index].start_pci_bus;
@ -127,26 +127,26 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
enumerate_hardware([&](const Address& address, ID id) {
m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value()));
m_physical_ids.append({ address, id, get_capabilities(address) });
dbgln<debug_pci>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr());
dbgln<PCI_DEBUG>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr());
});
}
Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
{
dbgln<debug_pci>("PCI: Getting device configuration space for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting device configuration space for {}", address);
for (auto& mapping : m_mapped_device_regions) {
auto checked_address = mapping.address();
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address);
dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address);
if (address.seg() == checked_address.seg()
&& address.bus() == checked_address.bus()
&& address.slot() == checked_address.slot()
&& address.function() == checked_address.function()) {
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Found {}", checked_address);
dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Found {}", checked_address);
return mapping.vaddr();
}
}
dbgln<debug_pci>("PCI: No device configuration space found for {}", address);
dbgln<PCI_DEBUG>("PCI: No device configuration space found for {}", address);
return {};
}
@ -154,7 +154,7 @@ u8 MMIOAccess::read8_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
return *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -162,7 +162,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
return *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -170,7 +170,7 @@ u32 MMIOAccess::read32_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
return *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -178,28 +178,28 @@ void MMIOAccess::write8_field(Address address, u32 field, u8 value)
{
InterruptDisabler disabler;
ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::write16_field(Address address, u32 field, u16 value)
{
InterruptDisabler disabler;
ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::write32_field(Address address, u32 field, u32 value)
{
InterruptDisabler disabler;
ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::enumerate_hardware(Function<void(Address, ID)> callback)
{
for (u16 seg = 0; seg < m_segments.size(); seg++) {
dbgln<debug_pci>("PCI: Enumerating Memory mapped IO segment {}", seg);
dbgln<PCI_DEBUG>("PCI: Enumerating Memory mapped IO segment {}", seg);
// Single PCI host controller.
if ((early_read8_field(Address(seg), PCI_HEADER_TYPE) & 0x80) == 0) {
enumerate_bus(-1, 0, callback);

View file

@ -351,7 +351,7 @@ Process::Process(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gi
, m_ppid(ppid)
, m_wait_block_condition(*this)
{
dbgln<debug_process>("Created new process {}({})", m_name, m_pid.value());
dbgln<PROCESS_DEBUG>("Created new process {}({})", m_name, m_pid.value());
m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
@ -615,7 +615,7 @@ void Process::finalize()
{
ASSERT(Thread::current() == g_finalizer);
dbgln<debug_process>("Finalizing process {}", *this);
dbgln<PROCESS_DEBUG>("Finalizing process {}", *this);
if (is_dumpable()) {
if (m_should_dump_core)

View file

@ -129,13 +129,13 @@ bool Scheduler::pick_next()
// Scheduler::enter_current because we don't want to allow it to
// transition back to user mode.
if constexpr (debug_scheduler)
if constexpr (SCHEDULER_DEBUG)
dbgln("Scheduler[{}]: Thread {} is dying", Processor::current().id(), *current_thread);
current_thread->set_state(Thread::Dying);
}
if constexpr (debug_scheduler_runnable) {
if constexpr (SCHEDULER_RUNNABLE_DEBUG) {
dbgln("Scheduler[{}j]: Non-runnables:", Processor::current().id());
Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision {
if (thread.state() == Thread::Dying) {
@ -196,7 +196,7 @@ bool Scheduler::pick_next()
// but since we're still holding the scheduler lock we're still in a critical section
critical.leave();
dbgln<debug_scheduler>("Processing pending donate to {} reason={}", *thread_to_schedule, reason);
dbgln<SCHEDULER_DEBUG>("Processing pending donate to {} reason={}", *thread_to_schedule, reason);
return donate_to_and_switch(thread_to_schedule, reason);
}
@ -224,7 +224,7 @@ bool Scheduler::pick_next()
if (!thread_to_schedule)
thread_to_schedule = Processor::current().idle_thread();
if constexpr (debug_scheduler) {
if constexpr (SCHEDULER_DEBUG) {
dbgln("Scheduler[{}]: Switch to {} @ {:04x}:{:08x}",
Processor::current().id(),
*thread_to_schedule,
@ -250,7 +250,7 @@ bool Scheduler::yield()
scheduler_data.m_pending_donate_reason = nullptr;
auto current_thread = Thread::current();
dbgln<debug_scheduler>("Scheduler[{}]: yielding thread {} in_irq={}", proc.id(), *current_thread, proc.in_irq());
dbgln<SCHEDULER_DEBUG>("Scheduler[{}]: yielding thread {} in_irq={}", proc.id(), *current_thread, proc.in_irq());
ASSERT(current_thread != nullptr);
if (proc.in_irq() || proc.in_critical()) {
// If we're handling an IRQ we can't switch context, or we're in
@ -263,7 +263,7 @@ bool Scheduler::yield()
if (!Scheduler::pick_next())
return false;
if constexpr (debug_scheduler)
if constexpr (SCHEDULER_DEBUG)
dbgln("Scheduler[{}]: yield returns to thread {} in_irq={}", Processor::current().id(), *current_thread, Processor::current().in_irq());
return true;
}
@ -280,7 +280,7 @@ bool Scheduler::donate_to_and_switch(Thread* beneficiary, [[maybe_unused]] const
return Scheduler::yield();
unsigned ticks_to_donate = min(ticks_left - 1, time_slice_for(*beneficiary));
dbgln<debug_scheduler>("Scheduler[{}]: Donating {} ticks to {}, reason={}", proc.id(), ticks_to_donate, *beneficiary, reason);
dbgln<SCHEDULER_DEBUG>("Scheduler[{}]: Donating {} ticks to {}, reason={}", proc.id(), ticks_to_donate, *beneficiary, reason);
beneficiary->set_ticks_left(ticks_to_donate);
return Scheduler::context_switch(beneficiary);

View file

@ -176,7 +176,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu
// which could cause page faults. Note that this may be called immediately
// before Processor::deferred_call_queue returns!
Processor::deferred_call_queue([this, result]() {
dbgln<debug_pata>("IDEChannel::complete_current_request result: {}", (int)result);
dbgln<PATA_DEBUG>("IDEChannel::complete_current_request result: {}", (int)result);
ASSERT(m_current_request);
auto& request = *m_current_request;
m_current_request = nullptr;
@ -364,7 +364,7 @@ void IDEChannel::ata_read_sectors_with_dma(bool slave_request)
{
auto& request = *m_current_request;
u32 lba = request.block_index();
dbgln<debug_pata>("IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count());
dbgln<PATA_DEBUG>("IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count());
prdt().offset = m_dma_buffer_page->paddr();
prdt().size = 512 * request.block_count();
@ -483,7 +483,7 @@ void IDEChannel::ata_write_sectors_with_dma(bool slave_request)
{
auto& request = *m_current_request;
u32 lba = request.block_index();
dbgln<debug_pata>("IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count());
dbgln<PATA_DEBUG>("IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count());
prdt().offset = m_dma_buffer_page->paddr();
prdt().size = 512 * request.block_count();

View file

@ -33,7 +33,7 @@ namespace Kernel {
int Process::sys$fcntl(int fd, int cmd, u32 arg)
{
REQUIRE_PROMISE(stdio);
dbgln<debug_io>("sys$fcntl: fd={}, cmd={}, arg={}", fd, cmd, arg);
dbgln<IO_DEBUG>("sys$fcntl: fd={}, cmd={}, arg={}", fd, cmd, arg);
auto description = file_description(fd);
if (!description)
return -EBADF;

View file

@ -50,7 +50,7 @@ pid_t Process::sys$fork(RegisterState& regs)
child->m_pg = m_pg;
child->m_umask = m_umask;
dbgln<debug_fork>("fork: child={}", child);
dbgln<FORK_DEBUG>("fork: child={}", child);
child->m_extra_gids = m_extra_gids;
@ -79,7 +79,7 @@ pid_t Process::sys$fork(RegisterState& regs)
{
ScopedSpinLock lock(m_lock);
for (auto& region : m_regions) {
dbgln<debug_fork>("fork: cloning Region({}) '{}' @ {}", &region, region.name(), region.vaddr());
dbgln<FORK_DEBUG>("fork: cloning Region({}) '{}' @ {}", &region, region.name(), region.vaddr());
auto region_clone = region.clone(*child);
if (!region_clone) {
dbgln("fork: Cannot clone region, insufficient memory");

View file

@ -39,7 +39,7 @@ FutexQueue::FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject)
: m_user_address_or_offset(user_address_or_offset)
, m_is_global(vmobject != nullptr)
{
dbgln<debug_futex>("Futex @ {}{}",
dbgln<FUTEX_DEBUG>("Futex @ {}{}",
this,
m_is_global ? " (global)" : " (local)");
@ -56,7 +56,7 @@ FutexQueue::~FutexQueue()
if (auto vmobject = m_vmobject.strong_ref())
vmobject->unregister_on_deleted_handler(*this);
}
dbgln<debug_futex>("~Futex @ {}{}",
dbgln<FUTEX_DEBUG>("~Futex @ {}{}",
this,
m_is_global ? " (global)" : " (local)");
}
@ -68,7 +68,7 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
// to make sure we have at last a reference until we're done
NonnullRefPtr<FutexQueue> own_ref(*this);
dbgln<debug_futex>("Futex::vmobject_deleted @ {}{}",
dbgln<FUTEX_DEBUG>("Futex::vmobject_deleted @ {}{}",
this,
m_is_global ? " (global)" : " (local)");
@ -84,7 +84,7 @@ void FutexQueue::vmobject_deleted(VMObject& vmobject)
bool did_wake_all;
auto wake_count = wake_all(did_wake_all);
if constexpr (debug_futex) {
if constexpr (FUTEX_DEBUG) {
if (wake_count > 0)
dbgln("Futex @ {} unblocked {} waiters due to vmobject free", this, wake_count);
}

View file

@ -63,7 +63,7 @@ int Process::sys$open(Userspace<const Syscall::SC_open_params*> user_params)
if (path.is_error())
return path.error();
dbgln<debug_io>("sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode);
dbgln<IO_DEBUG>("sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode);
int fd = alloc_fd();
if (fd < 0)
return fd;
@ -99,7 +99,7 @@ int Process::sys$close(int fd)
{
REQUIRE_PROMISE(stdio);
auto description = file_description(fd);
dbgln<debug_io>("sys$close({}) {}", fd, description.ptr());
dbgln<IO_DEBUG>("sys$close({}) {}", fd, description.ptr());
if (!description)
return -EBADF;
int rc = description->close();

View file

@ -37,7 +37,7 @@ ssize_t Process::sys$read(int fd, Userspace<u8*> buffer, ssize_t size)
return -EINVAL;
if (size == 0)
return 0;
dbgln<debug_io>("sys$read({}, {}, {})", fd, buffer.ptr(), size);
dbgln<IO_DEBUG>("sys$read({}, {}, {})", fd, buffer.ptr(), size);
auto description = file_description(fd);
if (!description)
return -EBADF;

View file

@ -95,11 +95,11 @@ int Process::sys$select(const Syscall::SC_select_params* user_params)
fds.append(fd);
}
if constexpr (debug_io || debug_poll_select)
if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
dbgln("selecting on {} fds, timeout={}", fds_info.size(), params.timeout);
if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted()) {
dbgln<debug_poll_select>("select was interrupted");
dbgln<POLL_SELECT_DEBUG>("select was interrupted");
return -EINTR;
}
@ -198,7 +198,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
current_thread->update_signal_mask(previous_signal_mask);
});
if constexpr (debug_io || debug_poll_select)
if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
dbgln("polling on {} fds, timeout={}", fds_info.size(), params.timeout);
if (current_thread->block<Thread::SelectBlocker>(timeout, fds_info).was_interrupted())

View file

@ -55,7 +55,7 @@ pid_t Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> user_param
if (!copy_from_user(&params, user_params))
return -EFAULT;
dbgln<debug_process>("sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options);
dbgln<PROCESS_DEBUG>("sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options);
auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options);
if (siginfo_or_error.is_error())

View file

@ -125,7 +125,7 @@ ssize_t Process::sys$write(int fd, const u8* data, ssize_t size)
if (size == 0)
return 0;
dbgln<debug_io>("sys$write({}, {}, {})", fd, data, size);
dbgln<IO_DEBUG>("sys$write({}, {}, {})", fd, data, size);
auto description = file_description(fd);
if (!description)
return -EBADF;

View file

@ -53,7 +53,7 @@ MasterPTY::MasterPTY(unsigned index)
MasterPTY::~MasterPTY()
{
dbgln<debug_masterpty>("~MasterPTY({})", m_index);
dbgln<MASTERPTY_DEBUG>("~MasterPTY({})", m_index);
PTYMultiplexer::the().notify_master_destroyed({}, m_index);
}
@ -91,7 +91,7 @@ bool MasterPTY::can_write(const FileDescription&, size_t) const
void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
{
dbgln<debug_masterpty>("MasterPTY({}): slave closed, my retains: {}, slave retains: {}", m_index, ref_count(), m_slave->ref_count());
dbgln<MASTERPTY_DEBUG>("MasterPTY({}): slave closed, my retains: {}, slave retains: {}", m_index, ref_count(), m_slave->ref_count());
// +1 ref for my MasterPTY::m_slave
// +1 ref for FileDescription::m_device
if (m_slave->ref_count() == 2)

View file

@ -61,7 +61,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
return EBUSY;
auto master_index = m_freelist.take_last();
auto master = adopt(*new MasterPTY(master_index));
dbgln<debug_ptmx>("PTYMultiplexer::open: Vending master {}", master->index());
dbgln<PTMX_DEBUG>("PTYMultiplexer::open: Vending master {}", master->index());
auto description = FileDescription::create(move(master));
if (!description.is_error()) {
description.value()->set_rw_mode(options);
@ -74,7 +74,7 @@ void PTYMultiplexer::notify_master_destroyed(Badge<MasterPTY>, unsigned index)
{
LOCKER(m_lock);
m_freelist.append(index);
dbgln<debug_ptmx>("PTYMultiplexer: {} added to freelist", index);
dbgln<PTMX_DEBUG>("PTYMultiplexer: {} added to freelist", index);
}
}

View file

@ -47,7 +47,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index)
SlavePTY::~SlavePTY()
{
dbgln<debug_slavepty>("~SlavePTY({})", m_index);
dbgln<SLAVEPTY_DEBUG>("~SlavePTY({})", m_index);
DevPtsFS::unregister_slave_pty(*this);
}

View file

@ -304,7 +304,7 @@ void TTY::set_termios(const termios& t)
{
m_termios = t;
dbgln<debug_tty>("{} set_termios: ECHO={}, ISIG={}, ICANON={}, ECHOE={}, ECHOK={}, ECHONL={}, ISTRIP={}, ICRNL={}, INLCR={}, IGNCR={}",
dbgln<TTY_DEBUG>("{} set_termios: ECHO={}, ISIG={}, ICANON={}, ECHOE={}, ECHOK={}, ECHONL={}, ISTRIP={}, ICRNL={}, INLCR={}, IGNCR={}",
tty_name(),
should_echo_input(),
should_generate_signals(),

View file

@ -59,7 +59,7 @@ Thread::Thread(NonnullRefPtr<Process> process)
} else {
m_tid = Process::allocate_pid().value();
}
if constexpr (debug_thread)
if constexpr (THREAD_DEBUG)
dbgln("Created new thread {}({}:{})", m_process->name(), m_process->pid().value(), m_tid.value());
set_default_signal_dispositions();
m_fpu_state = (FPUState*)kmalloc_aligned<16>(sizeof(FPUState));
@ -370,7 +370,7 @@ void Thread::finalize()
{
ScopedSpinLock lock(g_scheduler_lock);
dbgln<debug_thread>("Finalizing thread {}", *this);
dbgln<THREAD_DEBUG>("Finalizing thread {}", *this);
set_state(Thread::State::Dead);
m_join_condition.thread_finalizing();
}
@ -476,11 +476,11 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
// FIXME: Figure out what to do for masked signals. Should we also ignore them here?
if (should_ignore_signal(signal)) {
dbgln<debug_signal>("Signal {} was ignored by {}", signal, process());
dbgln<SIGNAL_DEBUG>("Signal {} was ignored by {}", signal, process());
return;
}
if constexpr (debug_signal) {
if constexpr (SIGNAL_DEBUG) {
if (sender)
dbgln("Signal: {} sent {} to {}", *sender, signal, process());
else
@ -493,12 +493,12 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
if (m_state == Stopped) {
ScopedSpinLock lock(m_lock);
if (pending_signals_for_state()) {
dbgln<debug_signal>("Signal: Resuming stopped {} to deliver signal {}", *this, signal);
dbgln<SIGNAL_DEBUG>("Signal: Resuming stopped {} to deliver signal {}", *this, signal);
resume_from_stopped();
}
} else {
ScopedSpinLock block_lock(m_block_lock);
dbgln<debug_signal>("Signal: Unblocking {} to deliver signal {}", *this, signal);
dbgln<SIGNAL_DEBUG>("Signal: Unblocking {} to deliver signal {}", *this, signal);
unblock(signal);
}
}
@ -710,7 +710,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
auto& process = this->process();
auto tracer = process.tracer();
if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) {
dbgln<debug_signal>("signal: signal {} sopping thread {}", signal, *this);
dbgln<SIGNAL_DEBUG>("signal: signal {} sopping thread {}", signal, *this);
set_state(State::Stopped, signal);
return DispatchSignalResult::Yield;
}
@ -873,13 +873,13 @@ 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()) {
dbgln<debug_thread>("Dispatch pending signals to new thread {}", *this);
dbgln<THREAD_DEBUG>("Dispatch pending signals to new thread {}", *this);
dispatch_one_pending_signal();
}
}
m_state = new_state;
dbgln<debug_thread>("Set thread {} state to {}", *this, state_string());
dbgln<THREAD_DEBUG>("Set thread {} state to {}", *this, state_string());
}
if (m_process->pid() != 0) {
@ -894,7 +894,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) {
if (&thread == this || !thread.is_stopped())
return IterationDecision::Continue;
dbgln<debug_thread>("Resuming peer thread {}", thread);
dbgln<THREAD_DEBUG>("Resuming peer thread {}", thread);
thread.resume_from_stopped();
return IterationDecision::Continue;
});
@ -910,7 +910,7 @@ void Thread::set_state(State new_state, u8 stop_signal)
process.for_each_thread([&](auto& thread) {
if (&thread == this || thread.is_stopped())
return IterationDecision::Continue;
dbgln<debug_thread>("Stopping peer thread {}", thread);
dbgln<THREAD_DEBUG>("Stopping peer thread {}", thread);
thread.set_state(Stopped, stop_signal);
return IterationDecision::Continue;
});

View file

@ -462,9 +462,9 @@ void Thread::WaitBlockCondition::try_unblock(Thread::WaitBlocker& blocker)
if (blocker.is_wait()) {
if (info.flags == Thread::WaitBlocker::UnblockFlags::Terminated) {
m_processes.remove(i);
dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, remove {}", m_process, *info.process);
dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] terminated, remove {}", m_process, *info.process);
} else {
dbgln<debug_waitblock>("WaitBlockCondition[{}] terminated, mark as waited {}", m_process, *info.process);
dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] terminated, mark as waited {}", m_process, *info.process);
info.was_waited = true;
}
}
@ -488,7 +488,7 @@ void Thread::WaitBlockCondition::disowned_by_waiter(Process& process)
ASSERT(did_unblock); // disowning must unblock everyone
return true;
});
dbgln<debug_waitblock>("WaitBlockCondition[{}] disowned {}", m_process, *info.process);
dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] disowned {}", m_process, *info.process);
m_processes.remove(i);
continue;
}
@ -541,13 +541,13 @@ bool Thread::WaitBlockCondition::unblock(Process& process, WaitBlocker::UnblockF
info.flags = flags;
info.signal = signal;
info.was_waited = did_wait;
dbgln<debug_waitblock>("WaitBlockCondition[{}] update {} flags={}, waited={}", m_process, process, (int)flags, info.was_waited);
dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] update {} flags={}, waited={}", m_process, process, (int)flags, info.was_waited);
updated_existing = true;
break;
}
}
if (!updated_existing) {
dbgln<debug_waitblock>("WaitBlockCondition[{}] add {} flags: {}", m_process, process, (int)flags);
dbgln<WAITBLOCK_DEBUG>("WaitBlockCondition[{}] add {} flags: {}", m_process, process, (int)flags);
m_processes.append(ProcessBlockInfo(process, flags, signal));
}
}

View file

@ -206,7 +206,7 @@ void HPET::update_periodic_comparator_value()
// and we can only write the period into the comparator value...
timer.capabilities = timer.capabilities | (u32)HPETFlags::TimerConfiguration::ValueSet;
u64 value = frequency() / comparator.ticks_per_second();
dbgln<debug_hpet>("HPET: Update periodic comparator {} comparator value to {} main value was: {}",
dbgln<HPET_DEBUG>("HPET: Update periodic comparator {} comparator value to {} main value was: {}",
comparator.comparator_number(),
value,
previous_main_value);
@ -217,7 +217,7 @@ void HPET::update_periodic_comparator_value()
// Set the new target comparator value to the delta to the remaining ticks
u64 current_value = (u64)timer.comparator_value.low | ((u64)timer.comparator_value.high << 32);
u64 value = current_value - previous_main_value;
dbgln<debug_hpet>("HPET: Update non-periodic comparator {} comparator value from {} to {} main value was: {}",
dbgln<HPET_DEBUG>("HPET: Update non-periodic comparator {} comparator value from {} to {} main value was: {}",
comparator.comparator_number(),
current_value,
value,

View file

@ -109,7 +109,7 @@ bool HPETComparator::try_to_set_frequency(size_t frequency)
m_frequency = frequency;
m_enabled = true;
dbgln<debug_hpet_comperator>("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic());
dbgln<HPET_COMPARATOR_DEBUG>("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic());
if (is_periodic()) {
HPET::the().update_periodic_comparator_value();

View file

@ -472,7 +472,7 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
}
u8* dest_ptr = MM.quickmap_page(*page);
dbgln<debug_page_fault>(" >> COW {} <- {}", page->paddr(), page_slot->paddr());
dbgln<PAGE_FAULT_DEBUG>(" >> COW {} <- {}", page->paddr(), page_slot->paddr());
{
SmapDisabler disabler;
void* fault_at;

View file

@ -42,7 +42,7 @@ ContiguousVMObject::ContiguousVMObject(size_t size)
auto contiguous_physical_pages = MM.allocate_contiguous_supervisor_physical_pages(size);
for (size_t i = 0; i < page_count(); i++) {
physical_pages()[i] = contiguous_physical_pages[i];
dbgln<debug_contiguous_vmobject>("Contiguous page[{}]: {}", i, physical_pages()[i]->paddr());
dbgln<CONTIGUOUS_VMOBJECT_DEBUG>("Contiguous page[{}]: {}", i, physical_pages()[i]->paddr());
}
}

View file

@ -79,7 +79,7 @@ Vector<Range, 2> Range::carve(const Range& taken)
if (taken.end() < end())
parts.append({ taken.end(), end().get() - taken.end().get() });
if constexpr (debug_vra) {
if constexpr (VRA_DEBUG) {
dbgln("VRA: carve: take {:x}-{:x} from {:x}-{:x}",
taken.base().get(),
taken.end().get() - 1,
@ -129,13 +129,13 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
Range allocated_range(VirtualAddress(aligned_base), size);
if (available_range == allocated_range) {
dbgln<debug_vra>("VRA: Allocated perfect-fit anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
dbgln<VRA_DEBUG>("VRA: Allocated perfect-fit anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
m_available_ranges.remove(i);
return allocated_range;
}
carve_at_index(i, allocated_range);
if constexpr (debug_vra) {
dbgln<debug_vra>("VRA: Allocated anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
if constexpr (VRA_DEBUG) {
dbgln<VRA_DEBUG>("VRA: Allocated anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
dump();
}
return allocated_range;
@ -161,7 +161,7 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
}
carve_at_index(i, allocated_range);
if constexpr (debug_vra) {
if constexpr (VRA_DEBUG) {
dbgln("VRA: Allocated specific({}): {}", size, available_range.base().get());
dump();
}
@ -179,7 +179,7 @@ void RangeAllocator::deallocate(Range range)
ASSERT(range.size());
ASSERT(range.base() < range.end());
if constexpr (debug_vra) {
if constexpr (VRA_DEBUG) {
dbgln("VRA: Deallocate: {}({})", range.base().get(), range.size());
dump();
}

View file

@ -410,7 +410,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
return PageFaultResponse::ShouldCrash;
}
if (vmobject().is_inode()) {
dbgln<debug_page_fault>("NP(inode) fault in Region({})[{}]", this, page_index_in_region);
dbgln<PAGE_FAULT_DEBUG>("NP(inode) fault in Region({})[{}]", this, page_index_in_region);
return handle_inode_fault(page_index_in_region);
}
@ -435,10 +435,10 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
}
ASSERT(fault.type() == PageFault::Type::ProtectionViolation);
if (fault.access() == PageFault::Access::Write && is_writable() && should_cow(page_index_in_region)) {
dbgln<debug_page_fault>("PV(cow) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
dbgln<PAGE_FAULT_DEBUG>("PV(cow) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
auto* phys_page = physical_page(page_index_in_region);
if (phys_page->is_shared_zero_page() || phys_page->is_lazy_committed_page()) {
dbgln<debug_page_fault>("NP(zero) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
dbgln<PAGE_FAULT_DEBUG>("NP(zero) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
return handle_zero_fault(page_index_in_region);
}
return handle_cow_fault(page_index_in_region);
@ -472,14 +472,14 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
if (page_slot->is_lazy_committed_page()) {
page_slot = static_cast<AnonymousVMObject&>(*m_vmobject).allocate_committed_page(page_index_in_vmobject);
dbgln<debug_page_fault>(" >> ALLOCATED COMMITTED {}", page_slot->paddr());
dbgln<PAGE_FAULT_DEBUG>(" >> ALLOCATED COMMITTED {}", page_slot->paddr());
} else {
page_slot = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
if (page_slot.is_null()) {
klog() << "MM: handle_zero_fault was unable to allocate a physical page";
return PageFaultResponse::OutOfMemory;
}
dbgln<debug_page_fault>(" >> ALLOCATED {}", page_slot->paddr());
dbgln<PAGE_FAULT_DEBUG>(" >> ALLOCATED {}", page_slot->paddr());
}
if (!remap_vmobject_page(page_index_in_vmobject)) {
@ -518,10 +518,10 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region);
auto& vmobject_physical_page_entry = inode_vmobject.physical_pages()[page_index_in_vmobject];
dbgln<debug_page_fault>("Inode fault in {} page index: {}", name(), page_index_in_region);
dbgln<PAGE_FAULT_DEBUG>("Inode fault in {} page index: {}", name(), page_index_in_region);
if (!vmobject_physical_page_entry.is_null()) {
dbgln<debug_page_fault>("MM: page_in_from_inode() but page already present. Fine with me!");
dbgln<PAGE_FAULT_DEBUG>("MM: page_in_from_inode() but page already present. Fine with me!");
if (!remap_vmobject_page(page_index_in_vmobject))
return PageFaultResponse::OutOfMemory;
return PageFaultResponse::Continue;

View file

@ -37,22 +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;
dbgln<debug_waitqueue>("WaitQueue @ {}: do not block thread {}, wake was pending", this, data);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: do not block thread {}, wake was pending", this, data);
return false;
}
dbgln<debug_waitqueue>("WaitQueue @ {}: should block thread {}", this, data);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: should block thread {}", this, data);
return true;
}
void WaitQueue::wake_one()
{
ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one", this);
dbgln<WAITQUEUE_DEBUG>("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);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_one unblocking {}", this, data);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_one unblocking {}", this, data);
if (blocker.unblock()) {
stop_iterating = true;
return true;
@ -67,14 +67,14 @@ u32 WaitQueue::wake_n(u32 wake_count)
if (wake_count == 0)
return 0; // should we assert instead?
ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n({})", this, wake_count);
dbgln<WAITQUEUE_DEBUG>("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);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_n unblocking {}", this, data);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_n unblocking {}", this, data);
ASSERT(did_wake < wake_count);
if (blocker.unblock()) {
if (++did_wake >= wake_count)
@ -91,7 +91,7 @@ u32 WaitQueue::wake_all()
{
ScopedSpinLock lock(m_lock);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all", this);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_all", this);
u32 did_wake = 0;
bool did_unblock_any = do_unblock([&](Thread::Blocker& b, void* data, bool&) {
@ -99,7 +99,7 @@ u32 WaitQueue::wake_all()
ASSERT(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
dbgln<debug_waitqueue>("WaitQueue @ {}: wake_all unblocking {}", this, data);
dbgln<WAITQUEUE_DEBUG>("WaitQueue @ {}: wake_all unblocking {}", this, data);
if (blocker.unblock()) {
did_wake++;