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:
asynts 2021-01-15 21:29:01 +01:00 committed by Andreas Kling
parent 7b0a1a98d9
commit 27bc48e06c
11 changed files with 116 additions and 109 deletions

View file

@ -255,3 +255,45 @@ constexpr bool debug_ptmx = true;
#else
constexpr bool debug_ptmx = false;
#endif
#ifdef TTY_DEBUG
constexpr bool debug_tty = true;
#else
constexpr bool debug_tty = false;
#endif
#ifdef CONTIGUOUS_VMOBJECT_DEBUG
constexpr bool debug_contiguous_vmobject = true;
#else
constexpr bool debug_contiguous_vmobject = false;
#endif
#ifdef VRA_DEBUG
constexpr bool debug_vra = true;
#else
constexpr bool debug_vra = false;
#endif
#ifdef COPY_DEBUG
constexpr bool debug_copy = true;
#else
constexpr bool debug_copy = false;
#endif
#ifdef DEBUG_CURSOR_TOOL
constexpr bool debug_cursor_tool = true;
#else
constexpr bool debug_cursor_tool = false;
#endif
#ifdef DEBUG_FILE_CONTENT
constexpr bool debug_file_content = true;
#else
constexpr bool debug_file_content = false;
#endif
#ifdef DEBUG_GZIP
constexpr bool debug_gzip = true;
#else
constexpr bool debug_gzip = false;
#endif

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/ScopeGuard.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/TTY.h>
@ -304,19 +305,19 @@ void TTY::flush_input()
void TTY::set_termios(const termios& t)
{
m_termios = t;
#ifdef TTY_DEBUG
dbg() << tty_name() << " set_termios: "
<< "ECHO=" << should_echo_input()
<< ", ISIG=" << should_generate_signals()
<< ", ICANON=" << in_canonical_mode()
<< ", ECHOE=" << ((m_termios.c_lflag & ECHOE) != 0)
<< ", ECHOK=" << ((m_termios.c_lflag & ECHOK) != 0)
<< ", ECHONL=" << ((m_termios.c_lflag & ECHONL) != 0)
<< ", ISTRIP=" << ((m_termios.c_iflag & ISTRIP) != 0)
<< ", ICRNL=" << ((m_termios.c_iflag & ICRNL) != 0)
<< ", INLCR=" << ((m_termios.c_iflag & INLCR) != 0)
<< ", IGNCR=" << ((m_termios.c_iflag & IGNCR) != 0);
#endif
dbgln<debug_tty>("{} set_termios: ECHO={}, ISIG={}, ICANON={}, ECHOE={}, ECHOK={}, ECHONL={}, ISTRIP={}, ICRNL={}, INLCR={}, IGNCR={}",
tty_name(),
should_echo_input(),
should_generate_signals(),
in_canonical_mode(),
((m_termios.c_lflag & ECHOE) != 0),
((m_termios.c_lflag & ECHOK) != 0),
((m_termios.c_lflag & ECHONL) != 0),
((m_termios.c_iflag & ISTRIP) != 0),
((m_termios.c_iflag & ICRNL) != 0),
((m_termios.c_iflag & INLCR) != 0),
((m_termios.c_iflag & IGNCR) != 0));
}
int TTY::ioctl(FileDescription&, unsigned request, FlatPtr arg)

View file

@ -24,14 +24,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <Kernel/Process.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PhysicalPage.h>
//#define COMMIT_DEBUG
//#define PAGE_FAULT_DEBUG
namespace Kernel {
RefPtr<VMObject> AnonymousVMObject::clone()
@ -474,9 +472,7 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
}
u8* dest_ptr = MM.quickmap_page(*page);
#ifdef PAGE_FAULT_DEBUG
dbg() << " >> COW " << page->paddr() << " <- " << page_slot->paddr();
#endif
dbgln<debug_page_fault>(" >> COW {} <- {}", page->paddr(), page_slot->paddr());
{
SmapDisabler disabler;
void* fault_at;

View file

@ -24,14 +24,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <Kernel/VM/ContiguousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PhysicalPage.h>
namespace Kernel {
//#define CONTIGUOUS_VMOBJECT_DEBUG
NonnullRefPtr<ContiguousVMObject> ContiguousVMObject::create_with_size(size_t size)
{
return adopt(*new ContiguousVMObject(size));
@ -43,9 +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];
#ifdef CONTIGUOUS_VMOBJECT_DEBUG
dbg() << "Contiguous page[" << i << "]: " << physical_pages()[i]->paddr();
#endif
dbgln<debug_contiguous_vmobject>("Contiguous page[{}]: {}", i, physical_pages()[i]->paddr());
}
}

View file

@ -25,12 +25,12 @@
*/
#include <AK/BinarySearch.h>
#include <AK/Debug.h>
#include <AK/QuickSort.h>
#include <Kernel/Random.h>
#include <Kernel/Thread.h>
#include <Kernel/VM/RangeAllocator.h>
//#define VRA_DEBUG
#define VM_GUARD_PAGES
namespace Kernel {
@ -78,11 +78,18 @@ Vector<Range, 2> Range::carve(const Range& taken)
parts.append({ base(), taken.base().get() - base().get() });
if (taken.end() < end())
parts.append({ taken.end(), end().get() - taken.end().get() });
#ifdef VRA_DEBUG
dbg() << "VRA: carve: take " << String::format("%x", taken.base().get()) << "-" << String::format("%x", taken.end().get() - 1) << " from " << String::format("%x", base().get()) << "-" << String::format("%x", end().get() - 1);
for (size_t i = 0; i < parts.size(); ++i)
dbg() << " " << String::format("%x", parts[i].base().get()) << "-" << String::format("%x", parts[i].end().get() - 1);
#endif
if constexpr (debug_vra) {
dbgln("VRA: carve: take {:x}-{:x} from {:x}-{:x}",
taken.base().get(),
taken.end().get() - 1,
base().get(),
end().get() - 1);
for (size_t i = 0; i < parts.size(); ++i)
dbgln(" {:x}-{:x}", parts[i].base().get(), parts[i].end().get() - 1);
}
return parts;
}
@ -122,17 +129,15 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
Range allocated_range(VirtualAddress(aligned_base), size);
if (available_range == allocated_range) {
#ifdef VRA_DEBUG
dbg() << "VRA: Allocated perfect-fit anywhere(" << String::format("%zu", size) << ", " << String::format("%zu", alignment) << "): " << String::format("%x", allocated_range.base().get());
#endif
dbgln<debug_vra>("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);
#ifdef VRA_DEBUG
dbg() << "VRA: Allocated anywhere(" << String::format("%zu", size) << ", " << String::format("%zu", alignment) << "): " << String::format("%x", allocated_range.base().get());
dump();
#endif
if constexpr (debug_vra) {
dbgln<debug_vra>("VRA: Allocated anywhere({}, {}): {}", size, alignment, allocated_range.base().get());
dump();
}
return allocated_range;
}
klog() << "VRA: Failed to allocate anywhere: " << size << ", " << alignment;
@ -155,10 +160,12 @@ Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
return allocated_range;
}
carve_at_index(i, allocated_range);
#ifdef VRA_DEBUG
dbg() << "VRA: Allocated specific(" << size << "): " << String::format("%x", available_range.base().get());
dump();
#endif
if constexpr (debug_vra) {
dbgln("VRA: Allocated specific({}): {}", size, available_range.base().get());
dump();
}
return allocated_range;
}
dbgln("VRA: Failed to allocate specific range: {}({})", base, size);
@ -172,10 +179,10 @@ void RangeAllocator::deallocate(Range range)
ASSERT(range.size());
ASSERT(range.base() < range.end());
#ifdef VRA_DEBUG
dbg() << "VRA: Deallocate: " << String::format("%x", range.base().get()) << "(" << range.size() << ")";
dump();
#endif
if constexpr (debug_vra) {
dbgln("VRA: Deallocate: {}({})", range.base().get(), range.size());
dump();
}
ASSERT(!m_available_ranges.is_empty());

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/Memory.h>
#include <AK/StringView.h>
#include <Kernel/FileSystem/Inode.h>
@ -35,8 +36,6 @@
#include <Kernel/VM/Region.h>
#include <Kernel/VM/SharedInodeVMObject.h>
//#define PAGE_FAULT_DEBUG
namespace Kernel {
Region::Region(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, u8 access, bool cacheable, bool kernel, bool shared)
@ -411,9 +410,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
return PageFaultResponse::ShouldCrash;
}
if (vmobject().is_inode()) {
#ifdef PAGE_FAULT_DEBUG
dbg() << "NP(inode) fault in Region{" << this << "}[" << page_index_in_region << "]";
#endif
dbgln<debug_page_fault>("NP(inode) fault in Region({})[{}]", this, page_index_in_region);
return handle_inode_fault(page_index_in_region);
}
@ -438,14 +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)) {
#ifdef PAGE_FAULT_DEBUG
dbg() << "PV(cow) fault in Region{" << this << "}[" << page_index_in_region << "] at " << fault.vaddr();
#endif
dbgln<debug_page_fault>("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()) {
#ifdef PAGE_FAULT_DEBUG
dbg() << "NP(zero) fault in Region{" << this << "}[" << page_index_in_region << "] at " << fault.vaddr();
#endif
dbgln<debug_page_fault>("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);
@ -479,18 +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);
#ifdef PAGE_FAULT_DEBUG
dbg() << " >> ALLOCATED COMMITTED " << page_slot->paddr();
#endif
dbgln<debug_page_fault>(" >> 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;
}
#ifdef PAGE_FAULT_DEBUG
dbg() << " >> ALLOCATED " << page_slot->paddr();
#endif
dbgln<debug_page_fault>(" >> ALLOCATED {}", page_slot->paddr());
}
if (!remap_vmobject_page(page_index_in_vmobject)) {
@ -529,14 +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];
#ifdef PAGE_FAULT_DEBUG
dbg() << "Inode fault in " << name() << " page index: " << page_index_in_region;
#endif
dbgln<debug_page_fault>("Inode fault in {} page index: {}", name(), page_index_in_region);
if (!vmobject_physical_page_entry.is_null()) {
#ifdef PAGE_FAULT_DEBUG
dbg() << ("MM: page_in_from_inode() but page already present. Fine with me!");
#endif
dbgln<debug_page_fault>("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

@ -28,6 +28,7 @@
#include "JSIntegration.h"
#include "Workbook.h"
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/GenericLexer.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
@ -354,9 +355,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
auto& target = to.first();
for (auto& position : from) {
#ifdef COPY_DEBUG
dbg() << "Paste from '" << position.to_url() << "' to '" << target.to_url() << "'";
#endif
dbgln<debug_copy>("Paste from '{}' to '{}'", position.to_url(), target.to_url());
copy_to(position, resolve_relative_to.has_value() ? offset_relative_to(target, position, resolve_relative_to.value()) : target);
}
@ -367,9 +366,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
// Fill the target selection with the single cell.
auto& source = from.first();
for (auto& position : to) {
#ifdef COPY_DEBUG
dbg() << "Paste from '" << source.to_url() << "' to '" << position.to_url() << "'";
#endif
dbgln<debug_copy>("Paste from '{}' to '{}'", source.to_url(), position.to_url());
copy_to(source, resolve_relative_to.has_value() ? offset_relative_to(position, source, resolve_relative_to.value()) : position);
}
return;

View file

@ -28,11 +28,10 @@
#include "FormEditorWidget.h"
#include "FormWidget.h"
#include "WidgetTreeModel.h"
#include <AK/Debug.h>
#include <AK/LogStream.h>
#include <LibGfx/Palette.h>
//#define DEBUG_CURSOR_TOOL
namespace HackStudio {
void CursorTool::on_mousedown(GUI::MouseEvent& event)
@ -49,9 +48,7 @@ void CursorTool::on_mousedown(GUI::MouseEvent& event)
m_editor.selection().toggle(*result.widget);
} else if (!event.modifiers()) {
if (!m_editor.selection().contains(*result.widget)) {
#ifdef DEBUG_CURSOR_TOOL
dbg() << "Selection didn't contain " << *result.widget << ", making it the only selected one";
#endif
dbgln<debug_cursor_tool>("Selection didn't contain {}, making it the only selected one", *result.widget);
m_editor.selection().set(*result.widget);
}

View file

@ -26,13 +26,11 @@
#include "ClientConnection.h"
#include "AutoComplete.h"
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <LibCore/File.h>
#include <LibGUI/TextDocument.h>
// #define DEBUG_CPP_LANGUAGE_SERVER
// #define DEBUG_FILE_CONTENT
namespace LanguageServers::Cpp {
static HashMap<int, RefPtr<ClientConnection>> s_connections;
@ -89,9 +87,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
auto document = GUI::TextDocument::create(&s_default_document_client);
document->set_text(content_view);
m_open_files.set(message.file_name(), document);
#ifdef DEBUG_FILE_CONTENT
dbg() << document->text();
#endif
dbgln<debug_file_content>("{}", document->text());
}
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)

View file

@ -26,13 +26,11 @@
#include "ClientConnection.h"
#include "AutoComplete.h"
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <LibCore/File.h>
#include <LibGUI/TextDocument.h>
// #define DEBUG_SH_LANGUAGE_SERVER
// #define DEBUG_FILE_CONTENT
namespace LanguageServers::Shell {
static HashMap<int, RefPtr<ClientConnection>> s_connections;
@ -89,9 +87,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
auto document = GUI::TextDocument::create(&s_default_document_client);
document->set_text(content_view);
m_open_files.set(message.file_name(), document);
#ifdef DEBUG_FILE_CONTENT
dbg() << document->text();
#endif
dbgln<debug_file_content>("{}", document->text());
}
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
@ -133,9 +129,7 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText
};
document->remove(range);
#ifdef DEBUG_FILE_CONTENT
dbg() << document->text();
#endif
dbgln<debug_file_content>("{}", document->text());
}
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)

View file

@ -25,14 +25,13 @@
*/
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/Optional.h>
#include <LibCore/Gzip.h>
#include <LibCore/puff.h>
#include <limits.h>
#include <stddef.h>
//#define DEBUG_GZIP
namespace Core {
bool Gzip::is_compressed(const ByteBuffer& data)
@ -103,9 +102,7 @@ static Optional<ByteBuffer> get_gzip_payload(const ByteBuffer& data)
}
auto new_size = data.size() - current;
#ifdef DEBUG_GZIP
dbg() << "get_gzip_payload: Returning slice from " << current << " with size " << new_size;
#endif
dbgln<debug_gzip>("get_gzip_payload: Returning slice from {} with size {}", current, new_size);
return data.slice(current, new_size);
}
@ -113,9 +110,7 @@ Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
{
ASSERT(is_compressed(data));
#ifdef DEBUG_GZIP
dbg() << "Gzip::decompress: Decompressing gzip compressed data. Size = " << data.size();
#endif
dbgln<debug_gzip>("Gzip::decompress: Decompressing gzip compressed data. size={}", data.size());
auto optional_payload = get_gzip_payload(data);
if (!optional_payload.has_value()) {
return Optional<ByteBuffer>();
@ -127,13 +122,13 @@ Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
while (true) {
unsigned long destination_len = destination.size();
#ifdef DEBUG_GZIP
dbg() << "Gzip::decompress: Calling puff()\n"
<< " destination_data = " << destination.data() << "\n"
<< " destination_len = " << destination_len << "\n"
<< " source_data = " << source.data() << "\n"
<< " source_len = " << source_len;
#endif
if constexpr (debug_gzip) {
dbgln("Gzip::decompress: Calling puff()");
dbgln(" destination_data = {}", destination.data());
dbgln(" destination_len = {}", destination_len);
dbgln(" source_data = {}", source.data());
dbgln(" source_len = {}", source_len);
}
auto puff_ret = puff(
destination.data(), &destination_len,