diff --git a/kernel/debug.cmake b/kernel/debug.cmake index b15446a3..01f225a3 100644 --- a/kernel/debug.cmake +++ b/kernel/debug.cmake @@ -3,4 +3,9 @@ target_compile_definitions(moon PRIVATE DEBUG_MODE) target_compile_definitions(moon PRIVATE ELF_DEBUG) target_compile_definitions(moon PRIVATE MMU_DEBUG) target_compile_definitions(moon PRIVATE MMAP_DEBUG) +target_compile_definitions(moon PRIVATE EXEC_DEBUG) +target_compile_definitions(moon PRIVATE OPEN_DEBUG) +target_compile_definitions(moon PRIVATE REAP_DEBUG) +target_compile_definitions(moon PRIVATE PCI_DEBUG) +target_compile_definitions(moon PRIVATE DEVICE_REGISTRY_DEBUG) target_compile_options(moon PRIVATE -fsanitize=undefined) diff --git a/kernel/src/arch/PCI.cpp b/kernel/src/arch/PCI.cpp index 3a7bb6a9..1923ad88 100644 --- a/kernel/src/arch/PCI.cpp +++ b/kernel/src/arch/PCI.cpp @@ -96,12 +96,16 @@ namespace PCI // Single-function PCI bus if ((header_type & 0x80) == 0) { +#ifdef PCI_DEBUG kdbgln("PCI bus is single-function"); +#endif scan_bus(0, { callback, match }); } else { +#ifdef PCI_DEBUG kdbgln("PCI bus is multiple-function"); +#endif for (u32 function = 0; function < 8; function++) { if (read16({ 0, 0, function }, Field::VendorID) != PCI::INVALID_ID) diff --git a/kernel/src/fs/GPT.cpp b/kernel/src/fs/GPT.cpp index f9a8e922..713be6dd 100644 --- a/kernel/src/fs/GPT.cpp +++ b/kernel/src/fs/GPT.cpp @@ -16,8 +16,8 @@ namespace GPT if (memcmp(header.signature, GPT_SIGNATURE, GPT_SIGNATURE_LENGTH)) return false; - kdbgln("gpt: Found GUID partition table on device %s, revision %#.8x, with space for %d partition entries!", - device->device_path().chars(), header.revision, header.num_partitions); + kinfoln("gpt: Found GUID partition table on device %s, revision %#.8x, with space for %d partition entries!", + device->device_path().chars(), header.revision, header.num_partitions); if (header.revision != GPT_REVISION) { @@ -55,7 +55,7 @@ namespace GPT if (!memcmp(entry.type_guid, null_guid, 16)) continue; - kdbgln("gpt: Partition entry #%u is active: start=%lu, end=%lu", i, entry.start_lba, entry.end_lba); + kinfoln("gpt: Partition entry #%u is active: start=%lu, end=%lu", i, entry.start_lba, entry.end_lba); TRY(MBR::PartitionDevice::create(device, entry.start_lba, entry.end_lba - entry.start_lba, partition_index++)); diff --git a/kernel/src/fs/VFS.cpp b/kernel/src/fs/VFS.cpp index 3de5af10..d8e3c6d1 100644 --- a/kernel/src/fs/VFS.cpp +++ b/kernel/src/fs/VFS.cpp @@ -232,7 +232,7 @@ namespace VFS auto parent_path = TRY(parser.dirname()); auto child = TRY(parser.basename()); - kdbgln("vfs: Mounting filesystem on target %s", path); + kinfoln("vfs: Mounting filesystem on target %s", path); auto parent_inode = TRY(resolve_path(parent_path.chars(), auth, working_directory)); @@ -255,7 +255,7 @@ namespace VFS if (child.view() == "/") return err(EBUSY); - kdbgln("vfs: Unmounting filesystem on target %s", path); + kinfoln("vfs: Unmounting filesystem on target %s", path); auto parent_inode = TRY(resolve_path(parent_path.chars(), auth, working_directory)); diff --git a/kernel/src/fs/devices/DeviceRegistry.cpp b/kernel/src/fs/devices/DeviceRegistry.cpp index 116da3cd..5b58243b 100644 --- a/kernel/src/fs/devices/DeviceRegistry.cpp +++ b/kernel/src/fs/devices/DeviceRegistry.cpp @@ -51,7 +51,9 @@ namespace DeviceRegistry const char* name = device->device_path().chars(); +#ifdef DEVICE_REGISTRY_DEBUG kdbgln("DeviceRegistry: registered new device type %u:%u at path /%s in devfs", major, minor, name); +#endif auto desc = DeviceDescriptor { .device = device, .major = major, .minor = minor, .name = name, .mode = mode }; diff --git a/kernel/src/sys/exec.cpp b/kernel/src/sys/exec.cpp index 8cb10be2..1fdc13f5 100644 --- a/kernel/src/sys/exec.cpp +++ b/kernel/src/sys/exec.cpp @@ -66,7 +66,9 @@ Result sys_execve(Registers* regs, SyscallArgs args) if (!VFS::can_execute(inode, current->auth)) return err(EACCES); - kinfoln("exec: attempting to replace current image with %s", path.chars()); +#ifdef EXEC_DEBUG + kdbgln("exec: attempting to replace current image with %s", path.chars()); +#endif auto guard = make_scope_guard([current] { MMU::switch_page_directory(current->directory); }); @@ -80,7 +82,9 @@ Result sys_execve(Registers* regs, SyscallArgs args) // From now on, nothing should fail. - kinfoln("exec: image load ok, will now replace existing process image"); +#ifdef EXEC_DEBUG + kdbgln("exec: image load ok, will now replace existing process image"); +#endif guard.deactivate(); @@ -110,6 +114,8 @@ Result sys_execve(Registers* regs, SyscallArgs args) memcpy(regs, ¤t->regs, sizeof(*regs)); + kinfoln("exec: thread %lu was replaced with %s", current->id, path.chars()); + return 0; } @@ -151,7 +157,9 @@ Result sys_fork(Registers* regs, SyscallArgs) Scheduler::add_thread(thread); - kinfoln("fork: thread %lu forked into child %lu", current->id, thread->id); +#ifdef FORK_DEBUG + kdbgln("fork: thread %lu forked into child %lu", current->id, thread->id); +#endif return thread->id; } diff --git a/kernel/src/sys/open.cpp b/kernel/src/sys/open.cpp index abe904b5..4bb2ffc6 100644 --- a/kernel/src/sys/open.cpp +++ b/kernel/src/sys/open.cpp @@ -74,7 +74,9 @@ Result sys_openat(Registers*, SyscallArgs args) int fd = TRY(current->allocate_fd(0)); - kinfoln("openat: opening file %s from dirfd %d, flags %d, mode %#o = fd %d", path.chars(), dirfd, flags, mode, fd); +#ifdef OPEN_DEBUG + kdbgln("openat: opening file %s from dirfd %d, flags %d, mode %#o = fd %d", path.chars(), dirfd, flags, mode, fd); +#endif inode->add_handle(); diff --git a/kernel/src/thread/ELF.cpp b/kernel/src/thread/ELF.cpp index db0d870f..eac1acfc 100644 --- a/kernel/src/thread/ELF.cpp +++ b/kernel/src/thread/ELF.cpp @@ -73,7 +73,9 @@ namespace ELFLoader return err(ENOEXEC); } - kinfoln("ELF: Loading ELF with entry=%#.16lx", elf_header.e_entry); +#ifdef ELF_DEBUG + kdbgln("ELF: Loading ELF with entry=%#.16lx", elf_header.e_entry); +#endif usize i; Elf64_Phdr program_header; diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index de0ba2f6..090e6ca9 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -171,7 +171,9 @@ namespace Scheduler { CPU::disable_interrupts(); - kinfoln("reap: reaping thread with id %zu", thread->id); +#ifdef REAP_DEBUG + kdbgln("reap: reaping thread with id %zu", thread->id); +#endif if (thread->is_kernel) {