|
|
|
@ -41,26 +41,29 @@ |
|
|
|
|
|
|
|
|
|
/** A debug stream created by a client
|
|
|
|
|
* |
|
|
|
|
* A client provides a file descriptor for the server to write debug |
|
|
|
|
* messages into. A weston_debug_stream is associated to one |
|
|
|
|
* weston_log_scope via the scope name, and the scope provides the messages. |
|
|
|
|
* There can be several streams for the same scope, all streams getting the |
|
|
|
|
* same messages. |
|
|
|
|
* A client provides a file descriptor for the server to write debug messages |
|
|
|
|
* into. A weston_log_debug_wayland is associated to one weston_log_scope via the |
|
|
|
|
* scope name, and the scope provides the messages. There can be several |
|
|
|
|
* streams for the same scope, all streams getting the same messages. |
|
|
|
|
* |
|
|
|
|
* The following is specific to weston-debug protocol. |
|
|
|
|
* Subscription/unsubscription takes place in the stream_create(), respectively |
|
|
|
|
* in stream_destroy(). |
|
|
|
|
*/ |
|
|
|
|
struct weston_debug_stream { |
|
|
|
|
struct weston_log_debug_wayland { |
|
|
|
|
struct weston_log_subscriber base; |
|
|
|
|
int fd; /**< client provided fd */ |
|
|
|
|
struct wl_resource *resource; /**< weston_debug_stream_v1 object */ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static struct weston_debug_stream * |
|
|
|
|
to_weston_debug_stream(struct weston_log_subscriber *sub) |
|
|
|
|
static struct weston_log_debug_wayland * |
|
|
|
|
to_weston_log_debug_wayland(struct weston_log_subscriber *sub) |
|
|
|
|
{ |
|
|
|
|
return container_of(sub, struct weston_debug_stream, base); |
|
|
|
|
return container_of(sub, struct weston_log_debug_wayland, base); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
stream_close_unlink(struct weston_debug_stream *stream) |
|
|
|
|
stream_close_unlink(struct weston_log_debug_wayland *stream) |
|
|
|
|
{ |
|
|
|
|
if (stream->fd != -1) |
|
|
|
|
close(stream->fd); |
|
|
|
@ -68,7 +71,7 @@ stream_close_unlink(struct weston_debug_stream *stream) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void WL_PRINTF(2, 3) |
|
|
|
|
stream_close_on_failure(struct weston_debug_stream *stream, |
|
|
|
|
stream_close_on_failure(struct weston_log_debug_wayland *stream, |
|
|
|
|
const char *fmt, ...) |
|
|
|
|
{ |
|
|
|
|
char *msg; |
|
|
|
@ -104,16 +107,16 @@ stream_close_on_failure(struct weston_debug_stream *stream, |
|
|
|
|
* Otherwise on failure, the stream is closed and |
|
|
|
|
* \c weston_debug_stream_v1.failure event is sent to the client. |
|
|
|
|
* |
|
|
|
|
* \memberof weston_debug_stream |
|
|
|
|
* \memberof weston_log_debug_wayland |
|
|
|
|
*/ |
|
|
|
|
static void |
|
|
|
|
weston_debug_stream_write(struct weston_log_subscriber *sub, |
|
|
|
|
const char *data, size_t len) |
|
|
|
|
weston_log_debug_wayland_write(struct weston_log_subscriber *sub, |
|
|
|
|
const char *data, size_t len) |
|
|
|
|
{ |
|
|
|
|
ssize_t len_ = len; |
|
|
|
|
ssize_t ret; |
|
|
|
|
int e; |
|
|
|
|
struct weston_debug_stream *stream = to_weston_debug_stream(sub); |
|
|
|
|
struct weston_log_debug_wayland *stream = to_weston_log_debug_wayland(sub); |
|
|
|
|
|
|
|
|
|
if (stream->fd == -1) |
|
|
|
|
return; |
|
|
|
@ -144,29 +147,29 @@ weston_debug_stream_write(struct weston_log_subscriber *sub, |
|
|
|
|
* event to the client. This tells the client the debug information dump |
|
|
|
|
* is complete. |
|
|
|
|
* |
|
|
|
|
* \memberof weston_debug_stream |
|
|
|
|
* \memberof weston_log_debug_wayland |
|
|
|
|
*/ |
|
|
|
|
static void |
|
|
|
|
weston_debug_stream_complete(struct weston_log_subscriber *sub) |
|
|
|
|
weston_log_debug_wayland_complete(struct weston_log_subscriber *sub) |
|
|
|
|
{ |
|
|
|
|
struct weston_debug_stream *stream = to_weston_debug_stream(sub); |
|
|
|
|
struct weston_log_debug_wayland *stream = to_weston_log_debug_wayland(sub); |
|
|
|
|
|
|
|
|
|
stream_close_unlink(stream); |
|
|
|
|
weston_debug_stream_v1_send_complete(stream->resource); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
weston_debug_stream_to_destroy(struct weston_log_subscriber *sub) |
|
|
|
|
weston_log_debug_wayland_to_destroy(struct weston_log_subscriber *sub) |
|
|
|
|
{ |
|
|
|
|
struct weston_debug_stream *stream = to_weston_debug_stream(sub); |
|
|
|
|
struct weston_log_debug_wayland *stream = to_weston_log_debug_wayland(sub); |
|
|
|
|
stream_close_on_failure(stream, "debug name removed"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static struct weston_debug_stream * |
|
|
|
|
static struct weston_log_debug_wayland * |
|
|
|
|
stream_create(struct weston_log_context *log_ctx, const char *name, |
|
|
|
|
int32_t streamfd, struct wl_resource *stream_resource) |
|
|
|
|
{ |
|
|
|
|
struct weston_debug_stream *stream; |
|
|
|
|
struct weston_log_debug_wayland *stream; |
|
|
|
|
struct weston_log_scope *scope; |
|
|
|
|
struct weston_log_subscription *sub; |
|
|
|
|
|
|
|
|
@ -177,9 +180,9 @@ stream_create(struct weston_log_context *log_ctx, const char *name, |
|
|
|
|
stream->fd = streamfd; |
|
|
|
|
stream->resource = stream_resource; |
|
|
|
|
|
|
|
|
|
stream->base.write = weston_debug_stream_write; |
|
|
|
|
stream->base.destroy = weston_debug_stream_to_destroy; |
|
|
|
|
stream->base.complete = weston_debug_stream_complete; |
|
|
|
|
stream->base.write = weston_log_debug_wayland_write; |
|
|
|
|
stream->base.destroy = weston_log_debug_wayland_to_destroy; |
|
|
|
|
stream->base.complete = weston_log_debug_wayland_complete; |
|
|
|
|
wl_list_init(&stream->base.subscription_list); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -200,7 +203,7 @@ stream_create(struct weston_log_context *log_ctx, const char *name, |
|
|
|
|
static void |
|
|
|
|
stream_destroy(struct wl_resource *stream_resource) |
|
|
|
|
{ |
|
|
|
|
struct weston_debug_stream *stream; |
|
|
|
|
struct weston_log_debug_wayland *stream; |
|
|
|
|
struct weston_log_subscription *sub = NULL; |
|
|
|
|
|
|
|
|
|
stream = wl_resource_get_user_data(stream_resource); |
|
|
|
@ -244,7 +247,7 @@ weston_debug_subscribe(struct wl_client *client, |
|
|
|
|
struct weston_log_context *log_ctx; |
|
|
|
|
struct wl_resource *stream_resource; |
|
|
|
|
uint32_t version; |
|
|
|
|
struct weston_debug_stream *stream; |
|
|
|
|
struct weston_log_debug_wayland *stream; |
|
|
|
|
|
|
|
|
|
log_ctx = wl_resource_get_user_data(global_resource); |
|
|
|
|
version = wl_resource_get_version(global_resource); |
|
|
|
|