#define SUFFIX_MODULE ".so"
#define DEFAULT_MODULE "libtdm-default"SUFFIX_MODULE
-int tdm_debug_buffer;
-int tdm_debug_thread;
-int tdm_debug_mutex;
+int tdm_debug_module;
int tdm_debug_dump;
static tdm_private_display *g_private_display;
return g_private_display;
}
- debug = getenv("TDM_DEBUG_BUFFER");
- if (debug && (strstr(debug, "1")))
- tdm_debug_buffer = 1;
+ debug = getenv("TDM_DEBUG_MODULE");
+ if (debug)
+ tdm_display_enable_debug_module(debug);
debug = getenv("TDM_DEBUG_DUMP");
if (debug)
tdm_display_enable_dump(debug);
- debug = getenv("TDM_DEBUG_THREAD");
- if (debug && (strstr(debug, "1")))
- tdm_debug_thread = 1;
-
- debug = getenv("TDM_DEBUG_MUTEX");
- if (debug && (strstr(debug, "1")))
- tdm_debug_mutex = 1;
-
private_display = calloc(1, sizeof(tdm_private_display));
if (!private_display) {
ret = TDM_ERROR_OUT_OF_MEMORY;
failed_mutex_init:
free(private_display);
failed_alloc:
- tdm_debug_buffer = 0;
if (error)
*error = ret;
_pthread_mutex_unlock(&gLock);
pthread_mutex_destroy(&private_display->lock);
free(private_display);
g_private_display = NULL;
- tdm_debug_buffer = 0;
_pthread_mutex_unlock(&gLock);
return 1;
}
-INTERN void
-tdm_display_enable_debug(char *debug, int enable)
+INTERN tdm_error
+tdm_display_enable_debug_module(const char*modules)
{
- if (!strncmp(debug, "TDM_DEBUG_BUFFER", 16))
- tdm_debug_buffer = enable;
- else if (!strncmp(debug, "TDM_DEBUG_THREAD", 16))
- tdm_debug_thread = enable;
- else if (!strncmp(debug, "TDM_DEBUG_MUTEX", 15))
- tdm_debug_mutex = enable;
+ char temp[TDM_PATH_LEN];
+ char *arg;
+ char *end;
+
+ snprintf(temp, TDM_PATH_LEN, "%s", modules);
+
+ tdm_debug_module = 0;
+
+ arg = strtok_r(temp, TDM_DELIM, &end);
+ while (arg) {
+ if (!strncmp(arg, "none", 4)) {
+ tdm_debug_module = 0;
+ return TDM_ERROR_NONE;
+ }
+ if (!strncmp(arg, "all", 3)) {
+ tdm_debug_module = 0xFFFFFFFF;
+ return TDM_ERROR_NONE;
+ }
+ if (!strncmp(arg, "buffer", 6))
+ tdm_debug_module |= TDM_DEBUG_BUFFER;
+ else if (!strncmp(arg, "thread", 6))
+ tdm_debug_module |= TDM_DEBUG_THREAD;
+ else if (!strncmp(arg, "mutex", 5))
+ tdm_debug_module |= TDM_DEBUG_MUTEX;
+ else
+ return TDM_ERROR_BAD_REQUEST;
+
+ arg = strtok_r(NULL, TDM_DELIM, &end);
+ }
+
+ TDM_INFO("module debugging... '%s'", modules);
+
+ return TDM_ERROR_NONE;
}
-INTERN void
+INTERN tdm_error
tdm_display_enable_dump(const char *dump_str)
{
char temp[1024];
char *arg;
char *end;
- int flags = 0;
+
+ tdm_debug_dump = 0;
snprintf(temp, sizeof(temp), "%s", dump_str);
arg = strtok_r(temp, ",", &end);
while (arg) {
+ if (!strncmp(arg, "none", 4)) {
+ tdm_debug_dump = 0;
+ return TDM_ERROR_NONE;
+ }
if (!strncmp(arg, "all", 3)) {
- flags = TDM_DUMP_FLAG_LAYER|TDM_DUMP_FLAG_PP|TDM_DUMP_FLAG_CAPTURE;
- break;
+ tdm_debug_dump = 0xFFFFFFFF;
+ return TDM_ERROR_NONE;
}
- else if (!strncmp(arg, "layer", 5))
- flags |= TDM_DUMP_FLAG_LAYER;
+ if (!strncmp(arg, "layer", 5))
+ tdm_debug_dump |= TDM_DUMP_FLAG_LAYER;
else if (!strncmp(arg, "pp", 2))
- flags |= TDM_DUMP_FLAG_PP;
+ tdm_debug_dump |= TDM_DUMP_FLAG_PP;
else if (!strncmp(arg, "capture", 7))
- flags |= TDM_DUMP_FLAG_CAPTURE;
- else if (!strncmp(arg, "none", 4))
- flags = 0;
+ tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
+ else
+ return TDM_ERROR_BAD_REQUEST;
+
arg = strtok_r(NULL, ",", &end);
}
- tdm_debug_dump = flags;
+ TDM_INFO("dump... '%s'", dump_str);
+
+ return TDM_ERROR_NONE;
}
if (buf_info->backend_ref_count > 0) {
TDM_NEVER_GET_HERE();
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("%p", buf_info->buffer);
}
free(func_info);
}
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("%p destroyed", buf_info->buffer);
free(buf_info);
return NULL;
}
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("%p created", buf_info->buffer);
}
tdm_helper_dump_buffer_str(buffer, str);
}
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("capture(%p) done: %p", private_capture, buffer);
first_entry = tdm_buffer_list_get_first_entry(&private_capture->buffer_list);
if ((buf_info = tdm_buffer_get_info(buffer)))
LIST_ADDTAIL(&buf_info->link, &private_capture->pending_buffer_list);
- if (tdm_debug_buffer) {
+ if (tdm_debug_module & TDM_DEBUG_BUFFER) {
TDM_INFO("capture(%p) attached:", private_capture);
tdm_buffer_list_dump(&private_capture->buffer_list);
}
static void
_tdm_dbg_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
- int value;
+ int level;
char *arg;
char *end;
}
arg = argv[2];
- value = strtol(arg, &end, 10);
+ level = strtol(arg, &end, 10);
- tdm_log_set_debug_level(value);
+ tdm_log_set_debug_level(level);
+ TDM_SNPRINTF(reply, len, "debug level: %d\n", level);
- value = !!value;
- tdm_log_enable_debug(value);
+ if (*end == '@') {
+ char *arg = end + 1;
- TDM_SNPRINTF(reply, len, "debug '%s'\n", (value) ? "on" : "off");
+ tdm_display_enable_debug_module((const char *)arg);
- if (argc > 3) {
- char temp[TDM_PATH_LEN];
- char *arg;
- char *end;
-
- snprintf(temp, TDM_PATH_LEN, "%s", argv[3]);
-
- arg = strtok_r(temp, TDM_DELIM, &end);
- while (arg) {
- tdm_display_enable_debug(arg, value);
- if (value)
- TDM_SNPRINTF(reply, len, "debuging '%s'...\n", arg);
- arg = strtok_r(NULL, TDM_DELIM, &end);
- }
+ TDM_SNPRINTF(reply, len, "debugging... '%s'\n", arg);
}
}
},
{
"debug", _tdm_dbg_server_debug,
- "enable the debug level log",
- "<enable>",
- "0 or 1"
+ "set the debug level and modules(none,mutex,buffer,thread,vblank)",
+ "<level>[@<module1>[,<module2>]]",
+ NULL
},
{
"log_path", _tdm_dbg_server_log_path,
fds.fd = fd;
fds.revents = 0;
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) polling in", fd);
while (poll(&fds, 1, -1) < 0) {
}
}
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) polling out", fd);
if (tdm_thread_is_running())
private_layer->showing_buffer = private_layer->waiting_buffer;
private_layer->waiting_buffer = NULL;
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p) showing_buffer(%p)",
private_layer, private_layer->waiting_buffer,
private_layer->showing_buffer);
}
private_layer->waiting_buffer = tdm_buffer_ref_backend(buffer);
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p)",
private_layer, private_layer->waiting_buffer);
}
_pthread_mutex_lock(&private_display->lock);
private_layer->waiting_buffer = NULL;
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p)",
private_layer, private_layer->waiting_buffer);
}
_pthread_mutex_lock(&private_display->lock);
private_layer->showing_buffer = NULL;
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) showing_buffer(%p)",
private_layer, private_layer->showing_buffer);
}
private_layer->waiting_buffer = tdm_buffer_ref_backend(surface);
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p)",
private_layer, private_layer->waiting_buffer);
private_layer->waiting_buffer = NULL;
_pthread_mutex_lock(&private_display->lock);
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p)",
private_layer, private_layer->waiting_buffer);
}
private_layer->waiting_buffer = NULL;
_pthread_mutex_lock(&private_display->lock);
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) waiting_buffer(%p)",
private_layer, private_layer->waiting_buffer);
}
_pthread_mutex_lock(&private_display->lock);
private_layer->showing_buffer = NULL;
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("layer(%p) showing_buffer(%p)",
private_layer, private_layer->showing_buffer);
}
private_loop = private_display->private_loop;
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("backend fd(%d) event happens", private_loop->backend_fd);
func_display = &private_display->func_display;
TDM_RETURN_VAL_IF_FAIL(private_loop->wl_loop != NULL, TDM_ERROR_OPERATION_FAILED);
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("dispatch");
if (tdm_thread_is_running() &&
tdm_helper_dump_buffer_str(dst, str);
}
- if (tdm_debug_buffer)
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
TDM_INFO("pp(%p) done: src(%p) dst(%p)", private_pp, src, dst);
if (!LIST_IS_EMPTY(&private_pp->buffer_list)) {
pp_buffer->src = tdm_buffer_ref_backend(src);
pp_buffer->dst = tdm_buffer_ref_backend(dst);
- if (tdm_debug_buffer) {
+ if (tdm_debug_module & TDM_DEBUG_BUFFER) {
TDM_INFO("pp(%p) attached:", private_pp);
_tdm_pp_print_list(&private_pp->pending_buffer_list);
}
* @brief The private header file for a frontend library
*/
-extern int tdm_debug_buffer;
-extern int tdm_debug_mutex;
-extern int tdm_debug_thread;
+enum {
+ TDM_DEBUG_NONE,
+ TDM_DEBUG_BUFFER = (1 << 0),
+ TDM_DEBUG_MUTEX = (1 << 1),
+ TDM_DEBUG_THREAD = (1 << 2),
+ TDM_DEBUG_SERVER = (1 << 3),
+ TDM_DEBUG_VBLANK = (1 << 4),
+};
+
+extern int tdm_debug_module;
extern int tdm_debug_dump;
#ifdef HAVE_TTRACE
#define _pthread_mutex_unlock(l) \
do { \
- if (tdm_debug_mutex) \
+ if (tdm_debug_module & TDM_DEBUG_MUTEX) \
TDM_INFO("mutex unlock"); \
pthread_mutex_lock(&tdm_mutex_check_lock); \
tdm_mutex_locked = 0; \
#define MUTEX_TIMEOUT_SEC 5
#define _pthread_mutex_lock(l) \
do { \
- if (tdm_debug_mutex) \
+ if (tdm_debug_module & TDM_DEBUG_MUTEX) \
TDM_INFO("mutex lock"); \
struct timespec rtime; \
clock_gettime(CLOCK_REALTIME, &rtime); \
#else //TDM_CONFIG_MUTEX_TIMEOUT
#define _pthread_mutex_lock(l) \
do { \
- if (tdm_debug_mutex) \
+ if (tdm_debug_module & TDM_DEBUG_MUTEX) \
TDM_INFO("mutex lock"); \
pthread_mutex_lock(l); \
pthread_mutex_lock(&tdm_mutex_check_lock); \
tdm_error
tdm_display_update_output(tdm_private_display *private_display,
tdm_output *output_backend, int pipe);
-void
-tdm_display_enable_debug(char *debug, int enable);
-void
+tdm_error
+tdm_display_enable_debug_module(const char*modules);
+tdm_error
tdm_display_enable_dump(const char *dump_str);
/**
return;
}
- TDM_DBG("req_id(%d) done", wait_info->req_id);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ TDM_INFO("req_id(%d) done", wait_info->req_id);
vblank_info = wait_info->vblank_info;
wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id,
wait_info->vblank_info = vblank_info;
wait_info->req_id = req_id;
- TDM_DBG("req_id(%d) wait", req_id);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ TDM_INFO("req_id(%d) wait", req_id);
ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info);
TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
return;
}
- TDM_DBG("tdm server binding");
-
wl_resource_set_implementation(resource, &tdm_implementation, data, NULL);
}
fds.revents = 0;
while (1) {
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("server flush");
tdm_event_loop_flush(private_loop->dpy);
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) polling in", fd);
ret = poll(&fds, 1, -1);
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) polling out", fd);
if (ret < 0) {
}
}
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("thread got events");
if (tdm_event_loop_dispatch(private_loop->dpy) < 0)
private_thread = private_loop->private_thread;
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) type(%d), length(%d)",
private_thread->pipe[1], base->type, base->length);
len = read(private_thread->pipe[0], buffer, sizeof buffer);
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("fd(%d) read length(%d)", private_thread->pipe[0], len);
if (len == 0)
i = 0;
while (i < len) {
base = (tdm_thread_cb_base*)&buffer[i];
- if (tdm_debug_thread)
+ if (tdm_debug_module & TDM_DEBUG_THREAD)
TDM_INFO("type(%d), length(%d)", base->type, base->length);
switch (base->type) {
case TDM_THREAD_CB_OUTPUT_COMMIT: {
LIST_ADD(&private_vblank->link, &vblank_list);
- VDB("created. vrefresh(%d) dpms(%d)",
- private_vblank->vrefresh, private_vblank->dpms);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("created. vrefresh(%d) dpms(%d)",
+ private_vblank->vrefresh, private_vblank->dpms);
return (tdm_vblank*)private_vblank;
}
free(w);
}
- VIN("destroyed");
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("destroyed");
free(private_vblank);
}
private_vblank->fps = fps;
private_vblank->check_HW_or_SW = 1;
- VDB("fps(%d)", private_vblank->fps);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("fps(%d)", private_vblank->fps);
return TDM_ERROR_NONE;
}
private_vblank->offset = offset;
private_vblank->check_HW_or_SW = 1;
- VDB("offset(%d)", private_vblank->offset);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("offset(%d)", private_vblank->offset);
return TDM_ERROR_NONE;
}
private_vblank->enable_fake = enable_fake;
- VDB("enable_fake(%d)", private_vblank->enable_fake);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("enable_fake(%d)", private_vblank->enable_fake);
return TDM_ERROR_NONE;
}
wait_info->func(private_vblank, TDM_ERROR_NONE, private_vblank->last_seq,
tv_sec, tv_usec, wait_info->user_data);
- VDB("wait(%p) done", wait_info);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) done", wait_info);
free(wait_info);
}
return ret;
}
- VDB("wait(%p) waiting", wait_info);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) waiting", wait_info);
return TDM_ERROR_NONE;
}
first_wait_info = container_of(private_vblank->SW_wait_list.next, first_wait_info, link);
TDM_RETURN_VAL_IF_FAIL(first_wait_info != NULL, TDM_ERROR_OPERATION_FAILED);
- VDB("wait(%p) done", first_wait_info);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) done", first_wait_info);
private_vblank->last_seq = first_wait_info->target_seq;
private_vblank->last_tv_sec = first_wait_info->target_sec;
w = container_of((&private_vblank->SW_pending_wait_list)->next, w, link);
TDM_RETURN_IF_FAIL(w != NULL);
- VDB("wait(%p) done", w);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) done", w);
min_interval = w->interval;
if (ms_delay < 1)
ms_delay = 1;
- VDB("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)",
- first_wait_info, curr, target, ms_delay);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)",
+ first_wait_info, curr, target, ms_delay);
tdm_display_lock(private_vblank->dpy);
LIST_DEL(&wait_info->link);
return ret;
}
- VDB("wait(%p) waiting", wait_info);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) waiting", wait_info);
}
return TDM_ERROR_NONE;
}
}
}
- VDB("target_seq(%d) last_seq(%d) skip(%d)",
- wait_info->target_seq, private_vblank->last_seq, skip);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("target_seq(%d) last_seq(%d) skip(%d)",
+ wait_info->target_seq, private_vblank->last_seq, skip);
#if 0
target -= (private_vblank->SW_align_offset * skip * private_vblank->HW_quotient);
wait_info->target_sec = target / 1000000;
wait_info->target_usec = target % 1000000;
- VDB("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)",
- wait_info, last, req - last, prev - last, curr - last,
- skip, wait_info->target_hw_interval, target, target - last);
+ if (tdm_debug_module & TDM_DEBUG_VBLANK)
+ VIN("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)",
+ wait_info, last, req - last, prev - last, curr - last,
+ skip, wait_info->target_hw_interval, target, target - last);
}
tdm_error