summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/EchoServer/Client.cpp2
-rw-r--r--Userland/Services/SystemMenu/main.cpp15
-rw-r--r--Userland/Services/SystemServer/Service.cpp18
-rw-r--r--Userland/Services/SystemServer/main.cpp13
-rw-r--r--Userland/Services/WebContent/ClientConnection.cpp13
-rw-r--r--Userland/Services/WebServer/Client.cpp8
-rw-r--r--Userland/Services/WindowServer/ClientConnection.cpp2
-rw-r--r--Userland/Services/WindowServer/Compositor.cpp102
8 files changed, 75 insertions, 98 deletions
diff --git a/Userland/Services/EchoServer/Client.cpp b/Userland/Services/EchoServer/Client.cpp
index 874553915b..249e7b6365 100644
--- a/Userland/Services/EchoServer/Client.cpp
+++ b/Userland/Services/EchoServer/Client.cpp
@@ -39,7 +39,7 @@ void Client::drain_socket()
while (m_socket->can_read()) {
auto buf = m_socket->read(1024);
- dbg() << "Read " << buf.size() << " bytes: " << buf;
+ dbgln("Read {} bytes.", buf.size());
if (m_socket->eof()) {
quit();
diff --git a/Userland/Services/SystemMenu/main.cpp b/Userland/Services/SystemMenu/main.cpp
index 9a54236989..7c193cf3f6 100644
--- a/Userland/Services/SystemMenu/main.cpp
+++ b/Userland/Services/SystemMenu/main.cpp
@@ -25,6 +25,7 @@
*/
#include "ShutdownDialog.h"
+#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <LibCore/ConfigFile.h>
@@ -42,8 +43,6 @@
#include <serenity.h>
#include <spawn.h>
-//#define SYSTEM_MENU_DEBUG
-
struct AppMetadata {
String executable;
String name;
@@ -143,14 +142,14 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
for (const auto& app : g_apps) {
auto icon = GUI::FileIconProvider::icon_for_executable(app.executable).bitmap_for_size(16);
-#ifdef SYSTEM_MENU_DEBUG
- if (icon)
- dbg() << "App " << app.name << " has icon with size " << icon->size();
-#endif
+ if constexpr (debug_system_menu) {
+ if (icon)
+ dbgln("App {} has icon with size {}", app.name, icon->size());
+ }
auto parent_menu = app_category_menus.get(app.category).value_or(*system_menu);
parent_menu->add_action(GUI::Action::create(app.name, icon, [app_identifier](auto&) {
- dbg() << "Activated app with ID " << app_identifier;
+ dbgln("Activated app with ID {}", app_identifier);
const auto& bin = g_apps[app_identifier].executable;
pid_t child_pid;
const char* argv[] = { bin.characters(), nullptr };
@@ -189,7 +188,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
for (auto& theme : g_themes) {
auto action = GUI::Action::create_checkable(theme.name, [theme_identifier](auto&) {
auto& theme = g_themes[theme_identifier];
- dbg() << "Theme switched to " << theme.name << " at path " << theme.path;
+ dbgln("Theme switched to {} at path {}", theme.name, theme.path);
auto response = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetSystemTheme>(theme.path, theme.name);
ASSERT(response->success());
});
diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp
index b481e6cdc7..c53644a595 100644
--- a/Userland/Services/SystemServer/Service.cpp
+++ b/Userland/Services/SystemServer/Service.cpp
@@ -25,6 +25,7 @@
*/
#include "Service.h"
+#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
@@ -83,7 +84,7 @@ void Service::setup_socket()
auto socket_address = Core::SocketAddress::local(m_socket_path);
auto un_optional = socket_address.to_sockaddr_un();
if (!un_optional.has_value()) {
- dbg() << "Socket name " << m_socket_path << " is too long. BUG! This should have failed earlier!";
+ dbgln("Socket name {} is too long. BUG! This should have failed earlier!", m_socket_path);
ASSERT_NOT_REACHED();
}
auto un = un_optional.value();
@@ -114,9 +115,8 @@ void Service::setup_notifier()
void Service::handle_socket_connection()
{
-#ifdef SERVICE_DEBUG
- dbg() << "Ready to read on behalf of " << name();
-#endif
+ dbgln<debug_service>("Ready to read on behalf of {}", name());
+
if (m_accept_socket_connections) {
int accepted_fd = accept(m_socket_fd, nullptr, nullptr);
if (accepted_fd < 0) {
@@ -144,16 +144,14 @@ void Service::activate()
void Service::spawn(int socket_fd)
{
-#ifdef SERVICE_DEBUG
- dbg() << "Spawning " << name();
-#endif
+ dbgln<debug_service>("Spawning {}", name());
m_run_timer.start();
pid_t pid = fork();
if (pid < 0) {
perror("fork");
- dbg() << "Failed to spawn " << name() << ". Sucks, dude :(";
+ dbgln("Failed to spawn {}. Sucks, dude :(", name());
} else if (pid == 0) {
// We are the child.
@@ -241,7 +239,7 @@ void Service::did_exit(int exit_code)
ASSERT(m_pid > 0);
ASSERT(!m_multi_instance);
- dbg() << "Service " << name() << " has exited with exit code " << exit_code;
+ dbgln("Service {} has exited with exit code {}", name(), exit_code);
s_service_map.remove(m_pid);
m_pid = -1;
@@ -261,7 +259,7 @@ void Service::did_exit(int exit_code)
dbgln("Third time's a charm?");
break;
default:
- dbg() << "Giving up on " << name() << ". Good luck!";
+ dbgln("Giving up on {}. Good luck!", name());
return;
}
m_restart_attempts++;
diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp
index 6409b0eda6..2cc0c9166e 100644
--- a/Userland/Services/SystemServer/main.cpp
+++ b/Userland/Services/SystemServer/main.cpp
@@ -27,6 +27,7 @@
#include "Service.h"
#include <AK/Assertions.h>
#include <AK/ByteBuffer.h>
+#include <AK/Debug.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
@@ -53,9 +54,7 @@ static void sigchld_handler(int)
if (pid == 0)
break;
-#ifdef SYSTEMSERVER_DEBUG
- dbg() << "Reaped child with pid " << pid << ", exit status " << status;
-#endif
+ dbgln<debug_system_server>("Reaped child with pid {}, exit status {}", pid, status);
Service* service = Service::find_by_pid(pid);
if (service == nullptr) {
@@ -71,18 +70,18 @@ static void parse_boot_mode()
{
auto f = Core::File::construct("/proc/cmdline");
if (!f->open(Core::IODevice::ReadOnly)) {
- dbg() << "Failed to read command line: " << f->error_string();
+ dbgln("Failed to read command line: {}", f->error_string());
return;
}
const String cmdline = String::copy(f->read_all(), Chomp);
- dbg() << "Read command line: " << cmdline;
+ dbgln("Read command line: {}", cmdline);
for (auto& part : cmdline.split_view(' ')) {
auto pair = part.split_view('=', 2);
if (pair.size() == 2 && pair[0] == "boot_mode")
g_boot_mode = pair[1];
}
- dbg() << "Booting in " << g_boot_mode << " mode";
+ dbgln("Booting in {} mode", g_boot_mode);
}
static void prepare_devfs()
@@ -234,7 +233,7 @@ int main(int, char**)
}
// After we've set them all up, activate them!
- dbg() << "Activating " << services.size() << " services...";
+ dbgln("Activating {} services...", services.size());
for (auto& service : services)
service.activate();
diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp
index 0e771c20cb..f1865b21d9 100644
--- a/Userland/Services/WebContent/ClientConnection.cpp
+++ b/Userland/Services/WebContent/ClientConnection.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/Badge.h>
+#include <AK/Debug.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/SystemTheme.h>
#include <WebContent/ClientConnection.h>
@@ -79,25 +80,19 @@ void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemThem
void ClientConnection::handle(const Messages::WebContentServer::LoadURL& message)
{
-#ifdef DEBUG_SPAM
- dbg() << "handle: WebContentServer::LoadURL: url=" << message.url();
-#endif
+ dbgln<debug_spam>("handle: WebContentServer::LoadURL: url={}", message.url());
page().load(message.url());
}
void ClientConnection::handle(const Messages::WebContentServer::LoadHTML& message)
{
-#ifdef DEBUG_SPAM
- dbg() << "handle: WebContentServer::LoadHTML: html=" << message.html() << ", url=" << message.url();
-#endif
+ dbgln<debug_spam>("handle: WebContentServer::LoadHTML: html={}, url={}", message.html(), message.url());
page().load_html(message.html(), message.url());
}
void ClientConnection::handle(const Messages::WebContentServer::SetViewportRect& message)
{
-#ifdef DEBUG_SPAM
- dbg() << "handle: WebContentServer::SetViewportRect: rect=" << message.rect();
-#endif
+ dbgln<debug_spam>("handle: WebContentServer::SetViewportRect: rect={}", message.rect());
m_page_host->set_viewport_rect(message.rect());
}
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp
index c3840bd118..0cd1f2af81 100644
--- a/Userland/Services/WebServer/Client.cpp
+++ b/Userland/Services/WebServer/Client.cpp
@@ -63,7 +63,7 @@ void Client::start()
return;
}
- dbg() << "Got raw request: '" << String::copy(raw_request) << "'";
+ dbgln("Got raw request: '{}'", String::copy(raw_request));
handle_request(raw_request.bytes());
die();
@@ -77,9 +77,9 @@ void Client::handle_request(ReadonlyBytes raw_request)
return;
auto& request = request_or_error.value();
- dbg() << "Got HTTP request: " << request.method_name() << " " << request.resource();
+ dbgln("Got HTTP request: {} {}", request.method_name(), request.resource());
for (auto& header : request.headers()) {
- dbg() << " " << header.name << " => " << header.value;
+ dbgln(" {} => {}", header.name, header.value);
}
if (request.method() != HTTP::HttpRequest::Method::GET) {
@@ -88,7 +88,7 @@ void Client::handle_request(ReadonlyBytes raw_request)
}
auto requested_path = LexicalPath::canonicalized_path(request.resource());
- dbg() << "Canonical requested path: '" << requested_path << "'";
+ dbgln("Canonical requested path: '{}'", requested_path);
StringBuilder path_builder;
path_builder.append(m_root_path);
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp
index 3c9df70dc2..0693bf9c6d 100644
--- a/Userland/Services/WindowServer/ClientConnection.cpp
+++ b/Userland/Services/WindowServer/ClientConnection.cpp
@@ -195,7 +195,7 @@ OwnPtr<Messages::WindowServer::AddMenuItemResponse> ClientConnection::handle(con
unsigned identifier = message.identifier();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
- dbg() << "AddMenuItem: Bad menu ID: " << menu_id;
+ dbgln("AddMenuItem: Bad menu ID: {}", menu_id);
return {};
}
auto& menu = *(*it).value;
diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp
index 1be79338bb..9d2d025e02 100644
--- a/Userland/Services/WindowServer/Compositor.cpp
+++ b/Userland/Services/WindowServer/Compositor.cpp
@@ -31,6 +31,7 @@
#include "Screen.h"
#include "Window.h"
#include "WindowManager.h"
+#include <AK/Debug.h>
#include <AK/Memory.h>
#include <AK/ScopeGuard.h>
#include <LibCore/Timer.h>
@@ -39,9 +40,6 @@
#include <LibGfx/StylePainter.h>
#include <LibThread/BackgroundAction.h>
-//#define COMPOSE_DEBUG
-//#define OCCLUSIONS_DEBUG
-
namespace WindowServer {
Compositor& Compositor::the()
@@ -196,11 +194,12 @@ void Compositor::compose()
if (m_custom_background_color.has_value())
background_color = m_custom_background_color.value();
-#ifdef COMPOSE_DEBUG
- dbg() << "COMPOSE: invalidated: window:" << m_invalidated_window << " cursor:" << m_invalidated_cursor << " any: " << m_invalidated_any;
- for (auto& r : dirty_screen_rects.rects())
- dbg() << "dirty screen: " << r;
-#endif
+ if constexpr (debug_compose) {
+ dbgln("COMPOSE: invalidated: window: {} cursor: {}, any: {}", m_invalidated_window, m_invalidated_cursor, m_invalidated_any);
+ for (auto& r : dirty_screen_rects.rects())
+ dbgln("dirty screen: {}", r);
+ }
+
Gfx::DisjointRectSet flush_rects;
Gfx::DisjointRectSet flush_transparent_rects;
Gfx::DisjointRectSet flush_special_rects;
@@ -216,9 +215,7 @@ void Compositor::compose()
};
auto prepare_rect = [&](const Gfx::IntRect& rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " -> flush opaque: " << rect;
-#endif
+ dbgln<debug_compose>(" -> flush opaque: {}", rect);
ASSERT(!flush_rects.intersects(rect));
ASSERT(!flush_transparent_rects.intersects(rect));
flush_rects.add(rect);
@@ -226,9 +223,7 @@ void Compositor::compose()
};
auto prepare_transparency_rect = [&](const Gfx::IntRect& rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " -> flush transparent: " << rect;
-#endif
+ dbgln<debug_compose>(" -> flush transparent: {}", rect);
ASSERT(!flush_rects.intersects(rect));
bool have_rect = false;
for (auto& r : flush_transparent_rects.rects()) {
@@ -275,9 +270,7 @@ void Compositor::compose()
};
m_opaque_wallpaper_rects.for_each_intersected(dirty_screen_rects, [&](const Gfx::IntRect& render_rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " render wallpaper opaque: " << render_rect;
-#endif
+ dbgln<debug_compose>(" render wallpaper opaque: {}", render_rect);
prepare_rect(render_rect);
paint_wallpaper(back_painter, render_rect);
return IterationDecision::Continue;
@@ -289,9 +282,7 @@ void Compositor::compose()
return IterationDecision::Continue;
auto frame_rects = frame_rect.shatter(window.rect());
-#ifdef COMPOSE_DEBUG
- dbg() << " window " << window.title() << " frame rect: " << frame_rect;
-#endif
+ dbgln<debug_compose>(" window {} frame rect: {}", window.title(), frame_rect);
RefPtr<Gfx::Bitmap> backing_store = window.backing_store();
auto compose_window_rect = [&](Gfx::Painter& painter, const Gfx::IntRect& rect) {
@@ -300,9 +291,7 @@ void Compositor::compose()
// TODO: Should optimize this to use a backing buffer
Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(intersected_rect);
-#ifdef COMPOSE_DEBUG
- dbg() << " render frame: " << intersected_rect;
-#endif
+ dbgln<debug_compose>(" render frame: {}", intersected_rect);
window.frame().paint(painter);
return IterationDecision::Continue;
});
@@ -370,22 +359,22 @@ void Compositor::compose()
};
auto& dirty_rects = window.dirty_rects();
-#ifdef COMPOSE_DEBUG
- for (auto& dirty_rect : dirty_rects.rects())
- dbg() << " dirty: " << dirty_rect;
- for (auto& r : window.opaque_rects().rects())
- dbg() << " opaque: " << r;
- for (auto& r : window.transparency_rects().rects())
- dbg() << " transparent: " << r;
-#endif
+
+ if constexpr (debug_compose) {
+ for (auto& dirty_rect : dirty_rects.rects())
+ dbgln(" dirty: {}", dirty_rect);
+ for (auto& r : window.opaque_rects().rects())
+ dbgln(" opaque: {}", r);
+ for (auto& r : window.transparency_rects().rects())
+ dbgln(" transparent: {}", r);
+ }
// Render opaque portions directly to the back buffer
auto& opaque_rects = window.opaque_rects();
if (!opaque_rects.is_empty()) {
opaque_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " render opaque: " << render_rect;
-#endif
+ dbgln<debug_compose>(" render opaque: {}", render_rect);
+
prepare_rect(render_rect);
Gfx::PainterStateSaver saver(back_painter);
back_painter.add_clip_rect(render_rect);
@@ -399,9 +388,8 @@ void Compositor::compose()
auto& transparency_wallpaper_rects = window.transparency_wallpaper_rects();
if (!transparency_wallpaper_rects.is_empty()) {
transparency_wallpaper_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " render wallpaper: " << render_rect;
-#endif
+ dbgln<debug_compose>(" render wallpaper: {}", render_rect);
+
prepare_transparency_rect(render_rect);
paint_wallpaper(temp_painter, render_rect);
return IterationDecision::Continue;
@@ -410,9 +398,8 @@ void Compositor::compose()
auto& transparency_rects = window.transparency_rects();
if (!transparency_rects.is_empty()) {
transparency_rects.for_each_intersected(dirty_rects, [&](const Gfx::IntRect& render_rect) {
-#ifdef COMPOSE_DEBUG
- dbg() << " render transparent: " << render_rect;
-#endif
+ dbgln<debug_compose>(" render transparent: {}", render_rect);
+
prepare_transparency_rect(render_rect);
Gfx::PainterStateSaver saver(temp_painter);
temp_painter.add_clip_rect(render_rect);
@@ -440,7 +427,7 @@ void Compositor::compose()
for (auto& rect_transparent : flush_transparent_rects.rects()) {
for (auto& rect_opaque : flush_rects.rects()) {
if (rect_opaque.intersects(rect_transparent)) {
- dbg() << "Transparent rect " << rect_transparent << " overlaps opaque rect: " << rect_opaque << ": " << rect_opaque.intersected(rect_transparent);
+ dbgln("Transparent rect {} overlaps opaque rect: {}: {}", rect_transparent, rect_opaque, rect_opaque.intersected(rect_transparent));
return true;
}
}
@@ -684,9 +671,7 @@ void Compositor::run_animations(Gfx::DisjointRectSet& flush_rects)
from_rect.height() - (int)(height_delta_per_step * animation_index)
};
-#ifdef MINIMIZE_ANIMATION_DEBUG
- dbg() << "Minimize animation from " << from_rect << " to " << to_rect << " frame# " << animation_index << " " << rect;
-#endif
+ dbgln<debug_minimize_animation>("Minimize animation from {} to {} frame# {} {}", from_rect, to_rect, animation_index, rect);
painter.draw_rect(rect, Color::Transparent); // Color doesn't matter, we draw inverted
flush_rects.add(rect);
@@ -708,7 +693,7 @@ bool Compositor::set_resolution(int desired_width, int desired_height, int scale
// Make sure it's impossible to set an invalid resolution
if (!(desired_width >= 640 && desired_height >= 480 && scale_factor >= 1)) {
- dbg() << "Compositor: Tried to set invalid resolution: " << desired_width << "x" << desired_height << " @ " << scale_factor << "x";
+ dbgln("Compositor: Tried to set invalid resolution: {}x{}", desired_width, desired_height);
return false;
}
@@ -1016,25 +1001,26 @@ void Compositor::recompute_occlusions()
m_opaque_wallpaper_rects = move(visible_rects);
}
-#ifdef OCCLUSIONS_DEBUG
- for (auto& r : m_opaque_wallpaper_rects.rects())
- dbg() << " wallpaper opaque: " << r;
-#endif
+ if constexpr (debug_occlusions) {
+ for (auto& r : m_opaque_wallpaper_rects.rects())
+ dbgln(" wallpaper opaque: {}", r);
+ }
wm.for_each_visible_window_from_back_to_front([&](Window& w) {
auto window_frame_rect = w.frame().rect().intersected(screen_rect);
if (w.is_minimized() || window_frame_rect.is_empty())
return IterationDecision::Continue;
-#ifdef OCCLUSIONS_DEBUG
- dbg() << " Window " << w.title() << " frame rect: " << window_frame_rect;
- for (auto& r : w.opaque_rects().rects())
- dbg() << " opaque: " << r;
- for (auto& r : w.transparency_wallpaper_rects().rects())
- dbg() << " transparent wallpaper: " << r;
- for (auto& r : w.transparency_rects().rects())
- dbg() << " transparent: " << r;
-#endif
+ if constexpr (debug_occlusions) {
+ dbgln(" Window {} frame rect: {}", w.title(), window_frame_rect);
+ for (auto& r : w.opaque_rects().rects())
+ dbgln(" opaque: {}", r);
+ for (auto& r : w.transparency_wallpaper_rects().rects())
+ dbgln(" transparent wallpaper: {}", r);
+ for (auto& r : w.transparency_rects().rects())
+ dbgln(" transparent: {}", r);
+ }
+
ASSERT(!w.opaque_rects().intersects(m_opaque_wallpaper_rects));
ASSERT(!w.transparency_rects().intersects(m_opaque_wallpaper_rects));
ASSERT(!w.transparency_wallpaper_rects().intersects(m_opaque_wallpaper_rects));