headless_debug: add winfo script and fix usage() and so on 07/207207/1
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 22 May 2019 08:59:54 +0000 (17:59 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 30 May 2019 08:35:07 +0000 (17:35 +0900)
Change-Id: Ie067007c0b717d01bf62e6ef0fc0a06b220d5e39
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
data/scripts/winfo [new file with mode: 0644]
packaging/pepper.spec
src/bin/headless/debug/debug.c

diff --git a/data/scripts/winfo b/data/scripts/winfo
new file mode 100644 (file)
index 0000000..106f974
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+if [ "$XDG_RUNTIME_DIR" = "" ]; then
+       export XDG_RUNTIME_DIR=/run
+fi
+
+WINFO_RUN_DIR="$XDG_RUNTIME_DIR/pepper"
+
+if [ ! -d "$WINFO_RUN_DIR" ]; then
+       echo "Error: no ${WINFO_RUN_DIR} directory exist."
+       exit 1
+fi
+
+cd $WINFO_RUN_DIR
+
+function usage()
+{
+       echo "Usage> # winfo {command}"
+       echo ""
+       echo "   Supported commands:"
+       echo ""
+       echo "     protocol_trace_on (turn on wayland protocol trace)"
+       echo "     protocol_trace_off (turn off wayland protocol trace)"
+       echo "     stdout (redirect STDOUT to a file : /run/pepper/stdout.txt)"
+       echo "     stderr (redirect STDERR to a file : /run/pepper/stderr.txt)"
+       echo "     keygrab_status (MUST BE IMPLEMENTED)"
+       echo "     topvwins (MSUT BE IMPLEMENTED)"
+       echo "     connected_clients (display connected clients info : pid, uid, gid, socket fd)"
+       echo "     reslist (display resources info of the connected clients"
+       echo "     help (display this help message)"
+       echo ""
+       echo "   To execute commands, just create/remove/update a file with the commands above."
+       echo "   Please refer to the following examples."
+       echo ""
+       echo "     # winfo protocol_trace_on   : enable event trace"
+       echo "     # winfo protocol_trace_off  : disable event trace"
+       echo "     # winfo stdout              : redirect STDOUT"
+       echo "     # winfo stderr              : redirect STDERR" 
+       echo "     # winfo keygrab_status      : display keygrab status"
+       echo "     # winfo topvwins            : display top/visible window stack"
+       echo "     # winfo connected_clients   : display connected clients information"
+       echo "     # winfo reslist             : display each resources information of connected clients" 
+       echo "     # winfo help                : display this help message"
+       echo ""
+}
+
+if [ "$1" = "" ]; then
+       usage
+       exit 1
+fi
+
+CMD="$1"
+
+rm -f ${CMD} ; touch ${CMD}
+echo "winfo ${CMD}"
index c9da524c1bfef5a9fb1776de9966986505a16472..caeb81bebc90e7491ce3a1b733a720092c1fc76d 100644 (file)
@@ -298,6 +298,7 @@ make %{?_smp_mflags}
 %__mkdir_p %{buildroot}%{_unitdir}
 install -m 644 data/units/display-manager.service.doctor %{buildroot}%{_unitdir}
 install -m 644 data/units/display-manager.service.headless %{buildroot}%{_unitdir}
+install -m 550 data/scripts/* %{buildroot}%{_bindir}
 install -m 644 data/units/display-manager-ready.path %{buildroot}%{_unitdir}
 install -m 644 data/units/display-manager-ready.service %{buildroot}%{_unitdir}
 
@@ -584,6 +585,7 @@ rm -f %{_unitdir_user}/basic.target.wants/display-user.service
 %defattr(-,root,root,-)
 %license COPYING
 %{_bindir}/headless*
+%{_bindir}/winfo
 %{_unitdir}/display-manager-ready.path
 %{_unitdir}/display-manager-ready.service
 %{_unitdir}/display-manager.service.headless
index 6ca7f2536ee7f8cc500916955c08f765db38421f..3360903e5d359368b9623ac21e611a572a59d758 100644 (file)
@@ -34,8 +34,8 @@
 
 #define STDOUT_REDIR                   "stdout"
 #define STDERR_REDIR                   "stderr"
-#define EVENT_TRACE_ON                 "event_trace_on"
-#define EVENT_TRACE_OFF                "event_trace_off"
+#define PROTOCOL_TRACE_ON              "protocol_trace_on"
+#define PROTOCOL_TRACE_OFF             "protocol_trace_off"
 #define KEYGRAB_STATUS                 "keygrab_status"
 #define TOPVWINS                       "topvwins"
 #define CONNECTED_CLIENTS              "connected_clients"
@@ -63,9 +63,9 @@ extern void wl_debug_server_enable(int enable);
 static void
 _headless_debug_usage()
 {
-       fprintf(stdout, "Commands:\n\n");
-       fprintf(stdout, "\t %s\n", EVENT_TRACE_ON);
-       fprintf(stdout, "\t %s\n", EVENT_TRACE_OFF);
+       fprintf(stdout, "Supported commands:\n\n");
+       fprintf(stdout, "\t %s\n", PROTOCOL_TRACE_ON);
+       fprintf(stdout, "\t %s\n", PROTOCOL_TRACE_OFF);
        fprintf(stdout, "\t %s\n", STDOUT_REDIR);
        fprintf(stdout, "\t %s\n", STDERR_REDIR);
        fprintf(stdout, "\t %s\n", KEYGRAB_STATUS);
@@ -76,19 +76,19 @@ _headless_debug_usage()
 
        fprintf(stdout, "\nTo execute commands, just create/remove/update a file with the commands above.\n");
        fprintf(stdout, "Please refer to the following examples.\n\n");
-       fprintf(stdout, "\t touch %s (to enable event trace)\n", EVENT_TRACE_ON);
-       fprintf(stdout, "\t rm -f %s (to disable event trace)\n", EVENT_TRACE_ON);
-       fprintf(stdout, "\t touch %s (to disable event trace)\n", EVENT_TRACE_OFF);
-       fprintf(stdout, "\t touch stdout (to redirect STDOUT to stdout.txt)\n");
-       fprintf(stdout, "\t touch stderr (to redirect STDERR to stderr.txt)\n");
-       fprintf(stdout, "\t touch connected_clients (to display connected clients information)\n");
-       fprintf(stdout, "\t echo 1 > connected_clients (to display connected clients information)\n");
-       fprintf(stdout, "\t touch reslist (to display resources information of the each connected client)\n");
-       fprintf(stdout, "\t echo 1 > reslist (to display resources information of the each connected client)\n");
+       fprintf(stdout, "\t # winfo protocol_trace_on\t : enable event trace\n");
+       fprintf(stdout, "\t # winfo event_trace_off\t : disable event trace\n");
+       fprintf(stdout, "\t # winfo stdout\t\t\t : redirect STDOUT\n");
+       fprintf(stdout, "\t # winfo stderr\t\t\t : redirect STDERR\n");
+       fprintf(stdout, "\t # winfo keygrab_status\t\t : display keygrab status\n");
+       fprintf(stdout, "\t # winfo topvwins\t\t : display top/visible window stack\n");
+       fprintf(stdout, "\t # winfo connected_clients\t : display connected clients information\n");
+       fprintf(stdout, "\t # winfo reslist\t\t : display each resources information of connected clients\n");
+       fprintf(stdout, "\t # winfo help\t\t\t : display this help message\n");
 }
 
 static void
-_headless_debug_event_trace_on(headless_debug_t *hdebug, void *data)
+_headless_debug_protocol_trace_on(headless_debug_t *hdebug, void *data)
 {
        (void) hdebug;
        (void) data;
@@ -96,7 +96,7 @@ _headless_debug_event_trace_on(headless_debug_t *hdebug, void *data)
 }
 
 static void
-_headless_debug_event_trace_off(headless_debug_t *hdebug, void *data)
+_headless_debug_protocol_trace_off(headless_debug_t *hdebug, void *data)
 {
        (void) hdebug;
        (void) data;
@@ -217,14 +217,23 @@ _headless_debug_redir_stderr(headless_debug_t *hdebug, void *data)
 
 }
 
+static void
+_headless_debug_NOT_supported(headless_debug_t *hdebug, void *data)
+{
+       (void) hdebug;
+       (void) data;
+
+       PEPPER_TRACE("NOT SUPPORTED. WILL BE IMPLEMENTED SOON.\n");
+}
+
 static const headless_debug_action_t debug_actions[] =
 {
        { STDOUT_REDIR,  _headless_debug_redir_stdout, NULL },
        { STDERR_REDIR,  _headless_debug_redir_stderr, NULL },
-       { EVENT_TRACE_ON,  _headless_debug_event_trace_on, _headless_debug_event_trace_off },
-       { EVENT_TRACE_OFF, _headless_debug_event_trace_off, NULL },
-       { KEYGRAB_STATUS, _headless_debug_dummy, NULL },
-       { TOPVWINS, _headless_debug_dummy, NULL },
+       { PROTOCOL_TRACE_ON,  _headless_debug_protocol_trace_on, _headless_debug_protocol_trace_off },
+       { PROTOCOL_TRACE_OFF, _headless_debug_protocol_trace_off, NULL },
+       { KEYGRAB_STATUS, _headless_debug_NOT_supported, NULL },
+       { TOPVWINS, _headless_debug_NOT_supported, NULL },
        { CONNECTED_CLIENTS, _headless_debug_connected_clients, NULL },
        { CLIENT_RESOURCES, _headless_debug_connected_clients, NULL },
        { HELP_MSG, _headless_debug_dummy, NULL },