[PATCH weston] weston: add wait-for-debugger option

Quentin Glidic sardemff7+wayland at sardemff7.net
Wed Nov 1 14:34:19 UTC 2017


On 11/1/17 3:23 PM, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> When you need to start Weston via weston-launch, systemd unit, or any
> other runner, it is annoying to try to get in with a debugger,
> especially if the thing you are interested in happens at start-up. To
> make it easy, a new option is introduced.
> 
> The new option, implemented both as a command line option and a
> weston.ini option, raises SIGSTOP early in the start-up, before the
> weston_compositor has been created. This allows one to attach a debugger
> at a known point in execution, and resume execution with SIGCONT.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Quite useful indeed:
Reviewed-by: Quentin Glidic <sardemff7+git at sardemff7.net>

Thanks,


> ---
>   compositor/main.c  | 13 +++++++++++++
>   man/weston.ini.man |  8 ++++++++
>   man/weston.man     |  8 ++++++++
>   3 files changed, 29 insertions(+)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 9e4451e5..78178e99 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -557,6 +557,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"
> +		"  --wait-for-debugger\tRaise SIGSTOP on start-up\n"
>   		"  -h, --help\t\tThis help message\n\n");
>   
>   #if defined(BUILD_DRM_COMPOSITOR)
> @@ -1786,6 +1787,7 @@ int main(int argc, char *argv[])
>   	struct weston_seat *seat;
>   	struct wet_compositor user_data;
>   	int require_input;
> +	int32_t wait_for_debugger = 0;
>   
>   	const struct weston_option core_options[] = {
>   		{ WESTON_OPTION_STRING, "backend", 'B', &backend },
> @@ -1799,6 +1801,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, "wait-for-debugger", 0, &wait_for_debugger },
>   	};
>   
>   	if (os_fd_set_cloexec(fileno(stdin))) {
> @@ -1860,6 +1863,16 @@ int main(int argc, char *argv[])
>   
>   	section = weston_config_get_section(config, "core", NULL, NULL);
>   
> +	if (!wait_for_debugger)
> +		weston_config_section_get_bool(section, "wait-for-debugger",
> +					       &wait_for_debugger, 0);
> +	if (wait_for_debugger) {
> +		weston_log("Weston PID is %ld - "
> +			   "waiting for debugger, send SIGCONT to continue...\n",
> +			   (long)getpid());
> +		raise(SIGSTOP);
> +	}
> +
>   	if (!backend) {
>   		weston_config_section_get_string(section, "backend", &backend,
>   						 NULL);
> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index 4cfefc91..f237fd60 100644
> --- a/man/weston.ini.man
> +++ b/man/weston.ini.man
> @@ -181,6 +181,14 @@ require an input device for launch
>   sets Weston's pageflip timeout in milliseconds.  This sets a timer to exit
>   gracefully with a log message and an exit code of 1 in case the DRM driver is
>   non-responsive.  Setting it to 0 disables this feature.
> +.TP 7
> +.BI "wait-for-debugger=" true
> +Raises SIGSTOP before initializing the compositor. This allows the user to
> +attach with a debugger and continue execution by sending SIGCONT. This is
> +useful for debugging a crash on start-up when it would be inconvenient to
> +launch weston directly from a debugger. Boolean, defaults to
> +.BR false .
> +There is also a command line option to do the same.
>   
>   .SH "LIBINPUT SECTION"
>   The
> diff --git a/man/weston.man b/man/weston.man
> index d19c2d4b..cd53df69 100644
> --- a/man/weston.man
> +++ b/man/weston.man
> @@ -168,6 +168,14 @@ Weston will export
>   .B WAYLAND_DISPLAY
>   with this value in the environment for all child processes to allow them to
>   connect to the right server automatically.
> +.TP
> +\fB\-\-wait-for-debugger\fR
> +Raises SIGSTOP before initializing the compositor. This allows the user to
> +attach with a debugger and continue execution by sending SIGCONT. This is
> +useful for debugging a crash on start-up when it would be inconvenient to
> +launch weston directly from a debugger. There is also a
> +.IR weston.ini " option to do the same."
> +.
>   .SS DRM backend options:
>   See
>   .BR weston-drm (7).
> 


-- 

Quentin “Sardem FF7” Glidic


More information about the wayland-devel mailing list