diff --git a/AK/Debug.h b/AK/Debug.h index 803951ea2f3..80ac26ec837 100644 --- a/AK/Debug.h +++ b/AK/Debug.h @@ -213,3 +213,45 @@ constexpr bool debug_io = true; #else constexpr bool debug_io = false; #endif + +#ifdef FORK_DEBUG +constexpr bool debug_fork = true; +#else +constexpr bool debug_fork = false; +#endif + +#ifdef DEBUG_POLL_SELECT +constexpr bool debug_poll_select = true; +#else +constexpr bool debug_poll_select = false; +#endif + +#ifdef HPET_DEBUG +constexpr bool debug_hpet = true; +#else +constexpr bool debug_hpet = false; +#endif + +#ifdef HPET_COMPARATOR_DEBUG +constexpr bool debug_hpet_comperator = true; +#else +constexpr bool debug_hpet_comperator = false; +#endif + +#ifdef MASTERPTY_DEBUG +constexpr bool debug_masterpty = true; +#else +constexpr bool debug_masterpty = false; +#endif + +#ifdef SLAVEPTY_DEBUG +constexpr bool debug_slavepty = true; +#else +constexpr bool debug_slavepty = false; +#endif + +#ifdef PTMX_DEBUG +constexpr bool debug_ptmx = true; +#else +constexpr bool debug_ptmx = false; +#endif diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 05e61b3c582..2641b1ab959 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -24,13 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include #include -//#define FORK_DEBUG - namespace Kernel { pid_t Process::sys$fork(RegisterState& regs) @@ -51,9 +50,7 @@ pid_t Process::sys$fork(RegisterState& regs) child->m_pg = m_pg; child->m_umask = m_umask; -#ifdef FORK_DEBUG - dbg() << "fork: child=" << child; -#endif + dbgln("fork: child={}", child); child->m_extra_gids = m_extra_gids; @@ -82,9 +79,7 @@ pid_t Process::sys$fork(RegisterState& regs) { ScopedSpinLock lock(m_lock); for (auto& region : m_regions) { -#ifdef FORK_DEBUG - dbg() << "fork: cloning Region{" << ®ion << "} '" << region.name() << "' @ " << region.vaddr(); -#endif + dbgln("fork: cloning Region({}) '{}' @ {}", ®ion, region.name(), region.vaddr()); auto region_clone = region.clone(*child); if (!region_clone) { dbgln("fork: Cannot clone region, insufficient memory"); diff --git a/Kernel/Syscalls/open.cpp b/Kernel/Syscalls/open.cpp index abcc413f01f..8da12548a6f 100644 --- a/Kernel/Syscalls/open.cpp +++ b/Kernel/Syscalls/open.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -61,9 +62,8 @@ int Process::sys$open(Userspace user_params) auto path = get_syscall_path_argument(params.path); if (path.is_error()) return path.error(); -#ifdef DEBUG_IO - dbg() << "sys$open(dirfd=" << dirfd << ", path=\"" << path.value() << "\", options=" << options << ", mode=" << mode << ")"; -#endif + + dbgln("sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode); int fd = alloc_fd(); if (fd < 0) return fd; @@ -99,9 +99,7 @@ int Process::sys$close(int fd) { REQUIRE_PROMISE(stdio); auto description = file_description(fd); -#ifdef DEBUG_IO - dbg() << "sys$close(" << fd << ") " << description.ptr(); -#endif + dbgln("sys$close({}) {}", fd, description.ptr()); if (!description) return -EBADF; int rc = description->close(); diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index 0e8c8209751..4b1b1f6902d 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -24,11 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -//#define DEBUG_IO - namespace Kernel { ssize_t Process::sys$read(int fd, Userspace buffer, ssize_t size) @@ -38,9 +37,7 @@ ssize_t Process::sys$read(int fd, Userspace buffer, ssize_t size) return -EINVAL; if (size == 0) return 0; -#ifdef DEBUG_IO - dbg() << "sys$read(" << fd << ", " << (const void*)buffer.ptr() << ", " << size << ")"; -#endif + dbgln("sys$read({}, {}, {})", fd, buffer.ptr(), size); auto description = file_description(fd); if (!description) return -EBADF; diff --git a/Kernel/Syscalls/select.cpp b/Kernel/Syscalls/select.cpp index 9b6855d7c1c..8a0d9a1f929 100644 --- a/Kernel/Syscalls/select.cpp +++ b/Kernel/Syscalls/select.cpp @@ -24,14 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include #include -//#define DEBUG_IO -//#define DEBUG_POLL_SELECT - namespace Kernel { int Process::sys$select(const Syscall::SC_select_params* user_params) @@ -97,14 +95,11 @@ int Process::sys$select(const Syscall::SC_select_params* user_params) fds.append(fd); } -#if defined(DEBUG_IO) || defined(DEBUG_POLL_SELECT) - dbg() << "selecting on " << fds_info.size() << " fds, timeout=" << params.timeout; -#endif + if constexpr (debug_io || debug_poll_select) + dbgln("selecting on {} fds, timeout={}", fds_info.size(), params.timeout); if (current_thread->block(timeout, fds_info).was_interrupted()) { -#ifdef DEBUG_POLL_SELECT - dbgln("select was interrupted"); -#endif + dbgln("select was interrupted"); return -EINTR; } @@ -203,9 +198,8 @@ int Process::sys$poll(Userspace user_params) current_thread->update_signal_mask(previous_signal_mask); }); -#if defined(DEBUG_IO) || defined(DEBUG_POLL_SELECT) - dbg() << "polling on " << fds_info.size() << " fds, timeout=" << params.timeout; -#endif + if constexpr (debug_io || debug_poll_select) + dbgln("polling on {} fds, timeout={}", fds_info.size(), params.timeout); if (current_thread->block(timeout, fds_info).was_interrupted()) return -EINTR; diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp index ea6fb3248a4..e3090766bea 100644 --- a/Kernel/Syscalls/waitid.cpp +++ b/Kernel/Syscalls/waitid.cpp @@ -24,10 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include -//#define PROCESS_DEBUG - namespace Kernel { KResultOr Process::do_waitid(idtype_t idtype, int id, int options) @@ -56,9 +55,7 @@ pid_t Process::sys$waitid(Userspace user_param if (!copy_from_user(¶ms, user_params)) return -EFAULT; -#ifdef PROCESS_DEBUG - dbg() << "sys$waitid(" << params.idtype << ", " << params.id << ", " << params.infop << ", " << params.options << ")"; -#endif + dbgln("sys$waitid({}, {}, {}, {})", params.idtype, params.id, params.infop, params.options); auto siginfo_or_error = do_waitid(static_cast(params.idtype), params.id, params.options); if (siginfo_or_error.is_error()) diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp index f6c25e2e981..326bc797c72 100644 --- a/Kernel/Syscalls/write.cpp +++ b/Kernel/Syscalls/write.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -124,9 +125,7 @@ ssize_t Process::sys$write(int fd, const u8* data, ssize_t size) if (size == 0) return 0; -#ifdef DEBUG_IO - dbg() << "sys$write(" << fd << ", " << (const void*)(data) << ", " << size << ")"; -#endif + dbgln("sys$write({}, {}, {})", fd, data, size); auto description = file_description(fd); if (!description) return -EBADF; diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index 538b4716992..79512b40a2a 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -27,13 +27,12 @@ #include "MasterPTY.h" #include "PTYMultiplexer.h" #include "SlavePTY.h" +#include #include #include #include #include -//#define MASTERPTY_DEBUG - namespace Kernel { MasterPTY::MasterPTY(unsigned index) @@ -54,9 +53,7 @@ MasterPTY::MasterPTY(unsigned index) MasterPTY::~MasterPTY() { -#ifdef MASTERPTY_DEBUG - dbg() << "~MasterPTY(" << m_index << ")"; -#endif + dbgln("~MasterPTY({})", m_index); PTYMultiplexer::the().notify_master_destroyed({}, m_index); } @@ -94,9 +91,7 @@ bool MasterPTY::can_write(const FileDescription&, size_t) const void MasterPTY::notify_slave_closed(Badge) { -#ifdef MASTERPTY_DEBUG - dbg() << "MasterPTY(" << m_index << "): slave closed, my retains: " << ref_count() << ", slave retains: " << m_slave->ref_count(); -#endif + dbgln("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) diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp index 3ccf768b6d9..65e0e6339ca 100644 --- a/Kernel/TTY/PTYMultiplexer.cpp +++ b/Kernel/TTY/PTYMultiplexer.cpp @@ -26,13 +26,12 @@ #include "PTYMultiplexer.h" #include "MasterPTY.h" +#include #include #include #include #include -//#define PTMX_DEBUG - namespace Kernel { static const unsigned s_max_pty_pairs = 8; @@ -62,9 +61,7 @@ KResultOr> PTYMultiplexer::open(int options) return EBUSY; auto master_index = m_freelist.take_last(); auto master = adopt(*new MasterPTY(master_index)); -#ifdef PTMX_DEBUG - dbg() << "PTYMultiplexer::open: Vending master " << master->index(); -#endif + dbgln("PTYMultiplexer::open: Vending master {}", master->index()); auto description = FileDescription::create(move(master)); if (!description.is_error()) { description.value()->set_rw_mode(options); @@ -77,9 +74,7 @@ void PTYMultiplexer::notify_master_destroyed(Badge, unsigned index) { LOCKER(m_lock); m_freelist.append(index); -#ifdef PTMX_DEBUG - dbg() << "PTYMultiplexer: " << index << " added to freelist"; -#endif + dbgln("PTYMultiplexer: {} added to freelist", index); } } diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index 8d74137d69d..a4704616dd7 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -26,11 +26,10 @@ #include "SlavePTY.h" #include "MasterPTY.h" +#include #include #include -//#define SLAVEPTY_DEBUG - namespace Kernel { SlavePTY::SlavePTY(MasterPTY& master, unsigned index) @@ -48,9 +47,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index) SlavePTY::~SlavePTY() { -#ifdef SLAVEPTY_DEBUG - dbg() << "~SlavePTY(" << m_index << ")"; -#endif + dbgln("~SlavePTY({})", m_index); DevPtsFS::unregister_slave_pty(*this); } diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index c4d0c7adbdc..ea29c56736e 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -207,9 +208,10 @@ 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(); -#ifdef HPET_DEBUG - dbg() << "HPET: Update periodic comparator " << comparator.comparator_number() << " comparator value to " << value << " main value was: " << previous_main_value; -#endif + dbgln("HPET: Update periodic comparator {} comparator value to {} main value was: {}", + comparator.comparator_number(), + value, + previous_main_value); timer.comparator_value.low = (u32)value; timer.capabilities = timer.capabilities | (u32)HPETFlags::TimerConfiguration::ValueSet; timer.comparator_value.high = (u32)(value >> 32); @@ -217,9 +219,11 @@ 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; -#ifdef HPET_DEBUG - dbg() << "HPET: Update non-periodic comparator " << comparator.comparator_number() << " comparator value from " << current_value << " to " << value << " main value was: " << previous_main_value; -#endif + dbgln("HPET: Update non-periodic comparator {} comparator value from {} to {} main value was: {}", + comparator.comparator_number(), + current_value, + value, + previous_main_value); timer.comparator_value.low = (u32)value; timer.comparator_value.high = (u32)(value >> 32); } diff --git a/Kernel/Time/HPETComparator.cpp b/Kernel/Time/HPETComparator.cpp index 7e9196cc6d4..85b0080779c 100644 --- a/Kernel/Time/HPETComparator.cpp +++ b/Kernel/Time/HPETComparator.cpp @@ -24,12 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include -//#define HPET_COMPARATOR_DEBUG - namespace Kernel { NonnullRefPtr HPETComparator::create(u8 number, u8 irq, bool periodic_capable) @@ -110,9 +109,7 @@ bool HPETComparator::try_to_set_frequency(size_t frequency) m_frequency = frequency; m_enabled = true; -#ifdef HPET_COMPARATOR_DEBUG - dbg() << "HPET Comparator: Max frequency " << hpet_frequency << " Hz, want to set " << frequency << " Hz, periodic: " << is_periodic(); -#endif + dbgln("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic()); if (is_periodic()) { HPET::the().update_periodic_comparator_value();