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.Everything:
This commit is contained in:
asynts 2021-01-10 16:21:56 +01:00 committed by Andreas Kling
parent 5931758dbc
commit 723effd051
Notes: sideshowbarker 2024-07-18 23:56:36 +09:00
13 changed files with 55 additions and 48 deletions

View file

@ -396,6 +396,7 @@ template<typename... Parameters>
void dbgln(StringView fmtstr, const Parameters&... parameters) { vdbgln(fmtstr, VariadicFormatParams { parameters... }); }
template<typename... Parameters>
void dbgln(const char* fmtstr, const Parameters&... parameters) { dbgln(StringView { fmtstr }, parameters...); }
inline void dbgln() { dbgln(""); }
template<typename T, typename = void>
struct HasFormatter : TrueType {

View file

@ -63,7 +63,7 @@ KResultOr<u32> Process::peek_user_data(Userspace<const u32*> address)
// process that called PT_PEEK
ProcessPagingScope scope(*this);
if (!copy_from_user(&result, address)) {
dbg() << "Invalid address for peek_user_data: " << address.ptr();
dbgln("Invalid address for peek_user_data: {}", address.ptr());
return KResult(-EFAULT);
}

View file

@ -91,7 +91,7 @@ int Process::sys$select(const Syscall::SC_select_params* user_params)
auto description = file_description(fd);
if (!description) {
dbg() << "sys$select: Bad fd number " << fd;
dbgln("sys$select: Bad fd number {}", fd);
return -EBADF;
}
fds_info.append({ description.release_nonnull(), (Thread::FileBlocker::BlockFlags)block_flags });
@ -183,7 +183,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
auto& pfd = fds_copy[i];
auto description = file_description(pfd.fd);
if (!description) {
dbg() << "sys$poll: Bad fd number " << pfd.fd;
dbgln("sys$poll: Bad fd number {}", pfd.fd);
return -EBADF;
}
u32 block_flags = (u32)Thread::FileBlocker::BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL

View file

@ -154,22 +154,22 @@ void TTY::emit(u8 ch, bool do_evaluate_block_conditions)
{
if (should_generate_signals()) {
if (ch == m_termios.c_cc[VINFO]) {
dbg() << tty_name() << ": VINFO pressed!";
dbgln("{}: VINFO pressed!", tty_name());
generate_signal(SIGINFO);
return;
}
if (ch == m_termios.c_cc[VINTR]) {
dbg() << tty_name() << ": VINTR pressed!";
dbgln("{}: VINTR pressed!", tty_name());
generate_signal(SIGINT);
return;
}
if (ch == m_termios.c_cc[VQUIT]) {
dbg() << tty_name() << ": VQUIT pressed!";
dbgln("{}: VQUIT pressed!", tty_name());
generate_signal(SIGQUIT);
return;
}
if (ch == m_termios.c_cc[VSUSP]) {
dbg() << tty_name() << ": VSUSP pressed!";
dbgln("{}: VSUSP pressed!", tty_name());
generate_signal(SIGTSTP);
if (auto original_process_parent = m_original_process_parent.strong_ref()) {
[[maybe_unused]] auto rc = original_process_parent->send_signal(SIGCHLD, nullptr);
@ -284,10 +284,10 @@ void TTY::generate_signal(int signal)
return;
if (should_flush_on_signal())
flush_input();
dbg() << tty_name() << ": Send signal " << signal << " to everyone in pgrp " << pgid().value();
dbgln("{}: Send signal {} to everyone in pgrp {}", tty_name(), signal, pgid().value());
InterruptDisabler disabler; // FIXME: Iterate over a set of process handles instead?
Process::for_each_in_pgrp(pgid(), [&](auto& process) {
dbg() << tty_name() << ": Send signal " << signal << " to " << process;
dbgln("{}: Send signal {} to {}", tty_name(), signal, process);
// FIXME: Should this error be propagated somehow?
[[maybe_unused]] auto rc = process.send_signal(signal, nullptr);
return IterationDecision::Continue;

View file

@ -100,7 +100,7 @@ void VirtualConsole::switch_to(unsigned index)
}
active_console->set_active(false);
}
dbg() << "VC: Switch to " << index << " (" << s_consoles[index] << ")";
dbgln("VC: Switch to {} ({})", index, s_consoles[index]);
s_active_console = index;
s_consoles[s_active_console]->set_active(true);
}

View file

@ -101,7 +101,7 @@ bool HPETComparator::try_to_set_frequency(size_t frequency)
{
InterruptDisabler disabler;
if (!is_capable_of_frequency(frequency)) {
dbg() << "HPETComparator: not cable of frequency: " << frequency;
dbgln("HPETComparator: not cable of frequency: {}", frequency);
return false;
}

View file

@ -82,10 +82,10 @@ bool RealTimeClock::try_to_set_frequency(size_t frequency)
disable_irq();
u8 previous_rate = CMOS::read(0x8A);
u8 rate = quick_log2(32768 / frequency) + 1;
dbg() << "RTC: Set rate to " << rate;
dbgln("RTC: Set rate to {}", rate);
CMOS::write(0x8A, (previous_rate & 0xF0) | rate);
m_frequency = frequency;
dbg() << "RTC: Set frequency to " << frequency << " Hz";
dbgln("RTC: Set frequency to {} Hz", frequency);
enable_irq();
return true;
}

View file

@ -90,7 +90,7 @@ NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(Ph
RefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
{
if (paddr.offset(size) < paddr) {
dbg() << "Shenanigans! create_for_physical_range(" << paddr << ", " << size << ") would wrap around";
dbgln("Shenanigans! create_for_physical_range({}, {}) would wrap around", paddr, size);
return nullptr;
}
return adopt(*new AnonymousVMObject(paddr, size));
@ -482,9 +482,11 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
void* fault_at;
if (!safe_memcpy(dest_ptr, vaddr.as_ptr(), PAGE_SIZE, fault_at)) {
if ((u8*)fault_at >= dest_ptr && (u8*)fault_at <= dest_ptr + PAGE_SIZE)
dbg() << " >> COW: error copying page " << page_slot->paddr() << "/" << vaddr << " to " << page->paddr() << "/" << VirtualAddress(dest_ptr) << ": failed to write to page at " << VirtualAddress(fault_at);
dbgln(" >> COW: error copying page {}/{} to {}/{}: failed to write to page at {}",
page_slot->paddr(), vaddr, page->paddr(), VirtualAddress(dest_ptr), VirtualAddress(fault_at));
else if ((u8*)fault_at >= vaddr.as_ptr() && (u8*)fault_at <= vaddr.as_ptr() + PAGE_SIZE)
dbg() << " >> COW: error copying page " << page_slot->paddr() << "/" << vaddr << " to " << page->paddr() << "/" << VirtualAddress(dest_ptr) << ": failed to read from page at " << VirtualAddress(fault_at);
dbgln(" >> COW: error copying page {}/{} to {}/{}: failed to read from page at {}",
page_slot->paddr(), vaddr, page->paddr(), VirtualAddress(dest_ptr), VirtualAddress(fault_at));
else
ASSERT_NOT_REACHED();
}

View file

@ -74,7 +74,7 @@ size_t InodeVMObject::amount_dirty() const
void InodeVMObject::inode_size_changed(Badge<Inode>, size_t old_size, size_t new_size)
{
dbg() << "VMObject::inode_size_changed: {" << m_inode->fsid() << ":" << m_inode->index() << "} " << old_size << " -> " << new_size;
dbgln("VMObject::inode_size_changed: ({}:{}) {} -> {}", m_inode->fsid(), m_inode->index(), old_size, new_size);
InterruptDisabler disabler;

View file

@ -243,7 +243,7 @@ PageTableEntry* MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual
bool did_purge = false;
auto page_table = allocate_user_physical_page(ShouldZeroFill::Yes, &did_purge);
if (!page_table) {
dbg() << "MM: Unable to allocate page table to map " << vaddr;
dbgln("MM: Unable to allocate page table to map {}", vaddr);
return nullptr;
}
if (did_purge) {
@ -382,7 +382,8 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
ASSERT_INTERRUPTS_DISABLED();
ScopedSpinLock lock(s_mm_lock);
if (Processor::current().in_irq()) {
dbg() << "CPU[" << Processor::current().id() << "] BUG! Page fault while handling IRQ! code=" << fault.code() << ", vaddr=" << fault.vaddr() << ", irq level: " << Processor::current().in_irq();
dbgln("CPU[{}] BUG! Page fault while handling IRQ! code={}, vaddr={}, irq level: {}",
Processor::current().id(), fault.code(), fault.vaddr(), Processor::current().in_irq());
dump_kernel_regions();
return PageFaultResponse::ShouldCrash;
}
@ -808,14 +809,14 @@ bool MemoryManager::validate_range(const Process& process, VirtualAddress base_v
ASSERT(s_mm_lock.is_locked());
ASSERT(size);
if (base_vaddr > base_vaddr.offset(size)) {
dbg() << "Shenanigans! Asked to validate wrappy " << base_vaddr << " size=" << size;
dbgln("Shenanigans! Asked to validate wrappy {} size={}", base_vaddr, size);
return false;
}
VirtualAddress vaddr = base_vaddr.page_base();
VirtualAddress end_vaddr = base_vaddr.offset(size - 1).page_base();
if (end_vaddr < vaddr) {
dbg() << "Shenanigans! Asked to validate " << base_vaddr << " size=" << size;
dbgln("Shenanigans! Asked to validate {} size={}", base_vaddr, size);
return false;
}
const Region* region = nullptr;

View file

@ -63,9 +63,9 @@ RangeAllocator::~RangeAllocator()
void RangeAllocator::dump() const
{
ASSERT(m_lock.is_locked());
dbg() << "RangeAllocator{" << this << "}";
dbgln("RangeAllocator({})", this);
for (auto& range : m_available_ranges) {
dbg() << " " << String::format("%x", range.base().get()) << " -> " << String::format("%x", range.end().get() - 1);
dbgln(" {:x} -> {:x}", range.base().get(), range.end().get() - 1);
}
}
@ -161,7 +161,7 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
#endif
return allocated_range;
}
dbg() << "VRA: Failed to allocate specific range: " << base << "(" << size << ")";
dbgln("VRA: Failed to allocate specific range: {}({})", base, size);
return {};
}

View file

@ -437,11 +437,11 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
auto page_index_in_region = page_index_from_address(fault.vaddr());
if (fault.type() == PageFault::Type::PageNotPresent) {
if (fault.is_read() && !is_readable()) {
dbg() << "NP(non-readable) fault in Region{" << this << "}[" << page_index_in_region << "]";
dbgln("NP(non-readable) fault in Region({})[{}]", this, page_index_in_region);
return PageFaultResponse::ShouldCrash;
}
if (fault.is_write() && !is_writable()) {
dbg() << "NP(non-writable) write fault in Region{" << this << "}[" << page_index_in_region << "] at " << fault.vaddr();
dbgln("NP(non-writable) write fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
return PageFaultResponse::ShouldCrash;
}
if (vmobject().is_inode()) {
@ -466,7 +466,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
}
return handle_zero_fault(page_index_in_region);
#else
dbg() << "BUG! Unexpected NP fault at " << fault.vaddr();
dbgln("BUG! Unexpected NP fault at {}", fault.vaddr());
return PageFaultResponse::ShouldCrash;
#endif
}
@ -484,7 +484,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
}
return handle_cow_fault(page_index_in_region);
}
dbg() << "PV(error) fault in Region{" << this << "}[" << page_index_in_region << "] at " << fault.vaddr();
dbgln("PV(error) fault in Region({})[{}] at {}", this, page_index_in_region, fault.vaddr());
return PageFaultResponse::ShouldCrash;
}
@ -608,7 +608,10 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
void* fault_at;
if (!safe_memcpy(dest_ptr, page_buffer, PAGE_SIZE, fault_at)) {
if ((u8*)fault_at >= dest_ptr && (u8*)fault_at <= dest_ptr + PAGE_SIZE)
dbg() << " >> inode fault: error copying data to " << vmobject_physical_page_entry->paddr() << "/" << VirtualAddress(dest_ptr) << ", failed at " << VirtualAddress(fault_at);
dbgln(" >> inode fault: error copying data to {}/{}, failed at {}",
vmobject_physical_page_entry->paddr(),
VirtualAddress(dest_ptr),
VirtualAddress(fault_at));
else
ASSERT_NOT_REACHED();
}

View file

@ -449,24 +449,24 @@ void __malloc_init()
void serenity_dump_malloc_stats()
{
dbg() << "# malloc() calls: " << g_malloc_stats.number_of_malloc_calls;
dbg();
dbg() << "big alloc hits: " << g_malloc_stats.number_of_big_allocator_hits;
dbg() << "big alloc hits that were purged: " << g_malloc_stats.number_of_big_allocator_purge_hits;
dbg() << "big allocs: " << g_malloc_stats.number_of_big_allocs;
dbg();
dbg() << "empty block hits: " << g_malloc_stats.number_of_empty_block_hits;
dbg() << "empty block hits that were purged: " << g_malloc_stats.number_of_empty_block_purge_hits;
dbg() << "block allocs: " << g_malloc_stats.number_of_block_allocs;
dbg() << "filled blocks: " << g_malloc_stats.number_of_blocks_full;
dbg();
dbg() << "# free() calls: " << g_malloc_stats.number_of_free_calls;
dbg();
dbg() << "big alloc keeps: " << g_malloc_stats.number_of_big_allocator_keeps;
dbg() << "big alloc frees: " << g_malloc_stats.number_of_big_allocator_frees;
dbg();
dbg() << "full block frees: " << g_malloc_stats.number_of_freed_full_blocks;
dbg() << "number of keeps: " << g_malloc_stats.number_of_keeps;
dbg() << "number of frees: " << g_malloc_stats.number_of_frees;
dbgln("# malloc() calls: {}", g_malloc_stats.number_of_malloc_calls);
dbgln();
dbgln("big alloc hits: {}", g_malloc_stats.number_of_big_allocator_hits);
dbgln("big alloc hits that were purged: {}", g_malloc_stats.number_of_big_allocator_purge_hits);
dbgln("big allocs: {}", g_malloc_stats.number_of_big_allocs);
dbgln();
dbgln("empty block hits: {}", g_malloc_stats.number_of_empty_block_hits);
dbgln("empty block hits that were purged: {}", g_malloc_stats.number_of_empty_block_purge_hits);
dbgln("block allocs: {}", g_malloc_stats.number_of_block_allocs);
dbgln("filled blocks: {}", g_malloc_stats.number_of_blocks_full);
dbgln();
dbgln("# free() calls: {}", g_malloc_stats.number_of_free_calls);
dbgln();
dbgln("big alloc keeps: {}", g_malloc_stats.number_of_big_allocator_keeps);
dbgln("big alloc frees: {}", g_malloc_stats.number_of_big_allocator_frees);
dbgln();
dbgln("full block frees: {}", g_malloc_stats.number_of_freed_full_blocks);
dbgln("number of keeps: {}", g_malloc_stats.number_of_keeps);
dbgln("number of frees: {}", g_malloc_stats.number_of_frees);
}
}