[PATCH weston v5 03/14] libweston: add weston_debug API and implementation

Pekka Paalanen ppaalanen at gmail.com
Mon Aug 6 13:05:42 UTC 2018


On Fri, 20 Jul 2018 20:03:24 +0100
Daniel Stone <daniels at collabora.com> wrote:

> From: Pekka Paalanen <pq at iki.fi>
> 
> weston_debug is both a libweston API for relaying debugging messages,
> and the compositor-debug wayland protocol implementation for accessing those
> debug messages from a Wayland client.
> 
> weston_debug_compositor_{create,destroy}() are private API, hence not
> exported.
> 
> Signed-off-by: Pekka Paalanen <pq at iki.fi>
> 
> append the debug scope name along with the timestamp in
> weston_debug_scope_timestamp API
> 
> Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss at in.bosch.com>
> Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> Add explicit advertisement of debug scope names.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  Makefile.am              |   2 +
>  libweston/compositor.c   |   6 +
>  libweston/compositor.h   |   9 +
>  libweston/weston-debug.c | 723 +++++++++++++++++++++++++++++++++++++++
>  libweston/weston-debug.h | 107 ++++++
>  5 files changed, 847 insertions(+)
>  create mode 100644 libweston/weston-debug.c
>  create mode 100644 libweston/weston-debug.h
> 

Hi,

yet another thing I noticed.

> +/** Write data into a specific debug stream
> + *
> + * \param stream The debug stream to write into.
> + * \param data[in] Pointer to the data to write.
> + * \param len Number of bytes to write.
> + *
> + * Writes the given data (binary verbatim) into the debug stream.
> + * If \c len is zero or negative, the write is silently dropped.
> + *
> + * Writing is continued until all data has been written or
> + * a write fails. If the write fails due to a signal, it is re-tried.
> + * Otherwise on failure, the stream is closed and
> + * \c weston_debug_stream_v1.failure event is sent to the client.
> + *
> + * \memberof weston_debug_stream
> + */
> +WL_EXPORT void
> +weston_debug_stream_write(struct weston_debug_stream *stream,
> +			  const char *data, size_t len)
> +{
> +	ssize_t len_ = len;
> +	ssize_t ret;
> +	int e;
> +
> +	if (stream->fd == -1)
> +		return;
> +
> +	while (len_ > 0) {
> +		ret = write(stream->fd, data, len_);
> +		e = errno;
> +		if (ret < 0) {
> +			if (e == EINTR)
> +				continue;
> +
> +			stream_close_on_failure(stream,
> +					"Error writing %zd bytes: %s (%d)",
> +					len_, strerror(e), e);
> +			break;
> +		}
> +
> +		len_ -= ret;
> +		data += ret;

If write() starts returning zero, we might be in for a very long loop.

> +	}
> +}


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180806/3a6bf8d9/attachment-0001.sig>


More information about the wayland-devel mailing list