Organize ttrace log. 63/68163/5
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 3 May 2016 00:37:53 +0000 (09:37 +0900)
committerGwan-gyeong Mun <kk.moon@samsung.com>
Tue, 10 May 2016 12:54:17 +0000 (05:54 -0700)
 - The flag in the .spec file, ENABLE_TTRACE default value is Zero(disable).
 - If you want to use this feature, change the value of ENABLE_TTRACE zero to one(enable).

Change-Id: If03bb923700fb5a3d1e3c889e2de4138af8a7d6e

Makefile
packaging/libtpl-egl.spec
src/tpl_gbm.c
src/tpl_surface.c
src/tpl_utils.h
src/tpl_wayland_egl.c

index 1f971fe..a04e032 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,14 +37,17 @@ ifneq ($(call is-feature-enabled,winsys_tbm),)
 endif
 
 ifneq ($(call is-feature-enabled,ttrace),)
-       CFLAGS += -DTTRACE_ENABLE
+       CFLAGS += -DTTRACE_ENABLE=1
+       CFLAGS += `pkg-config --cflags ttrace`
+       LDFLAGS += `pkg-config --libs ttrace`
 endif
 ifneq ($(call is-feature-enabled,dlog),)
        CFLAGS += -DDLOG_DEFAULT_ENABLE
 endif
 ifneq ($(call is-feature-enabled,pngdump),)
        CFLAGS += -DPNG_DUMP_ENABLE
-       LDFLAGS += `pkg-config libpng`
+       CFLAGS += `pkg-config --cflags libpng`
+       LDFLAGS += `pkg-config --libs libpng`
 endif
 
 ifneq ($(call is-feature-enabled,arm_atomic_operation),)
index 807a708..b982aae 100644 (file)
@@ -73,6 +73,10 @@ BuildRequires:  pkgconfig(wayland-tbm-server)
 BuildRequires: pkgconfig(libpng)
 %endif
 
+%if "%{ENABLE_TTRACE}" == "1"
+BuildRequires: pkgconfig(ttrace)
+%endif
+
 %global TZ_SYS_RO_SHARE  %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share}
 
 %description
index bb28718..583e0b5 100644 (file)
@@ -315,6 +315,8 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface,
                                 tbm_surface_h tbm_surface, int num_rects,
                                 const int *rects)
 {
+       tbm_bo bo;
+
        TPL_ASSERT(surface);
        TPL_ASSERT(surface->display);
        TPL_ASSERT(surface->display->native_handle);
@@ -331,9 +333,8 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface,
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
-       tbm_bo_handle bo_handle =
-               tbm_bo_get_handle(tbm_surface_internal_get_bo(tbm_surface, 0),
-                                 TBM_DEVICE_CPU);
+       bo = tbm_surface_internal_get_bo(tbm_surface, 0);
+       tbm_bo_handle bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_CPU);
 
        if (bo_handle.ptr)
                TPL_IMAGE_DUMP(bo_handle.ptr, surface->width, surface->height,
@@ -354,6 +355,7 @@ __tpl_gbm_surface_enqueue_buffer(tpl_surface_t *surface,
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
+        TRACE_MARK("[ENQ] BO_NAME:%d", tbm_bo_export(bo));
        return TPL_ERROR_NONE;
 }
 
@@ -382,6 +384,7 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface)
 
        gbm_surface = (tpl_gbm_surface_t *)surface->backend.data;
 
+       TRACE_BEGIN("WAITING FOR DEQUEUEABLE");
        tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface);
        if (!tbm_surface
            && tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) {
@@ -389,15 +392,21 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface)
                if (!tbm_surface) {
                        TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",
                                tsq_err);
+                       TRACE_END();
                        return NULL;
                }
        }
+       TRACE_END();
        /* Inc ref count about tbm_surface */
        /* It will be dec when before tbm_surface_queue_enqueue called */
        tbm_surface_internal_ref(tbm_surface);
 
        gbm_buffer = __tpl_gbm_get_gbm_buffer_from_tbm_surface(tbm_surface);
-       if (gbm_buffer) return tbm_surface;
+       if (gbm_buffer)
+       {
+               TRACE_MARK("[DEQ][REUSED]BO_NAME:%d",tbm_bo_export(gbm_buffer->bo));
+               return tbm_surface;
+       }
 
        if (!(bo = tbm_surface_internal_get_bo(tbm_surface, 0))) {
                TPL_ERR("Failed to get tbm_bo from tbm_surface");
@@ -419,6 +428,8 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface)
 
        __tpl_gbm_set_gbm_buffer_to_tbm_surface(tbm_surface, gbm_buffer);
 
+       TRACE_MARK("[DEQ][NEW]BO_NAME:%d",tbm_bo_export(gbm_buffer->bo));
+
        return tbm_surface;
 }
 
index 35d263c..18c8686 100644 (file)
@@ -131,13 +131,11 @@ tpl_surface_validate(tpl_surface_t *surface)
                return TPL_FALSE;
        }
 
-       TRACE_BEGIN("TPL:VALIDATEFRAME");
        TPL_OBJECT_LOCK(surface);
 
        if (!surface->backend.validate(surface)) was_valid = TPL_FALSE;
 
        TPL_OBJECT_UNLOCK(surface);
-       TRACE_END();
 
        return was_valid;
 }
@@ -186,7 +184,7 @@ tpl_surface_dequeue_buffer(tpl_surface_t *surface)
                return NULL;
        }
 
-       TRACE_BEGIN("TPL:GETBUFFER");
+       TRACE_BEGIN("TPL:DEQUEUE_BUFFER");
        TPL_OBJECT_LOCK(surface);
 
        tbm_surface = surface->backend.dequeue_buffer(surface);
@@ -213,7 +211,7 @@ tpl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface)
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
-       TRACE_BEGIN("TPL:POST");
+       TRACE_BEGIN("TPL:ENQUEUE_BUFFER");
        TPL_OBJECT_LOCK(surface);
 
        if (!tbm_surface) {
@@ -244,7 +242,7 @@ tpl_surface_enqueue_buffer_with_damage(tpl_surface_t *surface,
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
-       TRACE_BEGIN("TPL:POST");
+       TRACE_BEGIN("TPL:ENQUEUE_BUFFER_WITH_DAMAGE");
        TPL_OBJECT_LOCK(surface);
 
        if (!tbm_surface) {
index 1f46908..763d9ee 100644 (file)
 #include <ttrace.h>
 #define TRACE_BEGIN(name,...) traceBegin(TTRACE_TAG_GRAPHICS, name, ##__VA_ARGS__)
 #define TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS)
-#define TRACE_ASYNC_BEGIN(key, name) traceAsyncBegin(TTRACE_TAG_GRAPHICS, key, name)
-#define TRACE_ASYNC_END(key, name) traceAsyncEnd(TTRACE_TAG_GRAPHICS, key, name)
+#define TRACE_ASYNC_BEGIN(key, name,...) traceAsyncBegin(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
+#define TRACE_ASYNC_END(key, name,...) traceAsyncEnd(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
 #define TRACE_COUNTER(value, name,...) traceCounter(TTRACE_TAG_GRAPHICS, value, name, ##__VA_ARGS__)
 #define TRACE_MARK(name,...) traceMark(TTRACE_TAG_GRAPHICS, name, ##__VA_ARGS__)
 #else
 #define TRACE_BEGIN(name,...)
 #define TRACE_END()
-#define TRACE_ASYNC_BEGIN(key, name)
-#define TRACE_ASYNC_END(key, name)
+#define TRACE_ASYNC_BEGIN(key, name,...)
+#define TRACE_ASYNC_END(key, name,...)
 #define TRACE_COUNTER(value, name,...)
 #define TRACE_MARK(name,...)
 #endif
index 4bc938d..e0f5c13 100644 (file)
@@ -466,6 +466,8 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
                __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface);
        TPL_ASSERT(wayland_egl_buffer);
 
+       TRACE_ASYNC_END((int)wayland_egl_buffer, "[DEQ]~[ENQ] BO_NAME:%d",
+                       tbm_bo_export(wayland_egl_buffer->bo));
        tbm_bo_handle bo_handle =
                tbm_bo_get_handle(wayland_egl_buffer->bo , TBM_DEVICE_CPU);
 
@@ -501,6 +503,9 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
        wl_surface_commit(wl_egl_window->surface);
 
        wl_display_flush((struct wl_display *)surface->display->native_handle);
+
+       TRACE_ASYNC_BEGIN((int)tbm_surface, "[COMMIT ~ RELEASE_CB] BO_NAME:%d",
+                          tbm_bo_export(wayland_egl_buffer->bo));
 }
 
 
@@ -519,6 +524,8 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface,
        tbm_surface_queue_error_e tsq_err;
 
        TPL_LOG(3, "window(%p, %p)", surface, surface->native_handle);
+       TRACE_MARK("[ENQ] BO_NAME:%d",
+                  tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
 
        tsq_err = tbm_surface_queue_enqueue(wayland_egl_surface->tbm_queue,
                                            tbm_surface);
@@ -617,6 +624,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface)
        wl_display_dispatch_queue_pending((struct wl_display *)
                                          surface->display->native_handle,
                                          wayland_egl_display->wl_queue);
+       TRACE_BEGIN("WAITING FOR DEQUEUEABLE");
        while (tbm_surface_queue_can_dequeue(
                       wayland_egl_surface->tbm_queue, 0) == 0) {
                /* Application sent all buffers to the server. Wait for server response. */
@@ -626,6 +634,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface)
                        return NULL;
                }
        }
+       TRACE_END();
        TPL_OBJECT_LOCK(surface);
 
        tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue,
@@ -640,6 +649,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface)
 
        if ((wayland_egl_buffer =
                     __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL) {
+               TRACE_MARK("[DEQ][REUSED]BO_NAME:%d",tbm_bo_export(wayland_egl_buffer->bo));
+               TRACE_ASYNC_BEGIN((int)wayland_egl_buffer, "[DEQ]~[ENQ] BO_NAME:%d",
+                                 tbm_bo_export(wayland_egl_buffer->bo));
                return tbm_surface;
        }
 
@@ -675,6 +687,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface)
        __tpl_wayland_egl_set_wayland_buffer_to_tbm_surface(tbm_surface,
                        wayland_egl_buffer);
 
+       TRACE_MARK("[DEQ][NEW]BO_NAME:%d",tbm_bo_export(wayland_egl_buffer->bo));
+       TRACE_ASYNC_BEGIN((int)wayland_egl_buffer, "[DEQ]~[ENQ] BO_NAME:%d",
+                         tbm_bo_export(wayland_egl_buffer->bo));
        return tbm_surface;
 }
 
@@ -787,6 +802,8 @@ __cb_client_buffer_release_callback(void *data, struct wl_proxy *proxy)
 
        tbm_surface = (tbm_surface_h) data;
 
+       TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE_CB] BO_NAME:%d",
+                       tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
        /* If tbm_surface_queue reset/destroy before this callback
         * tbm_surface will be not used any more.
         * So, it should be detroyed before getting its user_data */