Imporve tbm_bufmgr_debug_tbm_info_get() to show gem name
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.c
index c7b4800..130f29c 100644 (file)
@@ -77,6 +77,8 @@ static void _tbm_bufmgr_mutex_unlock(void);
 #define GET_MODULE_MINOR_VERSION(vers)    (((vers) >> 16) & 0xFF)
 #define GET_MODULE_PATCHLEVEL(vers)    ((vers) & 0xFFFF)
 
+#define MAX_SIZE_N(dest)       (sizeof(dest) - strlen(dest) - 1)
+
 /* check condition */
 #define TBM_BUFMGR_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
@@ -774,6 +776,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
                        TBM_LOG_E("Un-freed bo(%p, ref:%d)\n", bo, bo->ref_cnt);
                        _tbm_bo_free(bo);
                }
+               LIST_DELINIT(&bufmgr->bo_list);
        }
 
        /* destroy surf_list */
@@ -784,6 +787,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
                        TBM_LOG_E("Un-freed surf(%p, ref:%d)\n", surf, surf->refcnt);
                        tbm_surface_destroy(surf);
                }
+               LIST_DELINIT(&bufmgr->surf_list);
        }
 
        /* destroy bufmgr priv */
@@ -1515,8 +1519,8 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
 
        if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
                LIST_FOR_EACH_ENTRY(debug_old_data, &bufmgr->debug_key_list, item_link) {
-                       strncat(title, "  ", 3);
-                       strncat(title, debug_old_data->key, strlen(debug_old_data->key) + 1);
+                       strncat(title, "  ", MAX_SIZE_N(title));
+                       strncat(title, debug_old_data->key, MAX_SIZE_N(title));
                }
        }
 
@@ -1561,13 +1565,13 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
                                LIST_FOR_EACH_ENTRY(debug_old_data, &bufmgr->debug_key_list, item_link) {
                                        char *value;
 
-                                       strncat(data, "  ", 3);
+                                       strncat(data, "  ", MAX_SIZE_N(title));
 
                                        value = _tbm_surface_internal_get_debug_data(surf, debug_old_data->key);
                                        if (value)
-                                               strncat(data, value, strlen(value) + 1);
+                                               strncat(data, value, MAX_SIZE_N(title));
                                        else
-                                               strncat(data, "none", 5);
+                                               strncat(data, "none", MAX_SIZE_N(title));
                                }
                        }
                        TBM_SNPRINTF(str, len, "%s\n", data);
@@ -1584,7 +1588,7 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
        TBM_SNPRINTF(str, len, "\n");
 
        TBM_SNPRINTF(str, len, "[tbm_bo information]\n");
-       TBM_SNPRINTF(str, len, "no  bo          refcnt  size    lock_cnt  map_cnt  flags  surface\n");
+       TBM_SNPRINTF(str, len, "no  bo          refcnt  size    lock_cnt  map_cnt  flags  surface     name\n");
 
        /* show the tbm_bo information in bo_list */
        if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
@@ -1592,7 +1596,7 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
                tbm_bo bo = NULL;
 
                LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) {
-                       TBM_SNPRINTF(str, len, "%-4d%-11p   %-4d  %-6d     %-5d     %-4u    %-3d  %-11p\n",
+                       TBM_SNPRINTF(str, len, "%-4d%-11p   %-4d  %-6d     %-5d     %-4u    %-3d  %-11p  %-4d\n",
                                  ++bo_cnt,
                                  bo,
                                  bo->ref_cnt,
@@ -1600,7 +1604,8 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
                                  bo->lock_cnt,
                                  bo->map_cnt,
                                  bo->flags,
-                                 bo->surface);
+                                 bo->surface,
+                                 tbm_bo_export(bo));
                }
        } else
                TBM_SNPRINTF(str, len, "no tbm_bos.\n");