/* intialize surf_list */
LIST_INITHEAD(&gBufMgr->surf_list);
+ /* intialize debug_key_list */
+ LIST_INITHEAD(&gBufMgr->debug_key_list);
+
pthread_mutex_unlock(&gLock);
return gBufMgr;
}
int i;
char app_name[255] = {0,};
unsigned int pid = 0;
+ char title[255] = {0,};
+ char data[255] = {0,};
+ tbm_surface_debug_data *debug_old_data = NULL, *debug_tmp = NULL;
pthread_mutex_lock(&gLock);
TBM_DEBUG("============TBM DEBUG: %s(%d)===========================\n",
app_name, getpid());
memset(app_name, 0x0, 255 * sizeof(char));
+ snprintf(title, 255, "%s", "no surface refcnt width height bpp size n_b n_p flags format app_name ");
+ if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(debug_old_data, debug_tmp, &bufmgr->debug_key_list, item_link) {
+ strncat(title, " ", 2);
+ strncat(title, debug_old_data->key, strlen(debug_old_data->key) + 1);
+ }
+ }
TBM_DEBUG("[tbm_surface information]\n");
- TBM_DEBUG("no surface refcnt width height bpp size num_bos num_planes flags format app_name\n");
+ TBM_DEBUG("%s\n", title);
/* show the tbm_surface information in surf_list */
if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
+ char *value = NULL;
+
LIST_FOR_EACH_ENTRY_SAFE(surf, tmp_surf, &bufmgr->surf_list, item_link) {
pid = _tbm_surface_internal_get_debug_pid(surf);
if (!pid) {
_tbm_util_get_appname_from_pid(pid, app_name);
_tbm_util_get_appname_brief(app_name);
- TBM_DEBUG("%-4d%-23p%-6d%-7d%-8d%-5d%-12d%-10d%-9d%-4d%-20s%s\n",
+ snprintf(data, 255, "%-2d %-9p %-4d %-5d %-6d %-3d %-6d %-2d %-2d %-3d %-8s %-15s",
++surf_cnt,
surf,
surf->refcnt,
surf->num_bos,
surf->num_planes,
surf->flags,
- _tbm_surface_internal_format_to_str(surf->info.format),
+ _tbm_surface_internal_format_to_str(surf->info.format) + 11,
app_name);
+ if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(debug_old_data, debug_tmp, &bufmgr->debug_key_list, item_link) {
+ strncat(data, " ", 2);
+
+ value = _tbm_surface_internal_get_debug_data(surf, debug_old_data->key);
+ if (value) {
+ strncat(data, value, strlen(value) + 1);
+ }
+ else {
+ strncat(data, "none", strlen("none") + 1);
+ }
+ }
+ }
+ TBM_DEBUG("%s\n", data);
+
for (i = 0; i < surf->num_bos; i++) {
TBM_DEBUG(" bo:%-12p %-26d%-10d\n",
surf->bos[i],
TBM_DEBUG("\n");
TBM_DEBUG("[tbm_bo information]\n");
- TBM_DEBUG("no bo refcnt size lock_cnt map_cnt flags surface\n");
+ TBM_DEBUG("no bo refcnt size lock_cnt map_cnt flags surface\n");
/* show the tbm_bo information in bo_list */
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp_bo, &bufmgr->bo_list, item_link) {
- TBM_DEBUG("%-4d%-11p %-6d%-12d%-9d%-9d%-4d%-11p\n",
+ TBM_DEBUG("%-4d%-11p %-4d %-6d %-5d %-4d %-3d %-11p\n",
++bo_cnt,
bo,
bo->ref_cnt,
struct list_head surf_list; /* list of surfaces belonging to bufmgr */
+ struct list_head debug_key_list; /* list of debug data key list belonging to bufmgr */
+
void *module_data;
tbm_bufmgr_backend backend; /* bufmgr backend */
struct list_head item_link; /* link of surface */
struct list_head user_data_list; /* list of the user_date in surface */
+
+ struct list_head debug_data_list; /* list of debug data */
};
typedef struct {
struct list_head item_link;
} tbm_user_data;
+typedef struct {
+ char *key;
+ char *value;
+
+ /* link of user_data */
+ struct list_head item_link;
+} tbm_surface_debug_data;
+
tbm_bufmgr _tbm_bufmgr_get_bufmgr(void);
int _tbm_bo_set_surface(tbm_bo bo, tbm_surface_h surface);
int _tbm_surface_is_valid(tbm_surface_h surface);
tbm_format tbm_surface_internal_get_format(tbm_surface_h surface);
unsigned int _tbm_surface_internal_get_debug_pid(tbm_surface_h surface);
char *_tbm_surface_internal_format_to_str(tbm_format format);
+char * _tbm_surface_internal_get_debug_data(tbm_surface_h surface, char *key);
tbm_user_data *user_data_lookup(struct list_head *user_data_list,
unsigned long key);
return time / 1000.0;
}
+static void
+_tbm_surface_internal_debug_data_delete(tbm_surface_debug_data *debug_data)
+{
+ LIST_DEL(&debug_data->item_link);
+
+ if (debug_data->key) free(debug_data->key);
+ if (debug_data->value) free(debug_data->value);
+ free(debug_data);
+}
+
char *
_tbm_surface_internal_format_to_str(tbm_format format)
{
int i;
tbm_bufmgr bufmgr = surface->bufmgr;
tbm_user_data *old_data = NULL, *tmp = NULL;
+ tbm_surface_debug_data *debug_old_data = NULL, *debug_tmp = NULL;
/* destory the user_data_list */
if (!LIST_IS_EMPTY(&surface->user_data_list)) {
surface->bos[i] = NULL;
}
+ if (!LIST_IS_EMPTY(&surface->debug_data_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(debug_old_data, debug_tmp, &surface->debug_data_list, item_link)
+ _tbm_surface_internal_debug_data_delete(debug_old_data);
+ }
+
LIST_DEL(&surface->item_link);
free(surface);
if (LIST_IS_EMPTY(&bufmgr->surf_list)) {
LIST_DELINIT(&bufmgr->surf_list);
+
+ if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(debug_old_data, debug_tmp, &bufmgr->debug_key_list, item_link) {
+ _tbm_surface_internal_debug_data_delete(debug_old_data);
+ }
+ }
+
_deinit_surface_bufmgr();
}
}
_tbm_surface_internal_format_to_str(format), flags, surf);
LIST_INITHEAD(&surf->user_data_list);
+ LIST_INITHEAD(&surf->debug_data_list);
LIST_ADD(&surf->item_link, &mgr->surf_list);
info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
LIST_INITHEAD(&surf->user_data_list);
+ LIST_INITHEAD(&surf->debug_data_list);
LIST_ADD(&surf->item_link, &mgr->surf_list);
surface->debug_pid = pid;
}
+static tbm_surface_debug_data *
+_tbm_surface_internal_debug_data_create(char *key, char *value)
+{
+ tbm_surface_debug_data *debug_data = NULL;
+
+ debug_data = calloc(1, sizeof(tbm_surface_debug_data));
+ if (!debug_data)
+ return NULL;
+
+ if (key) debug_data->key = strdup(key);
+ if (value) debug_data->value = strdup(value);
+
+ return debug_data;
+}
+
+int
+tbm_surface_internal_set_debug_data(tbm_surface_h surface, char *key, char *value)
+{
+ TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
+ TBM_RETURN_VAL_IF_FAIL(key, 0);
+
+ tbm_surface_debug_data *debug_data = NULL;
+ tbm_surface_debug_data *old_data = NULL, *tmp = NULL;
+ tbm_bufmgr bufmgr = surface->bufmgr;
+
+ TBM_RETURN_VAL_IF_FAIL(bufmgr, 0);
+
+ if (!LIST_IS_EMPTY(&surface->debug_data_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &surface->debug_data_list, item_link) {
+ if (!strcmp(old_data->key ,key)) {
+ if (value)
+ old_data->value = strdup(value);
+ else
+ old_data->value = NULL;
+ }
+ }
+ }
+
+ debug_data = _tbm_surface_internal_debug_data_create(key, value);
+ if (!debug_data) {
+ TBM_TRACE("error: tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
+ return 0;
+ }
+
+ TBM_TRACE("tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
+
+ LIST_ADD(&debug_data->item_link, &surface->debug_data_list);
+
+ if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &bufmgr->debug_key_list, item_link) {
+ if (!strcmp(old_data->key ,key)) {
+ return 1;
+ }
+ }
+ }
+
+ debug_data = _tbm_surface_internal_debug_data_create(key, NULL);
+ LIST_ADD(&debug_data->item_link, &bufmgr->debug_key_list);
+
+ return 1;
+}
+
+char *
+_tbm_surface_internal_get_debug_data(tbm_surface_h surface, char *key)
+{
+ TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), NULL);
+
+ tbm_surface_debug_data *old_data = NULL, *tmp = NULL;
+
+ if (!LIST_IS_EMPTY(&surface->debug_data_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &surface->debug_data_list, item_link) {
+ if (!strcmp(old_data->key, key)) {
+ return old_data->value;
+ }
+ }
+ }
+
+ return NULL;
+}
+
typedef struct _tbm_surface_dump_info tbm_surface_dump_info;
typedef struct _tbm_surface_dump_buf_info tbm_surface_dump_buf_info;
}
}
-
/* free resources */
if (!LIST_IS_EMPTY(&g_dump_info->surface_list)) {
LIST_FOR_EACH_ENTRY_SAFE(buf_info, tmp, &g_dump_info->surface_list, link) {
unsigned int pid);
/**
+ * @brief Set the string value to the tbm_surface for debugging.
+ * @since_tizen 3.0
+ * @param[in] surface : the tbm_surface_h
+ * @param[in] key : the key for debugging
+ * @param[in] value : the value for debugging
+ */
+int tbm_surface_internal_set_debug_data(tbm_surface_h surface,
+ char *key, char *value);
+
+/**
* @brief Adds a user_data to the tbm surface.
* @since_tizen 3.0
* @param[in] surface : the tbm surface.