From 405520caad9edef9c9482271c3b7fd1338182b8d Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 10 Aug 2016 16:06:09 +0900 Subject: [PATCH] set debug data resource id and proxy id Change-Id: Iace4a7472518d5a3eef5a33e40ee0fab288659df --- src/wayland-tbm-client.c | 20 +++++++++++++++++++- src/wayland-tbm-server.c | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/wayland-tbm-client.c b/src/wayland-tbm-client.c index d4e5c53..4774724 100644 --- a/src/wayland-tbm-client.c +++ b/src/wayland-tbm-client.c @@ -296,6 +296,7 @@ wayland_tbm_client_create_buffer(struct wayland_tbm_client *tbm_client, uint32_t flags = 0; struct wayland_tbm_buffer *buffer, *tmp; struct wayland_tbm_surface_queue *queue_info = NULL, *tmp_info = NULL; + char debug_id[64] = {0, }; /* if the surface is the attached surface from display server, * return the wl_buffer of the attached surface @@ -390,7 +391,10 @@ wayland_tbm_client_create_buffer(struct wayland_tbm_client *tbm_client, close(bufs[i]); } - wl_buffer_set_user_data(wl_buffer, surface); + wl_buffer_set_user_data(wl_buffer, surface); + + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_proxy_get_id((struct wl_proxy *)wl_buffer)); + tbm_surface_internal_set_debug_data(surface, "id", debug_id); #ifdef DEBUG_TRACE WL_TBM_TRACE(" pid:%d wl_buffer:%p tbm_surface:%p\n", getpid(), wl_buffer, surface); @@ -414,12 +418,18 @@ wayland_tbm_client_destroy_buffer(struct wayland_tbm_client *tbm_client, WL_TBM_RETURN_IF_FAIL(tbm_client != NULL); WL_TBM_RETURN_IF_FAIL(wl_buffer != NULL); + tbm_surface_h surface = NULL; + // TODO: valid check if the buffer is from this tbm_client??? #ifdef DEBUG_TRACE WL_TBM_TRACE(" pid:%d wl_buffer:%p\n", getpid(), wl_buffer); #endif + surface = wl_buffer_get_user_data(wl_buffer); + if (surface) + tbm_surface_internal_set_debug_data(surface, "id", NULL); + wl_buffer_set_user_data(wl_buffer, NULL); wl_buffer_destroy(wl_buffer); } @@ -703,6 +713,7 @@ handle_tbm_queue_buffer_attached_with_id(void *data, { struct wayland_tbm_surface_queue *queue_info = data; struct wayland_tbm_buffer *buffer; + char debug_id[64] = {0, }; buffer = calloc(1, sizeof(struct wayland_tbm_buffer)); wl_list_init(&buffer->link); @@ -728,6 +739,9 @@ handle_tbm_queue_buffer_attached_with_id(void *data, wl_proxy_set_queue((struct wl_proxy *)buffer->wl_buffer, NULL); wl_list_insert(&queue_info->attach_bufs, &buffer->link); + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_proxy_get_id((struct wl_proxy *)wl_buffer)); + tbm_surface_internal_set_debug_data(buffer->tbm_surface, "id", debug_id); + #ifdef DEBUG_TRACE WL_TBM_TRACE("pid:%d wl_buffer:%p tbm_surface:%p\n", getpid(), buffer->wl_buffer, buffer->tbm_surface); #endif @@ -768,6 +782,7 @@ handle_tbm_queue_buffer_attached_with_fd(void *data, { struct wayland_tbm_surface_queue *queue_info = data; struct wayland_tbm_buffer *buffer; + char debug_id[64] = {0, }; buffer = calloc(1, sizeof(struct wayland_tbm_buffer)); wl_list_init(&buffer->link); @@ -793,6 +808,9 @@ handle_tbm_queue_buffer_attached_with_fd(void *data, wl_proxy_set_queue((struct wl_proxy *)buffer->wl_buffer, NULL); wl_list_insert(&queue_info->attach_bufs, &buffer->link); + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_proxy_get_id((struct wl_proxy *)wl_buffer)); + tbm_surface_internal_set_debug_data(buffer->tbm_surface, "id", debug_id); + #ifdef DEBUG_TRACE WL_TBM_TRACE("pid:%d wl_buffer:%p tbm_surface:%p\n", getpid(), buffer->wl_buffer, buffer->tbm_surface); #endif diff --git a/src/wayland-tbm-server.c b/src/wayland-tbm-server.c index ac4e96a..8d967ea 100644 --- a/src/wayland-tbm-server.c +++ b/src/wayland-tbm-server.c @@ -113,6 +113,8 @@ _wayland_tbm_server_buffer_destory(struct wl_resource *wl_buffer) if (tbm_buffer->destroy_cb) tbm_buffer->destroy_cb(tbm_buffer->surface, tbm_buffer->user_data); + tbm_surface_internal_set_debug_data(tbm_buffer->surface, "id", NULL); + tbm_surface_internal_unref(tbm_buffer->surface); free(tbm_buffer); } @@ -387,6 +389,7 @@ _wayland_tbm_server_impl_create_buffer(struct wl_client *client, int bpp; int numPlane; int i; + char debug_id[64] = {0, }; bpp = tbm_surface_internal_get_bpp(format); numPlane = tbm_surface_internal_get_num_planes(format); @@ -443,6 +446,9 @@ _wayland_tbm_server_impl_create_buffer(struct wl_client *client, return; } + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_resource_get_id(tbm_buffer->wl_buffer)); + tbm_surface_internal_set_debug_data(surface, "id", debug_id); + #ifdef DEBUG_TRACE pid_t pid = 0; uid_t uid = 0; gid_t gid = 0; wl_client_get_credentials(client, &pid, &uid, &gid); @@ -471,6 +477,7 @@ _wayland_tbm_server_impl_create_buffer_with_fd(struct wl_client *client, int bpp; int numPlane; int i; + char debug_id[64] = {0, }; bpp = tbm_surface_internal_get_bpp(format); numPlane = tbm_surface_internal_get_num_planes(format); @@ -527,6 +534,9 @@ _wayland_tbm_server_impl_create_buffer_with_fd(struct wl_client *client, return; } + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_resource_get_id(tbm_buffer->wl_buffer)); + tbm_surface_internal_set_debug_data(surface, "id", debug_id); + #ifdef DEBUG_TRACE pid_t pid = 0; uid_t uid = 0; gid_t gid = 0; wl_client_get_credentials(client, &pid, &uid, &gid); @@ -926,6 +936,7 @@ wayland_tbm_server_client_queue_export_buffer(struct wayland_tbm_client_queue *c struct wl_resource *wl_tbm = NULL; struct wayland_tbm_buffer *tbm_buffer = NULL; struct wl_client *client = NULL; + char debug_id[64] = {0, }; WL_TBM_RETURN_VAL_IF_FAIL(cqueue != NULL, NULL); WL_TBM_RETURN_VAL_IF_FAIL(cqueue->wl_tbm_queue != NULL, NULL); @@ -951,6 +962,9 @@ wayland_tbm_server_client_queue_export_buffer(struct wayland_tbm_client_queue *c return NULL; } + snprintf(debug_id, sizeof(debug_id), "%u", (unsigned int)wl_resource_get_id(tbm_buffer->wl_buffer)); + tbm_surface_internal_set_debug_data(surface, "id", debug_id); + return tbm_buffer->wl_buffer; } -- 2.7.4