mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
parent
a348ab55b0
commit
7b0a1a98d9
Notes:
sideshowbarker
2024-07-18 22:58:57 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/7b0a1a98d9e Pull-request: https://github.com/SerenityOS/serenity/pull/5012 Reviewed-by: https://github.com/alimpfard
42
AK/Debug.h
42
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
|
||||
|
@ -24,13 +24,12 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/Region.h>
|
||||
|
||||
//#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<debug_fork>("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<debug_fork>("fork: cloning Region({}) '{}' @ {}", ®ion, region.name(), region.vaddr());
|
||||
auto region_clone = region.clone(*child);
|
||||
if (!region_clone) {
|
||||
dbgln("fork: Cannot clone region, insufficient memory");
|
||||
|
@ -24,6 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
@ -61,9 +62,8 @@ int Process::sys$open(Userspace<const Syscall::SC_open_params*> 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<debug_io>("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<debug_io>("sys$close({}) {}", fd, description.ptr());
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
int rc = description->close();
|
||||
|
@ -24,11 +24,10 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
//#define DEBUG_IO
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ssize_t Process::sys$read(int fd, Userspace<u8*> buffer, ssize_t size)
|
||||
@ -38,9 +37,7 @@ ssize_t Process::sys$read(int fd, Userspace<u8*> 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<debug_io>("sys$read({}, {}, {})", fd, buffer.ptr(), size);
|
||||
auto description = file_description(fd);
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
|
@ -24,14 +24,12 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
//#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<Thread::SelectBlocker>(timeout, fds_info).was_interrupted()) {
|
||||
#ifdef DEBUG_POLL_SELECT
|
||||
dbgln("select was interrupted");
|
||||
#endif
|
||||
dbgln<debug_poll_select>("select was interrupted");
|
||||
return -EINTR;
|
||||
}
|
||||
|
||||
@ -203,9 +198,8 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> 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<Thread::SelectBlocker>(timeout, fds_info).was_interrupted())
|
||||
return -EINTR;
|
||||
|
@ -24,10 +24,9 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
//#define PROCESS_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
|
||||
@ -56,9 +55,7 @@ pid_t Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> 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<debug_process>("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())
|
||||
|
@ -24,6 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
@ -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<debug_io>("sys$write({}, {}, {})", fd, data, size);
|
||||
auto description = file_description(fd);
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
|
@ -27,13 +27,12 @@
|
||||
#include "MasterPTY.h"
|
||||
#include "PTYMultiplexer.h"
|
||||
#include "SlavePTY.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
#include <LibC/signal_numbers.h>
|
||||
#include <LibC/sys/ioctl_numbers.h>
|
||||
|
||||
//#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<debug_masterpty>("~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<SlavePTY>)
|
||||
{
|
||||
#ifdef MASTERPTY_DEBUG
|
||||
dbg() << "MasterPTY(" << m_index << "): slave closed, my retains: " << ref_count() << ", slave retains: " << m_slave->ref_count();
|
||||
#endif
|
||||
dbgln<debug_masterpty>("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)
|
||||
|
@ -26,13 +26,12 @@
|
||||
|
||||
#include "PTYMultiplexer.h"
|
||||
#include "MasterPTY.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
//#define PTMX_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static const unsigned s_max_pty_pairs = 8;
|
||||
@ -62,9 +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));
|
||||
#ifdef PTMX_DEBUG
|
||||
dbg() << "PTYMultiplexer::open: Vending master " << master->index();
|
||||
#endif
|
||||
dbgln<debug_ptmx>("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<MasterPTY>, unsigned index)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
m_freelist.append(index);
|
||||
#ifdef PTMX_DEBUG
|
||||
dbg() << "PTYMultiplexer: " << index << " added to freelist";
|
||||
#endif
|
||||
dbgln<debug_ptmx>("PTYMultiplexer: {} added to freelist", index);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,11 +26,10 @@
|
||||
|
||||
#include "SlavePTY.h"
|
||||
#include "MasterPTY.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FileSystem/DevPtsFS.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
//#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<debug_slavepty>("~SlavePTY({})", m_index);
|
||||
DevPtsFS::unregister_slave_pty(*this);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/ACPI/Parser.h>
|
||||
#include <Kernel/Interrupts/InterruptManagement.h>
|
||||
@ -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<debug_hpet>("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<debug_hpet>("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);
|
||||
}
|
||||
|
@ -24,12 +24,11 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/Assertions.h>
|
||||
#include <Kernel/Time/HPETComparator.h>
|
||||
#include <Kernel/Time/TimeManagement.h>
|
||||
|
||||
//#define HPET_COMPARATOR_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<HPETComparator> 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<debug_hpet_comperator>("HPET Comparator: Max frequency {} Hz, want to set {} Hz, periodic: {}", hpet_frequency, frequency, is_periodic());
|
||||
|
||||
if (is_periodic()) {
|
||||
HPET::the().update_periodic_comparator_value();
|
||||
|
Loading…
Reference in New Issue
Block a user