mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr
This commit is contained in:
parent
4e6f03a860
commit
6cf59b6ae9
58 changed files with 315 additions and 469 deletions
|
@ -215,26 +215,20 @@ void Parser::try_acpi_shutdown()
|
||||||
size_t Parser::get_table_size(PhysicalAddress table_header)
|
size_t Parser::get_table_size(PhysicalAddress table_header)
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
#if ACPI_DEBUG
|
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Length");
|
||||||
dbgln("ACPI: Checking SDT Length");
|
|
||||||
#endif
|
|
||||||
return map_typed<Structures::SDTHeader>(table_header)->length;
|
return map_typed<Structures::SDTHeader>(table_header)->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Parser::get_table_revision(PhysicalAddress table_header)
|
u8 Parser::get_table_revision(PhysicalAddress table_header)
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
#if ACPI_DEBUG
|
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Revision");
|
||||||
dbgln("ACPI: Checking SDT Revision");
|
|
||||||
#endif
|
|
||||||
return map_typed<Structures::SDTHeader>(table_header)->revision;
|
return map_typed<Structures::SDTHeader>(table_header)->revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
|
UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
|
||||||
{
|
{
|
||||||
#if ACPI_DEBUG
|
dbgln_if(ACPI_DEBUG, "ACPI: Checking Main SDT Length to choose the correct mapping size");
|
||||||
dbgln("ACPI: Checking Main SDT Length to choose the correct mapping size");
|
|
||||||
#endif
|
|
||||||
VERIFY(!m_main_system_description_table.is_null());
|
VERIFY(!m_main_system_description_table.is_null());
|
||||||
auto length = get_table_size(m_main_system_description_table);
|
auto length = get_table_size(m_main_system_description_table);
|
||||||
auto revision = get_table_revision(m_main_system_description_table);
|
auto revision = get_table_revision(m_main_system_description_table);
|
||||||
|
|
|
@ -324,9 +324,7 @@ void page_fault_handler(TrapFrame* trap)
|
||||||
|
|
||||||
handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);
|
handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);
|
||||||
} else if (response == PageFaultResponse::Continue) {
|
} else if (response == PageFaultResponse::Continue) {
|
||||||
#if PAGE_FAULT_DEBUG
|
dbgln_if(PAGE_FAULT_DEBUG, "Continuing after resolved page fault");
|
||||||
dbgln("Continuing after resolved page fault");
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,10 +134,8 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.is_relative = true;
|
packet.is_relative = true;
|
||||||
#if PS2MOUSE_DEBUG
|
dbgln_if(PS2MOUSE_DEBUG, "PS2 Relative Mouse: Buttons {:x}", packet.buttons);
|
||||||
dbgln("PS2 Relative Mouse: Buttons {:x}", packet.buttons);
|
dbgln_if(PS2MOUSE_DEBUG, "Mouse: X {}, Y {}, Z {}", packet.x, packet.y, packet.z);
|
||||||
dbgln("Mouse: X {}, Y {}, Z {}", packet.x, packet.y, packet.z);
|
|
||||||
#endif
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,9 +176,8 @@ UNMAP_AFTER_INIT void UHCIController::create_structures()
|
||||||
transfer_descriptor->set_isochronous();
|
transfer_descriptor->set_isochronous();
|
||||||
transfer_descriptor->link_queue_head(m_interrupt_transfer_queue->paddr());
|
transfer_descriptor->link_queue_head(m_interrupt_transfer_queue->paddr());
|
||||||
|
|
||||||
#if UHCI_VERBOSE_DEBUG
|
if constexpr (UHCI_VERBOSE_DEBUG)
|
||||||
transfer_descriptor->print();
|
transfer_descriptor->print();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_free_td_pool.resize(MAXIMUM_NUMBER_OF_TDS);
|
m_free_td_pool.resize(MAXIMUM_NUMBER_OF_TDS);
|
||||||
|
@ -192,10 +191,10 @@ UNMAP_AFTER_INIT void UHCIController::create_structures()
|
||||||
// access the raw descriptor (that we later send to the controller)
|
// access the raw descriptor (that we later send to the controller)
|
||||||
m_free_td_pool.at(i) = new (placement_addr) Kernel::USB::TransferDescriptor(paddr);
|
m_free_td_pool.at(i) = new (placement_addr) Kernel::USB::TransferDescriptor(paddr);
|
||||||
|
|
||||||
#if UHCI_VERBOSE_DEBUG
|
if constexpr (UHCI_VERBOSE_DEBUG) {
|
||||||
auto transfer_descriptor = m_free_td_pool.at(i);
|
auto transfer_descriptor = m_free_td_pool.at(i);
|
||||||
transfer_descriptor->print();
|
transfer_descriptor->print();
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (UHCI_DEBUG) {
|
if constexpr (UHCI_DEBUG) {
|
||||||
|
|
|
@ -453,9 +453,7 @@ bool TCPSocket::protocol_is_disconnected() const
|
||||||
void TCPSocket::shut_down_for_writing()
|
void TCPSocket::shut_down_for_writing()
|
||||||
{
|
{
|
||||||
if (state() == State::Established) {
|
if (state() == State::Established) {
|
||||||
#if TCP_SOCKET_DEBUG
|
dbgln_if(TCP_SOCKET_DEBUG, " Sending FIN/ACK from Established and moving into FinWait1");
|
||||||
dbgln(" Sending FIN/ACK from Established and moving into FinWait1");
|
|
||||||
#endif
|
|
||||||
[[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
|
[[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
|
||||||
set_state(State::FinWait1);
|
set_state(State::FinWait1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -468,9 +466,7 @@ KResult TCPSocket::close()
|
||||||
Locker socket_locker(lock());
|
Locker socket_locker(lock());
|
||||||
auto result = IPv4Socket::close();
|
auto result = IPv4Socket::close();
|
||||||
if (state() == State::CloseWait) {
|
if (state() == State::CloseWait) {
|
||||||
#if TCP_SOCKET_DEBUG
|
dbgln_if(TCP_SOCKET_DEBUG, " Sending FIN from CloseWait and moving into LastAck");
|
||||||
dbgln(" Sending FIN from CloseWait and moving into LastAck");
|
|
||||||
#endif
|
|
||||||
[[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
|
[[maybe_unused]] auto rc = send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
|
||||||
set_state(State::LastAck);
|
set_state(State::LastAck);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,7 @@ void IOAccess::write32_field(Address address, u32 field, u32 value)
|
||||||
|
|
||||||
void IOAccess::enumerate_hardware(Function<void(Address, ID)> callback)
|
void IOAccess::enumerate_hardware(Function<void(Address, ID)> callback)
|
||||||
{
|
{
|
||||||
#if PCI_DEBUG
|
dbgln_if(PCI_DEBUG, "PCI: IO enumerating hardware");
|
||||||
dbgln("PCI: IO enumerating hardware");
|
|
||||||
#endif
|
|
||||||
// Single PCI host controller.
|
// Single PCI host controller.
|
||||||
if ((read8_field(Address(), PCI_HEADER_TYPE) & 0x80) == 0) {
|
if ((read8_field(Address(), PCI_HEADER_TYPE) & 0x80) == 0) {
|
||||||
enumerate_bus(-1, 0, callback, true);
|
enumerate_bus(-1, 0, callback, true);
|
||||||
|
|
|
@ -443,9 +443,7 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
|
||||||
auto& page_slot = physical_pages()[page_index];
|
auto& page_slot = physical_pages()[page_index];
|
||||||
bool have_committed = m_shared_committed_cow_pages && is_nonvolatile(page_index);
|
bool have_committed = m_shared_committed_cow_pages && is_nonvolatile(page_index);
|
||||||
if (page_slot->ref_count() == 1) {
|
if (page_slot->ref_count() == 1) {
|
||||||
#if PAGE_FAULT_DEBUG
|
dbgln_if(PAGE_FAULT_DEBUG, " >> It's a COW page but nobody is sharing it anymore. Remap r/w");
|
||||||
dbgln(" >> It's a COW page but nobody is sharing it anymore. Remap r/w");
|
|
||||||
#endif
|
|
||||||
set_should_cow(page_index, false);
|
set_should_cow(page_index, false);
|
||||||
if (have_committed) {
|
if (have_committed) {
|
||||||
if (m_shared_committed_cow_pages->return_one())
|
if (m_shared_committed_cow_pages->return_one())
|
||||||
|
@ -456,14 +454,10 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
|
||||||
|
|
||||||
RefPtr<PhysicalPage> page;
|
RefPtr<PhysicalPage> page;
|
||||||
if (have_committed) {
|
if (have_committed) {
|
||||||
#if PAGE_FAULT_DEBUG
|
dbgln_if(PAGE_FAULT_DEBUG, " >> It's a committed COW page and it's time to COW!");
|
||||||
dbgln(" >> It's a committed COW page and it's time to COW!");
|
|
||||||
#endif
|
|
||||||
page = m_shared_committed_cow_pages->allocate_one();
|
page = m_shared_committed_cow_pages->allocate_one();
|
||||||
} else {
|
} else {
|
||||||
#if PAGE_FAULT_DEBUG
|
dbgln_if(PAGE_FAULT_DEBUG, " >> It's a COW page and it's time to COW!");
|
||||||
dbgln(" >> It's a COW page and it's time to COW!");
|
|
||||||
#endif
|
|
||||||
page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No);
|
page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No);
|
||||||
if (page.is_null()) {
|
if (page.is_null()) {
|
||||||
dmesgln("MM: handle_cow_fault was unable to allocate a physical page");
|
dmesgln("MM: handle_cow_fault was unable to allocate a physical page");
|
||||||
|
|
|
@ -457,9 +457,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
|
||||||
auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region);
|
auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region);
|
||||||
|
|
||||||
if (!page_slot.is_null() && !page_slot->is_shared_zero_page() && !page_slot->is_lazy_committed_page()) {
|
if (!page_slot.is_null() && !page_slot->is_shared_zero_page() && !page_slot->is_lazy_committed_page()) {
|
||||||
#if PAGE_FAULT_DEBUG
|
dbgln_if(PAGE_FAULT_DEBUG, "MM: zero_page() but page already present. Fine with me!");
|
||||||
dbgln("MM: zero_page() but page already present. Fine with me!");
|
|
||||||
#endif
|
|
||||||
if (!remap_vmobject_page(page_index_in_vmobject))
|
if (!remap_vmobject_page(page_index_in_vmobject))
|
||||||
return PageFaultResponse::OutOfMemory;
|
return PageFaultResponse::OutOfMemory;
|
||||||
return PageFaultResponse::Continue;
|
return PageFaultResponse::Continue;
|
||||||
|
|
|
@ -233,16 +233,16 @@ void IRCClient::send_whois(const String& nick)
|
||||||
|
|
||||||
void IRCClient::handle(const Message& msg)
|
void IRCClient::handle(const Message& msg)
|
||||||
{
|
{
|
||||||
#if IRC_DEBUG
|
if constexpr (IRC_DEBUG) {
|
||||||
outln("IRCClient::execute: prefix='{}', command='{}', arguments={}",
|
outln("IRCClient::execute: prefix='{}', command='{}', arguments={}",
|
||||||
msg.prefix,
|
msg.prefix,
|
||||||
msg.command,
|
msg.command,
|
||||||
msg.arguments.size());
|
msg.arguments.size());
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (auto& arg : msg.arguments)
|
for (auto& arg : msg.arguments)
|
||||||
outln(" [{}]: {}", index++, arg);
|
outln(" [{}]: {}", index++, arg);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
auto numeric = msg.command.to_uint();
|
auto numeric = msg.command.to_uint();
|
||||||
|
|
||||||
|
@ -464,13 +464,11 @@ void IRCClient::handle_privmsg_or_notice(const Message& msg, PrivmsgOrNotice typ
|
||||||
|
|
||||||
bool is_ctcp = has_ctcp_payload(msg.arguments[1]);
|
bool is_ctcp = has_ctcp_payload(msg.arguments[1]);
|
||||||
|
|
||||||
#if IRC_DEBUG
|
outln_if(IRC_DEBUG, "handle_privmsg_or_notice: type='{}'{}, sender_nick='{}', target='{}'",
|
||||||
outln("handle_privmsg_or_notice: type='{}'{}, sender_nick='{}', target='{}'",
|
|
||||||
type == PrivmsgOrNotice::Privmsg ? "privmsg" : "notice",
|
type == PrivmsgOrNotice::Privmsg ? "privmsg" : "notice",
|
||||||
is_ctcp ? " (ctcp)" : "",
|
is_ctcp ? " (ctcp)" : "",
|
||||||
sender_nick,
|
sender_nick,
|
||||||
target);
|
target);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sender_nick.is_empty())
|
if (sender_nick.is_empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -15,9 +15,7 @@ namespace HackStudio {
|
||||||
|
|
||||||
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#if CURSOR_TOOL_DEBUG
|
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mousedown");
|
||||||
dbgln("CursorTool::on_mousedown");
|
|
||||||
#endif
|
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||||
|
|
||||||
|
@ -52,9 +50,7 @@ void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||||
|
|
||||||
void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#if CURSOR_TOOL_DEBUG
|
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mouseup");
|
||||||
dbgln("CursorTool::on_mouseup");
|
|
||||||
#endif
|
|
||||||
if (event.button() == GUI::MouseButton::Left) {
|
if (event.button() == GUI::MouseButton::Left) {
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||||
|
@ -73,9 +69,7 @@ void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
||||||
|
|
||||||
void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#if CURSOR_TOOL_DEBUG
|
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mousemove");
|
||||||
dbgln("CursorTool::on_mousemove");
|
|
||||||
#endif
|
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
|
|
||||||
if (m_rubber_banding) {
|
if (m_rubber_banding) {
|
||||||
|
@ -112,9 +106,7 @@ void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
||||||
|
|
||||||
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
||||||
{
|
{
|
||||||
#if CURSOR_TOOL_DEBUG
|
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_keydown");
|
||||||
dbgln("CursorTool::on_keydown");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto move_selected_widgets_by = [this](int x, int y) {
|
auto move_selected_widgets_by = [this](int x, int y) {
|
||||||
m_editor.selection().for_each([&](auto& widget) {
|
m_editor.selection().for_each([&](auto& widget) {
|
||||||
|
|
|
@ -140,10 +140,10 @@ void DiffViewer::set_content(const String& original, const String& diff)
|
||||||
m_original_lines = split_to_lines(original);
|
m_original_lines = split_to_lines(original);
|
||||||
m_hunks = Diff::parse_hunks(diff);
|
m_hunks = Diff::parse_hunks(diff);
|
||||||
|
|
||||||
#if DIFF_DEBUG
|
if constexpr (DIFF_DEBUG) {
|
||||||
for (size_t i = 0; i < m_original_lines.size(); ++i)
|
for (size_t i = 0; i < m_original_lines.size(); ++i)
|
||||||
dbgln("{}:{}", i, m_original_lines[i]);
|
dbgln("{}:{}", i, m_original_lines[i]);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DiffViewer::DiffViewer()
|
DiffViewer::DiffViewer()
|
||||||
|
|
|
@ -34,11 +34,11 @@ Vector<GUI::AutocompleteProvider::Entry> LexerAutoComplete::get_suggestions(cons
|
||||||
|
|
||||||
auto suggestions = identifier_prefixes(lines, tokens, index_of_target_token.value());
|
auto suggestions = identifier_prefixes(lines, tokens, index_of_target_token.value());
|
||||||
|
|
||||||
#if AUTOCOMPLETE_DEBUG
|
if constexpr (AUTOCOMPLETE_DEBUG) {
|
||||||
for (auto& suggestion : suggestions) {
|
for (auto& suggestion : suggestions) {
|
||||||
dbgln("suggestion: {}", suggestion.completion);
|
dbgln("suggestion: {}", suggestion.completion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return suggestions;
|
return suggestions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,8 @@ OwnPtr<ParserAutoComplete::DocumentData> ParserAutoComplete::create_document_dat
|
||||||
for (auto& path : document_data->preprocessor().included_paths()) {
|
for (auto& path : document_data->preprocessor().included_paths()) {
|
||||||
get_or_create_document_data(document_path_from_include_path(path));
|
get_or_create_document_data(document_path_from_include_path(path));
|
||||||
}
|
}
|
||||||
#ifdef CPP_LANGUAGE_SERVER_DEBUG
|
if constexpr (CPP_LANGUAGE_SERVER_DEBUG)
|
||||||
root->dump(0);
|
root->dump(0);
|
||||||
#endif
|
|
||||||
|
|
||||||
update_declared_symbols(*document_data);
|
update_declared_symbols(*document_data);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef GENERATE_DEBUG_CODE
|
||||||
|
# define GENERATE_DEBUG_CODE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Parameter {
|
struct Parameter {
|
||||||
Vector<String> attributes;
|
Vector<String> attributes;
|
||||||
String type;
|
String type;
|
||||||
|
@ -444,22 +448,22 @@ public:
|
||||||
stream >> message_endpoint_magic;
|
stream >> message_endpoint_magic;
|
||||||
if (stream.handle_any_error()) {
|
if (stream.handle_any_error()) {
|
||||||
)~~~");
|
)~~~");
|
||||||
#if GENERATE_DEBUG_CODE
|
if constexpr (GENERATE_DEBUG_CODE) {
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
dbgln("Failed to read message endpoint magic");
|
dbgln("Failed to read message endpoint magic");
|
||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message_endpoint_magic != @endpoint.magic@) {
|
if (message_endpoint_magic != @endpoint.magic@) {
|
||||||
)~~~");
|
)~~~");
|
||||||
#if GENERATE_DEBUG_CODE
|
if constexpr (GENERATE_DEBUG_CODE) {
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
dbgln("@endpoint.name@: Endpoint magic number message_endpoint_magic != @endpoint.magic@, not my message! (the other endpoint may have handled it)");
|
dbgln("@endpoint.name@: Endpoint magic number message_endpoint_magic != @endpoint.magic@, not my message! (the other endpoint may have handled it)");
|
||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -468,11 +472,11 @@ public:
|
||||||
stream >> message_id;
|
stream >> message_id;
|
||||||
if (stream.handle_any_error()) {
|
if (stream.handle_any_error()) {
|
||||||
)~~~");
|
)~~~");
|
||||||
#if GENERATE_DEBUG_CODE
|
if constexpr (GENERATE_DEBUG_CODE) {
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
dbgln("Failed to read message ID");
|
dbgln("Failed to read message ID");
|
||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -502,22 +506,22 @@ public:
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
default:
|
default:
|
||||||
)~~~");
|
)~~~");
|
||||||
#if GENERATE_DEBUG_CODE
|
if constexpr (GENERATE_DEBUG_CODE) {
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
dbgln("Failed to decode @endpoint.name@.({})", message_id);
|
dbgln("Failed to decode @endpoint.name@.({})", message_id);
|
||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.handle_any_error()) {
|
if (stream.handle_any_error()) {
|
||||||
)~~~");
|
)~~~");
|
||||||
#if GENERATE_DEBUG_CODE
|
if constexpr (GENERATE_DEBUG_CODE) {
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
dbgln("Failed to read the message");
|
dbgln("Failed to read the message");
|
||||||
)~~~");
|
)~~~");
|
||||||
#endif
|
}
|
||||||
endpoint_generator.append(R"~~~(
|
endpoint_generator.append(R"~~~(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,8 @@ namespace UserspaceEmulator {
|
||||||
|
|
||||||
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||||
{
|
{
|
||||||
#if SPAM_DEBUG
|
if constexpr (SPAM_DEBUG)
|
||||||
reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function);
|
reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function);
|
||||||
#endif
|
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case SC_chdir:
|
case SC_chdir:
|
||||||
return virt$chdir(arg1, arg2);
|
return virt$chdir(arg1, arg2);
|
||||||
|
|
|
@ -310,9 +310,8 @@ void MallocTracer::populate_memory_graph()
|
||||||
auto value = m_emulator.mmu().read32({ 0x23, mallocation.address + i * sizeof(u32) });
|
auto value = m_emulator.mmu().read32({ 0x23, mallocation.address + i * sizeof(u32) });
|
||||||
auto other_address = value.value();
|
auto other_address = value.value();
|
||||||
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
||||||
#if REACHABLE_DEBUG
|
if constexpr (REACHABLE_DEBUG)
|
||||||
reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.address);
|
reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.address);
|
||||||
#endif
|
|
||||||
edges_from_mallocation.edges_from_node.append(other_address);
|
edges_from_mallocation.edges_from_node.append(other_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,9 +338,8 @@ void MallocTracer::populate_memory_graph()
|
||||||
auto value = region.read32(i * sizeof(u32));
|
auto value = region.read32(i * sizeof(u32));
|
||||||
auto other_address = value.value();
|
auto other_address = value.value();
|
||||||
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
||||||
#if REACHABLE_DEBUG
|
if constexpr (REACHABLE_DEBUG)
|
||||||
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1);
|
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1);
|
||||||
#endif
|
|
||||||
m_memory_graph.find(other_address)->value.is_reachable = true;
|
m_memory_graph.find(other_address)->value.is_reachable = true;
|
||||||
reachable_mallocations.append(other_address);
|
reachable_mallocations.append(other_address);
|
||||||
}
|
}
|
||||||
|
@ -388,9 +386,8 @@ void MallocTracer::dump_leak_report()
|
||||||
|
|
||||||
populate_memory_graph();
|
populate_memory_graph();
|
||||||
|
|
||||||
#if REACHABLE_DEBUG
|
if constexpr (REACHABLE_DEBUG)
|
||||||
dump_memory_graph();
|
dump_memory_graph();
|
||||||
#endif
|
|
||||||
|
|
||||||
for_each_mallocation([&](auto& mallocation) {
|
for_each_mallocation([&](auto& mallocation) {
|
||||||
if (mallocation.freed)
|
if (mallocation.freed)
|
||||||
|
|
|
@ -138,18 +138,14 @@ ValueWithShadow<u128> SoftCPU::read_memory128(X86::LogicalAddress address)
|
||||||
{
|
{
|
||||||
VERIFY(address.selector() == 0x1b || address.selector() == 0x23 || address.selector() == 0x2b);
|
VERIFY(address.selector() == 0x1b || address.selector() == 0x23 || address.selector() == 0x2b);
|
||||||
auto value = m_emulator.mmu().read128(address);
|
auto value = m_emulator.mmu().read128(address);
|
||||||
#if MEMORY_DEBUG
|
outln_if(MEMORY_DEBUG, "\033[36;1mread_memory128: @{:04x}:{:08x} -> {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||||
outln("\033[36;1mread_memory128: @{:04x}:{:08x} -> {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
|
||||||
#endif
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
ValueWithShadow<u256> SoftCPU::read_memory256(X86::LogicalAddress address)
|
ValueWithShadow<u256> SoftCPU::read_memory256(X86::LogicalAddress address)
|
||||||
{
|
{
|
||||||
VERIFY(address.selector() == 0x1b || address.selector() == 0x23 || address.selector() == 0x2b);
|
VERIFY(address.selector() == 0x1b || address.selector() == 0x23 || address.selector() == 0x2b);
|
||||||
auto value = m_emulator.mmu().read256(address);
|
auto value = m_emulator.mmu().read256(address);
|
||||||
#if MEMORY_DEBUG
|
outln_if(MEMORY_DEBUG, "\033[36;1mread_memory256: @{:04x}:{:08x} -> {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||||
outln("\033[36;1mread_memory256: @{:04x}:{:08x} -> {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
|
||||||
#endif
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,18 +180,14 @@ void SoftCPU::write_memory64(X86::LogicalAddress address, ValueWithShadow<u64> v
|
||||||
void SoftCPU::write_memory128(X86::LogicalAddress address, ValueWithShadow<u128> value)
|
void SoftCPU::write_memory128(X86::LogicalAddress address, ValueWithShadow<u128> value)
|
||||||
{
|
{
|
||||||
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
||||||
#if MEMORY_DEBUG
|
outln_if(MEMORY_DEBUG, "\033[36;1mwrite_memory128: @{:04x}:{:08x} <- {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||||
outln("\033[36;1mwrite_memory128: @{:04x}:{:08x} <- {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
|
||||||
#endif
|
|
||||||
m_emulator.mmu().write128(address, value);
|
m_emulator.mmu().write128(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftCPU::write_memory256(X86::LogicalAddress address, ValueWithShadow<u256> value)
|
void SoftCPU::write_memory256(X86::LogicalAddress address, ValueWithShadow<u256> value)
|
||||||
{
|
{
|
||||||
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
||||||
#if MEMORY_DEBUG
|
outln_if(MEMORY_DEBUG, "\033[36;1mwrite_memory256: @{:04x}:{:08x} <- {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||||
outln("\033[36;1mwrite_memory256: @{:04x}:{:08x} <- {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
|
||||||
#endif
|
|
||||||
m_emulator.mmu().write256(address, value);
|
m_emulator.mmu().write256(address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,10 @@ bool WavLoaderPlugin::sniff()
|
||||||
|
|
||||||
RefPtr<Buffer> WavLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_input)
|
RefPtr<Buffer> WavLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_input)
|
||||||
{
|
{
|
||||||
#if AWAVLOADER_DEBUG
|
dbgln_if(AWAVLOADER_DEBUG, "Read {} bytes WAV with num_channels {} sample rate {}, "
|
||||||
dbgln("Read {} bytes WAV with num_channels {} sample rate {}, bits per sample {}, sample format {}", max_bytes_to_read_from_input, m_num_channels, m_sample_rate, pcm_bits_per_sample(m_sample_format), sample_format_name(m_sample_format));
|
"bits per sample {}, sample format {}",
|
||||||
#endif
|
max_bytes_to_read_from_input, m_num_channels,
|
||||||
|
m_sample_rate, pcm_bits_per_sample(m_sample_format), sample_format_name(m_sample_format));
|
||||||
size_t samples_to_read = static_cast<int>(max_bytes_to_read_from_input) / (m_num_channels * (pcm_bits_per_sample(m_sample_format) / 8));
|
size_t samples_to_read = static_cast<int>(max_bytes_to_read_from_input) / (m_num_channels * (pcm_bits_per_sample(m_sample_format) / 8));
|
||||||
RefPtr<Buffer> buffer;
|
RefPtr<Buffer> buffer;
|
||||||
if (m_file) {
|
if (m_file) {
|
||||||
|
@ -215,9 +216,8 @@ bool WavLoaderPlugin::parse_header()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if AWAVLOADER_DEBUG
|
dbgln_if(AWAVLOADER_DEBUG, "WAV format {} at {} bit, {} channels, rate {}Hz ",
|
||||||
dbgln("WAV format {} at {}bit, {} channels, rate {}Hz ", sample_format_name(m_sample_format), pcm_bits_per_sample(m_sample_format), m_num_channels, m_sample_rate);
|
sample_format_name(m_sample_format), pcm_bits_per_sample(m_sample_format), m_num_channels, m_sample_rate);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Read chunks until we find DATA
|
// Read chunks until we find DATA
|
||||||
bool found_data = false;
|
bool found_data = false;
|
||||||
|
|
|
@ -21,9 +21,8 @@ char* BC;
|
||||||
|
|
||||||
int tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name)
|
int tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name)
|
||||||
{
|
{
|
||||||
#if TERMCAP_DEBUG
|
if constexpr (TERMCAP_DEBUG)
|
||||||
fprintf(stderr, "tgetent: bp=%p, name='%s'\n", bp, name);
|
fprintf(stderr, "tgetent: bp=%p, name='%s'\n", bp, name);
|
||||||
#endif
|
|
||||||
PC = '\0';
|
PC = '\0';
|
||||||
BC = const_cast<char*>("\033[D");
|
BC = const_cast<char*>("\033[D");
|
||||||
UP = const_cast<char*>("\033[A");
|
UP = const_cast<char*>("\033[A");
|
||||||
|
@ -81,9 +80,8 @@ static void ensure_caps()
|
||||||
char* tgetstr(const char* id, char** area)
|
char* tgetstr(const char* id, char** area)
|
||||||
{
|
{
|
||||||
ensure_caps();
|
ensure_caps();
|
||||||
#if TERMCAP_DEBUG
|
if constexpr (TERMCAP_DEBUG)
|
||||||
fprintf(stderr, "tgetstr: id='%s'\n", id);
|
fprintf(stderr, "tgetstr: id='%s'\n", id);
|
||||||
#endif
|
|
||||||
auto it = caps->find(id);
|
auto it = caps->find(id);
|
||||||
if (it != caps->end()) {
|
if (it != caps->end()) {
|
||||||
char* ret = *area;
|
char* ret = *area;
|
||||||
|
@ -100,9 +98,8 @@ char* tgetstr(const char* id, char** area)
|
||||||
|
|
||||||
int tgetflag([[maybe_unused]] const char* id)
|
int tgetflag([[maybe_unused]] const char* id)
|
||||||
{
|
{
|
||||||
#if TERMCAP_DEBUG
|
if constexpr (TERMCAP_DEBUG)
|
||||||
fprintf(stderr, "tgetflag: '%s'\n", id);
|
fprintf(stderr, "tgetflag: '%s'\n", id);
|
||||||
#endif
|
|
||||||
auto it = caps->find(id);
|
auto it = caps->find(id);
|
||||||
if (it != caps->end())
|
if (it != caps->end())
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -111,9 +108,8 @@ int tgetflag([[maybe_unused]] const char* id)
|
||||||
|
|
||||||
int tgetnum(const char* id)
|
int tgetnum(const char* id)
|
||||||
{
|
{
|
||||||
#if TERMCAP_DEBUG
|
if constexpr (TERMCAP_DEBUG)
|
||||||
fprintf(stderr, "tgetnum: '%s'\n", id);
|
fprintf(stderr, "tgetnum: '%s'\n", id);
|
||||||
#endif
|
|
||||||
auto it = caps->find(id);
|
auto it = caps->find(id);
|
||||||
if (it != caps->end())
|
if (it != caps->end())
|
||||||
return atoi((*it).value);
|
return atoi((*it).value);
|
||||||
|
|
|
@ -23,9 +23,7 @@ Endpoint::Endpoint(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevic
|
||||||
|
|
||||||
void Endpoint::send_command(const Command& command)
|
void Endpoint::send_command(const Command& command)
|
||||||
{
|
{
|
||||||
#if UCI_DEBUG
|
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp));
|
||||||
dbgln("{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp));
|
|
||||||
#endif
|
|
||||||
m_out->write(command.to_string());
|
m_out->write(command.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +72,7 @@ NonnullOwnPtr<Command> Endpoint::read_command()
|
||||||
{
|
{
|
||||||
String line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
|
String line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
|
||||||
|
|
||||||
#if UCI_DEBUG
|
dbgln_if(UCI_DEBUG, "{} Received UCI Command: {}", class_name(), line);
|
||||||
dbgln("{} Received UCI Command: {}", class_name(), line);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (line == "uci") {
|
if (line == "uci") {
|
||||||
return make<UCICommand>(UCICommand::from_string(line));
|
return make<UCICommand>(UCICommand::from_string(line));
|
||||||
|
|
|
@ -393,9 +393,7 @@ void EventLoop::pump(WaitMode mode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (event.type() == Event::Type::DeferredInvoke) {
|
} else if (event.type() == Event::Type::DeferredInvoke) {
|
||||||
#if DEFERRED_INVOKE_DEBUG
|
dbgln_if(DEFERRED_INVOKE_DEBUG, "DeferredInvoke: receiver = {}", *receiver);
|
||||||
dbgln("DeferredInvoke: receiver = {}", *receiver);
|
|
||||||
#endif
|
|
||||||
static_cast<DeferredInvocationEvent&>(event).m_invokee(*receiver);
|
static_cast<DeferredInvocationEvent&>(event).m_invokee(*receiver);
|
||||||
} else {
|
} else {
|
||||||
NonnullRefPtr<Object> protector(*receiver);
|
NonnullRefPtr<Object> protector(*receiver);
|
||||||
|
|
|
@ -22,17 +22,17 @@ Parser::Parser(const StringView& program, const String& filename, Preprocessor::
|
||||||
, m_filename(filename)
|
, m_filename(filename)
|
||||||
{
|
{
|
||||||
initialize_program_tokens(program);
|
initialize_program_tokens(program);
|
||||||
#if CPP_DEBUG
|
if constexpr (CPP_DEBUG) {
|
||||||
dbgln("Tokens:");
|
dbgln("Tokens:");
|
||||||
for (auto& token : m_tokens) {
|
for (auto& token : m_tokens) {
|
||||||
StringView text;
|
StringView text;
|
||||||
if (token.start().line != token.end().line || token.start().column > token.end().column)
|
if (token.start().line != token.end().line || token.start().column > token.end().column)
|
||||||
text = {};
|
text = {};
|
||||||
else
|
else
|
||||||
text = text_of_token(token);
|
text = text_of_token(token);
|
||||||
dbgln("{} {}:{}-{}:{} ({})", token.to_string(), token.start().line, token.start().column, token.end().line, token.end().column, text);
|
dbgln("{} {}:{}-{}:{} ({})", token.to_string(), token.start().line, token.start().column, token.end().line, token.end().column, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::initialize_program_tokens(const StringView& program)
|
void Parser::initialize_program_tokens(const StringView& program)
|
||||||
|
|
|
@ -208,9 +208,7 @@ UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b)
|
||||||
|
|
||||||
GCD_without_allocation(a, b, temp_a, temp_b, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder, gcd_output);
|
GCD_without_allocation(a, b, temp_a, temp_b, temp_1, temp_2, temp_3, temp_4, temp_quotient, temp_remainder, gcd_output);
|
||||||
if (gcd_output == 0) {
|
if (gcd_output == 0) {
|
||||||
#if NT_DEBUG
|
dbgln_if(NT_DEBUG, "GCD is zero");
|
||||||
dbgln("GCD is zero");
|
|
||||||
#endif
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,11 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (child.get_attribute(Dwarf::Attribute::Inline).has_value()) {
|
if (child.get_attribute(Dwarf::Attribute::Inline).has_value()) {
|
||||||
#if SPAM_DEBUG
|
dbgln_if(SPAM_DEBUG, "DWARF inlined functions are not supported");
|
||||||
dbgln("DWARF inlined functions are not supported");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (child.get_attribute(Dwarf::Attribute::Ranges).has_value()) {
|
if (child.get_attribute(Dwarf::Attribute::Ranges).has_value()) {
|
||||||
#if SPAM_DEBUG
|
dbgln_if(SPAM_DEBUG, "DWARF ranges are not supported");
|
||||||
dbgln("DWARF ranges are not supported");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto name = child.get_attribute(Dwarf::Attribute::Name);
|
auto name = child.get_attribute(Dwarf::Attribute::Name);
|
||||||
|
@ -61,9 +57,7 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die)
|
||||||
scope.name = name.value().data.as_string;
|
scope.name = name.value().data.as_string;
|
||||||
|
|
||||||
if (!child.get_attribute(Dwarf::Attribute::LowPc).has_value()) {
|
if (!child.get_attribute(Dwarf::Attribute::LowPc).has_value()) {
|
||||||
#if SPAM_DEBUG
|
dbgln_if(SPAM_DEBUG, "DWARF: Couldn't find attribute LowPc for scope");
|
||||||
dbgln("DWARF: Couldn't find attribute LowPc for scope");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scope.address_low = child.get_attribute(Dwarf::Attribute::LowPc).value().data.as_u32;
|
scope.address_low = child.get_attribute(Dwarf::Attribute::LowPc).value().data.as_u32;
|
||||||
|
|
|
@ -263,9 +263,7 @@ Image::RelocationSection Image::Section::relocations() const
|
||||||
if (relocation_section.type() != SHT_REL)
|
if (relocation_section.type() != SHT_REL)
|
||||||
return static_cast<const RelocationSection>(m_image.section(0));
|
return static_cast<const RelocationSection>(m_image.section(0));
|
||||||
|
|
||||||
#if ELF_IMAGE_DEBUG
|
dbgln_if(ELF_IMAGE_DEBUG, "Found relocations for {} in {}", name(), relocation_section.name());
|
||||||
dbgln("Found relocations for {} in {}", name(), relocation_section.name());
|
|
||||||
#endif
|
|
||||||
return static_cast<const RelocationSection>(relocation_section);
|
return static_cast<const RelocationSection>(relocation_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,9 +87,7 @@ int Menu::realize_menu(RefPtr<Action> default_action)
|
||||||
unrealize_menu();
|
unrealize_menu();
|
||||||
m_menu_id = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateMenu>(m_name)->menu_id();
|
m_menu_id = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateMenu>(m_name)->menu_id();
|
||||||
|
|
||||||
#if MENU_DEBUG
|
dbgln_if(MENU_DEBUG, "GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id);
|
||||||
dbgln("GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id);
|
|
||||||
#endif
|
|
||||||
VERIFY(m_menu_id > 0);
|
VERIFY(m_menu_id > 0);
|
||||||
for (size_t i = 0; i < m_items.size(); ++i) {
|
for (size_t i = 0; i < m_items.size(); ++i) {
|
||||||
auto& item = m_items[i];
|
auto& item = m_items[i];
|
||||||
|
|
|
@ -474,9 +474,8 @@ void TextEditor::paint_event(PaintEvent& event)
|
||||||
for_each_visual_line(line_index, [&](const Gfx::IntRect& visual_line_rect, auto& visual_line_text, size_t start_of_visual_line, [[maybe_unused]] bool is_last_visual_line) {
|
for_each_visual_line(line_index, [&](const Gfx::IntRect& visual_line_rect, auto& visual_line_text, size_t start_of_visual_line, [[maybe_unused]] bool is_last_visual_line) {
|
||||||
if (is_multi_line() && line_index == m_cursor.line())
|
if (is_multi_line() && line_index == m_cursor.line())
|
||||||
painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f));
|
painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f));
|
||||||
#if TEXTEDITOR_DEBUG
|
if constexpr (TEXTEDITOR_DEBUG)
|
||||||
painter.draw_rect(visual_line_rect, Color::Cyan);
|
painter.draw_rect(visual_line_rect, Color::Cyan);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!placeholder().is_empty() && document().is_empty() && !is_focused() && line_index == 0) {
|
if (!placeholder().is_empty() && document().is_empty() && !is_focused() && line_index == 0) {
|
||||||
auto line_rect = visual_line_rect;
|
auto line_rect = visual_line_rect;
|
||||||
|
|
|
@ -238,9 +238,8 @@ void TreeView::paint_event(PaintEvent& event)
|
||||||
auto rect = a_rect.translated(0, y_offset);
|
auto rect = a_rect.translated(0, y_offset);
|
||||||
auto toggle_rect = a_toggle_rect.translated(0, y_offset);
|
auto toggle_rect = a_toggle_rect.translated(0, y_offset);
|
||||||
|
|
||||||
#if ITEM_RECTS_DEBUG
|
if constexpr (ITEM_RECTS_DEBUG)
|
||||||
painter.fill_rect(rect, Color::WarmGray);
|
painter.fill_rect(rect, Color::WarmGray);
|
||||||
#endif
|
|
||||||
|
|
||||||
bool is_selected_row = selection().contains(index);
|
bool is_selected_row = selection().contains(index);
|
||||||
|
|
||||||
|
|
|
@ -609,9 +609,7 @@ void Window::update(const Gfx::IntRect& a_rect)
|
||||||
|
|
||||||
for (auto& pending_rect : m_pending_paint_event_rects) {
|
for (auto& pending_rect : m_pending_paint_event_rects) {
|
||||||
if (pending_rect.contains(a_rect)) {
|
if (pending_rect.contains(a_rect)) {
|
||||||
#if UPDATE_COALESCING_DEBUG
|
dbgln_if(UPDATE_COALESCING_DEBUG, "Ignoring {} since it's contained by pending rect {}", a_rect, pending_rect);
|
||||||
dbgln("Ignoring {} since it's contained by pending rect {}", a_rect, pending_rect);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,7 @@ void GeminiJob::start()
|
||||||
m_socket = TLS::TLSv12::construct(this);
|
m_socket = TLS::TLSv12::construct(this);
|
||||||
m_socket->set_root_certificates(m_override_ca_certificates ? *m_override_ca_certificates : DefaultRootCACertificates::the().certificates());
|
m_socket->set_root_certificates(m_override_ca_certificates ? *m_override_ca_certificates : DefaultRootCACertificates::the().certificates());
|
||||||
m_socket->on_tls_connected = [this] {
|
m_socket->on_tls_connected = [this] {
|
||||||
#if GEMINIJOB_DEBUG
|
dbgln_if(GEMINIJOB_DEBUG, "GeminiJob: on_connected callback");
|
||||||
dbgln("GeminiJob: on_connected callback");
|
|
||||||
#endif
|
|
||||||
on_socket_connected();
|
on_socket_connected();
|
||||||
};
|
};
|
||||||
m_socket->on_tls_error = [this](TLS::AlertDescription error) {
|
m_socket->on_tls_error = [this](TLS::AlertDescription error) {
|
||||||
|
|
|
@ -132,9 +132,7 @@ void Job::on_socket_connected()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!is_established()) {
|
if (!is_established()) {
|
||||||
#if JOB_DEBUG
|
dbgln_if(JOB_DEBUG, "Connection appears to have closed, finishing up");
|
||||||
dbgln("Connection appears to have closed, finishing up");
|
|
||||||
#endif
|
|
||||||
finish_up();
|
finish_up();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -350,9 +350,7 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index)
|
||||||
while (true) {
|
while (true) {
|
||||||
Optional<u16> code = decoder.next_code();
|
Optional<u16> code = decoder.next_code();
|
||||||
if (!code.has_value()) {
|
if (!code.has_value()) {
|
||||||
#if GIF_DEBUG
|
dbgln_if(GIF_DEBUG, "Unexpectedly reached end of gif frame data");
|
||||||
dbgln("Unexpectedly reached end of gif frame data");
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,9 +497,7 @@ static bool load_gif_frame_descriptors(GIFLoadingContext& context)
|
||||||
|
|
||||||
if (extension_type == 0xF9) {
|
if (extension_type == 0xF9) {
|
||||||
if (sub_block.size() != 4) {
|
if (sub_block.size() != 4) {
|
||||||
#if GIF_DEBUG
|
dbgln_if(GIF_DEBUG, "Unexpected graphic control size");
|
||||||
dbgln("Unexpected graphic control size");
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,25 +169,22 @@ static bool load_ico_directory(ICOLoadingContext& context)
|
||||||
for (size_t i = 0; i < image_count.value(); ++i) {
|
for (size_t i = 0; i < image_count.value(); ++i) {
|
||||||
auto maybe_desc = decode_ico_direntry(stream);
|
auto maybe_desc = decode_ico_direntry(stream);
|
||||||
if (!maybe_desc.has_value()) {
|
if (!maybe_desc.has_value()) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_directory: error loading entry: %lu\n", i);
|
printf("load_ico_directory: error loading entry: %lu\n", i);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& desc = maybe_desc.value();
|
auto& desc = maybe_desc.value();
|
||||||
if (desc.offset + desc.size < desc.offset // detect integer overflow
|
if (desc.offset + desc.size < desc.offset // detect integer overflow
|
||||||
|| (desc.offset + desc.size) > context.data_size) {
|
|| (desc.offset + desc.size) > context.data_size) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_directory: offset: %lu size: %lu doesn't fit in ICO size: %lu\n",
|
printf("load_ico_directory: offset: %lu size: %lu doesn't fit in ICO size: %lu\n",
|
||||||
desc.offset, desc.size, context.data_size);
|
desc.offset, desc.size, context.data_size);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_directory: index %zu width: %u height: %u offset: %lu size: %lu\n",
|
printf("load_ico_directory: index %zu width: %u height: %u offset: %lu size: %lu\n",
|
||||||
i, desc.width, desc.height, desc.offset, desc.size);
|
i, desc.width, desc.height, desc.offset, desc.size);
|
||||||
#endif
|
|
||||||
context.images.append(desc);
|
context.images.append(desc);
|
||||||
}
|
}
|
||||||
context.largest_index = find_largest_image(context);
|
context.largest_index = find_largest_image(context);
|
||||||
|
@ -203,16 +200,14 @@ static bool load_ico_bmp(ICOLoadingContext& context, ImageDescriptor& desc)
|
||||||
|
|
||||||
memcpy(&info, context.data + desc.offset, sizeof(info));
|
memcpy(&info, context.data + desc.offset, sizeof(info));
|
||||||
if (info.size != sizeof(info)) {
|
if (info.size != sizeof(info)) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: info size: %u, expected: %lu\n", info.size, sizeof(info));
|
printf("load_ico_bmp: info size: %u, expected: %lu\n", info.size, sizeof(info));
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.width < 0) {
|
if (info.width < 0) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: width %d < 0\n", info.width);
|
printf("load_ico_bmp: width %d < 0\n", info.width);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool topdown = false;
|
bool topdown = false;
|
||||||
|
@ -222,37 +217,32 @@ static bool load_ico_bmp(ICOLoadingContext& context, ImageDescriptor& desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.planes != 1) {
|
if (info.planes != 1) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: planes: %d != 1", info.planes);
|
printf("load_ico_bmp: planes: %d != 1", info.planes);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.bpp != 32) {
|
if (info.bpp != 32) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: unsupported bpp: %u\n", info.bpp);
|
printf("load_ico_bmp: unsupported bpp: %u\n", info.bpp);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: width: %d height: %d direction: %s bpp: %d size_image: %u\n",
|
printf("load_ico_bmp: width: %d height: %d direction: %s bpp: %d size_image: %u\n",
|
||||||
info.width, info.height, topdown ? "TopDown" : "BottomUp", info.bpp, info.size_image);
|
info.width, info.height, topdown ? "TopDown" : "BottomUp", info.bpp, info.size_image);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (info.compression != 0 || info.palette_size != 0 || info.important_colors != 0) {
|
if (info.compression != 0 || info.palette_size != 0 || info.important_colors != 0) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: following fields must be 0: compression: %u palette_size: %u important_colors: %u\n",
|
printf("load_ico_bmp: following fields must be 0: compression: %u palette_size: %u important_colors: %u\n",
|
||||||
info.compression, info.palette_size, info.important_colors);
|
info.compression, info.palette_size, info.important_colors);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.width != desc.width || info.height != 2 * desc.height) {
|
if (info.width != desc.width || info.height != 2 * desc.height) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: size mismatch: ico %dx%d, bmp %dx%d\n",
|
printf("load_ico_bmp: size mismatch: ico %dx%d, bmp %dx%d\n",
|
||||||
desc.width, desc.height, info.width, info.height);
|
desc.width, desc.height, info.width, info.height);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,10 +251,9 @@ static bool load_ico_bmp(ICOLoadingContext& context, ImageDescriptor& desc)
|
||||||
size_t required_len = desc.height * (desc.width * sizeof(BMP_ARGB) + mask_row_len);
|
size_t required_len = desc.height * (desc.width * sizeof(BMP_ARGB) + mask_row_len);
|
||||||
size_t available_len = desc.size - sizeof(info);
|
size_t available_len = desc.size - sizeof(info);
|
||||||
if (required_len > available_len) {
|
if (required_len > available_len) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bmp: required_len: %lu > available_len: %lu\n",
|
printf("load_ico_bmp: required_len: %lu > available_len: %lu\n",
|
||||||
required_len, available_len);
|
required_len, available_len);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,17 +299,15 @@ static bool load_ico_bitmap(ICOLoadingContext& context, Optional<size_t> index)
|
||||||
if (png_decoder.sniff()) {
|
if (png_decoder.sniff()) {
|
||||||
desc.bitmap = png_decoder.bitmap();
|
desc.bitmap = png_decoder.bitmap();
|
||||||
if (!desc.bitmap) {
|
if (!desc.bitmap) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bitmap: failed to load PNG encoded image index: %lu\n", real_index);
|
printf("load_ico_bitmap: failed to load PNG encoded image index: %lu\n", real_index);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!load_ico_bmp(context, desc)) {
|
if (!load_ico_bmp(context, desc)) {
|
||||||
#if ICO_DEBUG
|
if constexpr (ICO_DEBUG)
|
||||||
printf("load_ico_bitmap: failed to load BMP encoded image index: %lu\n", real_index);
|
printf("load_ico_bitmap: failed to load BMP encoded image index: %lu\n", real_index);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -247,9 +247,7 @@ static Optional<u8> get_next_symbol(HuffmanStreamState& hstream, const HuffmanTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JPG_DEBUG
|
dbgln_if(JPG_DEBUG, "If you're seeing this...the jpeg decoder needs to support more kinds of JPEGs!");
|
||||||
dbgln("If you're seeing this...the jpeg decoder needs to support more kinds of JPEGs!");
|
|
||||||
#endif
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1880,11 +1880,11 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
|
||||||
quick_sort(active_list, [](const auto& line0, const auto& line1) {
|
quick_sort(active_list, [](const auto& line0, const auto& line1) {
|
||||||
return line1.x < line0.x;
|
return line1.x < line0.x;
|
||||||
});
|
});
|
||||||
#if FILL_PATH_DEBUG
|
if constexpr (FILL_PATH_DEBUG) {
|
||||||
if ((int)scanline % 10 == 0) {
|
if ((int)scanline % 10 == 0) {
|
||||||
draw_text(IntRect(active_list.last().x - 20, scanline, 20, 10), String::number((int)scanline));
|
draw_text(IntRect(active_list.last().x - 20, scanline, 20, 10), String::number((int)scanline));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (active_list.size() > 1) {
|
if (active_list.size() > 1) {
|
||||||
auto winding_number { winding_rule == WindingRule::Nonzero ? 1 : 0 };
|
auto winding_number { winding_rule == WindingRule::Nonzero ? 1 : 0 };
|
||||||
|
@ -1952,12 +1952,12 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FILL_PATH_DEBUG
|
if constexpr (FILL_PATH_DEBUG) {
|
||||||
size_t i { 0 };
|
size_t i { 0 };
|
||||||
for (auto& segment : segments) {
|
for (auto& segment : segments) {
|
||||||
draw_line(Point<int>(segment.from), Point<int>(segment.to), Color::from_hsv(i++ * 360.0 / segments.size(), 1.0, 1.0), 1);
|
draw_line(Point<int>(segment.from), Point<int>(segment.to), Color::from_hsv(i++ * 360.0 / segments.size(), 1.0, 1.0), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Painter::blit_disabled(const IntPoint& location, const Gfx::Bitmap& bitmap, const IntRect& rect, const Palette& palette)
|
void Painter::blit_disabled(const IntPoint& location, const Gfx::Bitmap& bitmap, const IntRect& rect, const Palette& palette)
|
||||||
|
|
|
@ -17,9 +17,7 @@ void HttpJob::start()
|
||||||
VERIFY(!m_socket);
|
VERIFY(!m_socket);
|
||||||
m_socket = Core::TCPSocket::construct(this);
|
m_socket = Core::TCPSocket::construct(this);
|
||||||
m_socket->on_connected = [this] {
|
m_socket->on_connected = [this] {
|
||||||
#if CHTTPJOB_DEBUG
|
dbgln_if(CHTTPJOB_DEBUG, "HttpJob: on_connected callback");
|
||||||
dbgln("HttpJob: on_connected callback");
|
|
||||||
#endif
|
|
||||||
on_socket_connected();
|
on_socket_connected();
|
||||||
};
|
};
|
||||||
bool success = m_socket->connect(m_request.url().host(), m_request.url().port());
|
bool success = m_socket->connect(m_request.url().host(), m_request.url().port());
|
||||||
|
|
|
@ -20,9 +20,7 @@ void HttpsJob::start()
|
||||||
m_socket = TLS::TLSv12::construct(this);
|
m_socket = TLS::TLSv12::construct(this);
|
||||||
m_socket->set_root_certificates(m_override_ca_certificates ? *m_override_ca_certificates : DefaultRootCACertificates::the().certificates());
|
m_socket->set_root_certificates(m_override_ca_certificates ? *m_override_ca_certificates : DefaultRootCACertificates::the().certificates());
|
||||||
m_socket->on_tls_connected = [this] {
|
m_socket->on_tls_connected = [this] {
|
||||||
#if HTTPSJOB_DEBUG
|
dbgln_if(HTTPSJOB_DEBUG, "HttpsJob: on_connected callback");
|
||||||
dbgln("HttpsJob: on_connected callback");
|
|
||||||
#endif
|
|
||||||
on_socket_connected();
|
on_socket_connected();
|
||||||
};
|
};
|
||||||
m_socket->on_tls_error = [&](TLS::AlertDescription error) {
|
m_socket->on_tls_error = [&](TLS::AlertDescription error) {
|
||||||
|
|
|
@ -346,9 +346,7 @@ void Job::on_socket_connected()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!is_established()) {
|
if (!is_established()) {
|
||||||
#if JOB_DEBUG
|
dbgln_if(JOB_DEBUG, "Connection appears to have closed, finishing up");
|
||||||
dbgln("Connection appears to have closed, finishing up");
|
|
||||||
#endif
|
|
||||||
finish_up();
|
finish_up();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,9 +20,7 @@ void KeyCallbackMachine::register_key_input_callback(Vector<Key> keys, Function<
|
||||||
|
|
||||||
void KeyCallbackMachine::key_pressed(Editor& editor, Key key)
|
void KeyCallbackMachine::key_pressed(Editor& editor, Key key)
|
||||||
{
|
{
|
||||||
#if CALLBACK_MACHINE_DEBUG
|
dbgln_if(CALLBACK_MACHINE_DEBUG, "Key<{}, {}> pressed, seq_length={}, {} things in the matching vector", key.key, key.modifiers, m_sequence_length, m_current_matching_keys.size());
|
||||||
dbgln("Key<{}, {}> pressed, seq_length={}, {} things in the matching vector", key.key, key.modifiers, m_sequence_length, m_current_matching_keys.size());
|
|
||||||
#endif
|
|
||||||
if (m_sequence_length == 0) {
|
if (m_sequence_length == 0) {
|
||||||
VERIFY(m_current_matching_keys.is_empty());
|
VERIFY(m_current_matching_keys.is_empty());
|
||||||
|
|
||||||
|
@ -61,14 +59,14 @@ void KeyCallbackMachine::key_pressed(Editor& editor, Key key)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CALLBACK_MACHINE_DEBUG
|
if constexpr (CALLBACK_MACHINE_DEBUG) {
|
||||||
dbgln("seq_length={}, matching vector:", m_sequence_length);
|
dbgln("seq_length={}, matching vector:", m_sequence_length);
|
||||||
for (auto& key : m_current_matching_keys) {
|
for (auto& key : m_current_matching_keys) {
|
||||||
for (auto& k : key)
|
for (auto& k : key)
|
||||||
dbgln(" {}, {}", k.key, k.modifiers);
|
dbgln(" {}, {}", k.key, k.modifiers);
|
||||||
dbgln("");
|
dbgln("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
m_should_process_this_key = false;
|
m_should_process_this_key = false;
|
||||||
for (auto& key : m_current_matching_keys) {
|
for (auto& key : m_current_matching_keys) {
|
||||||
|
|
|
@ -222,17 +222,15 @@ Optional<Text> Text::parse(const StringView& str)
|
||||||
current_link_is_actually_img = true;
|
current_link_is_actually_img = true;
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
#if MARKDOWN_DEBUG
|
if constexpr (MARKDOWN_DEBUG) {
|
||||||
if (first_span_in_the_current_link != -1)
|
if (first_span_in_the_current_link != -1)
|
||||||
dbgln("Dropping the outer link");
|
dbgln("Dropping the outer link");
|
||||||
#endif
|
}
|
||||||
first_span_in_the_current_link = spans.size();
|
first_span_in_the_current_link = spans.size();
|
||||||
break;
|
break;
|
||||||
case ']': {
|
case ']': {
|
||||||
if (first_span_in_the_current_link == -1) {
|
if (first_span_in_the_current_link == -1) {
|
||||||
#if MARKDOWN_DEBUG
|
dbgln_if(MARKDOWN_DEBUG, "Unmatched ]");
|
||||||
dbgln("Unmatched ]");
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ScopeGuard guard = [&] {
|
ScopeGuard guard = [&] {
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include "LibRegex/RegexMatcher.h"
|
#include "LibRegex/RegexMatcher.h"
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
|
||||||
|
|
||||||
namespace regex {
|
namespace regex {
|
||||||
|
|
||||||
class RegexDebug {
|
class RegexDebug {
|
||||||
|
@ -131,5 +129,3 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
using regex::RegexDebug;
|
using regex::RegexDebug;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -130,9 +130,8 @@ Token Lexer::next()
|
||||||
case '\\':
|
case '\\':
|
||||||
return 2;
|
return 2;
|
||||||
default:
|
default:
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG)
|
||||||
fprintf(stderr, "[LEXER] Found invalid escape sequence: \\%c (the parser will have to deal with this!)\n", peek(1));
|
fprintf(stderr, "[LEXER] Found invalid escape sequence: \\%c (the parser will have to deal with this!)\n", peek(1));
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,9 +148,8 @@ Parser::Result Parser::parse(Optional<AllOptions> regex_options)
|
||||||
else
|
else
|
||||||
set_error(Error::InvalidPattern);
|
set_error(Error::InvalidPattern);
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG)
|
||||||
fprintf(stderr, "[PARSER] Produced bytecode with %lu entries (opcodes + arguments)\n", m_parser_state.bytecode.size());
|
fprintf(stderr, "[PARSER] Produced bytecode with %lu entries (opcodes + arguments)\n", m_parser_state.bytecode.size());
|
||||||
#endif
|
|
||||||
return {
|
return {
|
||||||
move(m_parser_state.bytecode),
|
move(m_parser_state.bytecode),
|
||||||
move(m_parser_state.capture_groups_count),
|
move(m_parser_state.capture_groups_count),
|
||||||
|
@ -461,9 +460,8 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si
|
||||||
if (match(TokenType::EscapeSequence)) {
|
if (match(TokenType::EscapeSequence)) {
|
||||||
length = 1;
|
length = 1;
|
||||||
Token t = consume();
|
Token t = consume();
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG)
|
||||||
printf("[PARSER] EscapeSequence with substring %s\n", String(t.value()).characters());
|
printf("[PARSER] EscapeSequence with substring %s\n", String(t.value()).characters());
|
||||||
#endif
|
|
||||||
|
|
||||||
bytecode.insert_bytecode_compare_values({ { CharacterCompareType::Char, (u32)t.value().characters_without_null_termination()[1] } });
|
bytecode.insert_bytecode_compare_values({ { CharacterCompareType::Char, (u32)t.value().characters_without_null_termination()[1] } });
|
||||||
should_parse_repetition_symbol = true;
|
should_parse_repetition_symbol = true;
|
||||||
|
|
|
@ -356,21 +356,21 @@ TEST_CASE(ini_file_entries)
|
||||||
Regex<PosixExtended> re("[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]");
|
Regex<PosixExtended> re("[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]");
|
||||||
RegexResult result;
|
RegexResult result;
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||||
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
||||||
EXPECT_EQ(result.count, 3u);
|
EXPECT_EQ(result.count, 3u);
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
for (auto& v : result.matches)
|
for (auto& v : result.matches)
|
||||||
fprintf(stderr, "%s\n", v.view.to_string().characters());
|
fprintf(stderr, "%s\n", v.view.to_string().characters());
|
||||||
#endif
|
}
|
||||||
|
|
||||||
EXPECT_EQ(result.matches.at(0).view, "[Window]");
|
EXPECT_EQ(result.matches.at(0).view, "[Window]");
|
||||||
EXPECT_EQ(result.capture_group_matches.at(0).at(0).view, "Window");
|
EXPECT_EQ(result.capture_group_matches.at(0).at(0).view, "Window");
|
||||||
|
@ -405,12 +405,12 @@ TEST_CASE(named_capture_group)
|
||||||
Regex<PosixExtended> re("[[:alpha:]]*=(?<Test>[[:digit:]]*)");
|
Regex<PosixExtended> re("[[:alpha:]]*=(?<Test>[[:digit:]]*)");
|
||||||
RegexResult result;
|
RegexResult result;
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||||
EXPECT_EQ(re.search(haystack, result, PosixFlags::Multiline), true);
|
EXPECT_EQ(re.search(haystack, result, PosixFlags::Multiline), true);
|
||||||
|
@ -426,12 +426,12 @@ TEST_CASE(a_star)
|
||||||
Regex<PosixExtended> re("a*");
|
Regex<PosixExtended> re("a*");
|
||||||
RegexResult result;
|
RegexResult result;
|
||||||
|
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||||
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
||||||
|
@ -488,14 +488,14 @@ TEST_CASE(ECMA262_parse)
|
||||||
for (auto& test : tests) {
|
for (auto& test : tests) {
|
||||||
Regex<ECMA262> re(test.pattern);
|
Regex<ECMA262> re(test.pattern);
|
||||||
EXPECT_EQ(re.parser_result.error, test.expected_error);
|
EXPECT_EQ(re.parser_result.error, test.expected_error);
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,14 +550,14 @@ TEST_CASE(ECMA262_match)
|
||||||
|
|
||||||
for (auto& test : tests) {
|
for (auto& test : tests) {
|
||||||
Regex<ECMA262> re(test.pattern, test.options);
|
Regex<ECMA262> re(test.pattern, test.options);
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
#endif
|
}
|
||||||
EXPECT_EQ(re.parser_result.error, Error::NoError);
|
EXPECT_EQ(re.parser_result.error, Error::NoError);
|
||||||
EXPECT_EQ(re.match(test.subject).success, test.matches);
|
EXPECT_EQ(re.match(test.subject).success, test.matches);
|
||||||
}
|
}
|
||||||
|
@ -583,14 +583,14 @@ TEST_CASE(replace)
|
||||||
|
|
||||||
for (auto& test : tests) {
|
for (auto& test : tests) {
|
||||||
Regex<ECMA262> re(test.pattern, test.options);
|
Regex<ECMA262> re(test.pattern, test.options);
|
||||||
#if REGEX_DEBUG
|
if constexpr (REGEX_DEBUG) {
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
RegexDebug regex_dbg(stderr);
|
RegexDebug regex_dbg(stderr);
|
||||||
regex_dbg.print_raw_bytecode(re);
|
regex_dbg.print_raw_bytecode(re);
|
||||||
regex_dbg.print_header();
|
regex_dbg.print_header();
|
||||||
regex_dbg.print_bytecode(re);
|
regex_dbg.print_bytecode(re);
|
||||||
dbgln("\n");
|
dbgln("\n");
|
||||||
#endif
|
}
|
||||||
EXPECT_EQ(re.parser_result.error, Error::NoError);
|
EXPECT_EQ(re.parser_result.error, Error::NoError);
|
||||||
EXPECT_EQ(re.replace(test.subject, test.replacement), test.expected);
|
EXPECT_EQ(re.replace(test.subject, test.replacement), test.expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,10 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
||||||
if (session_length && session_length <= 32) {
|
if (session_length && session_length <= 32) {
|
||||||
memcpy(m_context.session_id, buffer.offset_pointer(res), session_length);
|
memcpy(m_context.session_id, buffer.offset_pointer(res), session_length);
|
||||||
m_context.session_id_size = session_length;
|
m_context.session_id_size = session_length;
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("Remote session ID:");
|
dbgln("Remote session ID:");
|
||||||
print_buffer(ReadonlyBytes { m_context.session_id, session_length });
|
print_buffer(ReadonlyBytes { m_context.session_id, session_length });
|
||||||
#endif
|
}
|
||||||
} else {
|
} else {
|
||||||
m_context.session_id_size = 0;
|
m_context.session_id_size = 0;
|
||||||
}
|
}
|
||||||
|
@ -268,10 +268,10 @@ void TLSv12::build_random(PacketBuilder& builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& certificate = m_context.certificates[certificate_option.value()];
|
auto& certificate = m_context.certificates[certificate_option.value()];
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("PreMaster secret");
|
dbgln("PreMaster secret");
|
||||||
print_buffer(m_context.premaster_key);
|
print_buffer(m_context.premaster_key);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
Crypto::PK::RSA_PKCS1_EME rsa(certificate.public_key.modulus(), 0, certificate.public_key.public_exponent());
|
Crypto::PK::RSA_PKCS1_EME rsa(certificate.public_key.modulus(), 0, certificate.public_key.public_exponent());
|
||||||
|
|
||||||
|
@ -279,10 +279,10 @@ void TLSv12::build_random(PacketBuilder& builder)
|
||||||
auto outbuf = Bytes { out, rsa.output_size() };
|
auto outbuf = Bytes { out, rsa.output_size() };
|
||||||
rsa.encrypt(m_context.premaster_key, outbuf);
|
rsa.encrypt(m_context.premaster_key, outbuf);
|
||||||
|
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("Encrypted: ");
|
dbgln("Encrypted: ");
|
||||||
print_buffer(outbuf);
|
print_buffer(outbuf);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (!compute_master_secret(bytes)) {
|
if (!compute_master_secret(bytes)) {
|
||||||
dbgln("oh noes we could not derive a master key :(");
|
dbgln("oh noes we could not derive a master key :(");
|
||||||
|
|
|
@ -53,22 +53,22 @@ bool TLSv12::expand_key()
|
||||||
auto server_iv = key + offset;
|
auto server_iv = key + offset;
|
||||||
offset += iv_size;
|
offset += iv_size;
|
||||||
|
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("client key");
|
dbgln("client key");
|
||||||
print_buffer(client_key, key_size);
|
print_buffer(client_key, key_size);
|
||||||
dbgln("server key");
|
dbgln("server key");
|
||||||
print_buffer(server_key, key_size);
|
print_buffer(server_key, key_size);
|
||||||
dbgln("client iv");
|
dbgln("client iv");
|
||||||
print_buffer(client_iv, iv_size);
|
print_buffer(client_iv, iv_size);
|
||||||
dbgln("server iv");
|
dbgln("server iv");
|
||||||
print_buffer(server_iv, iv_size);
|
print_buffer(server_iv, iv_size);
|
||||||
if (!is_aead) {
|
if (!is_aead) {
|
||||||
dbgln("client mac key");
|
dbgln("client mac key");
|
||||||
print_buffer(m_context.crypto.local_mac, mac_size);
|
print_buffer(m_context.crypto.local_mac, mac_size);
|
||||||
dbgln("server mac key");
|
dbgln("server mac key");
|
||||||
print_buffer(m_context.crypto.remote_mac, mac_size);
|
print_buffer(m_context.crypto.remote_mac, mac_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (is_aead) {
|
if (is_aead) {
|
||||||
memcpy(m_context.crypto.local_aead_iv, client_iv, iv_size);
|
memcpy(m_context.crypto.local_aead_iv, client_iv, iv_size);
|
||||||
|
@ -153,10 +153,10 @@ bool TLSv12::compute_master_secret(size_t length)
|
||||||
ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) });
|
ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) });
|
||||||
|
|
||||||
m_context.premaster_key.clear();
|
m_context.premaster_key.clear();
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("master key:");
|
dbgln("master key:");
|
||||||
print_buffer(m_context.master_key);
|
print_buffer(m_context.master_key);
|
||||||
#endif
|
}
|
||||||
expand_key();
|
expand_key();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -195,9 +195,7 @@ ByteBuffer TLSv12::build_certificate()
|
||||||
builder.append((u8)HandshakeType::CertificateMessage);
|
builder.append((u8)HandshakeType::CertificateMessage);
|
||||||
|
|
||||||
if (!total_certificate_size) {
|
if (!total_certificate_size) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "No certificates, sending empty certificate message");
|
||||||
dbgln("No certificates, sending empty certificate message");
|
|
||||||
#endif
|
|
||||||
builder.append_u24(certificate_vector_header_size);
|
builder.append_u24(certificate_vector_header_size);
|
||||||
builder.append_u24(total_certificate_size);
|
builder.append_u24(total_certificate_size);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,9 +57,7 @@ String TLSv12::read_line(size_t max_size)
|
||||||
bool TLSv12::write(ReadonlyBytes buffer)
|
bool TLSv12::write(ReadonlyBytes buffer)
|
||||||
{
|
{
|
||||||
if (m_context.connection_status != ConnectionStatus::Established) {
|
if (m_context.connection_status != ConnectionStatus::Established) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "write request while not connected");
|
||||||
dbgln("write request while not connected");
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,9 +184,7 @@ bool TLSv12::check_connection_state(bool read)
|
||||||
{
|
{
|
||||||
if (!Core::Socket::is_open() || !Core::Socket::is_connected() || Core::Socket::eof()) {
|
if (!Core::Socket::is_open() || !Core::Socket::is_connected() || Core::Socket::eof()) {
|
||||||
// an abrupt closure (the server is a jerk)
|
// an abrupt closure (the server is a jerk)
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "Socket not open, assuming abrupt closure");
|
||||||
dbgln("Socket not open, assuming abrupt closure");
|
|
||||||
#endif
|
|
||||||
m_context.connection_finished = true;
|
m_context.connection_finished = true;
|
||||||
}
|
}
|
||||||
if (m_context.critical_error) {
|
if (m_context.critical_error) {
|
||||||
|
@ -209,9 +205,7 @@ bool TLSv12::check_connection_state(bool read)
|
||||||
m_context.application_buffer.size());
|
m_context.application_buffer.size());
|
||||||
} else {
|
} else {
|
||||||
m_context.connection_finished = false;
|
m_context.connection_finished = false;
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "FINISHED");
|
||||||
dbgln("FINISHED");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (!m_context.application_buffer.size()) {
|
if (!m_context.application_buffer.size()) {
|
||||||
m_context.connection_status = ConnectionStatus::Disconnected;
|
m_context.connection_status = ConnectionStatus::Disconnected;
|
||||||
|
@ -230,10 +224,10 @@ bool TLSv12::flush()
|
||||||
if (out_buffer_length == 0)
|
if (out_buffer_length == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("SENDING...");
|
dbgln("SENDING...");
|
||||||
print_buffer(out_buffer, out_buffer_length);
|
print_buffer(out_buffer, out_buffer_length);
|
||||||
#endif
|
}
|
||||||
if (Core::Socket::write(&out_buffer[out_buffer_index], out_buffer_length)) {
|
if (Core::Socket::write(&out_buffer[out_buffer_index], out_buffer_length)) {
|
||||||
write_buffer().clear();
|
write_buffer().clear();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -493,9 +493,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
||||||
ssize_t res = 0;
|
ssize_t res = 0;
|
||||||
|
|
||||||
if (buffer.size() < 3) {
|
if (buffer.size() < 3) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "not enough certificate header data");
|
||||||
dbgln("not enough certificate header data");
|
|
||||||
#endif
|
|
||||||
return (i8)Error::NeedMoreData;
|
return (i8)Error::NeedMoreData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,9 +507,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
||||||
res += 3;
|
res += 3;
|
||||||
|
|
||||||
if (certificate_total_length > buffer.size() - res) {
|
if (certificate_total_length > buffer.size() - res) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "not enough data for claimed total cert length");
|
||||||
dbgln("not enough data for claimed total cert length");
|
|
||||||
#endif
|
|
||||||
return (i8)Error::NeedMoreData;
|
return (i8)Error::NeedMoreData;
|
||||||
}
|
}
|
||||||
size_t size = certificate_total_length;
|
size_t size = certificate_total_length;
|
||||||
|
@ -522,18 +518,14 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
++index;
|
++index;
|
||||||
if (buffer.size() - res < 3) {
|
if (buffer.size() - res < 3) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "not enough data for certificate length");
|
||||||
dbgln("not enough data for certificate length");
|
|
||||||
#endif
|
|
||||||
return (i8)Error::NeedMoreData;
|
return (i8)Error::NeedMoreData;
|
||||||
}
|
}
|
||||||
size_t certificate_size = buffer[res] * 0x10000 + buffer[res + 1] * 0x100 + buffer[res + 2];
|
size_t certificate_size = buffer[res] * 0x10000 + buffer[res + 1] * 0x100 + buffer[res + 2];
|
||||||
res += 3;
|
res += 3;
|
||||||
|
|
||||||
if (buffer.size() - res < certificate_size) {
|
if (buffer.size() - res < certificate_size) {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "not enough data for certificate body");
|
||||||
dbgln("not enough data for certificate body");
|
|
||||||
#endif
|
|
||||||
return (i8)Error::NeedMoreData;
|
return (i8)Error::NeedMoreData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -797,9 +797,7 @@ void Terminal::ICH(const ParamVector& params)
|
||||||
|
|
||||||
void Terminal::on_input(u8 ch)
|
void Terminal::on_input(u8 ch)
|
||||||
{
|
{
|
||||||
#if TERMINAL_DEBUG
|
dbgln_if(TERMINAL_DEBUG, "Terminal::on_input: {:#02x} ({:c}), fg={}, bg={}\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color);
|
||||||
dbgln("Terminal::on_input: {:#02x} ({:c}), fg={}, bg={}\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto fail_utf8_parse = [this] {
|
auto fail_utf8_parse = [this] {
|
||||||
m_parser_state = Normal;
|
m_parser_state = Normal;
|
||||||
|
|
|
@ -58,11 +58,11 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
context.set_viewport_rect(old_viewport_rect);
|
context.set_viewport_rect(old_viewport_rect);
|
||||||
context.painter().restore();
|
context.painter().restore();
|
||||||
|
|
||||||
#if HIGHLIGHT_FOCUSED_FRAME_DEBUG
|
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
||||||
if (dom_node().content_frame()->is_focused_frame()) {
|
if (dom_node().content_frame()->is_focused_frame()) {
|
||||||
context.painter().draw_rect(absolute_rect().to<int>(), Color::Cyan);
|
context.painter().draw_rect(absolute_rect().to<int>(), Color::Cyan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,8 @@ static bool build_gemini_document(DOM::Document& document, const ByteBuffer& dat
|
||||||
auto gemini_document = Gemini::Document::parse(gemini_data, document.url());
|
auto gemini_document = Gemini::Document::parse(gemini_data, document.url());
|
||||||
String html_data = gemini_document->render_to_html();
|
String html_data = gemini_document->render_to_html();
|
||||||
|
|
||||||
#if GEMINI_DEBUG
|
dbgln_if(GEMINI_DEBUG, "Gemini data:\n\"\"\"{}\"\"\"", gemini_data);
|
||||||
dbgln("Gemini data:\n\"\"\"{}\"\"\"", gemini_data);
|
dbgln_if(GEMINI_DEBUG, "Converted to HTML:\n\"\"\"{}\"\"\"", html_data);
|
||||||
dbgln("Converted to HTML:\n\"\"\"{}\"\"\"", html_data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HTML::HTMLDocumentParser parser(document, html_data, "utf-8");
|
HTML::HTMLDocumentParser parser(document, html_data, "utf-8");
|
||||||
parser.run(document.url());
|
parser.run(document.url());
|
||||||
|
|
|
@ -75,9 +75,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
|
||||||
|
|
||||||
auto content_type = headers.get("Content-Type");
|
auto content_type = headers.get("Content-Type");
|
||||||
if (content_type.has_value()) {
|
if (content_type.has_value()) {
|
||||||
#if RESOURCE_DEBUG
|
dbgln_if(RESOURCE_DEBUG, "Content-Type header: '{}'", content_type.value());
|
||||||
dbgln("Content-Type header: '{}'", content_type.value());
|
|
||||||
#endif
|
|
||||||
m_encoding = encoding_from_content_type(content_type.value());
|
m_encoding = encoding_from_content_type(content_type.value());
|
||||||
m_mime_type = mime_type_from_content_type(content_type.value());
|
m_mime_type = mime_type_from_content_type(content_type.value());
|
||||||
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
|
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
|
||||||
|
@ -85,9 +83,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
|
||||||
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
|
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
|
||||||
m_mime_type = url().data_mime_type();
|
m_mime_type = url().data_mime_type();
|
||||||
} else {
|
} else {
|
||||||
#if RESOURCE_DEBUG
|
dbgln_if(RESOURCE_DEBUG, "No Content-Type header to go on! Guessing based on filename...");
|
||||||
dbgln("No Content-Type header to go on! Guessing based on filename...");
|
|
||||||
#endif
|
|
||||||
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
|
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
|
||||||
m_mime_type = Core::guess_mime_type_based_on_filename(url().path());
|
m_mime_type = Core::guess_mime_type_based_on_filename(url().path());
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,7 @@ void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateCon
|
||||||
|
|
||||||
void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelection&)
|
void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelection&)
|
||||||
{
|
{
|
||||||
#if SPAM_DEBUG
|
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeSelection!");
|
||||||
dbgln("handle: WebContentClient::DidChangeSelection!");
|
|
||||||
#endif
|
|
||||||
m_view.notify_server_did_change_selection({});
|
m_view.notify_server_did_change_selection({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +103,7 @@ void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& me
|
||||||
|
|
||||||
void WebContentClient::handle(const Messages::WebContentClient::DidUnhoverLink&)
|
void WebContentClient::handle(const Messages::WebContentClient::DidUnhoverLink&)
|
||||||
{
|
{
|
||||||
#if SPAM_DEBUG
|
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidUnhoverLink!");
|
||||||
dbgln("handle: WebContentClient::DidUnhoverLink!");
|
|
||||||
#endif
|
|
||||||
m_view.notify_server_did_unhover_link({});
|
m_view.notify_server_did_unhover_link({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,7 @@ void LookupServer::load_etc_hosts()
|
||||||
|
|
||||||
Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short record_type)
|
Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short record_type)
|
||||||
{
|
{
|
||||||
#if LOOKUPSERVER_DEBUG
|
dbgln_if(LOOKUPSERVER_DEBUG, "Got request for '{}'", name.as_string());
|
||||||
dbgln("Got request for '{}'", name.as_string());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Vector<DNSAnswer> answers;
|
Vector<DNSAnswer> answers;
|
||||||
auto add_answer = [&](const DNSAnswer& answer) {
|
auto add_answer = [&](const DNSAnswer& answer) {
|
||||||
|
@ -144,9 +142,7 @@ Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short recor
|
||||||
for (auto& answer : cached_answers.value()) {
|
for (auto& answer : cached_answers.value()) {
|
||||||
// TODO: Actually remove expired answers from the cache.
|
// TODO: Actually remove expired answers from the cache.
|
||||||
if (answer.type() == record_type && !answer.has_expired()) {
|
if (answer.type() == record_type && !answer.has_expired()) {
|
||||||
#if LOOKUPSERVER_DEBUG
|
dbgln_if(LOOKUPSERVER_DEBUG, "Cache hit: {} -> {}", name.as_string(), answer.record_data());
|
||||||
dbgln("Cache hit: {} -> {}", name.as_string(), answer.record_data());
|
|
||||||
#endif
|
|
||||||
add_answer(answer);
|
add_answer(answer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,9 +152,7 @@ Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short recor
|
||||||
|
|
||||||
// Third, ask the upstream nameservers.
|
// Third, ask the upstream nameservers.
|
||||||
for (auto& nameserver : m_nameservers) {
|
for (auto& nameserver : m_nameservers) {
|
||||||
#if LOOKUPSERVER_DEBUG
|
dbgln_if(LOOKUPSERVER_DEBUG, "Doing lookup using nameserver '{}'", nameserver);
|
||||||
dbgln("Doing lookup using nameserver '{}'", nameserver);
|
|
||||||
#endif
|
|
||||||
bool did_get_response = false;
|
bool did_get_response = false;
|
||||||
int retries = 3;
|
int retries = 3;
|
||||||
Vector<DNSAnswer> upstream_answers;
|
Vector<DNSAnswer> upstream_answers;
|
||||||
|
|
|
@ -240,12 +240,12 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
WindowIdentifier identifier { event.client_id(), event.window_id() };
|
WindowIdentifier identifier { event.client_id(), event.window_id() };
|
||||||
switch (event.type()) {
|
switch (event.type()) {
|
||||||
case GUI::Event::WM_WindowRemoved: {
|
case GUI::Event::WM_WindowRemoved: {
|
||||||
#if EVENT_DEBUG
|
if constexpr (EVENT_DEBUG) {
|
||||||
auto& removed_event = static_cast<GUI::WMWindowRemovedEvent&>(event);
|
auto& removed_event = static_cast<GUI::WMWindowRemovedEvent&>(event);
|
||||||
dbgln("WM_WindowRemoved: client_id={}, window_id={}",
|
dbgln("WM_WindowRemoved: client_id={}, window_id={}",
|
||||||
removed_event.client_id(),
|
removed_event.client_id(),
|
||||||
removed_event.window_id());
|
removed_event.window_id());
|
||||||
#endif
|
}
|
||||||
if (auto* window = WindowList::the().window(identifier))
|
if (auto* window = WindowList::the().window(identifier))
|
||||||
remove_window_button(*window, true);
|
remove_window_button(*window, true);
|
||||||
WindowList::the().remove_window(identifier);
|
WindowList::the().remove_window(identifier);
|
||||||
|
@ -253,13 +253,13 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GUI::Event::WM_WindowRectChanged: {
|
case GUI::Event::WM_WindowRectChanged: {
|
||||||
#if EVENT_DEBUG
|
if constexpr (EVENT_DEBUG) {
|
||||||
auto& changed_event = static_cast<GUI::WMWindowRectChangedEvent&>(event);
|
auto& changed_event = static_cast<GUI::WMWindowRectChangedEvent&>(event);
|
||||||
dbgln("WM_WindowRectChanged: client_id={}, window_id={}, rect={}",
|
dbgln("WM_WindowRectChanged: client_id={}, window_id={}, rect={}",
|
||||||
changed_event.client_id(),
|
changed_event.client_id(),
|
||||||
changed_event.window_id(),
|
changed_event.window_id(),
|
||||||
changed_event.rect());
|
changed_event.rect());
|
||||||
#endif
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,15 +274,15 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
|
|
||||||
case GUI::Event::WM_WindowStateChanged: {
|
case GUI::Event::WM_WindowStateChanged: {
|
||||||
auto& changed_event = static_cast<GUI::WMWindowStateChangedEvent&>(event);
|
auto& changed_event = static_cast<GUI::WMWindowStateChangedEvent&>(event);
|
||||||
#if EVENT_DEBUG
|
if constexpr (EVENT_DEBUG) {
|
||||||
dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}",
|
dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}",
|
||||||
changed_event.client_id(),
|
changed_event.client_id(),
|
||||||
changed_event.window_id(),
|
changed_event.window_id(),
|
||||||
changed_event.title(),
|
changed_event.title(),
|
||||||
changed_event.rect(),
|
changed_event.rect(),
|
||||||
changed_event.is_active(),
|
changed_event.is_active(),
|
||||||
changed_event.is_minimized());
|
changed_event.is_minimized());
|
||||||
#endif
|
}
|
||||||
if (changed_event.window_type() != GUI::WindowType::Normal || changed_event.is_frameless()) {
|
if (changed_event.window_type() != GUI::WindowType::Normal || changed_event.is_frameless()) {
|
||||||
if (auto* window = WindowList::the().window(identifier))
|
if (auto* window = WindowList::the().window(identifier))
|
||||||
remove_window_button(*window, false);
|
remove_window_button(*window, false);
|
||||||
|
|
|
@ -865,9 +865,7 @@ void Compositor::recompute_occlusions()
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
#if OCCLUSIONS_DEBUG
|
dbgln_if(OCCLUSIONS_DEBUG, "OCCLUSIONS:");
|
||||||
dbgln("OCCLUSIONS:");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto screen_rect = Screen::the().rect();
|
auto screen_rect = Screen::the().rect();
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,7 @@ void EventLoop::drain_mouse()
|
||||||
return;
|
return;
|
||||||
for (size_t i = 0; i < npackets; ++i) {
|
for (size_t i = 0; i < npackets; ++i) {
|
||||||
auto& packet = packets[i];
|
auto& packet = packets[i];
|
||||||
#if WSMESSAGELOOP_DEBUG
|
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
|
||||||
dbgln("EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
|
|
||||||
#endif
|
|
||||||
buttons = packet.buttons;
|
buttons = packet.buttons;
|
||||||
|
|
||||||
state.is_relative = packet.is_relative;
|
state.is_relative = packet.is_relative;
|
||||||
|
@ -115,9 +113,7 @@ void EventLoop::drain_mouse()
|
||||||
|
|
||||||
if (buttons != state.buttons) {
|
if (buttons != state.buttons) {
|
||||||
state.buttons = buttons;
|
state.buttons = buttons;
|
||||||
#if WSMESSAGELOOP_DEBUG
|
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse Button Event");
|
||||||
dbgln("EventLoop: Mouse Button Event");
|
|
||||||
#endif
|
|
||||||
screen.on_receive_mouse_data(state);
|
screen.on_receive_mouse_data(state);
|
||||||
if (state.is_relative) {
|
if (state.is_relative) {
|
||||||
state.x = 0;
|
state.x = 0;
|
||||||
|
|
|
@ -124,14 +124,10 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
|
||||||
auto prev_location = m_physical_cursor_location / m_scale_factor;
|
auto prev_location = m_physical_cursor_location / m_scale_factor;
|
||||||
if (packet.is_relative) {
|
if (packet.is_relative) {
|
||||||
m_physical_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
|
m_physical_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
|
||||||
#if WSSCREEN_DEBUG
|
dbgln_if(WSSCREEN_DEBUG, "Screen: New Relative mouse point @ {}", m_physical_cursor_location);
|
||||||
dbgln("Screen: New Relative mouse point @ {}", m_physical_cursor_location);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
m_physical_cursor_location = { packet.x * physical_width() / 0xffff, packet.y * physical_height() / 0xffff };
|
m_physical_cursor_location = { packet.x * physical_width() / 0xffff, packet.y * physical_height() / 0xffff };
|
||||||
#if WSSCREEN_DEBUG
|
dbgln_if(WSSCREEN_DEBUG, "Screen: New Absolute mouse point @ {}", m_physical_cursor_location);
|
||||||
dbgln("Screen: New Absolute mouse point @ {}", m_physical_cursor_location);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_physical_cursor_location.constrain(physical_rect());
|
m_physical_cursor_location.constrain(physical_rect());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue