1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

Everywhere: Replace a bundle of dbg with dbgln.

These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
This commit is contained in:
asynts 2021-01-17 20:28:43 +01:00 committed by Andreas Kling
parent 24888457d5
commit fb8d3635d9
9 changed files with 99 additions and 69 deletions

View file

@ -513,3 +513,45 @@ constexpr bool debug_occlusions = true;
#else #else
constexpr bool debug_occlusions = false; constexpr bool debug_occlusions = false;
#endif #endif
#ifdef DEBUG_MENUS
constexpr bool debug_menus = true;
#else
constexpr bool debug_menus = false;
#endif
#ifdef WSSCREEN_DEBUG
constexpr bool debug_wsscreen = true;
#else
constexpr bool debug_wsscreen = false;
#endif
#ifdef WINDOWMANAGER_DEBUG
constexpr bool debug_window_manager = true;
#else
constexpr bool debug_window_manager = false;
#endif
#ifdef RESIZE_DEBUG
constexpr bool debug_resize = true;
#else
constexpr bool debug_resize = false;
#endif
#ifdef MOVE_DEBUG
constexpr bool debug_move = true;
#else
constexpr bool debug_move = false;
#endif
#ifdef DOUBLECLICK_DEBUG
constexpr bool debug_double_click = true;
#else
constexpr bool debug_double_click = false;
#endif
#ifdef DISASM_DUMP
constexpr bool debug_disasm_dump = true;
#else
constexpr bool debug_disasm_dump = false;
#endif

View file

@ -67,7 +67,7 @@ CursorParams CursorParams::parse_from_file_name(const StringView& cursor_path, c
return parsed_number.value(); return parsed_number.value();
}(); }();
if (!value.has_value()) { if (!value.has_value()) {
dbg() << "Failed to parse value for property '" << property << "' from parsed cursor path: " << cursor_path; dbgln("Failed to parse value for property '{}' from parsed cursor path: {}", property, cursor_path);
return { default_hotspot }; return { default_hotspot };
} }
switch (property) { switch (property) {
@ -93,7 +93,7 @@ CursorParams CursorParams::parse_from_file_name(const StringView& cursor_path, c
in_display_scale_part = true; in_display_scale_part = true;
break; break;
default: default:
dbg() << "Ignore unknown property '" << property << "' with value " << value.value() << " parsed from cursor path: " << cursor_path; dbgln("Ignore unknown property '{}' with value {} parsed from cursor path: {}", property, value.value(), cursor_path);
return { default_hotspot }; return { default_hotspot };
} }
} }
@ -108,7 +108,7 @@ CursorParams CursorParams::constrained(const Gfx::Bitmap& bitmap) const
if (rect.width() % params.m_frames == 0) { if (rect.width() % params.m_frames == 0) {
rect.set_width(rect.width() / (int)params.m_frames); rect.set_width(rect.width() / (int)params.m_frames);
} else { } else {
dbg() << "Cannot divide cursor dimensions " << rect << " into " << params.m_frames << " frames"; dbgln("Cannot divide cursor dimensions {} into {} frames", rect, params.m_frames);
params.m_frames = 1; params.m_frames = 1;
} }
} }

View file

@ -26,6 +26,7 @@
*/ */
#include <AK/Badge.h> #include <AK/Badge.h>
#include <AK/Debug.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <LibCore/DirIterator.h> #include <LibCore/DirIterator.h>
#include <LibGfx/Font.h> #include <LibGfx/Font.h>
@ -36,8 +37,6 @@
#include <WindowServer/WindowManager.h> #include <WindowServer/WindowManager.h>
#include <unistd.h> #include <unistd.h>
//#define DEBUG_MENUS
namespace WindowServer { namespace WindowServer {
static MenuManager* s_the; static MenuManager* s_the;
@ -459,9 +458,9 @@ void MenuManager::set_current_menubar(MenuBar* menubar)
m_current_menubar = *menubar; m_current_menubar = *menubar;
else else
m_current_menubar = nullptr; m_current_menubar = nullptr;
#ifdef DEBUG_MENUS
dbg() << "[WM] Current menubar is now " << menubar; dbgln<debug_menus>("[WM] Current menubar is now {}", menubar);
#endif
Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 }; Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 };
for_each_active_menubar_menu([&](Menu& menu) { for_each_active_menubar_menu([&](Menu& menu) {
int text_width = menu.title_font().width(menu.name()); int text_width = menu.title_font().width(menu.name());

View file

@ -29,6 +29,7 @@
#include "Event.h" #include "Event.h"
#include "EventLoop.h" #include "EventLoop.h"
#include "WindowManager.h" #include "WindowManager.h"
#include <AK/Debug.h>
#include <Kernel/API/FB.h> #include <Kernel/API/FB.h>
#include <Kernel/API/MousePacket.h> #include <Kernel/API/MousePacket.h>
#include <fcntl.h> #include <fcntl.h>
@ -81,15 +82,14 @@ bool Screen::set_resolution(int width, int height, int new_scale_factor)
FBResolution physical_resolution { 0, (unsigned)new_physical_width, (unsigned)new_physical_height }; FBResolution physical_resolution { 0, (unsigned)new_physical_width, (unsigned)new_physical_height };
int rc = fb_set_resolution(m_framebuffer_fd, &physical_resolution); int rc = fb_set_resolution(m_framebuffer_fd, &physical_resolution);
#ifdef WSSCREEN_DEBUG dbgln<debug_wsscreen>("fb_set_resolution() - return code {}", rc);
dbg() << "fb_set_resolution() - return code " << rc;
#endif
if (rc == 0) { if (rc == 0) {
on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor); on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor);
return true; return true;
} }
if (rc == -1) { if (rc == -1) {
dbg() << "Invalid resolution " << width << "x" << height; dbgln("Invalid resolution {}x{}", width, height);
on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor); on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor);
return false; return false;
} }

View file

@ -139,13 +139,13 @@ bool WindowManager::set_resolution(int width, int height, int scale)
} }
if (m_config) { if (m_config) {
if (success) { if (success) {
dbg() << "Saving resolution: " << Gfx::IntSize(width, height) << " @ " << scale << "x to config file at " << m_config->file_name(); dbgln("Saving resolution: {} @ {}x to config file at {}", Gfx::IntSize(width, height), scale, m_config->file_name());
m_config->write_num_entry("Screen", "Width", width); m_config->write_num_entry("Screen", "Width", width);
m_config->write_num_entry("Screen", "Height", height); m_config->write_num_entry("Screen", "Height", height);
m_config->write_num_entry("Screen", "ScaleFactor", scale); m_config->write_num_entry("Screen", "ScaleFactor", scale);
m_config->sync(); m_config->sync();
} else { } else {
dbg() << "Saving fallback resolution: " << resolution() << " @ 1x to config file at " << m_config->file_name(); dbgln("Saving fallback resolution: {} @1x to config file at {}", resolution(), m_config->file_name());
m_config->write_num_entry("Screen", "Width", resolution().width()); m_config->write_num_entry("Screen", "Width", resolution().width());
m_config->write_num_entry("Screen", "Height", resolution().height()); m_config->write_num_entry("Screen", "Height", resolution().height());
m_config->write_num_entry("Screen", "ScaleFactor", 1); m_config->write_num_entry("Screen", "ScaleFactor", 1);
@ -347,9 +347,9 @@ void WindowManager::notify_title_changed(Window& window)
{ {
if (window.type() != WindowType::Normal) if (window.type() != WindowType::Normal)
return; return;
#ifdef WINDOWMANAGER_DEBUG
dbg() << "[WM] Window{" << &window << "} title set to \"" << window.title() << '"'; dbgln<debug_window_manager>("[WM] Window({}) title set to '{}'", &window, window.title());
#endif
if (m_switcher.is_visible()) if (m_switcher.is_visible())
m_switcher.refresh(); m_switcher.refresh();
@ -360,20 +360,19 @@ void WindowManager::notify_modal_unparented(Window& window)
{ {
if (window.type() != WindowType::Normal) if (window.type() != WindowType::Normal)
return; return;
#ifdef WINDOWMANAGER_DEBUG
dbg() << "[WM] Modal Window{" << &window << "} was unparented"; dbgln<debug_window_manager>("[WM] Window({}) was unparented", &window);
#endif
if (m_switcher.is_visible()) if (m_switcher.is_visible())
m_switcher.refresh(); m_switcher.refresh();
tell_wm_listeners_window_state_changed(window); tell_wm_listeners_window_state_changed(window);
} }
void WindowManager::notify_rect_changed(Window& window, [[maybe_unused]] const Gfx::IntRect& old_rect, [[maybe_unused]] const Gfx::IntRect& new_rect) void WindowManager::notify_rect_changed(Window& window, const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect)
{ {
#ifdef RESIZE_DEBUG dbgln<debug_resize>("[WM] Window({}) rect changed {} -> {}", &window, old_rect, new_rect);
dbg() << "[WM] Window " << &window << " rect changed " << old_rect << " -> " << new_rect;
#endif
if (m_switcher.is_visible() && window.type() != WindowType::WindowSwitcher) if (m_switcher.is_visible() && window.type() != WindowType::WindowSwitcher)
m_switcher.refresh(); m_switcher.refresh();
@ -437,9 +436,8 @@ bool WindowManager::pick_new_active_window(Window* previous_active)
void WindowManager::start_window_move(Window& window, const MouseEvent& event) void WindowManager::start_window_move(Window& window, const MouseEvent& event)
{ {
#ifdef MOVE_DEBUG dbgln<debug_move>("[WM] Begin moving Window({})", &window);
dbg() << "[WM] Begin moving Window{" << &window << "}";
#endif
move_to_front_and_make_active(window); move_to_front_and_make_active(window);
m_move_window = window; m_move_window = window;
m_move_window->set_default_positioned(false); m_move_window->set_default_positioned(false);
@ -459,7 +457,7 @@ void WindowManager::start_window_resize(Window& window, const Gfx::IntPoint& pos
Gfx::IntRect outer_rect = window.frame().rect(); Gfx::IntRect outer_rect = window.frame().rect();
if (!outer_rect.contains(position)) { if (!outer_rect.contains(position)) {
// FIXME: This used to be an ASSERT but crashing WindowServer over this seems silly. // FIXME: This used to be an ASSERT but crashing WindowServer over this seems silly.
dbg() << "FIXME: !outer_rect.contains(position): outer_rect=" << outer_rect << ", position=" << position; dbgln("FIXME: !outer_rect.contains(position): outer_rect={}, position={}", outer_rect, position);
} }
int window_relative_x = position.x() - outer_rect.x(); int window_relative_x = position.x() - outer_rect.x();
int window_relative_y = position.y() - outer_rect.y(); int window_relative_y = position.y() - outer_rect.y();
@ -471,9 +469,8 @@ void WindowManager::start_window_resize(Window& window, const Gfx::IntPoint& pos
return; return;
} }
#ifdef RESIZE_DEBUG dbgln<debug_resize>("[WM] Begin resizing Window({})", &window);
dbg() << "[WM] Begin resizing Window{" << &window << "}";
#endif
m_resizing_mouse_button = button; m_resizing_mouse_button = button;
m_resize_window = window; m_resize_window = window;
m_resize_origin = position; m_resize_origin = position;
@ -498,9 +495,8 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
if (!m_move_window) if (!m_move_window)
return false; return false;
if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) { if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) {
#ifdef MOVE_DEBUG
dbg() << "[WM] Finish moving Window{" << m_move_window << "}"; dbgln<debug_move>("[WM] Finish moving Window({})", m_move_window);
#endif
m_move_window->invalidate(); m_move_window->invalidate();
if (m_move_window->rect().contains(event.position())) if (m_move_window->rect().contains(event.position()))
@ -518,21 +514,17 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
return true; return true;
} }
if (event.type() == Event::MouseMove) { if (event.type() == Event::MouseMove) {
if constexpr (debug_move) {
#ifdef MOVE_DEBUG dbgln("[WM] Moving, origin: {}, now: {}", m_move_origin, event.position());
dbg() << "[WM] Moving, origin: " << m_move_origin << ", now: " << event.position(); if (m_move_window->is_maximized())
if (m_move_window->is_maximized()) { dbgln(" [!] The window is still maximized. Not moving yet.");
dbgln(" [!] The window is still maximized. Not moving yet.");
} }
#endif
const int tiling_deadzone = 10; const int tiling_deadzone = 10;
const int secondary_deadzone = 2; const int secondary_deadzone = 2;
if (m_move_window->is_maximized()) { if (m_move_window->is_maximized()) {
auto pixels_moved_from_start = event.position().pixels_moved(m_move_origin); auto pixels_moved_from_start = event.position().pixels_moved(m_move_origin);
// dbg() << "[WM] " << pixels_moved_from_start << " moved since start of window move";
if (pixels_moved_from_start > 5) { if (pixels_moved_from_start > 5) {
// dbgln("[WM] de-maximizing window"); // dbgln("[WM] de-maximizing window");
m_move_origin = event.position(); m_move_origin = event.position();
@ -585,9 +577,8 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
return false; return false;
if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) { if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) {
#ifdef RESIZE_DEBUG dbgln<debug_resize>("[WM] Finish resizing Window({})", m_resize_window);
dbg() << "[WM] Finish resizing Window{" << m_resize_window << "}";
#endif
Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect())); Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect()));
m_resize_window->invalidate(); m_resize_window->invalidate();
if (m_resize_window->rect().contains(event.position())) if (m_resize_window->rect().contains(event.position()))
@ -693,9 +684,9 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
if (m_resize_window->rect() == new_rect) if (m_resize_window->rect() == new_rect)
return true; return true;
#ifdef RESIZE_DEBUG
dbg() << "[WM] Resizing, original: " << m_resize_window_original_rect << ", now: " << new_rect; dbgln<debug_resize>("[WM] Resizing, original: {}, now: {}", m_resize_window_original_rect, new_rect);
#endif
m_resize_window->set_rect(new_rect); m_resize_window->set_rect(new_rect);
Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect)); Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect));
return true; return true;
@ -817,9 +808,9 @@ void WindowManager::start_menu_doubleclick(Window& window, const MouseEvent& eve
if (&window != m_double_click_info.m_clicked_window) { if (&window != m_double_click_info.m_clicked_window) {
// we either haven't clicked anywhere, or we haven't clicked on this // we either haven't clicked anywhere, or we haven't clicked on this
// window. set the current click window, and reset the timers. // window. set the current click window, and reset the timers.
#if defined(DOUBLECLICK_DEBUG)
dbg() << "Initial mousedown on window " << &window << " for menu (previous was " << m_double_click_info.m_clicked_window << ')'; dbgln<debug_double_click>("Initial mousedown on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window);
#endif
m_double_click_info.m_clicked_window = window; m_double_click_info.m_clicked_window = window;
m_double_click_info.reset(); m_double_click_info.reset();
} }
@ -850,9 +841,8 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev
if (&window != m_double_click_info.m_clicked_window) { if (&window != m_double_click_info.m_clicked_window) {
// we either haven't clicked anywhere, or we haven't clicked on this // we either haven't clicked anywhere, or we haven't clicked on this
// window. set the current click window, and reset the timers. // window. set the current click window, and reset the timers.
#if defined(DOUBLECLICK_DEBUG) dbgln<debug_double_click>("Initial mouseup on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window);
dbg() << "Initial mouseup on window " << &window << " (previous was " << m_double_click_info.m_clicked_window << ')';
#endif
m_double_click_info.m_clicked_window = window; m_double_click_info.m_clicked_window = window;
m_double_click_info.reset(); m_double_click_info.reset();
} }
@ -866,9 +856,8 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev
// clock // clock
metadata.clock.start(); metadata.clock.start();
} else { } else {
#if defined(DOUBLECLICK_DEBUG) dbgln<debug_double_click>("Transforming MouseUp to MouseDoubleClick ({} < {})!", metadata.clock.elapsed(), m_double_click_speed);
dbg() << "Transforming MouseUp to MouseDoubleClick (" << metadata.clock.elapsed() << " < " << m_double_click_speed << ")!";
#endif
event = MouseEvent(Event::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta()); event = MouseEvent(Event::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta());
// invalidate this now we've delivered a doubleclick, otherwise // invalidate this now we've delivered a doubleclick, otherwise
// tripleclick will deliver two doubleclick events (incorrectly). // tripleclick will deliver two doubleclick events (incorrectly).

View file

@ -55,7 +55,7 @@ public:
if (m_active) { if (m_active) {
auto elapsed = m_command_timer.elapsed(); auto elapsed = m_command_timer.elapsed();
// Don't mistake this for the command! // Don't mistake this for the command!
dbg() << "Job entry \"" << m_cmd << "\" deleted in " << elapsed << " ms"; dbgln("Job entry '{}' deleted in {} ms", m_cmd, elapsed);
} }
#endif #endif
} }

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/Debug.h>
#include <AK/LogStream.h> #include <AK/LogStream.h>
#include <AK/MappedFile.h> #include <AK/MappedFile.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
@ -35,8 +36,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
//#define DISASM_DUMP
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
const char* path = nullptr; const char* path = nullptr;
@ -100,10 +99,10 @@ int main(int argc, char** argv)
return a.size < b.size; return a.size < b.size;
return a.name < b.name; return a.name < b.name;
}); });
#ifdef DISASM_DUMP if constexpr (debug_disasm_dump) {
for (size_t i = 0; i < symbols.size(); ++i) for (size_t i = 0; i < symbols.size(); ++i)
dbg() << symbols[i].name << ": " << (void*)(uintptr_t)symbols[i].value << ", " << symbols[i].size; dbgln("{}: {:p}, {}", symbols[i].name, symbols[i].value, symbols[i].size);
#endif }
} }
} }

View file

@ -121,8 +121,8 @@ static bool mount_all()
int fd = get_source_fd(filename); int fd = get_source_fd(filename);
dbg() << "Mounting " << filename << "(" << fstype << ")" dbgln("Mounting {} ({}) on {}", filename, fstype, mountpoint);
<< " on " << mountpoint;
int rc = mount(fd, mountpoint, fstype, flags); int rc = mount(fd, mountpoint, fstype, flags);
if (rc != 0) { if (rc != 0) {
fprintf(stderr, "Failed to mount %s (FD: %d) (%s) on %s: %s\n", filename, fd, fstype, mountpoint, strerror(errno)); fprintf(stderr, "Failed to mount %s (FD: %d) (%s) on %s: %s\n", filename, fd, fstype, mountpoint, strerror(errno));

View file

@ -1832,7 +1832,7 @@ static void rsa_test_encrypt()
if (memcmp(buf.data(), "hellohellohellohellohellohellohellohellohello123-", 49)) if (memcmp(buf.data(), "hellohellohellohellohellohellohellohellohello123-", 49))
FAIL(Invalid encryption); FAIL(Invalid encryption);
else { else {
dbg() << "out size " << buf.size() << " values: " << StringView { (char*)buf.data(), buf.size() }; dbgln("out size {} values {}", buf.size(), StringView { (char*)buf.data(), buf.size() });
PASS; PASS;
} }
@ -1999,7 +1999,8 @@ static void rsa_test_encrypt_decrypt()
"9527497237087650398000977129550904920919162360737979403539302312977329868395261515707123424679295515888026193056908173564681660256268221509339074678416049"_bigint, "9527497237087650398000977129550904920919162360737979403539302312977329868395261515707123424679295515888026193056908173564681660256268221509339074678416049"_bigint,
"39542231845947188736992321577701849924317746648774438832456325878966594812143638244746284968851807975097653255909707366086606867657273809465195392910913"_bigint, "39542231845947188736992321577701849924317746648774438832456325878966594812143638244746284968851807975097653255909707366086606867657273809465195392910913"_bigint,
"65537"_bigint); "65537"_bigint);
dbg() << "Output size: " << rsa.output_size();
dbgln("Output size: {}", rsa.output_size());
u8 enc_buffer[rsa.output_size()]; u8 enc_buffer[rsa.output_size()];
u8 dec_buffer[rsa.output_size()]; u8 dec_buffer[rsa.output_size()];
@ -2012,7 +2013,7 @@ static void rsa_test_encrypt_decrypt()
rsa.encrypt(enc, dec); rsa.encrypt(enc, dec);
rsa.decrypt(dec, enc); rsa.decrypt(dec, enc);
dbg() << "enc size " << enc.size() << " dec size " << dec.size(); dbgln("enc size {} dec size {}", enc.size(), dec.size());
if (memcmp(enc.data(), "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64) != 0) { if (memcmp(enc.data(), "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64) != 0) {
FAIL(Could not encrypt then decrypt); FAIL(Could not encrypt then decrypt);