[PATCH weston v2 2/8] compositor: add option to enable weston_debug

Maniraj Devadoss external.mdevadoss at de.adit-jv.com
Mon Sep 11 15:35:53 UTC 2017


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>

Renamed the protocol name in weston.man from weston-debug
to compositor_debug_v1

Signed-off-by: Maniraj Devadoss <external.mdevadoss at de.adit-jv.com>
---
 compositor/main.c |  7 +++++++
 man/weston.man    | 15 +++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 0615d87..4a50a42 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -64,6 +64,7 @@
 #include "compositor-x11.h"
 #include "compositor-wayland.h"
 #include "windowed-output-api.h"
+#include "weston-debug.h"
 
 #define WINDOW_TITLE "Weston Compositor"
 
@@ -557,6 +558,7 @@ usage(int error_code)
 		"  --log=FILE\t\tLog to the given file\n"
 		"  -c, --config=FILE\tConfig file to load, defaults to weston.ini\n"
 		"  --no-config\t\tDo not read weston.ini\n"
+		"  --debug\t\tEnable debug extension\n"
 		"  -h, --help\t\tThis help message\n\n");
 
 #if defined(BUILD_DRM_COMPOSITOR)
@@ -1774,6 +1776,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;
@@ -1796,6 +1799,7 @@ int main(int argc, char *argv[])
 		{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
 		{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
 		{ WESTON_OPTION_STRING, "config", 'c', &config_file },
+		{ WESTON_OPTION_BOOLEAN, "debug", 0, &debug_protocol },
 	};
 
 	if (os_fd_set_cloexec(fileno(stdin))) {
@@ -1870,6 +1874,9 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
+	if (debug_protocol)
+		weston_compositor_enable_debug_protocol(ec);
+
 	if (weston_compositor_init_config(ec, config) < 0)
 		goto out;
 
diff --git a/man/weston.man b/man/weston.man
index face229..52e9d0d 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -22,7 +22,7 @@ under another Wayland server), it should be done with the command
 .B weston-launch
 to set up proper privileged access to devices.
 
-Weston also supports X clients via 
+Weston also supports X clients via
 .BR XWayland ", see below."
 .
 .\" ***************************************************************
@@ -106,7 +106,7 @@ Load
 .I backend.so
 instead of the default backend. The file is searched for in
 .IR "__weston_modules_dir__" ,
-or you can pass an absolute path. The default backend is 
+or you can pass an absolute path. The default backend is
 .I __weston_native_backend__
 unless the environment suggests otherwise, see
 .IR DISPLAY " and " WAYLAND_DISPLAY .
@@ -123,6 +123,17 @@ If also
 .B --no-config
 is given, no configuration file will be read.
 .TP
+.BR \-\-debug
+Enable debug protocol extension
+.I zcompositor_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.7.4



More information about the wayland-devel mailing list