tbm_bufmgr bufmgr;
+ WL_TBM_MONITOR_TRACE_STATUS trace_state;
+
struct wl_list queue_info_list;
};
struct wl_list link;
};
+WL_TBM_MONITOR_TRACE_STATUS trace_status;
+
//#define DEBUG_TRACE
#ifdef DEBUG_TRACE
-#define WL_TBM_TRACE(fmt, ...) fprintf (stderr, "[WL_TBM_C(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
+#define WL_TBM_TRACE(fmt, ...) if (trace_status == WL_TBM_MONITOR_TRACE_STATUS_ON) fprintf (stderr, "[WL_TBM_C(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
#else
#define WL_TBM_TRACE(fmt, ...)
#endif
{
struct wayland_tbm_client *tbm_client = (struct wayland_tbm_client *)data;
+#ifdef DEBUG_TRACE
+ WL_TBM_TRACE("command=%d, trace_command=%d, target=%d, pid=%d.\n",
+ command, trace_command, target, pid);
+#endif
+
if (command == WL_TBM_MONITOR_COMMAND_SHOW) {
if (target == WL_TBM_MONITOR_TARGET_CLIENT) {
if (getpid() == pid)
target);
}
} else if (command == WL_TBM_MONITOR_COMMAND_TRACE) {
- WL_TBM_LOG("[%s]: TRACE is not implemented.\n", __func__);
+ if (target == WL_TBM_MONITOR_TARGET_CLIENT) {
+ if (getpid() == pid) {
+ if (trace_command == WL_TBM_MONITOR_TRACE_COMMAND_STATUS)
+ WL_TBM_DEBUG("clinet(%d): trace status: %s\n", getpid(), _tarce_status_to_str(trace_status));
+ else
+ _change_trace_status(&trace_status, trace_command, tbm_client->bufmgr);
+ }
+ } else if (target == WL_TBM_MONITOR_TARGET_ALL) {
+ if (trace_command == WL_TBM_MONITOR_TRACE_COMMAND_STATUS)
+ WL_TBM_DEBUG("clinet(%d): trace status: %s\n", getpid(), _tarce_status_to_str(trace_status));
+ else
+ _change_trace_status(&trace_status, trace_command, tbm_client->bufmgr);
+ } else {
+ WL_TBM_LOG("[%s]: Error target is not available. target = %d\n", __func__,
+ target);
+ }
} else {
WL_TBM_LOG("[%s]: Error command is not available. command = %d\n", __func__,
command);
_wayland_tbm_check_dlog_enable();
+ trace_status = WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED;
+
tbm_client = calloc(1, sizeof(struct wayland_tbm_client));
WL_TBM_RETURN_VAL_IF_FAIL(tbm_client != NULL, NULL);
extern "C" {
#endif
+#include <tbm_bufmgr.h>
#include "wayland-tbm-client.h"
#define HAVE_DLOG
} WL_TBM_MONITOR_TRACE_COMMAND;
typedef enum {
+ WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED,
+ WL_TBM_MONITOR_TRACE_STATUS_OFF,
+ WL_TBM_MONITOR_TRACE_STATUS_ON,
+} WL_TBM_MONITOR_TRACE_STATUS;
+
+typedef enum {
WL_TBM_MONITOR_TARGET_CLIENT,
WL_TBM_MONITOR_TARGET_SERVER,
WL_TBM_MONITOR_TARGET_ALL,
void
_wayland_tbm_check_dlog_enable(void);
+void
+_change_trace_status(WL_TBM_MONITOR_TRACE_STATUS * curr_status, WL_TBM_MONITOR_TRACE_COMMAND cmd, tbm_bufmgr bufmgr);
+
+char *
+_tarce_status_to_str(WL_TBM_MONITOR_TRACE_STATUS status);
+
#ifdef __cplusplus
}
#endif
\r
#include "wayland-tbm-int.h"\r
\r
+WL_TBM_MONITOR_TRACE_STATUS trace_status;\r
+\r
//#define WL_TBM_SERVER_DEBUG\r
//#define DEBUG_TRACE\r
#ifdef DEBUG_TRACE\r
-#define WL_TBM_TRACE(fmt, ...) fprintf (stderr, "[WL_TBM_S(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)\r
+#define WL_TBM_TRACE(fmt, ...) if (trace_status == WL_TBM_MONITOR_TRACE_STATUS_ON) fprintf (stderr, "[WL_TBM_S(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)\r
#else\r
#define WL_TBM_TRACE(fmt, ...)\r
#endif\r
if (command == WL_TBM_MONITOR_COMMAND_SHOW) {\r
tbm_bufmgr_debug_show(tbm_srv->bufmgr);\r
} else if (command == WL_TBM_MONITOR_COMMAND_TRACE) {\r
- WL_TBM_LOG("[%s]: TRACE NOT IMPLEMENTED.\n", __func__);\r
+ if (trace_command == WL_TBM_MONITOR_TRACE_COMMAND_STATUS)\r
+ WL_TBM_DEBUG("server: trace status: %s\n",\r
+ _tarce_status_to_str(trace_status));\r
+ else\r
+ _change_trace_status(&trace_status, trace_command, tbm_srv->bufmgr);\r
} else\r
wl_resource_post_error(resource, WL_TBM_ERROR_INVALID_FORMAT,\r
"invalid format");\r
}\r
tbm_bufmgr_debug_show(tbm_srv->bufmgr);\r
} else if (command == WL_TBM_MONITOR_COMMAND_TRACE) {\r
- wl_tbm_send_monitor_client_tbm_bo(resource, command, trace_command, target,\r
- pid);\r
- WL_TBM_LOG("[%s]: TRACE NOT IMPLEMENTED.\n", __func__);\r
+ /* send the events to all client containing wl_tbm resource except for the wayland-tbm-monitor(requestor). */\r
+ if (!wl_list_empty(&tbm_srv->cresource_list)) {\r
+ wl_list_for_each_safe(c_res, tmp_res, &tbm_srv->cresource_list, link) {\r
+ /* skip the requestor (wayland-tbm-monitor */\r
+ if (c_res->resource == resource)\r
+ continue;\r
+\r
+ wl_tbm_send_monitor_client_tbm_bo(c_res->resource, command, trace_command,\r
+ target, pid);\r
+ }\r
+ }\r
+ if (trace_command == WL_TBM_MONITOR_TRACE_COMMAND_STATUS)\r
+ WL_TBM_DEBUG("server: trace status: %s\n",\r
+ _tarce_status_to_str(trace_status));\r
+ else\r
+ _change_trace_status(&trace_status, trace_command, tbm_srv->bufmgr);\r
} else\r
wl_resource_post_error(resource, WL_TBM_ERROR_INVALID_FORMAT,\r
"invalid format");\r
\r
_wayland_tbm_check_dlog_enable();\r
\r
+ trace_status = WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED;\r
+\r
tbm_srv = calloc(1, sizeof(struct wayland_tbm_server));\r
WL_TBM_RETURN_VAL_IF_FAIL(tbm_srv != NULL, NULL);\r
\r
int bDlog;
#endif
+char * _tarce_status_to_str(WL_TBM_MONITOR_TRACE_STATUS status)
+{
+ if (status == WL_TBM_MONITOR_TRACE_STATUS_OFF)
+ return "off";
+ else if (status == WL_TBM_MONITOR_TRACE_STATUS_ON)
+ return "on";
+ else if (status == WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED)
+ return "unregistered";
+ return "unknown";
+}
+
+void _change_trace_status(WL_TBM_MONITOR_TRACE_STATUS * curr_status, WL_TBM_MONITOR_TRACE_COMMAND cmd, tbm_bufmgr bufmgr)
+{
+ if (cmd == WL_TBM_MONITOR_TRACE_COMMAND_ON) {
+ if (*curr_status == WL_TBM_MONITOR_TRACE_STATUS_OFF) {
+ tbm_bufmgr_debug_trace(bufmgr, 1);
+ *curr_status = WL_TBM_MONITOR_TRACE_STATUS_ON;
+ }
+ } else if (cmd == WL_TBM_MONITOR_TRACE_COMMAND_OFF) {
+ if (*curr_status == WL_TBM_MONITOR_TRACE_STATUS_ON) {
+ tbm_bufmgr_debug_trace(bufmgr, 0);
+ *curr_status = WL_TBM_MONITOR_TRACE_STATUS_OFF;
+ }
+ } else if (cmd == WL_TBM_MONITOR_TRACE_COMMAND_REGISTER) {
+ if (*curr_status == WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED) {
+ tbm_bufmgr_debug_trace(bufmgr, 0);
+ *curr_status = WL_TBM_MONITOR_TRACE_STATUS_OFF;
+ }
+ } else if (cmd == WL_TBM_MONITOR_TRACE_COMMAND_UNREGISTER) {
+ *curr_status = WL_TBM_MONITOR_TRACE_STATUS_UNREGISTERED;
+ tbm_bufmgr_debug_trace(bufmgr, 0);
+ }
+}
+
void
_wayland_tbm_util_get_appname_brief(char *brief)
{
if (!strncmp(argv[2], "on", strlen(argv[2]) + 1)) {
tbm_monitor->options.trace_command = WL_TBM_MONITOR_TRACE_COMMAND_ON;
+ tbm_monitor->options.target = WL_TBM_MONITOR_TARGET_ALL;
} else if (!strncmp(argv[2], "off", strlen(argv[2]) + 1)) {
tbm_monitor->options.trace_command = WL_TBM_MONITOR_TRACE_COMMAND_OFF;
+ tbm_monitor->options.target = WL_TBM_MONITOR_TARGET_ALL;
} else if (!strncmp(argv[2], "register", strlen(argv[2]) + 1)) {
if (argc < 4) {
WL_TBM_LOG("error: no pid. please type the target(client [pid]/server/all).\n");
}
tbm_monitor->options.trace_command = WL_TBM_MONITOR_TRACE_COMMAND_REGISTER;
- if (_wl_tbm_select_target_option(tbm_monitor, argc, argv, 3)) {
+ if (!_wl_tbm_select_target_option(tbm_monitor, argc, argv, 3)) {
WL_TBM_LOG("error: no pid. please type the target(client [pid]/server/all).\n");
_wl_tbm_trace_usage();
return 0;
}
tbm_monitor->options.trace_command = WL_TBM_MONITOR_TRACE_COMMAND_UNREGISTER;
- if (_wl_tbm_select_target_option(tbm_monitor, argc, argv, 3)) {
+ if (!_wl_tbm_select_target_option(tbm_monitor, argc, argv, 3)) {
WL_TBM_LOG("error: no pid. please type the target(client [pid]/server/all).\n");
_wl_tbm_trace_usage();
return 0;
}
} else if (!strncmp(argv[2], "status", strlen(argv[2]) + 1)) {
tbm_monitor->options.trace_command = WL_TBM_MONITOR_TRACE_COMMAND_STATUS;
+ tbm_monitor->options.target = WL_TBM_MONITOR_TARGET_ALL;
} else {
_wl_tbm_trace_usage();
return 0;