[PATCH weston v5 04/14] compositor: add option to enable weston_debug

Daniel Stone daniels at collabora.com
Fri Jul 20 19:03:25 UTC 2018


From: Pekka Paalanen <pq at iki.fi>

Let users enable the compositor debug protocol on the compositor command
line. This allows weston-debug tool to work.

Signed-off-by: Pekka Paalanen <pq at iki.fi>
Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss at in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 compositor/main.c |  7 +++++++
 man/weston.man    | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index b5b4fc594..2f34e1115 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -60,6 +60,7 @@
 #include "compositor-x11.h"
 #include "compositor-wayland.h"
 #include "windowed-output-api.h"
+#include "weston-debug.h"
 
 #define WINDOW_TITLE "Weston Compositor"
 
@@ -508,6 +509,7 @@ usage(int error_code)
 		"  -c, --config=FILE\tConfig file to load, defaults to weston.ini\n"
 		"  --no-config\t\tDo not read weston.ini\n"
 		"  --wait-for-debugger\tRaise SIGSTOP on start-up\n"
+		"  --debug\t\tEnable debug extension\n"
 		"  -h, --help\t\tThis help message\n\n");
 
 #if defined(BUILD_DRM_COMPOSITOR)
@@ -2375,6 +2377,7 @@ int main(int argc, char *argv[])
 	char *socket_name = NULL;
 	int32_t version = 0;
 	int32_t noconfig = 0;
+	int32_t debug_protocol = 0;
 	int32_t numlock_on;
 	char *config_file = NULL;
 	struct weston_config *config = NULL;
@@ -2399,6 +2402,7 @@ int main(int argc, char *argv[])
 		{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
 		{ WESTON_OPTION_STRING, "config", 'c', &config_file },
 		{ WESTON_OPTION_BOOLEAN, "wait-for-debugger", 0, &wait_for_debugger },
+		{ WESTON_OPTION_BOOLEAN, "debug", 0, &debug_protocol },
 	};
 
 	wl_list_init(&wet.layoutput_list);
@@ -2486,6 +2490,9 @@ int main(int argc, char *argv[])
 	}
 	segv_compositor = wet.compositor;
 
+	if (debug_protocol)
+		weston_compositor_enable_debug_protocol(wet.compositor);
+
 	if (weston_compositor_init_config(wet.compositor, config) < 0)
 		goto out;
 
diff --git a/man/weston.man b/man/weston.man
index 596041dff..8a0e4a6f8 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -133,6 +133,17 @@ If also
 .B --no-config
 is given, no configuration file will be read.
 .TP
+.BR \-\-debug
+Enable debug protocol extension
+.I weston_debug_v1
+which any client can use to receive debugging messages from the compositor.
+
+.B WARNING:
+This is risky for two reasons. First, a client may cause a denial-of-service
+blocking the compositor by providing an unsuitable file descriptor, and
+second, the debug messages may expose sensitive information. This option
+should not be used in production.
+.TP
 .BR \-\-version
 Print the program version.
 .TP
-- 
2.17.1



More information about the wayland-devel mailing list