tpl_wayland_egl_thread: Added basic debug logs for thread monitoring. 13/134813/5
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 20 Apr 2017 23:45:06 +0000 (08:45 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 21 Jun 2017 07:04:25 +0000 (16:04 +0900)
Change-Id: I6d4d450392d06e0c704d4140e6db831cde04e000
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
Makefile
src/tpl_wayland_egl_thread.c

index e1ad5ad..943b97c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -118,6 +118,7 @@ clean:
        find . -name "*.o" -exec rm -vf {} \;
        find . -name "*~" -exec rm -vf {} \;
        rm -vf $(BIN_NAME)
+       rm -vf glib_wl_test
 
 install: all
        cp -va $(BIN_NAME) $(INST_DIR)/
index ec2b434..2a09187 100644 (file)
@@ -8,6 +8,10 @@
 #include <glib.h>
 #include <glib-unix.h>
 
+#ifndef WORKER_TEST_ONLY
+#define WORKER_TEST_ONLY
+#endif
+
 #ifdef WORKER_TEST_ONLY
 #include <glib.h>
 #include <sys/syscall.h>
@@ -28,9 +32,8 @@
                        syscall(SYS_gettid), __func__, ##x)
 
 #define TPL_ERR(f, x...)               tpl_log_e("[TPL_ERROR]", f, ##x)
-#define TPL_DEBUG_M(f, x...)   tpl_log_d("[MAIN]", f, ##x)
-#define TPL_DEBUG_T(f, x...)   tpl_log_t("[THREAD]", f, ##x)
-
+#define TPL_DEBUG(f, x...) \
+       ((int)getpid() == (int)syscall(SYS_gettid)) ? tpl_log_d("[MAIN]", f, ##x) : tpl_log_t("[THREAD]", f, ##x)
 typedef struct _twe_thread                     twe_thread;
 typedef struct _twe_thread_context     twe_thread_context;
 #else
@@ -92,9 +95,10 @@ _twe_thread_tdm_source_dispatch(gpointer user_data)
        twe_thread_context* context = user_data;
        tdm_error tdm_err;
 
+       TPL_DEBUG("tdm_dispatch| tdm_client(%p)", context->tdm_client);
        tdm_err = tdm_client_handle_events(context->tdm_client);
        if (tdm_err) {
-               TPL_ERR("TDM_ERROR:%d context:%p, tdm_cleint:%p\n", context, context->tdm_client);
+               TPL_ERR("TDM_ERROR:%d context:%p, tdm_cleint:%p\n", tdm_err, context, context->tdm_client);
                return G_SOURCE_REMOVE;
        }
 
@@ -106,6 +110,8 @@ _twe_thread_tdm_source_destroy(gpointer user_data)
 {
        twe_thread_context* context = user_data;
 
+       TPL_DEBUG("tdm_destroy| tdm_gsource(%p) tdm_client(%p)",
+                         context->tdm_gsource, context->tdm_client);
        g_source_destroy(context->tdm_gsource);
        g_source_unref(context->tdm_gsource);
        context->tdm_gsource = NULL;
@@ -150,6 +156,8 @@ twe_thread_create(void)
                                                                _twe_ctx,
                                                                _twe_thread_tdm_source_destroy);
                        g_source_attach(_twe_ctx->tdm_gsource, g_main_loop_get_context(_twe_ctx->twe_loop));
+                       TPL_DEBUG("tdm g_source(%p) attached to twe_loop(%p)",
+                                         _twe_ctx->tdm_gsource, _twe_ctx->twe_loop);
                }
        }
 
@@ -157,6 +165,7 @@ twe_thread_create(void)
        thread->ctx = _twe_ctx;
        _twe_ctx->ref_cnt++;
 
+       TPL_DEBUG("_twe_ctx(%p) twe_thread(%p)", _twe_ctx, thread);
        return thread;
 }
 
@@ -178,6 +187,8 @@ twe_thread_destroy(twe_thread* thread)
                thread->ctx = NULL;
        }
 
+       TPL_DEBUG("twe_thread(%p)", thread);
+
        thread->ctx = NULL;
        free(thread);
 }
@@ -187,6 +198,7 @@ _twe_thread_wl_disp_prepare(GSource *source, gint *time)
 {
        twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
 
+       TPL_DEBUG("prepare| gsource(%p) wl_display(%p)", source, wl_source->disp);
        while (wl_display_prepare_read_queue(wl_source->disp, wl_source->ev_queue) != 0) {
                wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
        }
@@ -203,9 +215,13 @@ _twe_thread_wl_disp_check(GSource *source)
        twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
 
        if (wl_source->gfd.revents) {
+               TPL_DEBUG("read_events| gsource(%p) wl_display(%p)",
+                                 source, wl_source->disp);
                wl_display_read_events(wl_source->disp);
                return TRUE;
        } else {
+               TPL_DEBUG("cancel_read| gsource(%p) wl_display(%p)",
+                                 source, wl_source->disp);
                wl_display_cancel_read(wl_source->disp);
        }
 
@@ -217,8 +233,11 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer date)
 {
        twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
 
-       if (wl_source->gfd.revents & G_IO_IN)
+       if (wl_source->gfd.revents & G_IO_IN) {
+               TPL_DEBUG("dispatch| gsource(%p) wl_display(%p)",
+                                 source, wl_source->disp);
                wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
+       }
 
        wl_display_flush(wl_source->disp);
 
@@ -233,6 +252,8 @@ _twe_thread_wl_disp_finalize(GSource *source)
        wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
        wl_event_queue_destroy(wl_source->ev_queue);
 
+       TPL_DEBUG("finalize| wl_event_queue(%p)",
+                         wl_source->ev_queue);
        return;
 }
 
@@ -265,6 +286,7 @@ _twe_thread_init_wl_tbm_client(struct wl_display *display,
 
        wl_proxy_set_queue(wl_tbm, ev_queue);
 
+       TPL_DEBUG("wl_tbm_client init| wl_tbm_client(%p)", wl_tbm_client);
        return wl_tbm_client;
 }
 
@@ -278,6 +300,7 @@ _twe_thread_fini_wl_tbm_client(struct wayland_tbm_client *wl_tbm_client)
                wl_proxy_set_queue(wl_tbm, NULL);
        }
 
+       TPL_DEBUG("wl_tbm_client deinit| wl_tbm_client(%p)", wl_tbm_client);
        wayland_tbm_client_deinit(wl_tbm_client);
 }
 
@@ -317,6 +340,9 @@ twe_thread_add_wl_display(twe_thread* thread,
        g_source_add_poll(&source->gsource, &source->gfd);
        g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
        g_source_unref(&source->gsource);
+
+       TPL_DEBUG("add| gsource(%p) ev_queue(%p) wl_display(%p)",
+                         source, source->ev_queue, display);
 }
 
 void
@@ -337,6 +363,8 @@ twe_thread_del_wl_display(twe_thread* thread, struct wl_display *display)
        g_source_remove_poll(&source->gsource, &source->gfd);
        g_source_destroy(&source->gsource);
        g_source_unref(&source->gsource);
+
+       TPL_DEBUG("del| gsource(%p) wl_display(%p)", source, display);
 }
 
 static gboolean
@@ -351,6 +379,8 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer date)
                ssize_t s;
                uint64_t u;
 
+               TPL_DEBUG("finalize| gsource(%p) read event_fd(%d)",
+                                 wl_surf_source, wl_surf_source->event_fd);
                s = read(wl_surf_source->event_fd, &u, sizeof(uint64_t));
                if (s != sizeof(uint64_t))
                        TPL_ERR("Failed to  read from event_fd(%d)\n",
@@ -367,6 +397,8 @@ _twe_thread_wl_surface_finalize(GSource *source)
 
        g_source_remove_unix_fd(source, wl_surf_source->tag);
 
+       TPL_DEBUG("gsource(%p) event_fd(%d)",
+                         source, wl_surf_source->event_fd);
        close(wl_surf_source->event_fd);
 
        return;
@@ -412,6 +444,8 @@ twe_thread_add_wl_surface(twe_thread* thread,
        g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
        g_source_unref(&source->gsource);
 
+       TPL_DEBUG("gsource(%p) wl_surface(%p) event_fd(%d)",
+                         source, surface, source->event_fd);
        return source->event_fd;
 }
 
@@ -430,6 +464,9 @@ twe_thread_del_wl_surface(twe_thread* thread, struct wl_surface *surface)
 
        g_source_destroy(&source->gsource);
        g_source_unref(&source->gsource);
+
+       TPL_DEBUG("gsource(%p) wl_surface(%p)",
+                         source, surface);
 }
 
 #ifdef WORKER_TEST_ONLY
@@ -439,7 +476,7 @@ static void reg_global(void *data,
                                           const char *interface,
                                           uint32_t version)
 {
-       TPL_DEBUG_M("reg_global: %s_v_%d\n", interface, version);
+       TPL_DEBUG("reg_global: %s_v_%d\n", interface, version);
 }
 
 
@@ -465,7 +502,7 @@ main(void)
 
        twe_thread *t_thread = NULL;
 
-       TPL_DEBUG_M("[[GLIB_WL_THREAD_TEST]]");
+       TPL_DEBUG("[[GLIB_WL_THREAD_TEST]]");
 
        /*Create the twe_thread*/
        t_thread = twe_thread_create();
@@ -488,7 +525,7 @@ main(void)
                if (count == 3) {
                        TPL_DEBUG_M("#### PRE_DEL");
                        twe_thread_del_wl_display(t_thread, display);
-                       TPL_DEBUG_M("#### DEL");
+                       TPL_DEBUG("#### DEL");
                }
        }