mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +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
|
@ -15,9 +15,7 @@ namespace HackStudio {
|
|||
|
||||
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||
{
|
||||
#if CURSOR_TOOL_DEBUG
|
||||
dbgln("CursorTool::on_mousedown");
|
||||
#endif
|
||||
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mousedown");
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
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)
|
||||
{
|
||||
#if CURSOR_TOOL_DEBUG
|
||||
dbgln("CursorTool::on_mouseup");
|
||||
#endif
|
||||
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mouseup");
|
||||
if (event.button() == GUI::MouseButton::Left) {
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
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)
|
||||
{
|
||||
#if CURSOR_TOOL_DEBUG
|
||||
dbgln("CursorTool::on_mousemove");
|
||||
#endif
|
||||
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_mousemove");
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
|
||||
if (m_rubber_banding) {
|
||||
|
@ -112,9 +106,7 @@ void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
|||
|
||||
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
||||
{
|
||||
#if CURSOR_TOOL_DEBUG
|
||||
dbgln("CursorTool::on_keydown");
|
||||
#endif
|
||||
dbgln_if(CURSOR_TOOL_DEBUG, "CursorTool::on_keydown");
|
||||
|
||||
auto move_selected_widgets_by = [this](int x, int y) {
|
||||
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_hunks = Diff::parse_hunks(diff);
|
||||
|
||||
#if DIFF_DEBUG
|
||||
for (size_t i = 0; i < m_original_lines.size(); ++i)
|
||||
dbgln("{}:{}", i, m_original_lines[i]);
|
||||
#endif
|
||||
if constexpr (DIFF_DEBUG) {
|
||||
for (size_t i = 0; i < m_original_lines.size(); ++i)
|
||||
dbgln("{}:{}", i, m_original_lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
#if AUTOCOMPLETE_DEBUG
|
||||
for (auto& suggestion : suggestions) {
|
||||
dbgln("suggestion: {}", suggestion.completion);
|
||||
if constexpr (AUTOCOMPLETE_DEBUG) {
|
||||
for (auto& suggestion : suggestions) {
|
||||
dbgln("suggestion: {}", suggestion.completion);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
|
|
@ -49,9 +49,8 @@ OwnPtr<ParserAutoComplete::DocumentData> ParserAutoComplete::create_document_dat
|
|||
for (auto& path : document_data->preprocessor().included_paths()) {
|
||||
get_or_create_document_data(document_path_from_include_path(path));
|
||||
}
|
||||
#ifdef CPP_LANGUAGE_SERVER_DEBUG
|
||||
root->dump(0);
|
||||
#endif
|
||||
if constexpr (CPP_LANGUAGE_SERVER_DEBUG)
|
||||
root->dump(0);
|
||||
|
||||
update_declared_symbols(*document_data);
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef GENERATE_DEBUG_CODE
|
||||
# define GENERATE_DEBUG_CODE 0
|
||||
#endif
|
||||
|
||||
struct Parameter {
|
||||
Vector<String> attributes;
|
||||
String type;
|
||||
|
@ -444,22 +448,22 @@ public:
|
|||
stream >> message_endpoint_magic;
|
||||
if (stream.handle_any_error()) {
|
||||
)~~~");
|
||||
#if GENERATE_DEBUG_CODE
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read message endpoint magic");
|
||||
if constexpr (GENERATE_DEBUG_CODE) {
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read message endpoint magic");
|
||||
)~~~");
|
||||
#endif
|
||||
}
|
||||
endpoint_generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
|
||||
if (message_endpoint_magic != @endpoint.magic@) {
|
||||
)~~~");
|
||||
#if GENERATE_DEBUG_CODE
|
||||
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)");
|
||||
if constexpr (GENERATE_DEBUG_CODE) {
|
||||
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)");
|
||||
)~~~");
|
||||
#endif
|
||||
}
|
||||
endpoint_generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
|
@ -468,11 +472,11 @@ public:
|
|||
stream >> message_id;
|
||||
if (stream.handle_any_error()) {
|
||||
)~~~");
|
||||
#if GENERATE_DEBUG_CODE
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read message ID");
|
||||
if constexpr (GENERATE_DEBUG_CODE) {
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read message ID");
|
||||
)~~~");
|
||||
#endif
|
||||
}
|
||||
endpoint_generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
|
@ -502,22 +506,22 @@ public:
|
|||
endpoint_generator.append(R"~~~(
|
||||
default:
|
||||
)~~~");
|
||||
#if GENERATE_DEBUG_CODE
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to decode @endpoint.name@.({})", message_id);
|
||||
if constexpr (GENERATE_DEBUG_CODE) {
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to decode @endpoint.name@.({})", message_id);
|
||||
)~~~");
|
||||
#endif
|
||||
}
|
||||
endpoint_generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
|
||||
if (stream.handle_any_error()) {
|
||||
)~~~");
|
||||
#if GENERATE_DEBUG_CODE
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read the message");
|
||||
if constexpr (GENERATE_DEBUG_CODE) {
|
||||
endpoint_generator.append(R"~~~(
|
||||
dbgln("Failed to read the message");
|
||||
)~~~");
|
||||
#endif
|
||||
}
|
||||
endpoint_generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -31,9 +31,8 @@ namespace UserspaceEmulator {
|
|||
|
||||
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||
{
|
||||
#if SPAM_DEBUG
|
||||
reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function);
|
||||
#endif
|
||||
if constexpr (SPAM_DEBUG)
|
||||
reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function);
|
||||
switch (function) {
|
||||
case SC_chdir:
|
||||
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 other_address = value.value();
|
||||
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
||||
#if REACHABLE_DEBUG
|
||||
reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.address);
|
||||
#endif
|
||||
if constexpr (REACHABLE_DEBUG)
|
||||
reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.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 other_address = value.value();
|
||||
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
|
||||
#if REACHABLE_DEBUG
|
||||
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1);
|
||||
#endif
|
||||
if constexpr (REACHABLE_DEBUG)
|
||||
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1);
|
||||
m_memory_graph.find(other_address)->value.is_reachable = true;
|
||||
reachable_mallocations.append(other_address);
|
||||
}
|
||||
|
@ -388,9 +386,8 @@ void MallocTracer::dump_leak_report()
|
|||
|
||||
populate_memory_graph();
|
||||
|
||||
#if REACHABLE_DEBUG
|
||||
dump_memory_graph();
|
||||
#endif
|
||||
if constexpr (REACHABLE_DEBUG)
|
||||
dump_memory_graph();
|
||||
|
||||
for_each_mallocation([&](auto& mallocation) {
|
||||
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);
|
||||
auto value = m_emulator.mmu().read128(address);
|
||||
#if MEMORY_DEBUG
|
||||
outln("\033[36;1mread_memory128: @{:04x}:{:08x} -> {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
#endif
|
||||
outln_if(MEMORY_DEBUG, "\033[36;1mread_memory128: @{:04x}:{:08x} -> {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
return value;
|
||||
}
|
||||
ValueWithShadow<u256> SoftCPU::read_memory256(X86::LogicalAddress address)
|
||||
{
|
||||
VERIFY(address.selector() == 0x1b || address.selector() == 0x23 || address.selector() == 0x2b);
|
||||
auto value = m_emulator.mmu().read256(address);
|
||||
#if MEMORY_DEBUG
|
||||
outln("\033[36;1mread_memory256: @{:04x}:{:08x} -> {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
#endif
|
||||
outln_if(MEMORY_DEBUG, "\033[36;1mread_memory256: @{:04x}:{:08x} -> {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
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)
|
||||
{
|
||||
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
||||
#if MEMORY_DEBUG
|
||||
outln("\033[36;1mwrite_memory128: @{:04x}:{:08x} <- {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
#endif
|
||||
outln_if(MEMORY_DEBUG, "\033[36;1mwrite_memory128: @{:04x}:{:08x} <- {:032x} ({:032x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
m_emulator.mmu().write128(address, value);
|
||||
}
|
||||
|
||||
void SoftCPU::write_memory256(X86::LogicalAddress address, ValueWithShadow<u256> value)
|
||||
{
|
||||
VERIFY(address.selector() == 0x23 || address.selector() == 0x2b);
|
||||
#if MEMORY_DEBUG
|
||||
outln("\033[36;1mwrite_memory256: @{:04x}:{:08x} <- {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
#endif
|
||||
outln_if(MEMORY_DEBUG, "\033[36;1mwrite_memory256: @{:04x}:{:08x} <- {:064x} ({:064x})\033[0m", address.selector(), address.offset(), value, value.shadow());
|
||||
m_emulator.mmu().write256(address, value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue